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_insert_item(self): dockitem1 = DockItem() dockitem2 = DockItem() dockitem3 = DockItem() dockgroup = DockGroup() dockgroup.insert_item(dockitem1, None) dockgroup.insert_item(dockitem2, 0) dockgroup.insert_item(dockitem3, 1) self.assertTrue(dockgroup.get_nth_item(0) is dockitem2) self.assertTrue(dockgroup.get_nth_item(1) is dockitem3) self.assertTrue(dockgroup.get_nth_item(2) is dockitem1) dockitem1.destroy() dockitem2.destroy() dockitem3.destroy() dockgroup.destroy()
def test_insert_item(self): dockitem1 = DockItem() dockitem2 = DockItem() dockitem3 = DockItem() dockgroup = DockGroup() dockgroup.insert_item(dockitem1, None) dockgroup.insert_item(dockitem2, 0) dockgroup.insert_item(dockitem3, 1) self.assertTrue(dockgroup.get_nth_item(0) is dockitem2) self.assertTrue(dockgroup.get_nth_item(1) is dockitem3) self.assertTrue(dockgroup.get_nth_item(2) is dockitem1) dockitem1.destroy() dockitem2.destroy() dockitem3.destroy() dockgroup.destroy()