aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtUiTools
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-06 18:53:39 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-07 12:18:03 -0300
commite75b82fdf6e9903e7264a1bc962ab7ed42c53bcd (patch)
tree6dac5ce544dc244dae7939ed96aeb0954d22766a /tests/QtUiTools
parent6b8d262b4067bffd4e5a9611c07b862aa64d2538 (diff)
Created unittest for widgets defined in Python and used during QUiLoader.loader function.
Reviewer: Hugo Parente Lima <hugo.pl@gmail.com> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/QtUiTools')
-rw-r--r--tests/QtUiTools/bug_392.py23
-rw-r--r--tests/QtUiTools/customwidget.ui51
-rw-r--r--tests/QtUiTools/pycustomwidget.ui36
3 files changed, 107 insertions, 3 deletions
diff --git a/tests/QtUiTools/bug_392.py b/tests/QtUiTools/bug_392.py
index 5717d457c..36b2f1091 100644
--- a/tests/QtUiTools/bug_392.py
+++ b/tests/QtUiTools/bug_392.py
@@ -5,6 +5,13 @@ from helper import UsesQApplication
from PySide import QtCore, QtGui, QtDeclarative
from PySide.QtUiTools import QUiLoader
+class MyWidget(QtGui.QComboBox):
+ def __init__(self, parent=None):
+ QtGui.QComboBox.__init__(self, parent)
+
+ def isPython(self):
+ return True
+
class BugTest(UsesQApplication):
def testCase(self):
w = QtGui.QWidget()
@@ -12,7 +19,7 @@ class BugTest(UsesQApplication):
filePath = os.path.join(os.path.dirname(__file__), 'action.ui')
result = loader.load(filePath, w)
- self.assertEqual(type(result.statusbar.actionFoo), QtGui.QAction)
+ self.assert_(isinstance(result.statusbar.actionFoo, QtGui.QAction))
def testCustomWidgets(self):
w = QtGui.QWidget()
@@ -20,8 +27,18 @@ class BugTest(UsesQApplication):
filePath = os.path.join(os.path.dirname(__file__), 'customwidget.ui')
result = loader.load(filePath, w)
- self.assert_(type(result.declarativeView), QtDeclarative.QDeclarativeView)
- self.assert_(type(result.worldTimeClock), QtGui.QWidget)
+ self.assert_(isinstance(result.declarativeView, QtDeclarative.QDeclarativeView))
+ self.assert_(isinstance(result.worldTimeClock, QtGui.QWidget))
+
+ def testPythonCustomWidgets(self):
+ w = QtGui.QWidget()
+ loader = QUiLoader()
+ loader.registerCustomWidget(MyWidget)
+
+ filePath = os.path.join(os.path.dirname(__file__), 'pycustomwidget.ui')
+ result = loader.load(filePath, w)
+ self.assert_(isinstance(result.custom, MyWidget))
+ self.assert_(result.custom.isPython())
if __name__ == '__main__':
diff --git a/tests/QtUiTools/customwidget.ui b/tests/QtUiTools/customwidget.ui
new file mode 100644
index 000000000..181ee6072
--- /dev/null
+++ b/tests/QtUiTools/customwidget.ui
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>qwidget</class>
+ <widget class="QWidget" name="qwidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>303</width>
+ <height>350</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <widget class="QDeclarativeView" name="declarativeView">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>150</y>
+ <width>300</width>
+ <height>200</height>
+ </rect>
+ </property>
+ </widget>
+ <widget class="WorldTimeClock" name="worldTimeClock">
+ <property name="geometry">
+ <rect>
+ <x>190</x>
+ <y>20</y>
+ <width>100</width>
+ <height>100</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>QDeclarativeView</class>
+ <extends>QGraphicsView</extends>
+ <header>QtDeclarative/QDeclarativeView</header>
+ </customwidget>
+ <customwidget>
+ <class>WorldTimeClock</class>
+ <extends>QWidget</extends>
+ <header>worldtimeclock.h</header>
+ </customwidget>
+</customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/tests/QtUiTools/pycustomwidget.ui b/tests/QtUiTools/pycustomwidget.ui
new file mode 100644
index 000000000..c066153a0
--- /dev/null
+++ b/tests/QtUiTools/pycustomwidget.ui
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>qwidget</class>
+ <widget class="QWidget" name="qwidget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>400</width>
+ <height>300</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <widget class="MyWidget" name="custom">
+ <property name="geometry">
+ <rect>
+ <x>10</x>
+ <y>10</y>
+ <width>79</width>
+ <height>23</height>
+ </rect>
+ </property>
+ </widget>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>MyWidget</class>
+ <extends>QComboBox</extends>
+ <header>customwidget</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>