diff options
author | Simon Feltman <sfeltman@src.gnome.org> | 2013-09-01 20:44:26 -0700 |
---|---|---|
committer | Simon Feltman <sfeltman@src.gnome.org> | 2013-09-01 21:21:01 -0700 |
commit | 19c1a2dfb91a83a6fb0ca76b9c95c42a49a3736e (patch) | |
tree | f2b4e30978abd8197094dc6eebdcda8e41c5b3e5 /tests/test_overrides_gtk.py | |
parent | dab0c09f1996e124ca98334e5aea0852904b44b5 (diff) | |
download | pygobject-19c1a2dfb91a83a6fb0ca76b9c95c42a49a3736e.tar.gz |
Change boxed type checking in marshaling to use __gtype__ attribute
Replace usage of pyg_boxed_check(pyboxed) with g_type_is_a and
pyg_type_from_object. This has the effect of using the __gtype__
attribute stashed on object class instead of the PyGBoxed
internally held gtype. This fixes type descrepencies for objects
marshaled into overridden signal class closures and passed back
to functions taking an alias their type.
https://bugzilla.gnome.org/show_bug.cgi?id=707140
Diffstat (limited to 'tests/test_overrides_gtk.py')
-rw-r--r-- | tests/test_overrides_gtk.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/test_overrides_gtk.py b/tests/test_overrides_gtk.py index f9d21c2a..fbe51ece 100644 --- a/tests/test_overrides_gtk.py +++ b/tests/test_overrides_gtk.py @@ -590,6 +590,40 @@ class TestGtk(unittest.TestCase): @unittest.skipUnless(Gtk, 'Gtk not available') +class TestSignals(unittest.TestCase): + class WindowWithSizeAllocOverride(Gtk.ScrolledWindow): + __gsignals__ = {'size-allocate': 'override'} + + def __init__(self): + Gtk.ScrolledWindow.__init__(self) + self._alloc_called = False + self._alloc_value = None + self._alloc_error = None + + def do_size_allocate(self, alloc): + self._alloc_called = True + self._alloc_value = alloc + + try: + Gtk.ScrolledWindow.do_size_allocate(self, alloc) + except Exception as e: + self._alloc_error = e + + def test_class_closure_override_with_aliased_type(self): + win = self.WindowWithSizeAllocOverride() + rect = Gdk.Rectangle() + rect.width = 100 + rect.height = 100 + + with realized(win): + win.show() + win.size_allocate(rect) + self.assertTrue(win._alloc_called) + self.assertIsInstance(win._alloc_value, Gdk.Rectangle) + self.assertTrue(win._alloc_error is None, win._alloc_error) + + +@unittest.skipUnless(Gtk, 'Gtk not available') class TestBuilder(unittest.TestCase): class SignalTest(GObject.GObject): __gtype_name__ = "GIOverrideSignalTest" |