Fix bug#436 - "Using a custom QValidator generates a segfault"
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
7013bd760e
commit
655219636b
3 changed files with 123 additions and 20 deletions
|
|
@ -71,6 +71,7 @@ PYSIDE_TEST(qtextedit_signal_test.py)
|
|||
PYSIDE_TEST(qtoolbar_test.py)
|
||||
PYSIDE_TEST(qtoolbox_test.py)
|
||||
PYSIDE_TEST(qvariant_test.py)
|
||||
PYSIDE_TEST(qvalidator_test.py)
|
||||
PYSIDE_TEST(qwidget_setlayout_test.py)
|
||||
PYSIDE_TEST(qwidget_test.py)
|
||||
PYSIDE_TEST(reference_count_test.py)
|
||||
|
|
|
|||
85
tests/QtGui/qvalidator_test.py
Normal file
85
tests/QtGui/qvalidator_test.py
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
from PySide.QtCore import *
|
||||
from PySide.QtGui import *
|
||||
|
||||
import unittest
|
||||
from helper import UsesQApplication
|
||||
|
||||
class MyValidator1(QValidator):
|
||||
def fixUp(self, input):
|
||||
return "fixed"
|
||||
|
||||
def validate(self, input, pos):
|
||||
return (QValidator.Acceptable, "fixed", 1)
|
||||
|
||||
class MyValidator2(QValidator):
|
||||
def fixUp(self, input):
|
||||
return "fixed"
|
||||
|
||||
def validate(self, input, pos):
|
||||
return (QValidator.Acceptable, "fixed")
|
||||
|
||||
class MyValidator3(QValidator):
|
||||
def fixUp(self, input):
|
||||
return "fixed"
|
||||
|
||||
def validate(self, input, pos):
|
||||
return (QValidator.Acceptable,)
|
||||
|
||||
class MyValidator4(QValidator):
|
||||
def fixUp(self, input):
|
||||
return "fixed"
|
||||
|
||||
def validate(self, input, pos):
|
||||
return QValidator.Acceptable
|
||||
|
||||
class QValidatorTest(UsesQApplication):
|
||||
def testValidator1(self):
|
||||
line = QLineEdit()
|
||||
line.setValidator(MyValidator1())
|
||||
line.show()
|
||||
line.setText("foo")
|
||||
|
||||
QTimer.singleShot(0, line.close)
|
||||
self.app.exec_()
|
||||
|
||||
self.assertEqual(line.text(), "fixed")
|
||||
self.assertEqual(line.cursorPosition(), 1)
|
||||
|
||||
def testValidator2(self):
|
||||
line = QLineEdit()
|
||||
line.setValidator(MyValidator2())
|
||||
line.show()
|
||||
line.setText("foo")
|
||||
|
||||
QTimer.singleShot(0, line.close)
|
||||
self.app.exec_()
|
||||
|
||||
self.assertEqual(line.text(), "fixed")
|
||||
self.assertEqual(line.cursorPosition(), 3)
|
||||
|
||||
def testValidator3(self):
|
||||
line = QLineEdit()
|
||||
line.setValidator(MyValidator3())
|
||||
line.show()
|
||||
line.setText("foo")
|
||||
|
||||
QTimer.singleShot(0, line.close)
|
||||
self.app.exec_()
|
||||
|
||||
self.assertEqual(line.text(), "foo")
|
||||
self.assertEqual(line.cursorPosition(), 3)
|
||||
|
||||
def testValidator4(self):
|
||||
line = QLineEdit()
|
||||
line.setValidator(MyValidator4())
|
||||
line.show()
|
||||
line.setText("foo")
|
||||
|
||||
QTimer.singleShot(0, line.close)
|
||||
self.app.exec_()
|
||||
|
||||
self.assertEqual(line.text(), "foo")
|
||||
self.assertEqual(line.cursorPosition(), 3)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue