ya2 · news · projects · code · about

retrieve test coordinates
[pmachines.git] / tests / functional_test.py
CommitLineData
361d3942
FC
1'''Create ref:
2* M-x fla-set-fun-test
3* rm options.ini
53ddf3c3
FC
4* python main.py --functional-test --functional-ref & python -m ya2.tools.functional_test.py 1
5* python main.py --functional-test --functional-ref & python -m ya2.tools.functional_test.py 2
361d3942
FC
6* M-x fla-unset-fun-test'''
7from panda3d.core import load_prc_file_data
8load_prc_file_data('', 'window-type none')
9import datetime
10from time import sleep
11from os import getcwd, system
158b04a8 12from xmlrpc.client import ServerProxy
361d3942
FC
13from logging import debug, info
14from pathlib import Path
15from shutil import rmtree
16from os import makedirs
17from os.path import join, exists
18from glob import glob
19from sys import exit, argv
20from panda3d.core import Filename
21from direct.showbase.ShowBase import ShowBase
22from direct.gui.OnscreenText import OnscreenText
b35b1f62 23from ya2.patterns.gameobject import GameObject
53ddf3c3 24from ya2.build.build import _branch
361d3942
FC
25
26
27class FunctionalTest(GameObject):
28
29 screenshot_time = 1.2
30 evt_time = 1.0
31 drag_time = 1.0
32 start_time = 2
33
68f6c184 34 def __init__(self, idx, offset):
361d3942
FC
35 super().__init__()
36 info('test idx: %s' % idx)
68f6c184 37 self._offset = offset
361d3942 38 sleep(5)
158b04a8 39 self._proxy = ServerProxy('http://localhost:6000')
361d3942
FC
40 self._curr_time = 0
41 self._tasks = []
42 self._prev_time = 0
43 taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable')
158b04a8 44 self._proxy.set_idx(idx)
361d3942
FC
45 self._do_screenshots(idx)
46
47 def _do_screenshot(self, name):
48 time = datetime.datetime.now().strftime('%y%m%d%H%M%S')
49 name = name + '.png'
158b04a8 50 self._proxy.screenshot(name)
361d3942
FC
51 info('screenshot %s' % name)
52
53 def _screenshot(self, time, name):
54 self._tasks += [(
55 self._curr_time + time,
56 lambda: self._do_screenshot(name),
57 'screenshot: %s' % name)]
58 self._curr_time += time
59
2d1773b1 60 def __mouse_click(self, tgt, btn):
2e5f0efc
FC
61 offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations
62 offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations
361d3942 63 btn = 3 if btn == 'right' else 1
2d1773b1
FC
64 pos = self._proxy.get_pos(tgt)
65 print(tgt, pos)
361d3942
FC
66 system('xdotool mousemove %s %s' % (offset_x + pos[0], offset_y + pos[1]))
67 def click(task):
68 system('xdotool click %s' % btn)
c8e3e941 69 taskMgr.do_method_later(.28, click, 'click')
361d3942
FC
70
71 def __mouse_drag(self, start, end, btn):
2e5f0efc
FC
72 offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations
73 offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations
361d3942
FC
74 btn = 3 if btn == 'right' else 1
75 system('xdotool mousemove %s %s' % (offset_x + start[0], offset_y + start[1]))
76 def mousedown(task):
77 system('xdotool mousedown %s' % btn)
78 def mousemove(task):
79 system('xdotool mousemove %s %s' % (offset_x + end[0], offset_y + end[1]))
80 def mouseup(task):
81 system('xdotool mouseup %s' % btn)
82 taskMgr.do_method_later(.28, mouseup, 'mouseup')
83 taskMgr.do_method_later(.28, mousemove, 'mousemove')
84 taskMgr.do_method_later(.28, mousedown, 'mousedown')
85
86 def _event(self, time, evt, mouse_args=None):
87 if evt == 'mouseclick':
88 cback = lambda: self.__mouse_click(*mouse_args)
89 elif evt == 'mousedrag':
90 cback = lambda: self.__mouse_drag(*mouse_args)
91 self._tasks += [(
92 self._curr_time + time,
93 cback,
94 'event: %s' % evt)]
95 self._curr_time += time
96
97 def _enforce_res(self, time, res):
98 def cback():
158b04a8 99 self._proxy.enforce_res(res)
361d3942
FC
100 info('enforce_res %s' % res)
101 self._tasks += [(
102 self._curr_time + time,
103 cback,
104 'enforce res: %s' % res)]
105 self._curr_time += time
106
74ed9732
FC
107 def _enforce_resolution(self, time, res):
108 def cback():
158b04a8 109 self._proxy.enforce_resolution(res)
74ed9732
FC
110 info('enforce_resolution %s (send)' % res)
111 self._tasks += [(
112 self._curr_time + time,
113 cback,
114 'enforce resolution: %s' % res)]
115 self._curr_time += time
116
361d3942
FC
117 def _verify(self):
118 def __verify():
158b04a8 119 self._proxy.verify()
361d3942
FC
120 info('verify')
121 self._tasks += [(
122 self._curr_time + 3,
123 lambda: __verify(),
124 'verify')]
125 self._curr_time += 3
126
127 def _exit(self):
128 def do_exit():
158b04a8 129 self._proxy.close()
361d3942
FC
130 exit()
131 self._tasks += [(
132 self._curr_time + 3,
133 lambda: do_exit(),
134 'exit')]
135
136 def on_frame_unpausable(self, task):
137 for tsk in self._tasks:
138 #if self._prev_time <= tsk[0] < self.eng.event.unpaused_time:
139 if self._prev_time <= tsk[0] < globalClock.getFrameTime():
140 debug('%s %s' % (tsk[0], tsk[2]))
141 tsk[1]()
142 self._prev_time = globalClock.getFrameTime() # self.eng.event.unpaused_time
143 return task.cont
144
145 def _do_screenshots_1(self):
146 info('_do_screenshots_1')
147 self._screenshot(FunctionalTest.start_time, 'main_menu')
fd51f753
FC
148 self._do_screenshots_credits()
149 self._do_screenshots_options()
361d3942
FC
150 self._do_screenshots_exit()
151
152 def _do_screenshots_credits(self):
2d1773b1
FC
153 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])
154 self._event(FunctionalTest.evt_time, 'mouseclick', ['credits', 'left'])
361d3942 155 self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
2d1773b1
FC
156 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left'])
157 self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left'])
361d3942
FC
158 self._screenshot(FunctionalTest.screenshot_time, 'main_menu_back_from_credits')
159
160 def _do_screenshots_options(self):
2d1773b1
FC
161 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 300), 'left'])
162 self._event(FunctionalTest.evt_time, 'mouseclick', ['options', 'left'])
361d3942
FC
163 self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
164 # languages
2d1773b1
FC
165 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 60), 'left'])
166 self._event(FunctionalTest.evt_time, 'mouseclick', ['languages', 'left'])
361d3942 167 self._screenshot(FunctionalTest.screenshot_time, 'open_languages')
2d1773b1
FC
168 #self._event(FunctionalTest.evt_time, 'mouseclick', [(980, 120), 'left'])
169 self._event(FunctionalTest.evt_time, 'mouseclick', ['italian', 'left'])
361d3942
FC
170 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_italian')
171 # volume
2d1773b1
FC
172 #self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 163), 'left'])
173 self._event(FunctionalTest.evt_time, 'mouseclick', ['volume', 'left'])
361d3942
FC
174 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_1')
175 # antialiasing
2d1773b1
FC
176 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 440), 'left'])
177 self._event(FunctionalTest.evt_time, 'mouseclick', ['aa', 'left'])
361d3942
FC
178 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_no')
179 # shadows
2d1773b1
FC
180 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 540), 'left'])
181 self._event(FunctionalTest.evt_time, 'mouseclick', ['shadows', 'left'])
361d3942
FC
182 self._screenshot(FunctionalTest.screenshot_time, 'shadows_no')
183 # test aa and shadows
2d1773b1
FC
184 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back
185 self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left']) # back
186 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play
187 self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left']) # play
188 #self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino
189 self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left']) # domino
190 #self._event(FunctionalTest.evt_time, 'mouseclick', [(900, 490), 'left']) # close instructions
191 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) # close instructions
361d3942 192 self._screenshot(FunctionalTest.screenshot_time, 'aa_no_shadows_no')
2d1773b1
FC
193 #self._event(FunctionalTest.evt_time, 'mouseclick', [(25, 740), 'left']) # home
194 self._event(FunctionalTest.evt_time, 'mouseclick', ['home', 'left']) # home
361d3942
FC
195
196 def _do_screenshots_restore_options(self):
2d1773b1
FC
197 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 300), 'left'])
198 self._event(FunctionalTest.evt_time, 'mouseclick', ['options', 'left'])
361d3942
FC
199 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
200 # languages
2d1773b1
FC
201 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 60), 'left'])
202 self._event(FunctionalTest.evt_time, 'mouseclick', ['languages', 'left'])
361d3942 203 self._screenshot(FunctionalTest.screenshot_time, 'open_languages_restored')
2d1773b1
FC
204 #self._event(FunctionalTest.evt_time, 'mouseclick', [(980, 20), 'left'])
205 self._event(FunctionalTest.evt_time, 'mouseclick', ['english', 'left'])
361d3942
FC
206 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_english')
207 # volume
2d1773b1
FC
208 #self._event(FunctionalTest.evt_time, 'mouseclick', [(719, 163), 'left'])
209 self._event(FunctionalTest.evt_time, 'mouseclick', ['volume_0', 'left'])
361d3942
FC
210 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2')
211 # fullscreen
212 # the first one is because of the windowed mode in test
2d1773b1
FC
213 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
214 self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left'])
e982cdde 215 self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
2d1773b1
FC
216 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
217 self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left'])
e982cdde 218 self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
5d67a04d 219 #self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(440, 120), 'left'])
2d1773b1
FC
220 #self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
221 self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left'])
e982cdde 222 self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen')
361d3942 223 # resolution
2d1773b1
FC
224 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 340), 'left'])
225 self._event(FunctionalTest.evt_time, 'mouseclick', ['resolutions', 'left'])
bd238983 226 self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
74ed9732 227 self._enforce_resolution(FunctionalTest.evt_time, '1440x900')
2d1773b1
FC
228 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1000, 440), 'left'])
229 self._event(FunctionalTest.evt_time, 'mouseclick', ['res_1440x900', 'left'])
bd238983 230 self._screenshot(FunctionalTest.screenshot_time, '1440x900')
2d1773b1
FC
231 #self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 400), 'left'])
232 self._event(FunctionalTest.evt_time, 'mouseclick', ['resolutions', 'left'])
bd238983 233 self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
74ed9732 234 self._enforce_resolution(FunctionalTest.evt_time, '1360x768')
2d1773b1
FC
235 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1110, 80), 'left'])
236 self._event(FunctionalTest.evt_time, 'mouseclick', ['res_1360x768', 'left'])
bd238983 237 self._screenshot(FunctionalTest.screenshot_time, '1360x768')
361d3942 238 # antialiasing
2d1773b1
FC
239 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 440), 'left'])
240 self._event(FunctionalTest.evt_time, 'mouseclick', ['aa', 'left'])
361d3942
FC
241 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_yes')
242 # shadows
2d1773b1
FC
243 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 540), 'left'])
244 self._event(FunctionalTest.evt_time, 'mouseclick', ['shadows', 'left'])
361d3942 245 self._screenshot(FunctionalTest.screenshot_time, 'shadows_yes')
2d1773b1
FC
246 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back
247 self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left'])
361d3942
FC
248
249 def _do_screenshots_play(self):
2d1773b1
FC
250 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play
251 self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left'])
361d3942 252 self._screenshot(FunctionalTest.screenshot_time, 'play_menu')
2d1773b1
FC
253 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back
254 self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left'])
361d3942 255 self._screenshot(FunctionalTest.screenshot_time, 'back_from_play')
2d1773b1
FC
256 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play
257 self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left'])
258 #self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino scene
259 self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left'])
361d3942 260 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_instructions')
2d1773b1
FC
261 #self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions
262 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
361d3942 263 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino')
2d1773b1
FC
264 #self._event(FunctionalTest.evt_time, 'mouseclick', [(25, 740), 'left']) # home
265 self._event(FunctionalTest.evt_time, 'mouseclick', ['home', 'left'])
361d3942 266 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_scene')
2d1773b1
FC
267 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play
268 self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left'])
269 #self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino
270 self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left'])
271 #self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions
272 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
273 #self._event(FunctionalTest.evt_time, 'mouseclick', [(70, 740), 'left']) # info
274 self._event(FunctionalTest.evt_time, 'mouseclick', ['information', 'left'])
361d3942 275 self._screenshot(FunctionalTest.screenshot_time, 'info')
2d1773b1
FC
276 #self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions
277 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
f26497a5
FC
278 # self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (430, 280), 'left']) # drag a piece
279 # self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged')
280 # self._event(FunctionalTest.evt_time, 'mouseclick', [(1220, 740), 'left']) # rewind
281 # self._screenshot(FunctionalTest.screenshot_time, 'rewind')
361d3942
FC
282 self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left']) # drag a piece
283 # self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left']) # drag a piece
2d1773b1
FC
284 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
285 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play
361d3942 286 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino')
2d1773b1
FC
287 #self._event(FunctionalTest.evt_time, 'mouseclick', [(630, 450), 'left']) # home
288 self._event(FunctionalTest.evt_time, 'mouseclick', ['home_win', 'left']) # home
361d3942 289 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_fail')
2d1773b1
FC
290 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play
291 self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left']) # play
292 #self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino
293 self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left'])
294 #self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions
295 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
361d3942
FC
296 self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left']) # drag a piece
297 self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left']) # drag a piece
2d1773b1
FC
298 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
299 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play
361d3942 300 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_2')
2d1773b1
FC
301 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
302 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) # play
361d3942
FC
303 self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (570, 380), 'left']) # drag a piece
304 self._event(FunctionalTest.drag_time, 'mousedrag', [(570, 355), (605, 355), 'right']) # rotate the piece
305 self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left']) # drag a piece
306 self._enforce_res(FunctionalTest.evt_time, 'win')
2d1773b1
FC
307 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
308 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play
361d3942
FC
309 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino')
310 self._enforce_res(FunctionalTest.evt_time, '')
2d1773b1
FC
311 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
312 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) # play
361d3942
FC
313 self._screenshot(FunctionalTest.screenshot_time, 'scene_box')
314 # scene 2
2d1773b1
FC
315 #self._event(FunctionalTest.evt_time, 'mouseclick', [(880, 490), 'left']) # close instructions
316 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
361d3942
FC
317 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left']) # drag a box
318 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left']) # drag a box
2d1773b1
FC
319 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
320 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942 321 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box')
2d1773b1
FC
322 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
323 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
361d3942
FC
324 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left']) # drag a box
325 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left']) # drag a box
326 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (705, 460), 'left']) # drag a box
327 self._enforce_res(FunctionalTest.evt_time, 'win')
2d1773b1
FC
328 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
329 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942
FC
330 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box')
331 self._enforce_res(FunctionalTest.evt_time, '')
2d1773b1
FC
332 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
333 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
361d3942
FC
334 self._screenshot(FunctionalTest.screenshot_time, 'scene_box_domino')
335 # scene 3
2d1773b1
FC
336 #self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left']) # close instructions
337 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
361d3942
FC
338 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left']) # drag a box
339 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 360), 'left']) # drag a box
2d1773b1
FC
340 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
341 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942 342 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box_domino')
2d1773b1
FC
343 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
344 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
361d3942
FC
345 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left']) # drag a box
346 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (835, 250), 'left']) # drag a box
347 self._enforce_res(FunctionalTest.evt_time, 'win')
2d1773b1
FC
348 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
349 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942
FC
350 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box_domino')
351 self._enforce_res(FunctionalTest.evt_time, '')
2d1773b1
FC
352 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
353 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
361d3942
FC
354 self._screenshot(FunctionalTest.screenshot_time, 'scene_basketball')
355 # scene 4
2d1773b1
FC
356 #self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 490), 'left']) # close instructions
357 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
361d3942 358 self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (650, 310), 'left']) # drag a ball
2d1773b1
FC
359 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
360 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942 361 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_basketball')
2d1773b1
FC
362 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
363 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
361d3942
FC
364 self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (380, 50), 'left']) # drag a ball
365 self._enforce_res(FunctionalTest.evt_time, 'win')
2d1773b1
FC
366 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
367 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942
FC
368 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_basketball')
369 self._enforce_res(FunctionalTest.evt_time, '')
2d1773b1
FC
370 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
371 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
361d3942
FC
372 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_box_basketball')
373 # scene 5
2d1773b1
FC
374 #self._event(FunctionalTest.evt_time, 'mouseclick', [(865, 490), 'left']) # close instructions
375 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
361d3942
FC
376 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left']) # drag a box
377 self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (590, 370), 'left']) # drag a piece
2d1773b1
FC
378 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
379 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942 380 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_box_basketball')
2d1773b1
FC
381 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
382 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
361d3942
FC
383 self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left']) # drag a box
384 self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (660, 440), 'left']) # drag a piece
385 self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 425), (625, 425), 'right']) # rotate a piece
386 self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 435), (650, 445), 'left']) # drag a piece
387 self._enforce_res(FunctionalTest.evt_time, 'win')
2d1773b1
FC
388 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
389 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361d3942
FC
390 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino_box_basketball')
391 self._enforce_res(FunctionalTest.evt_time, '')
2d1773b1
FC
392 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
393 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
39a6176f
FC
394 self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_tooter')
395 # scene 6
2d1773b1
FC
396 #self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 485), 'left']) # close instructions
397 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
39a6176f 398 self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 300), 'left']) # drag a box
2d1773b1
FC
399 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
400 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
39a6176f 401 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_tooter')
2d1773b1
FC
402 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
403 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
39a6176f
FC
404 self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 150), 'left']) # drag a box
405 self._event(FunctionalTest.drag_time, 'mousedrag', [(515, 115), (515, 122), 'right']) # rotate a box
406 self._enforce_res(FunctionalTest.evt_time, 'win')
2d1773b1
FC
407 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
408 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
39a6176f
FC
409 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_tooter')
410 self._enforce_res(FunctionalTest.evt_time, '')
2d1773b1
FC
411 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
412 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
39a6176f
FC
413 self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_domino_box_basketball')
414 # scene 7
2d1773b1
FC
415 #self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left']) # close instructions
416 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
39a6176f 417 self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (155, 180), 'left']) # drag a box
2d1773b1
FC
418 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
419 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
39a6176f 420 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_domino_box_basketball')
2d1773b1
FC
421 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
422 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
39a6176f
FC
423 self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (170, 80), 'left']) # drag a box
424 self._event(FunctionalTest.drag_time, 'mousedrag', [(195, 50), (195, 80), 'right']) # rotate a box
425 self._enforce_res(FunctionalTest.evt_time, 'win')
2d1773b1
FC
426 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
427 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
39a6176f
FC
428 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_domino_box_basketball')
429 self._enforce_res(FunctionalTest.evt_time, '')
2d1773b1
FC
430 #self._event(FunctionalTest.evt_time, 'mouseclick', [(630, 450), 'left']) # home
431 self._event(FunctionalTest.evt_time, 'mouseclick', ['home_win', 'left'])
361d3942
FC
432 self._screenshot(FunctionalTest.screenshot_time, 'home_from_play')
433
434 def _exit(self):
435 self._tasks += [(
436 self._curr_time + 3,
437 lambda: exit(),
438 'exit')]
439
440 def _do_screenshots_exit(self):
441 self._verify()
2d1773b1
FC
442 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 600), 'left'])
443 self._event(FunctionalTest.evt_time, 'mouseclick', ['exit', 'left'])
361d3942
FC
444 self._exit()
445
446 def _do_screenshots_2(self):
447 info('_do_screenshots_2')
448 self._screenshot(FunctionalTest.start_time, 'main_menu_2')
449 self._do_screenshots_restore_options()
450 self._do_screenshots_play()
451 self._do_screenshots_exit()
452
453 def _do_screenshots(self, idx):
454 [self._do_screenshots_1, self._do_screenshots_2][int(idx) - 1]()
455
456
457class TestApp(ShowBase):
458
459 def __init__(self):
460 ShowBase.__init__(self)
68f6c184
FC
461 offset = int(argv[2]) if len(argv) >= 3 else 0
462 fun_test = FunctionalTest(int(argv[1]), offset)
361d3942
FC
463
464
465TestApp().run()