def test_item_added_signal(self): add_events = [] item_added_events = [] def on_add(self, widget): add_events.append(widget) def on_item_added(dockgroup, child): item_added_events.append(child) dockitem1 = DockItem() dockitem2 = DockItem() dockgroup = DockGroup() dockgroup.connect('add', on_add) dockgroup.connect('item-added', on_item_added) dockgroup.add(dockitem1) dockgroup.insert_item(dockitem2) self.assertTrue(dockitem1 in item_added_events) self.assertTrue(dockitem1 in add_events) self.assertTrue(dockitem2 in item_added_events) self.assertFalse(dockitem2 in add_events) dockitem2.destroy() dockitem1.destroy() dockgroup.destroy()
def test_add_signal(self): events = [] item_in = [] item_in_after = [] def event_handler(self, w): events.append(w) item_in.append(w in self.items) def event_handler_after(self, w): item_in_after.append(w in self.items) dockgroup = DockGroup() dockgroup.connect('add', event_handler) dockgroup.connect_after('add', event_handler_after) dockitem1 = DockItem() dockgroup.add(dockitem1) self.assertEquals([dockitem1], events) self.assertEquals([True], item_in) self.assertEquals([True], item_in_after) dockitem2 = DockItem() dockgroup.insert_item(dockitem2) self.assertEquals([dockitem1], events) self.assertEquals([True], item_in) self.assertEquals([True], item_in_after)
def test_item_added_signal(self): add_events = [] item_added_events = [] def on_add(self, widget): add_events.append(widget) def on_item_added(dockgroup, child): item_added_events.append(child) dockitem1 = DockItem() dockitem2 = DockItem() dockgroup = DockGroup() dockgroup.connect('add', on_add) dockgroup.connect('item-added', on_item_added) dockgroup.add(dockitem1) dockgroup.insert_item(dockitem2) self.assertTrue(dockitem1 in item_added_events) self.assertTrue(dockitem1 in add_events) self.assertTrue(dockitem2 in item_added_events) self.assertFalse(dockitem2 in add_events) dockitem2.destroy() dockitem1.destroy() dockgroup.destroy()
def test_add_signal(self): events = [] item_in = [] item_in_after = [] def event_handler(self, w): events.append(w) item_in.append(w in self.items) def event_handler_after(self, w): item_in_after.append(w in self.items) dockgroup = DockGroup() dockgroup.connect('add', event_handler) dockgroup.connect_after('add', event_handler_after) dockitem1 = DockItem() dockgroup.add(dockitem1) self.assertEquals([dockitem1], events) self.assertEquals([True], item_in) self.assertEquals([True], item_in_after) dockitem2 = DockItem() dockgroup.insert_item(dockitem2) self.assertEquals([dockitem1], events) self.assertEquals([True], item_in) self.assertEquals([True], item_in_after)
def test_child_prop_weight(self): global child_notify_called def _on_child_notify(gobject, pspec): global child_notify_called child_notify_called = True dockpaned = DockPaned() dockgroup = DockGroup() dockgroup.connect('child-notify::weight', _on_child_notify) dockpaned.add(dockgroup) child_notify_called = False dockpaned.child_set_property(dockgroup, 'weight', 0.3) self.assertTrue(child_notify_called, msg='weight child property change notification failed') dockgroup.destroy() dockpaned.destroy()
def test_child_prop_weight(self): global child_notify_called def _on_child_notify(gobject, pspec): global child_notify_called child_notify_called = True dockpaned = DockPaned() dockgroup = DockGroup() dockgroup.connect('child-notify::weight', _on_child_notify) dockpaned.add(dockgroup) child_notify_called = False dockpaned.child_set_property(dockgroup, 'weight', 0.3) self.assertTrue(child_notify_called, msg='weight child property change notification failed') dockgroup.destroy() dockpaned.destroy()
def test_remove_signal(self): remove_events = [] item_removed_events = [] def on_remove(self, widget): remove_events.append(widget) def on_item_removed(dockgroup, child): item_removed_events.append(child) dockitem = DockItem() dockitem.add(gtk.Button()) dockgroup = DockGroup() dockgroup.connect('remove', on_remove) dockgroup.connect('item-removed', on_item_removed) dockgroup.add(dockitem) dockgroup.remove(dockitem) self.assertTrue(dockitem in remove_events) self.assertTrue(dockitem in item_removed_events) dockitem.destroy() dockgroup.destroy()
def test_remove_signal(self): remove_events = [] item_removed_events = [] def on_remove(self, widget): remove_events.append(widget) def on_item_removed(dockgroup, child): item_removed_events.append(child) dockitem = DockItem() dockitem.add(gtk.Button()) dockgroup = DockGroup() dockgroup.connect('remove', on_remove) dockgroup.connect('item-removed', on_item_removed) dockgroup.add(dockitem) dockgroup.remove(dockitem) self.assertTrue(dockitem in remove_events) self.assertTrue(dockitem in item_removed_events) dockitem.destroy() dockgroup.destroy()