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 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
|
import unittest
from unittests import wtc
import wx
#---------------------------------------------------------------------------
class WindowTests(wtc.WidgetTestCase):
def test_SimpleWindowCtor(self):
w = wx.Window(self.frame, -1, (10,10), (50,50), wx.BORDER_NONE)
self.assertEqual(w.GetWindowStyleFlag(), wx.BORDER_NONE)
self.assertTrue(w.Parent is self.frame)
def test_windowHandle(self):
w = wx.Window(self.frame, -1, (10,10), (50,50))
hdl = w.GetHandle()
self.assertTrue(isinstance(hdl, int))
def test_windowProperties(self):
w = wx.Window(self.frame, -1, (10,10), (50,50))
# Just test that these properties exist for now. More tests can be
# added later to ensure that they work correctly.
w.AcceleratorTable
w.AutoLayout
w.BackgroundColour
w.BackgroundStyle
w.EffectiveMinSize
w.BestSize
w.BestVirtualSize
w.Border
w.Caret
w.CharHeight
w.CharWidth
w.Children
w.ClientAreaOrigin
w.ClientRect
w.ClientSize
w.Constraints
w.ContainingSizer
w.Cursor
w.DefaultAttributes
w.DropTarget
w.EventHandler
w.ExtraStyle
w.Font
w.ForegroundColour
w.GrandParent
w.TopLevelParent
w.Handle
w.HelpText
w.Id
w.Label
w.LayoutDirection
w.MaxHeight
w.MaxSize
w.MaxWidth
w.MinHeight
w.MinSize
w.MinWidth
w.Name
w.Parent
w.Position
w.Rect
w.ScreenPosition
w.ScreenRect
w.Size
w.Sizer
w.ThemeEnabled
w.ToolTip
w.UpdateClientRect
w.UpdateRegion
w.Validator
w.VirtualSize
w.WindowStyle
w.WindowStyleFlag
w.WindowVariant
w.Shown
w.Enabled
w.TopLevel
w.MinClientSize
w.MaxClientSize
def test_windowFunctions(self):
wx.FindWindowById
wx.FindWindowByName
wx.FindWindowByLabel
self.assertEqual(wx.FindWindowById(self.frame.GetId()), self.frame)
def test_windowCoordConvFunctions(self):
w = wx.Window(self.frame, -1, (10,10), (50,50))
a = w.ClientToScreen(0, 0)
b = w.ClientToScreen((0, 0))
c = w.ScreenToClient(0, 0)
d = w.ScreenToClient((0, 0))
self.assertEqual(a[0], b.x)
self.assertEqual(a[1], b.y)
self.assertEqual(c[0], d.x)
self.assertEqual(c[1], d.y)
def test_DLG_UNIT(self):
def _check(val, typ):
assert isinstance(val, typ)
a, b = val
assert isinstance(a, int)
assert isinstance(b, int)
val = wx.DLG_UNIT(self.frame, wx.Point(10,10))
_check(val, wx.Point)
val = wx.DLG_UNIT(self.frame, wx.Size(10,10))
_check(val, wx.Size)
val = wx.DLG_UNIT(self.frame, (10,10))
_check(val, tuple)
val = wx.DLG_UNIT(self.frame, [10,10])
_check(val, tuple)
val = self.frame.DLG_UNIT(wx.Point(10, 10))
_check(val, wx.Point)
val = self.frame.DLG_UNIT(wx.Size(10, 10))
_check(val, wx.Size)
val = self.frame.DLG_UNIT((10, 10))
_check(val, tuple)
val = self.frame.DLG_UNIT([10, 10])
_check(val, tuple)
wx.DLG_SZE
wx.DLG_PNT
def test_vizattrs1(self):
w = wx.Window(self.frame, -1, (10,10), (50,50))
a = w.GetClassDefaultAttributes()
assert isinstance(a.colBg, wx.Colour)
assert isinstance(a.colFg, wx.Colour)
assert isinstance(a.font, wx.Font)
def test_vizattrs2(self):
w = wx.Window(self.frame, -1, (10,10), (50,50))
assert isinstance(w.GetClassDefaultAttributes().colBg, wx.Colour)
assert isinstance(w.GetClassDefaultAttributes().colFg, wx.Colour)
assert isinstance(w.GetClassDefaultAttributes().font, wx.Font)
def test_vizattrs3(self):
w = wx.Window(self.frame, -1, (10,10), (50,50))
a = w.GetClassDefaultAttributes()
with self.assertRaises(AttributeError):
a.colBg = wx.Colour('blue')
with self.assertRaises(AttributeError):
a.colFg = wx.Colour('blue')
with self.assertRaises(AttributeError):
a.font = wx.NORMAL_FONT
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()
|