ya2 · news · projects · code · about

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