aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-05-05 14:43:28 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:19 -0300
commit442bcd9d54b64e89f290e5f983f4fdcc5dac3381 (patch)
tree1def9aaad89721b900a503f20ba6b24a20d6faad /tests
parent8cb9b6d1973e9a1500399c2a2cab151d557c38d7 (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')
-rw-r--r--tests/QtDeclarative/CMakeLists.txt1
-rw-r--r--tests/QtDeclarative/bug_825.py55
-rw-r--r--tests/QtDeclarative/bug_825.qml10
3 files changed, 66 insertions, 0 deletions
diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt
index 7cad2d7ff..abde6fb80 100644
--- a/tests/QtDeclarative/CMakeLists.txt
+++ b/tests/QtDeclarative/CMakeLists.txt
@@ -3,6 +3,7 @@ PYSIDE_TEST(bug_456.py)
PYSIDE_TEST(bug_557.py)
PYSIDE_TEST(bug_726.py)
PYSIDE_TEST(bug_814.py)
+PYSIDE_TEST(bug_825.py)
PYSIDE_TEST(qdeclarativenetwork_test.py)
PYSIDE_TEST(qdeclarativeview_test.py)
PYSIDE_TEST(connect_python_qml.py)
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()
diff --git a/tests/QtDeclarative/bug_825.qml b/tests/QtDeclarative/bug_825.qml
new file mode 100644
index 000000000..dc1c450db
--- /dev/null
+++ b/tests/QtDeclarative/bug_825.qml
@@ -0,0 +1,10 @@
+import Qt 4.7
+import bugs 1.0
+
+Item {
+ width: 300; height: 200
+
+ Bug825 {
+
+ }
+}