-
Notifications
You must be signed in to change notification settings - Fork 8
/
Tests.py
97 lines (79 loc) · 2.94 KB
/
Tests.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
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
import sys
import wx
import wx.lib.buttons
def postCommandEvent(ctrl, evtType, evtId = None):
if evtId is None:
evtId = ctrl.GetId()
wx.PostEvent(ctrl, wx.CommandEvent(evtType, evtId))
wx.Yield()
def test_wxFrame(palette):
try:
# New frame
postCommandEvent(palette.palettePages[0].buttons['wx.Frame'],
wx.wxEVT_COMMAND_BUTTON_CLICKED)
# Open designer
mp = palette.editor.getActiveModulePage()
ctrlr = palette.editor.getControllerFromModel(mp.model)
ctrlr.OnDesigner(None)
# Select static text
btn = palette.palettePages[2].buttons['wx.StaticText']
btn.up = False
evt = wx.lib.buttons.GenButtonEvent(wx.wxEVT_COMMAND_BUTTON_CLICKED, btn.GetId())
evt.SetButtonObj(btn)
evt.SetIsDown(True)
wx.PostEvent(btn, evt)
wx.Yield()
# Drop component on Designer
model = palette.editor.getActiveModulePage().model
evt = wx.MouseEvent(wx.wxEVT_LEFT_DOWN)
# evt.SetEventObject(model.views['Designer'])
evt.m_x = 10
evt.m_y = 10
wx.PostEvent(model.views['Designer'], evt)
wx.Yield()
# Select Frame
evt = wx.MouseEvent(wx.wxEVT_LEFT_DOWN)
evt.m_x = 0
evt.m_y = 0
wx.PostEvent(model.views['Designer'], evt)
wx.Yield()
constructorPage = palette.editor.inspector.constr
for nv in constructorPage.nameValues:
if nv.propName == 'Name':
nv.propEditor.inspectorEdit()
nv.propEditor.editorCtrl.editorCtrl.SetValue('TestFrame')
nv.propEditor.inspectorPost(False)
break
# resize designer
model.views['Designer'].SetDimensions(10, 10, 200, 200)
model.views['Designer'].SetPosition( (0, 0) )
wx.Yield()
model.views['Designer'].Close()
except:
wx.MessageBox('Test failed\n'+`sys.exc_info()`)
else:
#if model.data == frame_answer:
wx.MessageBox('Test succeeded')
frame_answer = '''#Boa:Frame:TestFrame
import wx
def create(parent):
return TestFrame(parent)
[wxID_TESTFRAME, wxID_TESTFRAMESTATICTEXT1,
] = [wx.NewId() for _init_ctrls in range(2)]
class TestFrame(wx.Frame):
def _init_utils(self):
# generated method, don't edit
pass
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_TESTFRAME, name='TestFrame', parent=prnt,
pos= wx.Point(0, 0), size= wx.Size(200, 200),
style=wx.DEFAULT_FRAME_STYLE, title='wxFrame1')
self._init_utils()
self.SetClientSize(wx.Size(192, 173))
self.staticText1 = wx.StaticText(id=wxID_TESTFRAMESTATICTEXT1,
label='staticText1', name='staticText1', parent=self,
pos= wx.Point(0, 0), size= wx.Size(192, 173), style=0)
def __init__(self, parent):
self._init_ctrls(parent)
'''