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>
This commit is contained in:
renatofilho 2010-10-06 18:53:39 -03:00
commit e75b82fdf6
3 changed files with 107 additions and 3 deletions

View file

@ -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__':