Пример #1
0
    def test_prop_icon_name(self):
        global notify_called

        def _on_notify(gobject, pspec):
            global notify_called
            notify_called = True

        dockitem = DockItem()
        dockitem.connect('notify::icon-name', _on_notify)

        notify_called = False
        dockitem.set_icon_name('someicon')
        self.assertEquals(dockitem.get_icon_name(), 'someicon',
                          msg='get_icon_name method did not return expected value')
        self.assertTrue(notify_called,
                        msg='icon-name property change notification failed when using set_icon_name method')

        notify_called = False
        dockitem.set_property('icon-name', 'anothericon')
        self.assertEquals(dockitem.get_property('icon-name'), 'anothericon',
                          msg='get_property method did not return expected value')
        self.assertTrue(notify_called,
                        msg='icon-name property change notification failed when using set_property method')

        notify_called = False
        dockitem.props.icon_name = 'niceicon'
        self.assertEquals(dockitem.props.icon_name, 'niceicon',
                          msg='.props attribute did not return expected value')
        self.assertTrue(notify_called,
                        msg='icon-name property change notification failed when using .props attribute')

        dockitem.destroy()
Пример #2
0
    def test_prop_image(self):
        #TODO: is there a way to check we actually received the image we expect?
        dockitem = DockItem()
        dockitem.set_icon_name('someicon')
        self.assertTrue(isinstance(dockitem.get_image(), gtk.Image))
        self.assertTrue(isinstance(dockitem.props.image, gtk.Image))
        self.assertTrue(isinstance(dockitem.get_property('image'), gtk.Image))
        dockitem.destroy()

        dockitem = DockItem()
        dockitem.set_stock(gtk.STOCK_ABOUT)
        self.assertTrue(isinstance(dockitem.get_image(), gtk.Image))
        self.assertTrue(isinstance(dockitem.props.image, gtk.Image))
        self.assertTrue(isinstance(dockitem.get_property('image'), gtk.Image))
        dockitem.destroy()