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>
This commit is contained in:
renatofilho 2010-10-28 16:28:43 -03:00
commit bd8239b1cd
6 changed files with 66 additions and 10 deletions

View file

@ -1,2 +1,3 @@
PYSIDE_TEST(qdeclarativenetwork_test.py FALSE)
PYSIDE_TEST(qdeclarativeview_test.py FALSE)
PYSIDE_TEST(connect_python_qml.py FALSE)

View file

@ -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()

View file

@ -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
}
}
}