diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2011-05-05 14:43:28 -0300 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-08 16:54:19 -0300 |
commit | 442bcd9d54b64e89f290e5f983f4fdcc5dac3381 (patch) | |
tree | 1def9aaad89721b900a503f20ba6b24a20d6faad /tests/QtDeclarative/bug_825.py | |
parent | 8cb9b6d1973e9a1500399c2a2cab151d557c38d7 (diff) |
Fix bug 825 - "Can't register a class using that uses metaclasses in QML using qmlRegisterType"
Reviewer: Renato Araújo <renato.filho@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests/QtDeclarative/bug_825.py')
-rw-r--r-- | tests/QtDeclarative/bug_825.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/QtDeclarative/bug_825.py b/tests/QtDeclarative/bug_825.py new file mode 100644 index 000000000..d3c5519aa --- /dev/null +++ b/tests/QtDeclarative/bug_825.py @@ -0,0 +1,55 @@ +from PySide.QtCore import * +from PySide.QtGui import * +from PySide.QtDeclarative import * + +from helper import adjust_filename +import unittest + +paintCalled = False + +class MetaA(type): + pass + +class A(object): + __metaclass__ = MetaA + +MetaB = type(QDeclarativeItem) +B = QDeclarativeItem + +class MetaC(MetaA, MetaB): + pass + +class C(A, B): + __metaclass__ = MetaC + +class Bug825 (C): + + def __init__(self, parent = None): + QDeclarativeItem.__init__(self, parent) + # need to disable this flag to draw inside a QDeclarativeItem + self.setFlag(QGraphicsItem.ItemHasNoContents, False) + + def paint(self, painter, options, widget): + global paintCalled + pen = QPen(Qt.black, 2) + painter.setPen(pen); + painter.drawPie(self.boundingRect(), 0, 128); + paintCalled = True + +class TestBug825 (unittest.TestCase): + def testIt(self): + global paintCalled + app = QApplication([]) + qmlRegisterType(Bug825, 'bugs', 1, 0, 'Bug825') + self.assertRaises(TypeError, qmlRegisterType, A, 'bugs', 1, 0, 'A') + + view = QDeclarativeView() + view.setSource(QUrl.fromLocalFile(adjust_filename('bug_825.qml', __file__))) + view.show() + QTimer.singleShot(250, view.close) + app.exec_() + self.assertTrue(paintCalled) + + +if __name__ == '__main__': + unittest.main() |