summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-10-21 13:15:04 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-10-21 15:20:36 -0300
commit26750d345c61148d45b500e891b970b8e4e79661 (patch)
treed7af8dcd0cbe1819ca16f88a4a55b97b037df16d /tests
parent4f1a11b61f1488921eb2d5de339d92afec8fbc9f (diff)
downloadpyside-26750d345c61148d45b500e891b970b8e4e79661.tar.gz
pyside-26750d345c61148d45b500e891b970b8e4e79661.tar.xz
pyside-26750d345c61148d45b500e891b970b8e4e79661.zip
Implemented support to notify argument on Properties.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtCore/qobject_property_test.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/QtCore/qobject_property_test.py b/tests/QtCore/qobject_property_test.py
index 7406894..776a14d 100644
--- a/tests/QtCore/qobject_property_test.py
+++ b/tests/QtCore/qobject_property_test.py
@@ -36,6 +36,21 @@ class MyObject(QObject):
pp = Property(int, readPP)
+class MyObjectWithNotifyProperty(QObject):
+ def __init__(self, parent=None):
+ QObject.__init__(self, parent)
+ self.p = 0
+
+ def readP(self):
+ return self.p
+
+ def writeP(self, v):
+ self.p = v
+ self.notifyP.emit()
+
+ notifyP = Signal()
+ myProperty = Property(int, readP, fset=writeP, notify=notifyP)
+
class PropertyCase(unittest.TestCase):
'''Test case for QObject properties'''
@@ -146,6 +161,25 @@ class PropertyWithConstructorCase(unittest.TestCase):
self.assertEqual(o.pp, 42)
self.assertRaises(AttributeError, o.trySetPP)
+class PropertyWithNotify(unittest.TestCase):
+ def called(self):
+ self.called_ = True
+
+ def testMetaData(self):
+ obj = MyObjectWithNotifyProperty()
+ mo = obj.metaObject()
+ self.assertEqual(mo.propertyCount(), 2)
+ p = mo.property(1)
+ self.assertEqual(p.name(), "myProperty")
+ self.assert_(p.hasNotifySignal())
+
+ def testNotify(self):
+ self.called_ = False
+ obj = MyObjectWithNotifyProperty()
+ obj.notifyP.connect(self.called)
+ obj.myProperty = 10
+ self.assert_(self.called_)
+
if __name__ == '__main__':
unittest.main()