aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtDeclarative
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-28 16:28:43 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-28 17:40:12 -0300
commitbd8239b1cd99d25c26eb99a051072254342ab0bb (patch)
tree12fce76bd9206473ead1600e05d5591619f98393 /tests/QtDeclarative
parenta1524b78b632d99aa6076391d0d77e46271dd7c8 (diff)
Stop signal/slot connection if is impossible to register that on object.
Created unit test for bug #442, #437. Fixes bug #442. Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/QtDeclarative')
-rw-r--r--tests/QtDeclarative/CMakeLists.txt1
-rwxr-xr-xtests/QtDeclarative/connect_python_qml.py30
-rw-r--r--tests/QtDeclarative/connect_python_qml.qml20
3 files changed, 51 insertions, 0 deletions
diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt
index 4896010bd..98b797c97 100644
--- a/tests/QtDeclarative/CMakeLists.txt
+++ b/tests/QtDeclarative/CMakeLists.txt
@@ -1,2 +1,3 @@
PYSIDE_TEST(qdeclarativenetwork_test.py FALSE)
PYSIDE_TEST(qdeclarativeview_test.py FALSE)
+PYSIDE_TEST(connect_python_qml.py FALSE)
diff --git a/tests/QtDeclarative/connect_python_qml.py b/tests/QtDeclarative/connect_python_qml.py
new file mode 100755
index 000000000..bb505156e
--- /dev/null
+++ b/tests/QtDeclarative/connect_python_qml.py
@@ -0,0 +1,30 @@
+'''Test case for bug #442'''
+
+from PySide import QtCore, QtGui, QtDeclarative
+from helper import adjust_filename, TimedQApplication
+import unittest
+
+class TestConnectionWithInvalidSignature(TimedQApplication):
+ def onButtonClicked(self):
+ self.buttonClicked = True
+ self.app.quit()
+
+ def onButtonFailClicked(self):
+ pass
+
+ def testFailConnection(self):
+ self.buttonClicked = False
+ self.buttonFailClicked = False
+ view = QtDeclarative.QDeclarativeView()
+ view.setSource(QtCore.QUrl(adjust_filename('connect_python_qml.qml', __file__)))
+ root = view.rootObject()
+ button = root.findChild(QtCore.QObject, "buttonMouseArea")
+ self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('clicked()'), self.onButtonFailClicked])
+ button.clicked.connect(self.onButtonClicked)
+ button.clicked.emit()
+ view.show()
+ self.app.exec_()
+ self.assert_(self.buttonClicked)
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/QtDeclarative/connect_python_qml.qml b/tests/QtDeclarative/connect_python_qml.qml
new file mode 100644
index 000000000..dbf890f6f
--- /dev/null
+++ b/tests/QtDeclarative/connect_python_qml.qml
@@ -0,0 +1,20 @@
+import Qt 4.7
+
+Rectangle {
+ id: page
+ width: 500; height: 200
+ color: "lightgray"
+
+ Rectangle {
+ id: button
+ width: 150; height: 40
+ color: "darkgray"
+ anchors.horizontalCenter: page.horizontalCenter
+ y: 150
+ MouseArea {
+ id: buttonMouseArea
+ objectName: "buttonMouseArea"
+ anchors.fill: parent
+ }
+ }
+}