コード例 #1
0
ファイル: test_parts.py プロジェクト: ApsOps/flumotion-orig
class TestAdminStatusbar(testsuite.TestCase):

    def setUp(self):
        self.window = gtk.Window()
        self.widget = gtk.Statusbar()
        # work around a bug in Statusbar that ends up doing a negative
        # w/h size request by setting a window size
        self.window.set_size_request(100, 100)
        self.window.add(self.widget)
        self.window.show_all()
        self.bar = AdminStatusbar(self.widget)

    def tearDown(self):
        # the iterations make sure the window goes away
        self.window.hide()
        gtk.main_iteration()
        self.window.destroy()
        gtk.main_iteration()

    def testPushRemove(self):
        mid = self.bar.push('main', 'I am a message')
        self.failUnless(self.bar.remove('main', mid))
        self.failIf(self.bar.remove('main', mid))

        # non-existing context
        self.assertRaises(KeyError, self.bar.remove, 'idontexist', 0)
        # non-existing mid
        self.bar.remove('main', 0)

    def testPushPop(self):
        mid = self.bar.push('main', 'I am a message')
        self.failUnlessEqual(self.bar.pop('main'), mid)
        self.failIf(self.bar.pop('main'))

    def testSet(self):
        mid = self.bar.push('main', 'I am a message')
        mid2 = self.bar.set('main', 'I am another message')
        self.failUnless(mid2)
        self.failIfEqual(mid, mid2)

    def testTwoContexts(self):
        mid1 = self.bar.push('main', 'I am a message')
        mid2 = self.bar.push('notebook', 'I am a notebook message')
        self.failUnless(mid2)
        self.failIfEqual(mid1, mid2)
        self.failUnlessEqual(self.bar.pop('main'), mid1)
        self.failUnlessEqual(self.bar.pop('notebook'), mid2)

    def testClear(self):
        self.bar.push('main', 'I am a message')
        self.bar.push('notebook', 'I am a notebook message')
        self.bar.push('notebook', 'I am a second notebook message')
        self.bar.clear('main')
        self.failIf(self.bar.pop('main'))
        self.failUnless(self.bar.pop('notebook'))
        self.bar.clear()
        self.failIf(self.bar.pop('main'))
        self.failIf(self.bar.pop('notebook'))

    def testClearAll(self):
        self.bar.push('main', 'I am the first message')
        self.bar.push('main', 'I am the second message')
        self.bar.clear(None)
        self.failIf(self.bar.pop('main'))
コード例 #2
0
ファイル: test_parts.py プロジェクト: faroncoder/flumotion
class TestAdminStatusbar(testsuite.TestCase):

    def setUp(self):
        self.window = gtk.Window()
        self.widget = gtk.Statusbar()
        # work around a bug in Statusbar that ends up doing a negative
        # w/h size request by setting a window size
        self.window.set_size_request(100, 100)
        self.window.add(self.widget)
        self.window.show_all()
        self.bar = AdminStatusbar(self.widget)

    def tearDown(self):
        # the iterations make sure the window goes away
        self.window.hide()
        gtk.main_iteration()
        self.window.destroy()
        gtk.main_iteration()

    def testPushRemove(self):
        mid = self.bar.push('main', 'I am a message')
        self.failUnless(self.bar.remove('main', mid))
        self.failIf(self.bar.remove('main', mid))

        # non-existing context
        self.assertRaises(KeyError, self.bar.remove, 'idontexist', 0)
        # non-existing mid
        self.bar.remove('main', 0)

    def testPushPop(self):
        mid = self.bar.push('main', 'I am a message')
        self.failUnlessEqual(self.bar.pop('main'), mid)
        self.failIf(self.bar.pop('main'))

    def testSet(self):
        mid = self.bar.push('main', 'I am a message')
        mid2 = self.bar.set('main', 'I am another message')
        self.failUnless(mid2)
        self.failIfEqual(mid, mid2)

    def testTwoContexts(self):
        mid1 = self.bar.push('main', 'I am a message')
        mid2 = self.bar.push('notebook', 'I am a notebook message')
        self.failUnless(mid2)
        self.failIfEqual(mid1, mid2)
        self.failUnlessEqual(self.bar.pop('main'), mid1)
        self.failUnlessEqual(self.bar.pop('notebook'), mid2)

    def testClear(self):
        self.bar.push('main', 'I am a message')
        self.bar.push('notebook', 'I am a notebook message')
        self.bar.push('notebook', 'I am a second notebook message')
        self.bar.clear('main')
        self.failIf(self.bar.pop('main'))
        self.failUnless(self.bar.pop('notebook'))
        self.bar.clear()
        self.failIf(self.bar.pop('main'))
        self.failIf(self.bar.pop('notebook'))

    def testClearAll(self):
        self.bar.push('main', 'I am the first message')
        self.bar.push('main', 'I am the second message')
        self.bar.clear(None)
        self.failIf(self.bar.pop('main'))