summaryrefslogtreecommitdiff
path: root/tests/test_style.py
blob: e55f1028bad485fc15bc32112ac9f7edd39cfa89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest

from common import gtk

class StylePixmapTest(unittest.TestCase):
    def setUp(self):
        win = gtk.Window()
        win.realize()
        self.window = win.window
        self.bg_pixmap = win.style.bg_pixmap

    def _test(self, pixmap):
        self.bg_pixmap[gtk.STATE_NORMAL] = pixmap
        self.assertEqual(self.bg_pixmap[gtk.STATE_NORMAL], pixmap)

    def testNormal(self):
        self._test(gtk.gdk.Pixmap(self.window, 1, 1))

    def testNone(self):
        self._test(None)

    def testParentRelative(self):
        self._test(gtk.gdk.PARENT_RELATIVE)

    def testInvalid(self):
        func = self.bg_pixmap.__setitem__
        self.assertRaises(TypeError, func, gtk.STATE_NORMAL, True)
        self.assertRaises(TypeError, func, gtk.STATE_NORMAL, 0L)
        self.assertRaises(TypeError, func, gtk.STATE_NORMAL, object())