~ubuntu-branches/ubuntu/oneiric/pyside/oneiric

« back to all changes in this revision

Viewing changes to tests/QtUiTools/bug_360.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2010-10-19 22:52:14 UTC
  • mfrom: (1.1.4 upstream)
  • mto: (13.1.1 sid)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20101019225214-0s9fbpz12x3962qa
Tags: upstream-0.4.2
ImportĀ upstreamĀ versionĀ 0.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
import unittest
 
2
import os
 
3
from helper import UsesQApplication
 
4
 
 
5
from PySide import QtCore, QtGui
 
6
from PySide.QtUiTools import QUiLoader
 
7
 
 
8
class MyQUiLoader(QUiLoader):
 
9
    def __init__(self, baseinstance):
 
10
        QUiLoader.__init__(self)
 
11
        self.baseinstance = baseinstance
 
12
        self._widgets = []
 
13
 
 
14
    def createWidget(self, className, parent=None, name=""):
 
15
        widget = QUiLoader.createWidget(self, className, parent, name)
 
16
        self._widgets.append(widget)
 
17
        if parent is None:
 
18
            return self.baseinstance
 
19
        else:
 
20
            setattr(self.baseinstance, name, widget)
 
21
            return widget
 
22
 
 
23
class ButTest(UsesQApplication):
 
24
    def testCase(self):
 
25
        w = QtGui.QWidget()
 
26
        loader = MyQUiLoader(w)
 
27
 
 
28
        filePath = os.path.join(os.path.dirname(__file__), 'minimal.ui')
 
29
        ui = loader.load(filePath)
 
30
 
 
31
        self.assertEqual(len(loader._widgets), 1)
 
32
        self.assertEqual(type(loader._widgets[0]), QtGui.QFrame)
 
33
 
 
34
if __name__ == '__main__':
 
35
    unittest.main()
 
36