summaryrefslogtreecommitdiffstats
path: root/tests/QtDeclarative/bug_951.py
blob: 0cd89531529a8a3b07085c407b9aeb93968f6a2b (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
from PySide.QtDeclarative import QDeclarativeItem, qmlRegisterType, QDeclarativeView
from PySide.QtCore import QUrl

from helper import adjust_filename, TimedQApplication
import unittest

class MyItem(QDeclarativeItem):
    COMPONENT_COMPLETE_CALLED = False
    def __init__(self,parent=None):
        super(MyItem, self).__init__(parent)
        self.setObjectName("myitem")

    def componentComplete(self):
        MyItem.COMPONENT_COMPLETE_CALLED = True
        super(MyItem, self).componentComplete()

class TestRegisterQMLType(TimedQApplication):
    def setup(self):
        TimedQApplication.setup(self, 100 * 3) # 3s

    def testSignalEmission(self):
        qmlRegisterType(MyItem, "my.item", 1, 0, "MyItem")

        view = QDeclarativeView()
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_951.qml', __file__)))

        self.app.exec_()
        self.assertTrue(MyItem.COMPONENT_COMPLETE_CALLED)

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