Ejemplo n.º 1
0
    def test_item_added_signal(self):
        add_events = []
        item_added_events = []

        def on_add(self, widget):
            add_events.append(widget)

        def on_item_added(dockpaned, child):
            item_added_events.append(child)

        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('add', on_add)
        dockpaned.connect('item-added', on_item_added)
        dockpaned.add(dockgroup1)
        dockpaned.insert_item(dockgroup2)

        self.assertTrue(dockgroup1 in item_added_events)
        self.assertTrue(dockgroup1 in add_events)
        self.assertTrue(dockgroup2 in item_added_events)
        self.assertFalse(dockgroup2 in add_events)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Ejemplo n.º 2
0
    def test_item_removed_signal(self):
        remove_events = []
        item_removed_events = []

        def on_remove(self, widget):
            remove_events.append(widget)

        def on_item_removed(dockpaned, child):
            item_removed_events.append(child)

        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('remove', on_remove)
        dockpaned.connect('item-removed', on_item_removed)
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.remove(dockgroup1)
        dockpaned.remove_item(0)

        self.assertTrue(dockgroup1 in item_removed_events)
        self.assertTrue(dockgroup1 in remove_events)
        self.assertTrue(dockgroup2 in item_removed_events)
        self.assertFalse(dockgroup2 in remove_events)

        dockgroup1.destroy()
        dockgroup2.destroy()
        dockpaned.destroy()
Ejemplo n.º 3
0
    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()
Ejemplo n.º 4
0
    def test_add(self):
        dockitem = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem)

        self.assertTrue(dockitem in dockgroup)

        dockitem.destroy()
        dockgroup.destroy()
Ejemplo n.º 5
0
    def test_add(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)

        self.assertTrue(dockgroup in dockpaned)

        dockgroup.destroy()
        dockpaned.destroy()
Ejemplo n.º 6
0
    def test_append_item(self):
        dockitem = DockItem()
        dockgroup = DockGroup()
        index = dockgroup.append_item(dockitem)

        self.assertTrue(index == 0)
        self.assertTrue(dockgroup.get_nth_item(0) is dockitem)

        dockitem.destroy()
        dockgroup.destroy()
Ejemplo n.º 7
0
    def test_get_n_items(self):
        dockgroup = DockGroup()
        self.assertTrue(dockgroup.get_n_items() == len(dockgroup) == 0)

        dockitem = DockItem()
        dockgroup.add(dockitem)
        self.assertTrue(dockgroup.get_n_items() == len(dockgroup) == 1)

        dockitem.destroy()
        dockgroup.destroy()
Ejemplo n.º 8
0
    def test_remove(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)
        dockpaned.remove(dockgroup)

        self.assertTrue(dockgroup not in dockpaned)

        dockgroup.destroy()
        dockpaned.destroy()
Ejemplo n.º 9
0
    def test_item_num(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)

        self.assertTrue(dockgroup.item_num(dockitem1) == 0)
        self.assertTrue(dockgroup.item_num(dockitem2) is None)

        dockitem1.destroy()
        dockgroup.destroy()
Ejemplo n.º 10
0
    def test_get_n_handles(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned._get_n_handles() == 1)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Ejemplo n.º 11
0
    def test_len(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(len(dockpaned) == 2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Ejemplo n.º 12
0
    def test_child_destroy(self):
        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup)

        self.assertTrue(len(dockpaned) == len(dockpaned._items) == 1)

        dockgroup.destroy()

        self.assertTrue(len(dockpaned) == len(dockpaned._items) == 0)

        dockgroup.destroy()
        dockpaned.destroy()
Ejemplo n.º 13
0
    def test_get_nth_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned.get_nth_item(0) == dockgroup1)
        self.assertTrue(dockpaned.get_nth_item(1) == dockgroup2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Ejemplo n.º 14
0
    def test_get_current_item(self):
        dockitem = DockItem()
        dockgroup = DockGroup()
        self.assertTrue(dockgroup.get_current_item() is None)

        index = dockgroup.append_item(dockitem)
        self.assertTrue(dockgroup.get_current_item() == index)

        dockgroup.remove(dockitem)
        self.assertTrue(dockgroup.get_current_item() is None)

        dockitem.destroy()
        dockgroup.destroy()
Ejemplo n.º 15
0
    def test_item_num(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)

        self.assertTrue(dockpaned.item_num(dockgroup1) == 0)
        self.assertTrue(dockpaned.item_num(dockgroup2) == 1)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Ejemplo n.º 16
0
    def test_prepend_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        index1 = dockgroup.append_item(dockitem1)
        index2 = dockgroup.prepend_item(dockitem2)

        self.assertTrue(index1 == 0)
        self.assertTrue(index2 == 0)
        self.assertTrue(dockgroup.get_nth_item(0) is dockitem2)
        self.assertTrue(dockgroup.get_nth_item(1) is dockitem1)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()
Ejemplo n.º 17
0
    def test_remove_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)
        dockgroup.remove_item(0)
        dockgroup.remove_item(None)

        self.assertTrue(dockitem1 not in dockgroup)
        self.assertTrue(dockitem2 not in dockgroup)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()
