From e0c46d67613fe8c38c3bee6b99ae58260cb33260 Mon Sep 17 00:00:00 2001 From: Luciano Wolf Date: Mon, 14 Jun 2010 16:56:36 -0300 Subject: Implementing API2 modifications. Reviewer: Hugo Parente Lima , Marcelo Lira --- tests/QtGui/CMakeLists.txt | 1 + tests/QtGui/api2_test.py | 60 ++++++++++++++++++++++++++++++++++++++++++ tests/QtGui/qobject_mi_test.py | 6 +++-- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 tests/QtGui/api2_test.py (limited to 'tests') diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt index d2d89ee98..5d1cec422 100644 --- a/tests/QtGui/CMakeLists.txt +++ b/tests/QtGui/CMakeLists.txt @@ -1,3 +1,4 @@ +PYSIDE_TEST(api2_test.py) PYSIDE_TEST(add_action_test.py) PYSIDE_TEST(customproxywidget_test.py) PYSIDE_TEST(float_to_int_implicit_conversion_test.py) diff --git a/tests/QtGui/api2_test.py b/tests/QtGui/api2_test.py new file mode 100644 index 000000000..e458d8bbf --- /dev/null +++ b/tests/QtGui/api2_test.py @@ -0,0 +1,60 @@ +'''Test cases for PySide API2 support''' + + +import unittest + +from PySide.QtCore import QObject +from PySide.QtGui import * + +from helper import UsesQApplication + +class WidgetValidatorQInt(QWidget, QIntValidator): + def __init__(self, parent=None): + QWidget.__init__(self, parent) + QIntValidator.__init__(self, parent) + +class WidgetValidatorQSpinBox(QSpinBox): + def __init__(self, parent=None): + QSpinBox.__init__(self, parent) + + def fixup(self, text): + print "It was called!" + +class DoubleQObjectInheritanceTest(UsesQApplication): + + def testDouble(self): + '''Double inheritance from QObject classes''' + + obj = WidgetValidatorQInt() + + #QIntValidator methods + state, string, number = obj.validate('Test', 0) + self.assertEqual(state, QValidator.Invalid) + state, string, number = obj.validate('33', 0) + self.assertEqual(state, QValidator.Acceptable) + + def testQSpinBox(self): + obj = WidgetValidatorQSpinBox() + + obj.setRange(1, 10) + obj.setValue(0) + print "Value:", obj.value() + +class QClipboardTest(UsesQApplication): + + def testQClipboard(self): + clip = QClipboard() + clip.setText("Testing this thing!") + + text, subtype = clip.text("") + self.assertEqual(subtype, "plain") + self.assertEqual(text, "Testing this thing!") + +#class QFileDialog(UsesQApplication): +# +# def testQFileDialog(self): +# string, filtr = QFileDialog.getOpenFileName() +# print string, filtr + +if __name__ == '__main__': + unittest.main() diff --git a/tests/QtGui/qobject_mi_test.py b/tests/QtGui/qobject_mi_test.py index 8ccc1d35d..28b3cbd16 100644 --- a/tests/QtGui/qobject_mi_test.py +++ b/tests/QtGui/qobject_mi_test.py @@ -29,8 +29,10 @@ class DoubleQObjectInheritanceTest(UsesQApplication): self.assertFalse(obj.isVisible()) #QIntValidator methods - self.assertEqual(obj.validate('aaaa', 0), QValidator.Invalid) - self.assertEqual(obj.validate('33', 0), QValidator.Acceptable) + state, string, number = obj.validate('aaaa', 0) + self.assertEqual(state, QValidator.Invalid) + state, string, number = obj.validate('33', 0) + self.assertEqual(state, QValidator.Acceptable) if __name__ == '__main__': -- cgit v1.2.3