aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtUiTools/uiloader_test.py
blob: 09bc5bd1c1b76e1c671bdd9c2228ae33e40b363f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import unittest
import os
from helper import UsesQApplication

from PySide.QtGui import QWidget
from PySide.QtUiTools import QUiLoader

def get_file_path():
    for path in file_path:
        if os.path.exists(path):
            return path
    return ""

class QUioaderTeste(UsesQApplication):
    def testLoadFile(self):
        filePath = os.path.join(os.path.dirname(__file__), 'test.ui')
        loader = QUiLoader()
        parent = QWidget()
        w = loader.load(filePath, parent)
        self.assertNotEqual(w, None)

        self.assertEqual(len(parent.children()), 1)

        child = w.findChild(QWidget, "child_object")
        self.assertNotEqual(child, None)
        self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))

    def testLoadFileUnicodeFilePath(self):
        filePath = str(os.path.join(os.path.dirname(__file__), 'test.ui'))
        loader = QUiLoader()
        parent = QWidget()
        w = loader.load(filePath, parent)
        self.assertNotEqual(w, None)

        self.assertEqual(len(parent.children()), 1)

        child = w.findChild(QWidget, "child_object")
        self.assertNotEqual(child, None)
        self.assertEqual(w.findChild(QWidget, "grandson_object"), child.findChild(QWidget, "grandson_object"))

if __name__ == '__main__':
    unittest.main()