forked from wxWidgets/Phoenix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_windowlist.py
57 lines (44 loc) · 1.75 KB
/
test_windowlist.py
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
import sys
import unittest
import wx
from unittests import wtc
##import os; print 'PID:', os.getpid(); raw_input('Ready to start, press enter...')
#---------------------------------------------------------------------------
class WindowList(wtc.WidgetTestCase): #unittest.TestCase):
def setUp(self):
super(WindowList, self).setUp()
self.frames = list()
for i in range(5):
frm = wx.Frame(self.frame, title='frm%d' % i)
self.frames.append( frm )
frm.Show()
for i in range(5):
w = wx.Window(self.frames[4])
def _tearDown(self):
def _closeAll():
for frm in wx.GetTopLevelWindows():
if frm:
frm.Close()
self.myYield()
wx.CallAfter(_closeAll)
self.app.MainLoop()
del self.app
def test_WindowList_GetTLW1(self):
TLWs = wx.GetTopLevelWindows()
#self.assertEqual(len(TLWs), 6) # 1 created in the base class plus 5 here
# since TLWs delay destroying themselves there may be more than 6 of them here
# when we're running the whole test suite, so we have to comment out that
# assert...
for tlw in TLWs:
self.assertTrue(isinstance(tlw, wx.TopLevelWindow))
def test_WindowList_GetChildren(self):
children = self.frames[0].GetChildren()
self.assertEqual(len(children), 0)
children = self.frames[4].GetChildren()
self.assertEqual(len(children), 5)
def test_WindowList_repr(self):
TLWs = wx.GetTopLevelWindows()
self.assertTrue(repr(TLWs).startswith("WindowList:"))
#---------------------------------------------------------------------------
if __name__ == '__main__':
unittest.main()