summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-09-16 17:23:14 +0000
committerGustavo J. A. M. Carneiro <gjc@src.gnome.org>2006-09-16 17:23:14 +0000
commit7e823bfb034b82377d092e954d9f73c48af5795f (patch)
tree03b94021520e0c4f9cbf7c6fff9fe2a74169df98
parenteb7da192643f40736a8aedda0c548b358fecc55e (diff)
downloadpygobject-7e823bfb034b82377d092e954d9f73c48af5795f.tar.gz
pygobject-7e823bfb034b82377d092e954d9f73c48af5795f.tar.xz
pygobject-7e823bfb034b82377d092e954d9f73c48af5795f.zip
some more emission hook tests
-rw-r--r--ChangeLog5
-rw-r--r--tests/test_signal.py45
2 files changed, 50 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index e2c0399..d817805 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2006-09-16 Gustavo J. A. M. Carneiro <gjc@gnome.org>
+ * tests/test_signal.py (TestEmissionHook.testCallbackReturnFalse)
+ (TestEmissionHook.testCallbackReturnTrue)
+ (TestEmissionHook.testCallbackReturnTrueButRemove): Add a few more
+ emission hook tests.
+
* gobject/gobjectmodule.c (pyg_add_emission_hook): One too many
DECREF on 'extra_args'.
diff --git a/tests/test_signal.py b/tests/test_signal.py
index bb33fb8..a2018a9 100644
--- a/tests/test_signal.py
+++ b/tests/test_signal.py
@@ -139,6 +139,16 @@ class E(gobject.GObject):
assert self.status == 0
self.status = 1
+class F(gobject.GObject):
+ __gsignals__ = { 'signal': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
+ ()) }
+ def __init__(self):
+ gobject.GObject.__init__(self)
+ self.status = 0
+
+ def do_signal(self):
+ self.status += 1
+
class TestEmissionHook(unittest.TestCase):
def testAdd(self):
self.hook = True
@@ -168,6 +178,41 @@ class TestEmissionHook(unittest.TestCase):
self.assertEqual(e.status, 1)
e.status = 3
+ def testCallbackReturnFalse(self):
+ self.hook = False
+ obj = F()
+ def _emission_hook(obj):
+ obj.status += 1
+ return False
+ hook_id = gobject.add_emission_hook(obj, "signal", _emission_hook)
+ obj.emit('signal')
+ obj.emit('signal')
+ self.assertEqual(obj.status, 3)
+
+ def testCallbackReturnTrue(self):
+ self.hook = False
+ obj = F()
+ def _emission_hook(obj):
+ obj.status += 1
+ return True
+ hook_id = gobject.add_emission_hook(obj, "signal", _emission_hook)
+ obj.emit('signal')
+ obj.emit('signal')
+ gobject.remove_emission_hook(obj, "signal", hook_id)
+ self.assertEqual(obj.status, 4)
+
+ def testCallbackReturnTrueButRemove(self):
+ self.hook = False
+ obj = F()
+ def _emission_hook(obj):
+ obj.status += 1
+ return True
+ hook_id = gobject.add_emission_hook(obj, "signal", _emission_hook)
+ obj.emit('signal')
+ gobject.remove_emission_hook(obj, "signal", hook_id)
+ obj.emit('signal')
+ self.assertEqual(obj.status, 3)
+
class TestClosures(unittest.TestCase):
def setUp(self):
self.count = 0