ya2 · news · projects · code · about

reverted the workaround for flatpak
[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):
26e35eb5
FC
96 #base.win.move_pointer(0, pos[0], pos[1])
97 #self.__keypress('mouse%s' % (3 if btn == 'right' else 1))
98 offset_x = int((1920 - 1360) / 2) + 1 # xfce decorations
99 offset_y = int((1080 - 768) / 2) + 24 # xfce decorations
100 btn = 3 if btn == 'right' else 1
101 system('xdotool mousemove %s %s' % (offset_x + pos[0], offset_y + pos[1]))
102 def click(task):
103 system('xdotool click %s' % btn)
104 taskMgr.do_method_later(.01, click, 'click')
edeef6f9
FC
105
106 def __mouse_move(self, pos):
882c058d
FC
107 center = base.pipe.get_display_width() / 2, \
108 base.pipe.get_display_height() / 2
edeef6f9
FC
109 tgt = pos[0] + center[0], pos[1] + center[1]
110 system('xdotool mousemove %s %s' % tgt)
111
112 def __mouse_drag(self, start, end, btn):
26e35eb5
FC
113 # btn = 'mouse%s' % (3 if btn == 'right' else 1)
114 # dev = base.win.get_input_device(0)
115 # base.win.move_pointer(0, start[0], start[1])
116 # dev.buttonDown(btn)
117 # def drop(task):
118 # base.win.move_pointer(0, end[0], end[1])
119 # def drop_up(task):
120 # dev.button_up(btn)
121 # taskMgr.do_method_later(.01, drop_up, 'drop_up')
122 # taskMgr.do_method_later(.01, drop, 'drop')
123 offset_x = int((1920 - 1360) / 2) + 1 # xfce decorations
124 offset_y = int((1080 - 768) / 2) + 24 # xfce decorations
125 btn = 3 if btn == 'right' else 1
126 system('xdotool mousemove %s %s' % (offset_x + start[0], offset_y + start[1]))
127 def mousedown(task):
128 system('xdotool mousedown %s' % btn)
129 def mousemove(task):
130 system('xdotool mousemove %s %s' % (offset_x + end[0], offset_y + end[1]))
131 def mouseup(task):
132 system('xdotool mouseup %s' % btn)
133 taskMgr.do_method_later(.01, mouseup, 'mouseup')
134 taskMgr.do_method_later(.01, mousemove, 'mousemove')
135 taskMgr.do_method_later(.01, mousedown, 'mousedown')
edeef6f9
FC
136
137 def _event(self, time, evt, messenger_evt=False, append_up=True, mouse_args=None):
8ee66edd
FC
138 def _append_up(evt_name):
139 return evt + ('' if evt.endswith('-up') or not append_up else '-up')
140 def cback_char(_evt):
141 self.__char_entered(_evt)
142 def cback_keyp(_evt):
143 self.__keypress(_evt)
144 self.__keypress('raw-' + _evt)
145 cback = lambda: (cback_char(evt) if len(evt) == 1 else cback_keyp(evt))
edeef6f9
FC
146 if evt in ['mousemove', 'mouseclick', 'mousedrag']:
147 if evt == 'mousemove':
148 cback = lambda: self.__mouse_move(*mouse_args)
149 elif evt == 'mouseclick':
150 cback = lambda: self.__mouse_click(*mouse_args)
151 elif evt == 'mousedrag':
152 cback = lambda: self.__mouse_drag(*mouse_args)
8ee66edd
FC
153 if messenger_evt:
154 cback = lambda: messenger.send(_append_up(evt))
155 self._tasks += [(
156 self._curr_time + time,
157 cback,
158 'event: %s' % evt)]
159 def txt(show_hide):
160 self.txt['text'] = evt
161 (self.txt.show if show_hide else self.txt.hide)()
162 self._tasks += [(
163 self._curr_time + time + .2,
164 lambda: txt(True),
165 'event: %s (show)' % evt)]
166 self._tasks += [(
167 self._curr_time + time + .8,
168 lambda: txt(False),
169 'event: %s (hide)' % evt)]
170 self._curr_time += time
171
fa3662a6
FC
172 def _enforce_res(self, time, res):
173 cback = lambda: messenger.send('enforce_res', [res])
174 self._tasks += [(
175 self._curr_time + time,
176 cback,
177 'enforce res: %s' % res)]
178 self._curr_time += time
179
8ee66edd
FC
180 def _verify(self):
181 def __verify():
182 files = glob(self._path + '*')
183 for fname in self._fnames:
184 info('verifying %s' % fname)
185 assert exists(fname)
186 self._tasks += [(
187 self._curr_time + 3,
188 lambda: __verify(),
189 'verify')]
190 self._curr_time += 3
191
192 def _exit(self):
193 self._tasks += [(
194 self._curr_time + 3,
195 lambda: exit(),
196 'exit')]
197
edeef6f9 198 def on_frame_unpausable(self, task):
8ee66edd 199 for tsk in self._tasks:
edeef6f9
FC
200 #if self._prev_time <= tsk[0] < self.eng.event.unpaused_time:
201 if self._prev_time <= tsk[0] < globalClock.getFrameTime():
8ee66edd
FC
202 debug('%s %s' % (tsk[0], tsk[2]))
203 tsk[1]()
edeef6f9
FC
204 self._prev_time = globalClock.getFrameTime() # self.eng.event.unpaused_time
205 return task.cont
8ee66edd
FC
206
207 def _do_screenshots_1(self):
208 info('_do_screenshots_1')
209 self._screenshot(FunctionalTest.start_time, 'main_menu')
210 self._do_screenshots_credits()
d982c0a5 211 self._do_screenshots_options()
8ee66edd
FC
212 self._do_screenshots_exit()
213
214 def _do_screenshots_credits(self):
addec9c9 215 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left'])
8ee66edd 216 self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
addec9c9 217 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 680), 'left'])
edeef6f9
FC
218 self._screenshot(FunctionalTest.screenshot_time, 'main_menu_back_from_credits')
219 # # go to credits
220 # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
221 # self._event(FunctionalTest.evt_time, 'arrow_down')
222 # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
223 # self._event(FunctionalTest.evt_time, 'arrow_down')
224 # self._screenshot(FunctionalTest.screenshot_time, 'main_menu_highlight')
225 # self._event(FunctionalTest.evt_time, 'rcontrol')
226 # self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
227 # # go to supporters
228 # self._event(FunctionalTest.evt_time, 'joypad0-face_a', True)
229 # self._screenshot(FunctionalTest.screenshot_time, 'supporters_menu')
230 # # back to main
231 # self._event(FunctionalTest.evt_time, 'rcontrol')
232 # self._event(FunctionalTest.evt_time, 'joypad0-face_b', True)
233 # self._event(FunctionalTest.evt_time, 'arrow_up')
234 # self._event(FunctionalTest.evt_time, 'arrow_up')
235 # self._event(FunctionalTest.evt_time, 'arrow_up')
236 # self._event(FunctionalTest.evt_time, 'arrow_up')
8ee66edd 237
d982c0a5 238 def _do_screenshots_options(self):
addec9c9 239 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 300), 'left'])
d982c0a5
FC
240 self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
241 # languages
addec9c9 242 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 60), 'left'])
ebb440db 243 self._screenshot(FunctionalTest.screenshot_time, 'open_languages')
addec9c9 244 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(980, 120), 'left'])
d982c0a5
FC
245 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_italian')
246 # volume
addec9c9 247 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(740, 163), 'left'])
d982c0a5 248 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_1')
ebb440db 249 # antialiasing
addec9c9 250 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 440), 'left'])
ebb440db
FC
251 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_no')
252 # shadows
addec9c9 253 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 540), 'left'])
ebb440db
FC
254 self._screenshot(FunctionalTest.screenshot_time, 'shadows_no')
255 # test aa and shadows
addec9c9
FC
256 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 680), 'left']) # back
257 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 140), 'left']) # play
258 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(230, 160), 'left']) # domino
259 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(900, 490), 'left']) # close instructions
ebb440db 260 self._screenshot(FunctionalTest.screenshot_time, 'aa_no_shadows_no')
addec9c9 261 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(25, 740), 'left']) # home
ebb440db
FC
262
263 def _do_screenshots_restore_options(self):
addec9c9 264 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 300), 'left'])
ebb440db
FC
265 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
266 # languages
addec9c9 267 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 60), 'left'])
ebb440db 268 self._screenshot(FunctionalTest.screenshot_time, 'open_languages_restored')
addec9c9 269 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(980, 20), 'left'])
ebb440db
FC
270 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_english')
271 # volume
addec9c9 272 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(719, 163), 'left'])
d982c0a5
FC
273 self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2')
274 # fullscreen
ebb440db 275 # the first one is because of the windowed mode in test
addec9c9 276 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 250), 'left'])
ad5ef398 277 # self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
addec9c9 278 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 250), 'left'])
ad5ef398 279 # self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
addec9c9 280 # self._event(8 + FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 250), 'left'])
ad5ef398 281 # self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen')
d982c0a5 282 # resolution
addec9c9
FC
283 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 340), 'left'])
284 # self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
285 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1020, 160), 'left'])
286 # self._screenshot(FunctionalTest.screenshot_time, '1440x900')
287 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(740, 400), 'left'])
288 # self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
289 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1110, 80), 'left'])
290 # self._screenshot(FunctionalTest.screenshot_time, '1360x768')
d982c0a5 291 # antialiasing
addec9c9 292 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 440), 'left'])
ebb440db 293 self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_yes')
d982c0a5 294 # shadows
addec9c9 295 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 540), 'left'])
ebb440db 296 self._screenshot(FunctionalTest.screenshot_time, 'shadows_yes')
addec9c9 297 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 680), 'left']) # back
d982c0a5 298
edeef6f9
FC
299 # # go to options
300 # self._event(FunctionalTest.evt_time, 'arrow_down')
301 # self._event(FunctionalTest.evt_time, 'arrow_down')
302 # self._event(FunctionalTest.evt_time, 'rcontrol')
303 # self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
304 # # language
305 # self._event(FunctionalTest.evt_time, 'rcontrol')
306 # self._screenshot(FunctionalTest.screenshot_time, 'language_open')
307 # self._event(FunctionalTest.evt_time, 'arrow_down')
308 # self._screenshot(FunctionalTest.screenshot_time, 'language_highlight')
309 # self._event(FunctionalTest.evt_time, 'rcontrol')
310 # self._screenshot(FunctionalTest.screenshot_time, 'language_it')
311 # # volume
312 # self._event(FunctionalTest.evt_time, 'arrow_down')
313 # self._event(FunctionalTest.evt_time, 'arrow_right')
314 # self._event(FunctionalTest.evt_time, 'arrow_right')
315 # self._screenshot(FunctionalTest.screenshot_time, 'volume')
316 # # car's number
317 # self._event(FunctionalTest.evt_time, 'arrow_down')
318 # self._event(FunctionalTest.evt_time, 'rcontrol')
319 # self._screenshot(FunctionalTest.screenshot_time, 'cars_open')
320 # self._event(FunctionalTest.evt_time, 'rcontrol')
321 # self._screenshot(FunctionalTest.screenshot_time, 'cars_changed')
322 # # back
323 # self._event(FunctionalTest.evt_time, 'arrow_down')
324 # self._event(FunctionalTest.evt_time, 'arrow_down')
325 # self._event(FunctionalTest.evt_time, 'arrow_down')
326 # self._event(FunctionalTest.evt_time, 'rcontrol')
327 # self._event(FunctionalTest.evt_time, 'arrow_up')
328 # self._event(FunctionalTest.evt_time, 'arrow_up')
8ee66edd 329
882c058d 330 def _do_screenshots_play(self):
addec9c9 331 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 140), 'left']) # play
882c058d 332 self._screenshot(FunctionalTest.screenshot_time, 'play_menu')
addec9c9
FC
333 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 680), 'left']) # back
334 self._screenshot(FunctionalTest.screenshot_time, 'back_from_play')
335 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 140), 'left']) # play
336 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(230, 160), 'left']) # domino scene
882c058d 337 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_instructions')
addec9c9 338 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(850, 490), 'left']) # close instructions
882c058d 339 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino')
addec9c9 340 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(25, 740), 'left']) # home
882c058d 341 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_scene')
addec9c9
FC
342 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 140), 'left']) # play
343 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(230, 160), 'left']) # domino
344 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(850, 490), 'left']) # close instructions
345 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(70, 740), 'left']) # info
882c058d 346 self._screenshot(FunctionalTest.screenshot_time, 'info')
addec9c9
FC
347 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(850, 490), 'left']) # close instructions
348 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (430, 280), 'left']) # drag a piece
882c058d 349 self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged')
addec9c9 350 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1220, 740), 'left']) # rewind
882c058d 351 self._screenshot(FunctionalTest.screenshot_time, 'rewind')
addec9c9
FC
352 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (550, 380), 'left']) # drag a piece
353 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (715, 380), 'left']) # drag a piece
354 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 355 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino')
addec9c9 356 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(630, 450), 'left']) # home
882c058d 357 self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_fail')
addec9c9
FC
358 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 140), 'left']) # play
359 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(230, 160), 'left']) # domino
360 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(850, 490), 'left']) # close instructions
361 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (550, 380), 'left']) # drag a piece
362 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (715, 380), 'left']) # drag a piece
363 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 364 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_2')
addec9c9
FC
365 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left']) # replay
366 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (570, 380), 'left']) # drag a piece
367 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(570, 355), (605, 355), 'right']) # rotate the piece
368 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (715, 380), 'left']) # drag a piece
fa3662a6 369 self._enforce_res(FunctionalTest.evt_time, 'win')
addec9c9 370 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 371 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino')
fa3662a6 372 self._enforce_res(FunctionalTest.evt_time, '')
addec9c9 373 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
882c058d 374 self._screenshot(FunctionalTest.screenshot_time, 'scene_box')
4f15e3fc 375 # scene 2
addec9c9
FC
376 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(880, 490), 'left']) # close instructions
377 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (710, 620), 'left']) # drag a box
378 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (710, 540), 'left']) # drag a box
379 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 380 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box')
addec9c9
FC
381 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left']) # replay
382 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (710, 620), 'left']) # drag a box
383 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (710, 540), 'left']) # drag a box
384 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (705, 460), 'left']) # drag a box
fa3662a6 385 self._enforce_res(FunctionalTest.evt_time, 'win')
addec9c9 386 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 387 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box')
fa3662a6 388 self._enforce_res(FunctionalTest.evt_time, '')
addec9c9 389 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
4f15e3fc
FC
390 self._screenshot(FunctionalTest.screenshot_time, 'scene_box_domino')
391 # scene 3
addec9c9
FC
392 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(930, 485), 'left']) # close instructions
393 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (910, 440), 'left']) # drag a box
394 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (910, 360), 'left']) # drag a box
395 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 396 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box_domino')
addec9c9
FC
397 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left']) # replay
398 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (910, 440), 'left']) # drag a box
399 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (835, 250), 'left']) # drag a box
fa3662a6 400 self._enforce_res(FunctionalTest.evt_time, 'win')
addec9c9 401 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 402 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box_domino')
fa3662a6 403 self._enforce_res(FunctionalTest.evt_time, '')
addec9c9 404 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
4f15e3fc
FC
405 self._screenshot(FunctionalTest.screenshot_time, 'scene_basketball')
406 # scene 4
addec9c9
FC
407 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(870, 490), 'left']) # close instructions
408 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(55, 50), (650, 310), 'left']) # drag a ball
409 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 410 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_basketball')
addec9c9
FC
411 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left']) # replay
412 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(55, 50), (380, 50), 'left']) # drag a ball
fa3662a6 413 self._enforce_res(FunctionalTest.evt_time, 'win')
addec9c9 414 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 415 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_basketball')
fa3662a6 416 self._enforce_res(FunctionalTest.evt_time, '')
addec9c9 417 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
4f15e3fc
FC
418 self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_box_basketball')
419 # scene 5
addec9c9
FC
420 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(865, 490), 'left']) # close instructions
421 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (580, 440), 'left']) # drag a box
422 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 60), (590, 370), 'left']) # drag a piece
423 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 424 self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_box_basketball')
addec9c9
FC
425 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left']) # replay
426 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (580, 440), 'left']) # drag a box
427 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 60), (660, 440), 'left']) # drag a piece
428 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(660, 425), (625, 425), 'right']) # rotate a piece
429 self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(660, 435), (650, 445), 'left']) # drag a piece
fa3662a6 430 self._enforce_res(FunctionalTest.evt_time, 'win')
addec9c9 431 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
8ce16d6c 432 self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino_box_basketball')
fa3662a6 433 self._enforce_res(FunctionalTest.evt_time, '')
addec9c9 434 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
4f15e3fc
FC
435 # self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_tooter')
436 # # scene 6
ebb440db 437 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(820, 455), 'left']) # close instructions
4f15e3fc
FC
438 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (490, 300), 'left']) # drag a box
439 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
8ce16d6c 440 # self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_tooter')
4f15e3fc
FC
441 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
442 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (490, 150), 'left']) # drag a box
443 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(515, 115), (515, 122), 'right']) # rotate a box
444 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
8ce16d6c 445 # self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_tooter')
4f15e3fc
FC
446 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next
447 # self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_domino_box_basketball')
addec9c9 448 # # scene 7
ebb440db 449 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(880, 455), 'left']) # close instructions
4f15e3fc
FC
450 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (155, 180), 'left']) # drag a box
451 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
8ce16d6c 452 # self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_domino_box_basketball')
4f15e3fc
FC
453 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay
454 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (170, 80), 'left']) # drag a box
455 # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(195, 50), (195, 80), 'right']) # rotate a box
456 # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play
8ce16d6c 457 # self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_domino_box_basketball')
addec9c9 458 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(630, 450), 'left']) # home
4f15e3fc 459 self._screenshot(FunctionalTest.screenshot_time, 'home_from_play')
882c058d 460
8ee66edd 461 def _do_screenshots_exit(self):
edeef6f9
FC
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, 'arrow_down')
467 # self._event(FunctionalTest.evt_time, 'rcontrol')
468 # self._event(FunctionalTest.evt_time, 'arrow_down')
8ee66edd 469 self._verify()
edeef6f9
FC
470 # self._event(FunctionalTest.evt_time, 'rcontrol')
471 # self._exit()
addec9c9 472 self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 600), 'left'])
edeef6f9 473
8ee66edd
FC
474
475 def _do_screenshots_2(self):
476 info('_do_screenshots_2')
ebb440db
FC
477 self._screenshot(FunctionalTest.start_time, 'main_menu_2')
478 self._do_screenshots_restore_options()
479 self._do_screenshots_play()
480 self._do_screenshots_exit()
edeef6f9
FC
481 # self._do_screenshots_game()
482 # self._do_screenshots_end()
8ee66edd 483
edeef6f9
FC
484 # def _do_screenshots_restore_options(self):
485 # # go to options
486 # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
487 # self._event(FunctionalTest.evt_time, 'arrow_down')
488 # self._event(FunctionalTest.evt_time, 'rcontrol')
489 # self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
490 # # # language
491 # self._event(FunctionalTest.evt_time, 'rcontrol')
492 # self._event(FunctionalTest.evt_time, 'arrow_up')
493 # self._event(FunctionalTest.evt_time, 'rcontrol')
494 # self._screenshot(FunctionalTest.screenshot_time, 'language_en_restored')
495 # # # volume
496 # self._event(FunctionalTest.evt_time, 'arrow_down')
497 # self._event(FunctionalTest.evt_time, 'arrow_left')
498 # self._event(FunctionalTest.evt_time, 'arrow_left')
499 # self._screenshot(FunctionalTest.screenshot_time, 'volume_restored')
500 # # car's number
501 # self._event(FunctionalTest.evt_time, 'arrow_down')
502 # self._event(FunctionalTest.evt_time, 'rcontrol')
503 # self._event(FunctionalTest.evt_time, 'arrow_down')
504 # self._event(FunctionalTest.evt_time, 'arrow_down')
505 # self._event(FunctionalTest.evt_time, 'arrow_down')
506 # self._event(FunctionalTest.evt_time, 'arrow_down')
507 # self._event(FunctionalTest.evt_time, 'rcontrol')
508 # self._screenshot(FunctionalTest.screenshot_time, 'cars_restored')
509 # # graphics settings
510 # self._event(FunctionalTest.evt_time, 'arrow_down')
511 # self._event(FunctionalTest.evt_time, 'rcontrol')
512 # self._screenshot(FunctionalTest.screenshot_time, 'graphics_settings')
513 # self._event(FunctionalTest.evt_time, 'arrow_down')
514 # self._event(FunctionalTest.evt_time, 'arrow_down')
515 # self._event(FunctionalTest.evt_time, 'rcontrol')
516 # self._screenshot(FunctionalTest.screenshot_time, 'antialiasing')
517 # self._event(FunctionalTest.evt_time, 'rcontrol')
518 # self._event(FunctionalTest.evt_time, 'arrow_down')
519 # self._event(FunctionalTest.evt_time, 'rcontrol')
520 # self._screenshot(FunctionalTest.screenshot_time, 'shadows')
521 # self._event(FunctionalTest.evt_time, 'rcontrol')
522 # self._event(FunctionalTest.evt_time, 'arrow_down')
523 # self._event(FunctionalTest.evt_time, 'rcontrol')
524 # self._screenshot(FunctionalTest.screenshot_time, 'fog')
525 # self._event(FunctionalTest.evt_time, 'rcontrol')
526 # self._event(FunctionalTest.evt_time, 'arrow_down')
527 # self._event(FunctionalTest.evt_time, 'rcontrol')
528 # self._screenshot(FunctionalTest.screenshot_time, 'normal_mapping')
529 # self._event(FunctionalTest.evt_time, 'rcontrol')
530 # self._event(FunctionalTest.evt_time, 'arrow_down')
531 # self._event(FunctionalTest.evt_time, 'rcontrol')
532 # self._screenshot(FunctionalTest.screenshot_time, 'occlusion')
533 # self._event(FunctionalTest.evt_time, 'rcontrol')
534 # self._event(FunctionalTest.evt_time, 'arrow_down')
535 # self._event(FunctionalTest.evt_time, 'rcontrol')
536 # # input
537 # self._event(FunctionalTest.evt_time, 'arrow_down')
538 # self._event(FunctionalTest.evt_time, 'rcontrol')
539 # self._screenshot(FunctionalTest.screenshot_time, 'input')
540 # self._event(FunctionalTest.evt_time, 'rcontrol')
541 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1')
542 # self._event(FunctionalTest.evt_time, 'rcontrol')
543 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_rec')
544 # self._event(FunctionalTest.evt_time, '8', True, False)
545 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_changed')
546 # self._event(FunctionalTest.evt_time, 'rcontrol')
547 # self._event(FunctionalTest.evt_time, 'arrow_up', True, False)
548 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_restored')
549 # self._event(FunctionalTest.evt_time, 'rcontrol')
550 # self._event(FunctionalTest.evt_time, 'w', True, False)
551 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already')
552 # self._event(FunctionalTest.evt_time, 'rcontrol')
553 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already_closed')
554 # self._event(FunctionalTest.evt_time, 'arrow_down')
555 # self._event(FunctionalTest.evt_time, 'arrow_down')
556 # self._event(FunctionalTest.evt_time, 'arrow_down')
557 # self._event(FunctionalTest.evt_time, 'arrow_down')
558 # self._event(FunctionalTest.evt_time, 'rcontrol')
559 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p2')
560 # self._event(FunctionalTest.evt_time, 'arrow_down')
561 # self._event(FunctionalTest.evt_time, 'arrow_down')
562 # self._event(FunctionalTest.evt_time, 'arrow_down')
563 # self._event(FunctionalTest.evt_time, 'arrow_down')
564 # self._event(FunctionalTest.evt_time, 'rcontrol')
565 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p3')
566 # self._event(FunctionalTest.evt_time, 'arrow_down')
567 # self._event(FunctionalTest.evt_time, 'arrow_down')
568 # self._event(FunctionalTest.evt_time, 'arrow_down')
569 # self._event(FunctionalTest.evt_time, 'arrow_down')
570 # self._event(FunctionalTest.evt_time, 'rcontrol')
571 # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p4')
572 # self._event(FunctionalTest.evt_time, 'arrow_down')
573 # self._event(FunctionalTest.evt_time, 'arrow_down')
574 # self._event(FunctionalTest.evt_time, 'arrow_down')
575 # self._event(FunctionalTest.evt_time, 'arrow_down')
576 # self._event(FunctionalTest.evt_time, 'rcontrol')
577 # self._event(FunctionalTest.evt_time, 'arrow_down')
578 # self._event(FunctionalTest.evt_time, 'rcontrol')
579 # self._event(FunctionalTest.evt_time, 'arrow_down')
580 # self._event(FunctionalTest.evt_time, 'rcontrol')
581 # self._event(FunctionalTest.evt_time, 'arrow_down')
582 # self._event(FunctionalTest.evt_time, 'rcontrol')
583 # self._event(FunctionalTest.evt_time, 'arrow_down')
584 # self._event(FunctionalTest.evt_time, 'rcontrol')
585 # self._event(FunctionalTest.evt_time, 'arrow_down')
586 # self._event(FunctionalTest.evt_time, 'rcontrol')
587 # self._event(FunctionalTest.evt_time, 'arrow_up')
588 # self._event(FunctionalTest.evt_time, 'arrow_up')
8ee66edd 589
edeef6f9
FC
590 # def _do_screenshots_game(self):
591 # # single player
592 # self._event(FunctionalTest.evt_time, 'rcontrol')
593 # self._screenshot(FunctionalTest.screenshot_time, 'single_player_menu')
594 # self._event(FunctionalTest.evt_time, 'rcontrol')
595 # self._screenshot(FunctionalTest.screenshot_time, 'track_page')
596 # self._event(FunctionalTest.evt_time, 'rcontrol')
597 # self._screenshot(FunctionalTest.screenshot_time, 'car_page_start')
598 # self._event(FunctionalTest.evt_time, 'arrow_left')
599 # self._screenshot(FunctionalTest.screenshot_time, 'car_page_sel')
600 # self._event(FunctionalTest.evt_time, 'rcontrol')
601 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_start')
602 # self._event(FunctionalTest.evt_time, 'arrow_down')
603 # self._event(FunctionalTest.evt_time, 'arrow_down')
604 # self._event(FunctionalTest.evt_time, 'rcontrol')
605 # self._event(FunctionalTest.evt_time, 'arrow_down')
606 # self._event(FunctionalTest.evt_time, 'arrow_down')
607 # self._event(FunctionalTest.evt_time, 'rcontrol')
608 # self._event(FunctionalTest.evt_time, 'arrow_down')
609 # self._event(FunctionalTest.evt_time, 'rcontrol')
610 # self._event(FunctionalTest.evt_time, 'arrow_up')
611 # self._event(FunctionalTest.evt_time, 'rcontrol')
612 # self._event(FunctionalTest.evt_time, 'rcontrol')
613 # self._event(FunctionalTest.evt_time, 'arrow_left')
614 # self._event(FunctionalTest.evt_time, 'rcontrol')
615 # self._event(FunctionalTest.evt_time, 'rcontrol')
616 # self._event(FunctionalTest.evt_time, 'rcontrol')
617 # self._event(FunctionalTest.evt_time, 'rcontrol')
618 # self._event(FunctionalTest.evt_time, 'rcontrol')
619 # self._event(FunctionalTest.evt_time, 'arrow_left')
620 # self._event(FunctionalTest.evt_time, 'rcontrol')
621 # self._event(FunctionalTest.evt_time, 'arrow_up')
622 # self._event(FunctionalTest.evt_time, 'rcontrol')
623 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry')
624 # self._event(FunctionalTest.evt_time, 'backspace')
625 # self._event(FunctionalTest.evt_time, 'backspace')
626 # self._event(FunctionalTest.evt_time, 'backspace')
627 # self._event(FunctionalTest.evt_time, 'backspace')
628 # self._event(FunctionalTest.evt_time, 'backspace')
629 # self._event(FunctionalTest.evt_time, 'backspace')
630 # self._event(FunctionalTest.evt_time, 'backspace')
631 # self._event(FunctionalTest.evt_time, 'backspace')
632 # self._event(FunctionalTest.evt_time, 'backspace')
633 # self._event(FunctionalTest.evt_time, 'backspace')
634 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_empty')
635 # self._event(FunctionalTest.evt_time, 'f')
636 # self._event(FunctionalTest.evt_time, 'l')
637 # self._event(FunctionalTest.evt_time, 'a')
638 # self._event(FunctionalTest.evt_time, 'v')
639 # self._event(FunctionalTest.evt_time, 'i')
640 # self._event(FunctionalTest.evt_time, 'o')
641 # self._event(FunctionalTest.evt_time, 'enter')
642 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_full')
643 # self._event(FunctionalTest.evt_time, 'arrow_down')
644 # self._event(FunctionalTest.evt_time, 'arrow_right')
645 # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_sel')
646 # # some ai tests
647 # self._event(FunctionalTest.evt_time, 'rcontrol')
648 # self._event(40, 'escape-up')
649 # self._screenshot(FunctionalTest.screenshot_time, 'ingame_menu')
650 # self._event(FunctionalTest.evt_time, 'rcontrol')
651 # self._screenshot(FunctionalTest.screenshot_time, 'race_back')
652 # self._event(FunctionalTest.evt_time, 'escape-up')
653 # self._event(FunctionalTest.evt_time, 'arrow_down')
654 # self._screenshot(FunctionalTest.screenshot_time, 'ingame_sel')
655 # self._event(FunctionalTest.evt_time, 'rcontrol')
656 # self._screenshot(FunctionalTest.screenshot_time, 'main_page_back_race')
8ee66edd 657
edeef6f9
FC
658 # def _do_screenshots_end(self):
659 # self._event(FunctionalTest.evt_time, 'arrow_down')
660 # self._event(FunctionalTest.evt_time, 'arrow_down')
661 # self._event(FunctionalTest.evt_time, 'arrow_down')
662 # self._event(FunctionalTest.evt_time, 'arrow_down')
663 # self._event(FunctionalTest.evt_time, 'arrow_down')
664 # self._event(FunctionalTest.evt_time, 'rcontrol')
665 # self._screenshot(FunctionalTest.screenshot_time, 'exit_page')
666 # self._event(FunctionalTest.evt_time, 'arrow_down')
667 # self._screenshot(FunctionalTest.screenshot_time, 'exit_page_sel')
668 # self._verify()
669 # self._event(FunctionalTest.evt_time, 'rcontrol')
670 # self._exit()
8ee66edd
FC
671
672 def _do_screenshots(self, idx):
673 [self._do_screenshots_1, self._do_screenshots_2][int(idx) - 1]()