ya2 · news · projects · code · about

9aa1d8ac045095e9721da214449c8d8404fa3df0
[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.patterns.gameobject import GameObject
24 from ya2.build.build import _branch
25
26
27 class FunctionalTest(GameObject):
28
29 screenshot_time = 1.2
30 evt_time = 1.0
31 drag_time = 1.0
32 start_time = 2
33
34 def __init__(self, idx, offset):
35 super().__init__()
36 info('test idx: %s' % idx)
37 self._offset = offset
38 sleep(5)
39 self._proxy = ServerProxy('http://localhost:6000')
40 self._curr_time = 0
41 self._tasks = []
42 self._prev_time = 0
43 taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable')
44 self._proxy.set_idx(idx)
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'
50 self._proxy.screenshot(name)
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
60 def __mouse_click(self, tgt, btn):
61 offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations
62 offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations
63 btn = 3 if btn == 'right' else 1
64 pos = self._proxy.get_pos(tgt)
65 print(tgt, pos)
66 system('xdotool mousemove %s %s' % (offset_x + pos[0], offset_y + pos[1]))
67 def click(task):
68 system('xdotool click %s' % btn)
69 taskMgr.do_method_later(.28, click, 'click')
70
71 def __mouse_drag(self, start, end, btn):
72 offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations
73 offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations
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():
99 self._proxy.enforce_res(res)
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
107 def _enforce_resolution(self, time, res):
108 def cback():
109 self._proxy.enforce_resolution(res)
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
117 def _verify(self):
118 def __verify():
119 self._proxy.verify()
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():
129 self._proxy.close()
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')
148 self._do_screenshots_credits()
149 self._do_screenshots_options()
150 self._do_screenshots_exit()
151
152 def _do_screenshots_credits(self):
153 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left'])
154 self._event(FunctionalTest.evt_time, 'mouseclick', ['credits', 'left'])
155 self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
156 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left'])
157 self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left'])
158 self._screenshot(FunctionalTest.screenshot_time, 'main_menu_back_from_credits')
159
160 def _do_screenshots_options(self):
161 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 300), 'left'])
162 self._event(FunctionalTest.evt_time, 'mouseclick', ['options', 'left'])
163 self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
164 # languages
165 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 60), 'left'])
166 self._event(FunctionalTest.evt_time, 'mouseclick', ['languages', 'left'])
167 self._screenshot(FunctionalTest.screenshot_time, 'open_languages')
168 #self._event(FunctionalTest.evt_time, 'mouseclick', [(980, 120), 'left'])
169 self._event(FunctionalTest.evt_time, 'mouseclick', ['italian', 'left'])
170 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_italian')
171 # volume
172 #self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 163), 'left'])
173 self._event(FunctionalTest.evt_time, 'mouseclick', ['volume', 'left'])
174 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_1')
175 # antialiasing
176 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 440), 'left'])
177 self._event(FunctionalTest.evt_time, 'mouseclick', ['aa', 'left'])
178 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_no')
179 # shadows
180 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 540), 'left'])
181 self._event(FunctionalTest.evt_time, 'mouseclick', ['shadows', 'left'])
182 self._screenshot(FunctionalTest.screenshot_time, 'shadows_no')
183 # test aa and shadows
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
192 self._screenshot(FunctionalTest.screenshot_time, 'aa_no_shadows_no')
193 #self._event(FunctionalTest.evt_time, 'mouseclick', [(25, 740), 'left']) # home
194 self._event(FunctionalTest.evt_time, 'mouseclick', ['home', 'left']) # home
195
196 def _do_screenshots_restore_options(self):
197 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 300), 'left'])
198 self._event(FunctionalTest.evt_time, 'mouseclick', ['options', 'left'])
199 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
200 # languages
201 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 60), 'left'])
202 self._event(FunctionalTest.evt_time, 'mouseclick', ['languages', 'left'])
203 self._screenshot(FunctionalTest.screenshot_time, 'open_languages_restored')
204 #self._event(FunctionalTest.evt_time, 'mouseclick', [(980, 20), 'left'])
205 self._event(FunctionalTest.evt_time, 'mouseclick', ['english', 'left'])
206 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_english')
207 # volume
208 #self._event(FunctionalTest.evt_time, 'mouseclick', [(719, 163), 'left'])
209 self._event(FunctionalTest.evt_time, 'mouseclick', ['volume_0', 'left'])
210 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2')
211 # fullscreen
212 # the first one is because of the windowed mode in test
213 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
214 self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left'])
215 self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
216 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
217 self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left'])
218 self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
219 #self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(440, 120), 'left'])
220 #self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
221 self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left'])
222 self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen')
223 # resolution
224 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 340), 'left'])
225 self._event(FunctionalTest.evt_time, 'mouseclick', ['resolutions', 'left'])
226 self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
227 self._enforce_resolution(FunctionalTest.evt_time, '1440x900')
228 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1000, 440), 'left'])
229 self._event(FunctionalTest.evt_time, 'mouseclick', ['res_1440x900', 'left'])
230 self._screenshot(FunctionalTest.screenshot_time, '1440x900')
231 #self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 400), 'left'])
232 self._event(FunctionalTest.evt_time, 'mouseclick', ['resolutions', 'left'])
233 self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
234 self._enforce_resolution(FunctionalTest.evt_time, '1360x768')
235 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1110, 80), 'left'])
236 self._event(FunctionalTest.evt_time, 'mouseclick', ['res_1360x768', 'left'])
237 self._screenshot(FunctionalTest.screenshot_time, '1360x768')
238 # antialiasing
239 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 440), 'left'])
240 self._event(FunctionalTest.evt_time, 'mouseclick', ['aa', 'left'])
241 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_yes')
242 # shadows
243 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 540), 'left'])
244 self._event(FunctionalTest.evt_time, 'mouseclick', ['shadows', 'left'])
245 self._screenshot(FunctionalTest.screenshot_time, 'shadows_yes')
246 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back
247 self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left'])
248
249 def _do_screenshots_play(self):
250 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play
251 self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left'])
252 self._screenshot(FunctionalTest.screenshot_time, 'play_menu')
253 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back
254 self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left'])
255 self._screenshot(FunctionalTest.screenshot_time, 'back_from_play')
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'])
260 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_instructions')
261 #self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions
262 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
263 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino')
264 #self._event(FunctionalTest.evt_time, 'mouseclick', [(25, 740), 'left']) # home
265 self._event(FunctionalTest.evt_time, 'mouseclick', ['home', 'left'])
266 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_scene')
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'])
275 self._screenshot(FunctionalTest.screenshot_time, 'info')
276 #self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions
277 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
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')
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
284 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
285 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play
286 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino')
287 #self._event(FunctionalTest.evt_time, 'mouseclick', [(630, 450), 'left']) # home
288 self._event(FunctionalTest.evt_time, 'mouseclick', ['home_win', 'left']) # home
289 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_fail')
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'])
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
298 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
299 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play
300 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_2')
301 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
302 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) # play
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')
307 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
308 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play
309 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino')
310 self._enforce_res(FunctionalTest.evt_time, '')
311 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
312 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) # play
313 self._screenshot(FunctionalTest.screenshot_time, 'scene_box')
314 # scene 2
315 #self._event(FunctionalTest.evt_time, 'mouseclick', [(880, 490), 'left']) # close instructions
316 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
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
319 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
320 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
321 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box')
322 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
323 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
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')
328 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
329 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
330 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box')
331 self._enforce_res(FunctionalTest.evt_time, '')
332 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
333 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
334 self._screenshot(FunctionalTest.screenshot_time, 'scene_box_domino')
335 # scene 3
336 #self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left']) # close instructions
337 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
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
340 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
341 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
342 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box_domino')
343 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
344 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
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')
348 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
349 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
350 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box_domino')
351 self._enforce_res(FunctionalTest.evt_time, '')
352 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
353 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
354 self._screenshot(FunctionalTest.screenshot_time, 'scene_basketball')
355 # scene 4
356 #self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 490), 'left']) # close instructions
357 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
358 self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (650, 310), 'left']) # drag a ball
359 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
360 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
361 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_basketball')
362 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
363 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
364 self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (380, 50), 'left']) # drag a ball
365 self._enforce_res(FunctionalTest.evt_time, 'win')
366 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
367 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
368 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_basketball')
369 self._enforce_res(FunctionalTest.evt_time, '')
370 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
371 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
372 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_box_basketball')
373 # scene 5
374 #self._event(FunctionalTest.evt_time, 'mouseclick', [(865, 490), 'left']) # close instructions
375 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
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
378 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
379 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
380 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_box_basketball')
381 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
382 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
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')
388 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
389 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
390 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino_box_basketball')
391 self._enforce_res(FunctionalTest.evt_time, '')
392 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
393 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
394 self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_tooter')
395 # scene 6
396 #self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 485), 'left']) # close instructions
397 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
398 self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 300), 'left']) # drag a box
399 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
400 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
401 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_tooter')
402 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
403 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
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')
407 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
408 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
409 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_tooter')
410 self._enforce_res(FunctionalTest.evt_time, '')
411 #self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next
412 self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left'])
413 self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_domino_box_basketball')
414 # scene 7
415 #self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left']) # close instructions
416 self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left'])
417 self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (155, 180), 'left']) # drag a box
418 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
419 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
420 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_domino_box_basketball')
421 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay
422 self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left'])
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')
426 #self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
427 self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left'])
428 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_domino_box_basketball')
429 self._enforce_res(FunctionalTest.evt_time, '')
430 #self._event(FunctionalTest.evt_time, 'mouseclick', [(630, 450), 'left']) # home
431 self._event(FunctionalTest.evt_time, 'mouseclick', ['home_win', 'left'])
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()
442 #self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 600), 'left'])
443 self._event(FunctionalTest.evt_time, 'mouseclick', ['exit', 'left'])
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
457 class TestApp(ShowBase):
458
459 def __init__(self):
460 ShowBase.__init__(self)
461 offset = int(argv[2]) if len(argv) >= 3 else 0
462 fun_test = FunctionalTest(int(argv[1]), offset)
463
464
465 TestApp().run()