diff options
author | renatofilho <renato.filho@openbossa.org> | 2010-09-21 14:29:34 -0300 |
---|---|---|
committer | renatofilho <renato.filho@openbossa.org> | 2010-09-21 14:53:04 -0300 |
commit | 4229fa0082135c889094c6cea7baa970b5208587 (patch) | |
tree | aea56ff9056863b239a2ac7319c6c844e045a63a /tests | |
parent | 2a225be9c770ccf774a97457ab409b6b3f60b467 (diff) |
Created unit test for bug #360.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/QtUiTools/CMakeLists.txt | 1 | ||||
-rw-r--r-- | tests/QtUiTools/bug_360.py | 36 | ||||
-rw-r--r-- | tests/QtUiTools/minimal.ui | 6 |
3 files changed, 43 insertions, 0 deletions
diff --git a/tests/QtUiTools/CMakeLists.txt b/tests/QtUiTools/CMakeLists.txt index 9118b5b6c..03ce7687d 100644 --- a/tests/QtUiTools/CMakeLists.txt +++ b/tests/QtUiTools/CMakeLists.txt @@ -1,2 +1,3 @@ +PYSIDE_TEST(bug_360.py) PYSIDE_TEST(uiloader_test.py) PYSIDE_TEST(ui_test.py) diff --git a/tests/QtUiTools/bug_360.py b/tests/QtUiTools/bug_360.py new file mode 100644 index 000000000..aefc42234 --- /dev/null +++ b/tests/QtUiTools/bug_360.py @@ -0,0 +1,36 @@ +import unittest +import os +from helper import UsesQApplication + +from PySide import QtCore, QtGui +from PySide.QtUiTools import QUiLoader + +class MyQUiLoader(QUiLoader): + def __init__(self, baseinstance): + QUiLoader.__init__(self) + self.baseinstance = baseinstance + self._widgets = [] + + def createWidget(self, className, parent=None, name=""): + widget = QUiLoader.createWidget(self, className, parent, name) + self._widgets.append(widget) + if parent is None: + return self.baseinstance + else: + setattr(self.baseinstance, name, widget) + return widget + +class ButTest(UsesQApplication): + def testCase(self): + w = QtGui.QWidget() + loader = MyQUiLoader(w) + + filePath = os.path.join(os.path.dirname(__file__), 'minimal.ui') + ui = loader.load(filePath) + + self.assertEqual(len(loader._widgets), 1) + self.assertEqual(type(loader._widgets[0]), QtGui.QFrame) + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtUiTools/minimal.ui b/tests/QtUiTools/minimal.ui new file mode 100644 index 000000000..c6bb70cda --- /dev/null +++ b/tests/QtUiTools/minimal.ui @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>Form</class> + <widget class="QFrame" name="Form"> + </widget> +</ui> |