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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
# -*- Mode: Python; py-indent-offset: 4 -*-
# vim: tabstop=4 shiftwidth=4 expandtab
import unittest
import sys
import os
sys.path.insert(0, "../")
from gi.repository import Gdk
from gi.repository import Gtk
import gi.pygtkcompat
gi.pygtkcompat.enable()
gi.pygtkcompat.enable_gtk(version='3.0')
import atk
import pango
import pangocairo
import gtk
import gtk.gdk
class TestGTKCompat(unittest.TestCase):
def testButtons(self):
self.assertEquals(Gdk._2BUTTON_PRESS, 5)
self.assertEquals(Gdk.BUTTON_PRESS, 4)
def testEnums(self):
self.assertEquals(gtk.WINDOW_TOPLEVEL, Gtk.WindowType.TOPLEVEL)
self.assertEquals(gtk.PACK_START, Gtk.PackType.START)
def testFlags(self):
self.assertEquals(gtk.EXPAND, Gtk.AttachOptions.EXPAND)
def testKeysyms(self):
import gtk.keysyms
self.assertEquals(gtk.keysyms.Escape, Gdk.KEY_Escape)
self.failUnless(gtk.keysyms._0, Gdk.KEY_0)
def testStyle(self):
widget = gtk.Button()
self.failUnless(isinstance(widget.style.base[gtk.STATE_NORMAL],
gtk.gdk.Color))
def testAlignment(self):
a = gtk.Alignment()
self.assertEquals(a.props.xalign, 0.0)
self.assertEquals(a.props.yalign, 0.0)
self.assertEquals(a.props.xscale, 0.0)
self.assertEquals(a.props.yscale, 0.0)
def testBox(self):
box = gtk.Box()
child = gtk.Button()
box.pack_start(child)
expand, fill, padding, pack_type = box.query_child_packing(child)
self.failUnless(expand)
self.failUnless(fill)
self.assertEquals(padding, 0)
self.assertEquals(pack_type, gtk.PACK_START)
child = gtk.Button()
box.pack_end(child)
expand, fill, padding, pack_type = box.query_child_packing(child)
self.failUnless(expand)
self.failUnless(fill)
self.assertEquals(padding, 0)
self.assertEquals(pack_type, gtk.PACK_END)
def testComboBoxEntry(self):
liststore = gtk.ListStore(int, str)
liststore.append((1, 'One'))
liststore.append((2, 'Two'))
liststore.append((3, 'Three'))
combo = gtk.ComboBoxEntry(model=liststore)
combo.set_text_column(1)
combo.set_active(0)
self.assertEquals(combo.get_text_column(), 1)
self.assertEquals(combo.get_child().get_text(), 'One')
combo = gtk.combo_box_entry_new()
combo.set_model(liststore)
combo.set_text_column(1)
combo.set_active(0)
self.assertEquals(combo.get_text_column(), 1)
self.assertEquals(combo.get_child().get_text(), 'One')
combo = gtk.combo_box_entry_new_with_model(liststore)
combo.set_text_column(1)
combo.set_active(0)
self.assertEquals(combo.get_text_column(), 1)
self.assertEquals(combo.get_child().get_text(), 'One')
def testSizeRequest(self):
box = gtk.Box()
self.assertEqual(box.size_request(), [0, 0])
def testPixbuf(self):
gtk.gdk.Pixbuf()
def testPixbufLoader(self):
loader = gtk.gdk.PixbufLoader('png')
loader.close()
def testGdkWindow(self):
w = gtk.Window()
w.realize()
self.assertEquals(w.get_window().get_origin(), (0, 0))
|