ya2 · news · projects · code · about

functional tests: testing code
[pmachines.git] / lib / engine / functional.py
CommitLineData
8ee66edd
FC
1'''Create ref:
2* M-x fla-set-fun-test
3* rm options.ini
4* python main.py --functional-test 1 --functional-ref
5* python main.py --functional-test 2 --functional-ref
6* M-x fla-unset-fun-test'''
edeef6f9
FC
7import datetime
8from os import getcwd, system
8ee66edd
FC
9from logging import debug, info
10from pathlib import Path
11from shutil import rmtree
12from os import makedirs
13from os.path import join, exists
14from glob import glob
15from sys import exit
16from panda3d.core import Filename
17from direct.gui.OnscreenText import OnscreenText
18from lib.gameobject import GameObject
19from lib.build.build import _branch
20
21
22class FunctionalTest(GameObject):
23
24 screenshot_time = 1.2
25 evt_time = 1.0
d982c0a5 26 start_time = 2
8ee66edd
FC
27
28 def __init__(self, idx, ref):
29 super().__init__()
30 self.txt = OnscreenText('', fg=(1, 0, 0, 1), scale=.16)
31 #self._path = ''
32 #if self.eng.is_appimage:
33 self._path = str(Filename().get_user_appdata_directory())
edeef6f9 34 self._path += '/pmachines/'
8ee66edd
FC
35 self._path += 'tests/functional%s/' % ('_ref' if ref else '')
36 home = '/home/flavio' # we must force this for wine
37 # if self._path.startswith('/c/users/') and exists(str(Path.home()) + '/.local/share/flatpak-wine601/default/'):
38 # self._path = str(Path.home()) + '/.local/share/flatpak-wine601/default/drive_' + self._path[1:]
39 if self._path.startswith('/c/users/') and exists(home + '/.wine/'):
40 self._path = home + '/.wine/drive_' + self._path[1:]
41 if ref:
42 self._path = join(
43 Filename().get_user_appdata_directory(),
edeef6f9 44 'pmachines/tests/functional_ref_%s/' % _branch())
8ee66edd
FC
45 self._curr_time = 0
46 if int(idx) == 1:
47 rmtree(self._path, ignore_errors=True)
48 info('creating dir: %s' % self._path)
49 makedirs(self._path, exist_ok=True)
50 self._fnames = []
51 self._tasks = []
52 self._prev_time = 0
edeef6f9
FC
53 #self.eng.attach_obs(self.on_frame_unpausable)
54 taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable')
882c058d 55 self.__mouse_move((0, 0)) # otherwise it has not the pointer
8ee66edd
FC
56 self._do_screenshots(idx)
57
edeef6f9
FC
58 def _do_screenshot(self, path=None):
59 time = datetime.datetime.now().strftime('%y%m%d%H%M%S')
60 #res = base.win.save_screenshot(Filename(path or ("yocto%s.png" % time)))
61 #debug('screenshot %s (%s)' % (path or ("yocto%s.png" % time), res))
62 res = base.screenshot(path or ("pmachines%s.png" % time), False)
63 info('screenshot %s (%s; %s)' % (path or ("pmachines%s.png" % time), res, getcwd()))
64
8ee66edd
FC
65 def _screenshot(self, time, name):
66 self._fnames += [self._path + name + '.png']
67 self._tasks += [(
68 self._curr_time + time,
edeef6f9 69 lambda: self._do_screenshot(self._path + name + '.png'),
8ee66edd
FC
70 'screenshot: %s' % name)]
71 def txt(show_hide):
72 self.txt['text'] = name
73 (self.txt.show if show_hide else self.txt.hide)()
74 self._tasks += [(
75 self._curr_time + time + .1,
76 lambda: txt(True),
77 'screenshot: %s (show)' % name)]
78 self._tasks += [(
79 self._curr_time + time + FunctionalTest.evt_time - .1,
80 lambda: txt(False),
81 'screenshot: %s (hide)' % name)]
82 self._curr_time += time
83
84 def __keypress(self, key):
85 '''Emulates a keypress'''
86 dev = base.win.getInputDevice(0)
87 dev.buttonDown(key)
88 dev.buttonUp(key)
89
90 def __char_entered(self, char):
91 '''Emulates a character being entered.'''
92 dev = base.win.getInputDevice(0)
93 dev.keystroke(ord(char))
94
edeef6f9 95 def __mouse_click(self, pos, btn):
882c058d
FC
96 base.win.move_pointer(0, pos[0], pos[1])
97 self.__keypress('mouse%s' % (3 if btn == 'right' else 1))
edeef6f9
FC
98
99 def __mouse_move(self, pos):
882c058d
FC
100 center = base.pipe.get_display_width() / 2, \
101 base.pipe.get_display_height() / 2
edeef6f9
FC
102 tgt = pos[0] + center[0], pos[1] + center[1]
103 system('xdotool mousemove %s %s' % tgt)
104
105 def __mouse_drag(self, start, end, btn):
882c058d
FC
106 btn = 'mouse%s' % (3 if btn == 'right' else 1)
107 dev = base.win.get_input_device(0)
108 base.win.move_pointer(0, start[0], start[1])
109 dev.buttonDown(btn)
110 def drop(task):
111 base.win.move_pointer(0, end[0], end[1])
112 def drop_up(task):
113 dev.button_up(btn)
114 taskMgr.do_method_later(.01, drop_up, 'drop_up')
115 taskMgr.do_method_later(.01, drop, 'drop')
edeef6f9
FC
116
117 def _event(self, time, evt, messenger_evt=False, append_up=True, mouse_args=None):
8ee66edd
FC
118 def _append_up(evt_name):
119 return evt + ('' if evt.endswith('-up') or not append_up else '-up')
120 def cback_char(_evt):
121 self.__char_entered(_evt)
122 def cback_keyp(_evt):
123 self.__keypress(_evt)
124 self.__keypress('raw-' + _evt)
125 cback = lambda: (cback_char(evt) if len(evt) == 1 else cback_keyp(evt))
edeef6f9
FC
126 if evt in ['mousemove', 'mouseclick', 'mousedrag']:
127 if evt == 'mousemove':
128 cback = lambda: self.__mouse_move(*mouse_args)
129 elif evt == 'mouseclick':
130 cback = lambda: self.__mouse_click(*mouse_args)
131 elif evt == 'mousedrag':
132 cback = lambda: self.__mouse_drag(*mouse_args)
8ee66edd
FC
133 if messenger_evt:
134 cback = lambda: messenger.send(_append_up(evt))
135 self._tasks += [(
136 self._curr_time + time,
137 cback,
138 'event: %s' % evt)]
139 def txt(show_hide):
140 self.txt['text'] = evt
141 (self.txt.show if show_hide else self.txt.hide)()
142 self._tasks += [(
143 self._curr_time + time + .2,
144 lambda: txt(True),
145 'event: %s (show)' % evt)]
146 self._tasks += [(
147 self._curr_time + time + .8,
148 lambda: txt(False),
149 'event: %s (hide)' % evt)]
150 self._curr_time += time
151
152 def _verify(self):
153 def __verify():
154 files = glob(self._path + '*')
155 for fname in self._fnames:
156 info('verifying %s' % fname)
157 assert exists(fname)
158 self._tasks += [(
159 self._curr_time + 3,
160 lambda: __verify(),
161 'verify')]
162 self._curr_time += 3
163
164 def _exit(self):
165 self._tasks += [(
166 self._curr_time + 3,
167 lambda: exit(),
168 'exit')]
169
edeef6f9 170 def on_frame_unpausable(self, task):
8ee66edd 171 for tsk in self._tasks:
edeef6f9
FC
172 #if self._prev_time <= tsk[0] < self.eng.event.unpaused_time:
173 if self._prev_time <= tsk[0] < globalClock.getFrameTime():
8ee66edd
FC
174 debug('%s %s' % (tsk[0], tsk[2]))
175 tsk[1]()
edeef6f9
FC
176 self._prev_time = globalClock.getFrameTime() # self.eng.event.unpaused_time
177 return task.cont
8ee66edd
FC
178
179 def _do_screenshots_1(self):
180 info('_do_screenshots_1')
181 self._screenshot(FunctionalTest.start_time, 'main_menu')
182 self._do_screenshots_credits()
d982c0a5 183 self._do_screenshots_options()
8ee66edd
FC
184 self._do_screenshots_exit()
185
186 def _do_screenshots_credits(self):
882c058d 187 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 410), 'left'])
8ee66edd 188 self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
882c058d 189 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 630), 'left'])
edeef6f9
FC
190 self._screenshot(FunctionalTest.screenshot_time, 'main_menu_back_from_credits')
191 # # go to credits
192 # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
193 # self._event(FunctionalTest.evt_time, 'arrow_down')
194 # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
195 # self._event(FunctionalTest.evt_time, 'arrow_down')
196 # self._screenshot(FunctionalTest.screenshot_time, 'main_menu_highlight')
197 # self._event(FunctionalTest.evt_time, 'rcontrol')
198 # self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
199 # # go to supporters
200 # self._event(FunctionalTest.evt_time, 'joypad0-face_a', True)
201 # self._screenshot(FunctionalTest.screenshot_time, 'supporters_menu')
202 # # back to main
203 # self._event(FunctionalTest.evt_time, 'rcontrol')
204 # self._event(FunctionalTest.evt_time, 'joypad0-face_b', True)
205 # self._event(FunctionalTest.evt_time, 'arrow_up')
206 # self._event(FunctionalTest.evt_time, 'arrow_up')
207 # self._event(FunctionalTest.evt_time, 'arrow_up')
208 # self._event(FunctionalTest.evt_time, 'arrow_up')
8ee66edd 209
d982c0a5 210 def _do_screenshots_options(self):
882c058d 211 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 270), 'left'])
d982c0a5
FC
212 self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
213 # languages
882c058d 214 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 50), 'left'])
ebb440db 215 self._screenshot(FunctionalTest.screenshot_time, 'open_languages')
882c058d 216 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(930, 110), 'left'])
d982c0a5
FC
217 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_italian')
218 # volume
ebb440db 219 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(703, 153), 'left'])
d982c0a5 220 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_1')
ebb440db
FC
221 # antialiasing
222 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left'])
223 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_no')
224 # shadows
225 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 510), 'left'])
226 self._screenshot(FunctionalTest.screenshot_time, 'shadows_no')
227 # test aa and shadows
228 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 630), 'left']) # back
229 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play
230 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino
231 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(845, 455), 'left']) # close instructions
232 self._screenshot(FunctionalTest.screenshot_time, 'aa_no_shadows_no')
233 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(25, 695), 'left']) # home
234
235 def _do_screenshots_restore_options(self):
236 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 270), 'left'])
237 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
238 # languages
239 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 50), 'left'])
240 self._screenshot(FunctionalTest.screenshot_time, 'open_languages_restored')
241 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(930, 30), 'left'])
242 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_english')
243 # volume
244 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(677, 153), 'left'])
d982c0a5
FC
245 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2')
246 # fullscreen
ebb440db 247 # the first one is because of the windowed mode in test
ad5ef398
FC
248 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 240), 'left'])
249 # self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
250 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 240), 'left'])
251 # self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
252 # self._event(8 + FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 240), 'left'])
253 # self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen')
d982c0a5 254 # resolution
882c058d 255 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 330), 'left'])
d982c0a5 256 self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
882c058d 257 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(950, 470), 'left'])
d982c0a5 258 self._screenshot(FunctionalTest.screenshot_time, '1440x900')
882c058d 259 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(720, 410), 'left'])
d982c0a5 260 self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
882c058d 261 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1120, 420), 'left'])
d982c0a5
FC
262 self._screenshot(FunctionalTest.screenshot_time, '1280x720')
263 # antialiasing
882c058d 264 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left'])
ebb440db 265 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_yes')
d982c0a5 266 # shadows
882c058d 267 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 510), 'left'])
ebb440db 268 self._screenshot(FunctionalTest.screenshot_time, 'shadows_yes')
882c058d 269 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 630), 'left']) # back
d982c0a5 270
edeef6f9
FC
271 # # go to options
272 # self._event(FunctionalTest.evt_time, 'arrow_down')
273 # self._event(FunctionalTest.evt_time, 'arrow_down')
274 # self._event(FunctionalTest.evt_time, 'rcontrol')
275 # self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
276 # # language
277 # self._event(FunctionalTest.evt_time, 'rcontrol')
278 # self._screenshot(FunctionalTest.screenshot_time, 'language_open')
279 # self._event(FunctionalTest.evt_time, 'arrow_down')
280 # self._screenshot(FunctionalTest.screenshot_time, 'language_highlight')
281 # self._event(FunctionalTest.evt_time, 'rcontrol')
282 # self._screenshot(FunctionalTest.screenshot_time, 'language_it')
283 # # volume
284 # self._event(FunctionalTest.evt_time, 'arrow_down')
285 # self._event(FunctionalTest.evt_time, 'arrow_right')
286 # self._event(FunctionalTest.evt_time, 'arrow_right')
287 # self._screenshot(FunctionalTest.screenshot_time, 'volume')
288 # # car's number
289 # self._event(FunctionalTest.evt_time, 'arrow_down')
290 # self._event(FunctionalTest.evt_time, 'rcontrol')
291 # self._screenshot(FunctionalTest.screenshot_time, 'cars_open')
292 # self._event(FunctionalTest.evt_time, 'rcontrol')
293 # self._screenshot(FunctionalTest.screenshot_time, 'cars_changed')
294 # # back
295 # self._event(FunctionalTest.evt_time, 'arrow_down')
296 # self._event(FunctionalTest.evt_time, 'arrow_down')
297 # self._event(FunctionalTest.evt_time, 'arrow_down')
298 # self._event(FunctionalTest.evt_time, 'rcontrol')
299 # self._event(FunctionalTest.evt_time, 'arrow_up')
300 # self._event(FunctionalTest.evt_time, 'arrow_up')
8ee66edd 301
882c058d
FC
302 def _do_screenshots_play(self):
303 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play
304 self._screenshot(FunctionalTest.screenshot_time, 'play_menu')
305 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino scene
306 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_instructions')
ebb440db 307 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(800, 455), 'left']) # close instructions
882c058d
FC
308 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino')
309 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(25, 695), 'left']) # home
310 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_scene')
311 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play
312 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino
ebb440db 313 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(800, 455), 'left']) # close instructions
882c058d
FC
314 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(60, 695), 'left']) # info
315 self._screenshot(FunctionalTest.screenshot_time, 'info')
ebb440db 316 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(800, 455), 'left']) # close instructions
882c058d
FC
317 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (370, 220), 'left']) # drag a piece
318 self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged')
319 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(500, 340), 'left']) # rewind
320 self._screenshot(FunctionalTest.screenshot_time, 'rewind')
321 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (525, 350), 'left']) # drag a piece
322 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 510), (670, 350), 'left']) # drag a piece
323 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
324 self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_domino')
325 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(590, 420), 'left']) # home
326 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_fail')
327 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play
328 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino
ebb440db 329 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(800, 455), 'left']) # close instructions
882c058d
FC
330 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (525, 350), 'left']) # drag a piece
331 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (670, 350), 'left']) # drag a piece
332 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
333 self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_domino_2')
334 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
335 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (540, 140), 'left']) # drag a piece
336 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(540, 130), (600, 130), 'right']) # rotate the piece
337 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (665, 355), 'left']) # drag a piece
338 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
339 self._screenshot(10 + FunctionalTest.screenshot_time, 'win_domino')
340 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next
341 self._screenshot(FunctionalTest.screenshot_time, 'scene_box')
4f15e3fc 342 # scene 2
ebb440db 343 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(830, 455), 'left']) # close instructions
4f15e3fc
FC
344 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 585), 'left']) # drag a box
345 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 515), 'left']) # drag a box
346 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
347 self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_box')
348 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
349 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 585), 'left']) # drag a box
350 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 515), 'left']) # drag a box
351 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 430), 'left']) # drag a box
352 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
353 self._screenshot(10 + FunctionalTest.screenshot_time, 'win_box')
354 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next
355 self._screenshot(FunctionalTest.screenshot_time, 'scene_box_domino')
356 # scene 3
ebb440db 357 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(875, 455), 'left']) # close instructions
4f15e3fc
FC
358 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (865, 415), 'left']) # drag a box
359 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (865, 330), 'left']) # drag a box
360 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
361 self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_box_domino')
362 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
363 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (860, 415), 'left']) # drag a box
364 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (775, 235), 'left']) # drag a box
365 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
366 self._screenshot(10 + FunctionalTest.screenshot_time, 'win_box_domino')
367 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next
368 self._screenshot(FunctionalTest.screenshot_time, 'scene_basketball')
369 # scene 4
ebb440db 370 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(820, 455), 'left']) # close instructions
4f15e3fc
FC
371 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (630, 300), 'left']) # drag a ball
372 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
373 self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_basketball')
374 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
375 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (360, 150), 'left']) # drag a ball
376 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
377 self._screenshot(10 + FunctionalTest.screenshot_time, 'win_basketball')
378 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next
379 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_box_basketball')
380 # scene 5
ebb440db 381 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(815, 455), 'left']) # close instructions
4f15e3fc
FC
382 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (550, 415), 'left']) # drag a box
383 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (560, 340), 'left']) # drag a piece
384 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
385 self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_domino_box_basketball')
386 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
387 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (550, 415), 'left']) # drag a box
388 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (620, 410), 'left']) # drag a piece
389 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(620, 430), (665, 425), 'right']) # rotate a piece
390 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(615, 415), (615, 420), 'left']) # drag a piece
391 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
392 self._screenshot(10 + FunctionalTest.screenshot_time, 'win_domino_box_basketball')
393 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next
394 # self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_tooter')
395 # # scene 6
ebb440db 396 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(820, 455), 'left']) # close instructions
4f15e3fc
FC
397 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (490, 300), 'left']) # drag a box
398 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
399 # self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_teeter_tooter')
400 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
401 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (490, 150), 'left']) # drag a box
402 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(515, 115), (515, 122), 'right']) # rotate a box
403 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
404 # self._screenshot(10 + FunctionalTest.screenshot_time, 'win_teeter_tooter')
405 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next
406 # self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_domino_box_basketball')
407 # scene 7
ebb440db 408 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(880, 455), 'left']) # close instructions
4f15e3fc
FC
409 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (155, 180), 'left']) # drag a box
410 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
411 # self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_teeter_domino_box_basketball')
412 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
413 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (170, 80), 'left']) # drag a box
414 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(195, 50), (195, 80), 'right']) # rotate a box
415 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
416 # self._screenshot(10 + FunctionalTest.screenshot_time, 'win_teeter_domino_box_basketball')
ebb440db 417 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(590, 420), 'left']) # home
4f15e3fc 418 self._screenshot(FunctionalTest.screenshot_time, 'home_from_play')
882c058d 419
8ee66edd 420 def _do_screenshots_exit(self):
edeef6f9
FC
421 # self._event(FunctionalTest.evt_time, 'arrow_down')
422 # self._event(FunctionalTest.evt_time, 'arrow_down')
423 # self._event(FunctionalTest.evt_time, 'arrow_down')
424 # self._event(FunctionalTest.evt_time, 'arrow_down')
425 # self._event(FunctionalTest.evt_time, 'arrow_down')
426 # self._event(FunctionalTest.evt_time, 'rcontrol')
427 # self._event(FunctionalTest.evt_time, 'arrow_down')
8ee66edd 428 self._verify()
edeef6f9
FC
429 # self._event(FunctionalTest.evt_time, 'rcontrol')
430 # self._exit()
882c058d 431 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 560), 'left'])
edeef6f9 432
8ee66edd
FC
433
434 def _do_screenshots_2(self):
435 info('_do_screenshots_2')
ebb440db
FC
436 self._screenshot(FunctionalTest.start_time, 'main_menu_2')
437 self._do_screenshots_restore_options()
438 self._do_screenshots_play()
439 self._do_screenshots_exit()
edeef6f9
FC
440 # self._do_screenshots_game()
441 # self._do_screenshots_end()
8ee66edd 442
edeef6f9
FC
443 # def _do_screenshots_restore_options(self):
444 # # go to options
445 # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
446 # self._event(FunctionalTest.evt_time, 'arrow_down')
447 # self._event(FunctionalTest.evt_time, 'rcontrol')
448 # self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
449 # # # language
450 # self._event(FunctionalTest.evt_time, 'rcontrol')
451 # self._event(FunctionalTest.evt_time, 'arrow_up')
452 # self._event(FunctionalTest.evt_time, 'rcontrol')
453 # self._screenshot(FunctionalTest.screenshot_time, 'language_en_restored')
454 # # # volume
455 # self._event(FunctionalTest.evt_time, 'arrow_down')
456 # self._event(FunctionalTest.evt_time, 'arrow_left')
457 # self._event(FunctionalTest.evt_time, 'arrow_left')
458 # self._screenshot(FunctionalTest.screenshot_time, 'volume_restored')
459 # # car's number
460 # self._event(FunctionalTest.evt_time, 'arrow_down')
461 # self._event(FunctionalTest.evt_time, 'rcontrol')
462 # self._event(FunctionalTest.evt_time, 'arrow_down')
463 # self._event(FunctionalTest.evt_time, 'arrow_down')
464 # self._event(FunctionalTest.evt_time, 'arrow_down')
465 # self._event(FunctionalTest.evt_time, 'arrow_down')
466 # self._event(FunctionalTest.evt_time, 'rcontrol')
467 # self._screenshot(FunctionalTest.screenshot_time, 'cars_restored')
468 # # graphics settings
469 # self._event(FunctionalTest.evt_time, 'arrow_down')
470 # self._event(FunctionalTest.evt_time, 'rcontrol')
471 # self._screenshot(FunctionalTest.screenshot_time, 'graphics_settings')
472 # self._event(FunctionalTest.evt_time, 'arrow_down')
473 # self._event(FunctionalTest.evt_time, 'arrow_down')
474 # self._event(FunctionalTest.evt_time, 'rcontrol')
475 # self._screenshot(FunctionalTest.screenshot_time, 'antialiasing')
476 # self._event(FunctionalTest.evt_time, 'rcontrol')
477 # self._event(FunctionalTest.evt_time, 'arrow_down')
478 # self._event(FunctionalTest.evt_time, 'rcontrol')
479 # self._screenshot(FunctionalTest.screenshot_time, 'shadows')
480 # self._event(FunctionalTest.evt_time, 'rcontrol')
481 # self._event(FunctionalTest.evt_time, 'arrow_down')
482 # self._event(FunctionalTest.evt_time, 'rcontrol')
483 # self._screenshot(FunctionalTest.screenshot_time, 'fog')
484 # self._event(FunctionalTest.evt_time, 'rcontrol')
485 # self._event(FunctionalTest.evt_time, 'arrow_down')
486 # self._event(FunctionalTest.evt_time, 'rcontrol')
487 # self._screenshot(FunctionalTest.screenshot_time, 'normal_mapping')
488 # self._event(FunctionalTest.evt_time, 'rcontrol')
489 # self._event(FunctionalTest.evt_time, 'arrow_down')
490 # self._event(FunctionalTest.evt_time, 'rcontrol')
491 # self._screenshot(FunctionalTest.screenshot_time, 'occlusion')
492 # self._event(FunctionalTest.evt_time, 'rcontrol')
493 # self._event(FunctionalTest.evt_time, 'arrow_down')
494 # self._event(FunctionalTest.evt_time, 'rcontrol')
495 # # input
496 # self._event(FunctionalTest.evt_time, 'arrow_down')
497 # self._event(FunctionalTest.evt_time, 'rcontrol')
498 # self._screenshot(FunctionalTest.screenshot_time, 'input')
499 # self._event(FunctionalTest.evt_time, 'rcontrol')
500 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1')
501 # self._event(FunctionalTest.evt_time, 'rcontrol')
502 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_rec')
503 # self._event(FunctionalTest.evt_time, '8', True, False)
504 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_changed')
505 # self._event(FunctionalTest.evt_time, 'rcontrol')
506 # self._event(FunctionalTest.evt_time, 'arrow_up', True, False)
507 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_restored')
508 # self._event(FunctionalTest.evt_time, 'rcontrol')
509 # self._event(FunctionalTest.evt_time, 'w', True, False)
510 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already')
511 # self._event(FunctionalTest.evt_time, 'rcontrol')
512 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already_closed')
513 # self._event(FunctionalTest.evt_time, 'arrow_down')
514 # self._event(FunctionalTest.evt_time, 'arrow_down')
515 # self._event(FunctionalTest.evt_time, 'arrow_down')
516 # self._event(FunctionalTest.evt_time, 'arrow_down')
517 # self._event(FunctionalTest.evt_time, 'rcontrol')
518 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p2')
519 # self._event(FunctionalTest.evt_time, 'arrow_down')
520 # self._event(FunctionalTest.evt_time, 'arrow_down')
521 # self._event(FunctionalTest.evt_time, 'arrow_down')
522 # self._event(FunctionalTest.evt_time, 'arrow_down')
523 # self._event(FunctionalTest.evt_time, 'rcontrol')
524 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p3')
525 # self._event(FunctionalTest.evt_time, 'arrow_down')
526 # self._event(FunctionalTest.evt_time, 'arrow_down')
527 # self._event(FunctionalTest.evt_time, 'arrow_down')
528 # self._event(FunctionalTest.evt_time, 'arrow_down')
529 # self._event(FunctionalTest.evt_time, 'rcontrol')
530 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p4')
531 # self._event(FunctionalTest.evt_time, 'arrow_down')
532 # self._event(FunctionalTest.evt_time, 'arrow_down')
533 # self._event(FunctionalTest.evt_time, 'arrow_down')
534 # self._event(FunctionalTest.evt_time, 'arrow_down')
535 # self._event(FunctionalTest.evt_time, 'rcontrol')
536 # self._event(FunctionalTest.evt_time, 'arrow_down')
537 # self._event(FunctionalTest.evt_time, 'rcontrol')
538 # self._event(FunctionalTest.evt_time, 'arrow_down')
539 # self._event(FunctionalTest.evt_time, 'rcontrol')
540 # self._event(FunctionalTest.evt_time, 'arrow_down')
541 # self._event(FunctionalTest.evt_time, 'rcontrol')
542 # self._event(FunctionalTest.evt_time, 'arrow_down')
543 # self._event(FunctionalTest.evt_time, 'rcontrol')
544 # self._event(FunctionalTest.evt_time, 'arrow_down')
545 # self._event(FunctionalTest.evt_time, 'rcontrol')
546 # self._event(FunctionalTest.evt_time, 'arrow_up')
547 # self._event(FunctionalTest.evt_time, 'arrow_up')
8ee66edd 548
edeef6f9
FC
549 # def _do_screenshots_game(self):
550 # # single player
551 # self._event(FunctionalTest.evt_time, 'rcontrol')
552 # self._screenshot(FunctionalTest.screenshot_time, 'single_player_menu')
553 # self._event(FunctionalTest.evt_time, 'rcontrol')
554 # self._screenshot(FunctionalTest.screenshot_time, 'track_page')
555 # self._event(FunctionalTest.evt_time, 'rcontrol')
556 # self._screenshot(FunctionalTest.screenshot_time, 'car_page_start')
557 # self._event(FunctionalTest.evt_time, 'arrow_left')
558 # self._screenshot(FunctionalTest.screenshot_time, 'car_page_sel')
559 # self._event(FunctionalTest.evt_time, 'rcontrol')
560 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_start')
561 # self._event(FunctionalTest.evt_time, 'arrow_down')
562 # self._event(FunctionalTest.evt_time, 'arrow_down')
563 # self._event(FunctionalTest.evt_time, 'rcontrol')
564 # self._event(FunctionalTest.evt_time, 'arrow_down')
565 # self._event(FunctionalTest.evt_time, 'arrow_down')
566 # self._event(FunctionalTest.evt_time, 'rcontrol')
567 # self._event(FunctionalTest.evt_time, 'arrow_down')
568 # self._event(FunctionalTest.evt_time, 'rcontrol')
569 # self._event(FunctionalTest.evt_time, 'arrow_up')
570 # self._event(FunctionalTest.evt_time, 'rcontrol')
571 # self._event(FunctionalTest.evt_time, 'rcontrol')
572 # self._event(FunctionalTest.evt_time, 'arrow_left')
573 # self._event(FunctionalTest.evt_time, 'rcontrol')
574 # self._event(FunctionalTest.evt_time, 'rcontrol')
575 # self._event(FunctionalTest.evt_time, 'rcontrol')
576 # self._event(FunctionalTest.evt_time, 'rcontrol')
577 # self._event(FunctionalTest.evt_time, 'rcontrol')
578 # self._event(FunctionalTest.evt_time, 'arrow_left')
579 # self._event(FunctionalTest.evt_time, 'rcontrol')
580 # self._event(FunctionalTest.evt_time, 'arrow_up')
581 # self._event(FunctionalTest.evt_time, 'rcontrol')
582 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry')
583 # self._event(FunctionalTest.evt_time, 'backspace')
584 # self._event(FunctionalTest.evt_time, 'backspace')
585 # self._event(FunctionalTest.evt_time, 'backspace')
586 # self._event(FunctionalTest.evt_time, 'backspace')
587 # self._event(FunctionalTest.evt_time, 'backspace')
588 # self._event(FunctionalTest.evt_time, 'backspace')
589 # self._event(FunctionalTest.evt_time, 'backspace')
590 # self._event(FunctionalTest.evt_time, 'backspace')
591 # self._event(FunctionalTest.evt_time, 'backspace')
592 # self._event(FunctionalTest.evt_time, 'backspace')
593 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_empty')
594 # self._event(FunctionalTest.evt_time, 'f')
595 # self._event(FunctionalTest.evt_time, 'l')
596 # self._event(FunctionalTest.evt_time, 'a')
597 # self._event(FunctionalTest.evt_time, 'v')
598 # self._event(FunctionalTest.evt_time, 'i')
599 # self._event(FunctionalTest.evt_time, 'o')
600 # self._event(FunctionalTest.evt_time, 'enter')
601 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_full')
602 # self._event(FunctionalTest.evt_time, 'arrow_down')
603 # self._event(FunctionalTest.evt_time, 'arrow_right')
604 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_sel')
605 # # some ai tests
606 # self._event(FunctionalTest.evt_time, 'rcontrol')
607 # self._event(40, 'escape-up')
608 # self._screenshot(FunctionalTest.screenshot_time, 'ingame_menu')
609 # self._event(FunctionalTest.evt_time, 'rcontrol')
610 # self._screenshot(FunctionalTest.screenshot_time, 'race_back')
611 # self._event(FunctionalTest.evt_time, 'escape-up')
612 # self._event(FunctionalTest.evt_time, 'arrow_down')
613 # self._screenshot(FunctionalTest.screenshot_time, 'ingame_sel')
614 # self._event(FunctionalTest.evt_time, 'rcontrol')
615 # self._screenshot(FunctionalTest.screenshot_time, 'main_page_back_race')
8ee66edd 616
edeef6f9
FC
617 # def _do_screenshots_end(self):
618 # self._event(FunctionalTest.evt_time, 'arrow_down')
619 # self._event(FunctionalTest.evt_time, 'arrow_down')
620 # self._event(FunctionalTest.evt_time, 'arrow_down')
621 # self._event(FunctionalTest.evt_time, 'arrow_down')
622 # self._event(FunctionalTest.evt_time, 'arrow_down')
623 # self._event(FunctionalTest.evt_time, 'rcontrol')
624 # self._screenshot(FunctionalTest.screenshot_time, 'exit_page')
625 # self._event(FunctionalTest.evt_time, 'arrow_down')
626 # self._screenshot(FunctionalTest.screenshot_time, 'exit_page_sel')
627 # self._verify()
628 # self._event(FunctionalTest.evt_time, 'rcontrol')
629 # self._exit()
8ee66edd
FC
630
631 def _do_screenshots(self, idx):
632 [self._do_screenshots_1, self._do_screenshots_2][int(idx) - 1]()