Ejemplo n.º 18
0
    def test_add_signal(self):
        add_events = []

        def on_add(self, widget):
            add_events.append(widget)

        dockgroup = DockGroup()
        dockpaned = DockPaned()
        dockpaned.connect('add', on_add)
        dockpaned.add(dockgroup)

        self.assertTrue(dockgroup in add_events)

        dockgroup.destroy()
        dockpaned.destroy()
Ejemplo n.º 19
0
    def test_get_nth_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)

        self.assertTrue(dockgroup.get_nth_item(0) is dockitem1)
        self.assertTrue(dockgroup.get_nth_item(1) is dockitem2)
        self.assertTrue(dockgroup.get_nth_item(2) is None)
        self.assertTrue(dockgroup.get_nth_item(-1) is None)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()
Ejemplo n.º 20
0
    def test_prepend_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        item_num1 = dockpaned.prepend_item(dockgroup1)
        self.assertTrue(item_num1 == 0)
        item_num2 = dockpaned.prepend_item(dockgroup2)
        self.assertTrue(item_num2 == 0)

        self.assertTrue(dockpaned.get_nth_item(0) is dockgroup2)
        self.assertTrue(dockpaned.get_nth_item(1) is dockgroup1)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Ejemplo n.º 21
0
    def test_delitem(self):
        dg = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(DockGroup())
        dockpaned.add(dg)
        dockpaned.add(DockGroup())
        
        assert dg in dockpaned
        assert len(dockpaned) == 3
        assert dg is dockpaned[1]
        del dockpaned[1]
        assert len(dockpaned) == 2
        assert dg not in dockpaned

        dg.destroy()
        dockpaned.destroy()
Ejemplo n.º 22
0
    def test_item_destroy(self):
        win = gtk.Window()
        dockitem = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem)
        win.add(dockgroup)
        win.show_all()

        assert len(dockgroup.items) == 1
        dockitem.destroy()

        self.assertTrue(dockitem not in dockgroup)
        assert len(dockgroup.items) == 0

        win.destroy()
        dockgroup.destroy()
Ejemplo n.º 23
0
    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()
Ejemplo n.º 24
0
    def test_prev_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)
        self.assertTrue(dockgroup.get_current_item() == 1)

        dockgroup.prev_item()
        self.assertTrue(dockgroup.get_current_item() == 0)

        dockgroup.prev_item()
        self.assertTrue(dockgroup.get_current_item() == 0)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()
Ejemplo n.º 25
0
    def test_remove_item(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockgroup3 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        dockpaned.add(dockgroup3)
        dockpaned.remove_item(None)
        dockpaned.remove_item(0)
        dockpaned.remove_item(-1)

        self.assertTrue(dockgroup1 not in dockpaned)
        self.assertTrue(dockgroup2 not in dockpaned)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
Ejemplo n.º 26
0
    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()
Ejemplo n.º 27
0
    def test_reorder_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockitem3 = DockItem()
        dockgroup = DockGroup()
        dockgroup.add(dockitem1)
        dockgroup.add(dockitem2)
        dockgroup.add(dockitem3)
        dockgroup.reorder_item(dockitem3, 0)
        dockgroup.reorder_item(dockitem1, 2)

        self.assertTrue(dockgroup.item_num(dockitem1) == 2)
        self.assertTrue(dockgroup.item_num(dockitem2) == 1)
        self.assertTrue(dockgroup.item_num(dockitem3) == 0)

        dockitem1.destroy()
        dockitem2.destroy()
        dockitem3.destroy()
        dockgroup.destroy()
Ejemplo n.º 28
0
    def test_get_item_at_pos(self):
        dockgroup1 = DockGroup()
        dockgroup2 = DockGroup()
        dockpaned = DockPaned()
        dockpaned.add(dockgroup1)
        dockpaned.add(dockgroup2)
        window = gtk.Window()
        window.add(dockpaned)
        window.show_all()

        child1 = dockpaned.get_item_at_pos(dockgroup1.allocation.x + 1,
                                           dockgroup1.allocation.y + 1)

        child2 = dockpaned.get_item_at_pos(dockgroup2.allocation.x + 1,
                                           dockgroup2.allocation.y + 1)

        self.assertTrue(child1 is dockgroup1)
        self.assertTrue(child2 is dockgroup2)

        dockgroup2.destroy()
        dockgroup1.destroy()
        dockpaned.destroy()
        window.destroy()
Ejemplo n.º 29
0
    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()
Ejemplo n.º 30
0
    def test_set_current_item(self):
        dockitem1 = DockItem()
        dockitem2 = DockItem()
        dockgroup = DockGroup()
        self.assertTrue(dockgroup.get_current_item() is None)

        index = dockgroup.append_item(dockitem1)
        self.assertTrue(dockgroup.get_current_item() == index)

        index = dockgroup.append_item(dockitem2)
        self.assertTrue(dockgroup.get_current_item() == index)

        dockgroup.set_current_item(0)
        self.assertTrue(dockgroup.get_current_item() == 0)

        dockgroup.set_current_item(len(dockgroup) + 10)
        self.assertTrue(dockgroup.get_current_item() == len(dockgroup) - 1)

        dockgroup.set_current_item(-1)
        self.assertTrue(dockgroup.get_current_item() == 0)

        dockitem1.destroy()
        dockitem2.destroy()
        dockgroup.destroy()