Commit | Line | Data |
---|---|---|
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 |
7 | import datetime |
8 | from os import getcwd, system | |
8ee66edd FC |
9 | from logging import debug, info |
10 | from pathlib import Path | |
11 | from shutil import rmtree | |
12 | from os import makedirs | |
13 | from os.path import join, exists | |
14 | from glob import glob | |
15 | from sys import exit | |
16 | from panda3d.core import Filename | |
17 | from direct.gui.OnscreenText import OnscreenText | |
18 | from lib.gameobject import GameObject | |
19 | from lib.build.build import _branch | |
20 | ||
21 | ||
22 | class 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() |
882c058d | 184 | self._do_screenshots_play() |
8ee66edd FC |
185 | self._do_screenshots_exit() |
186 | ||
187 | def _do_screenshots_credits(self): | |
882c058d | 188 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 410), 'left']) |
8ee66edd | 189 | self._screenshot(FunctionalTest.screenshot_time, 'credits_menu') |
882c058d | 190 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 630), 'left']) |
edeef6f9 FC |
191 | self._screenshot(FunctionalTest.screenshot_time, 'main_menu_back_from_credits') |
192 | # # go to credits | |
193 | # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True) | |
194 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
195 | # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True) | |
196 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
197 | # self._screenshot(FunctionalTest.screenshot_time, 'main_menu_highlight') | |
198 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
199 | # self._screenshot(FunctionalTest.screenshot_time, 'credits_menu') | |
200 | # # go to supporters | |
201 | # self._event(FunctionalTest.evt_time, 'joypad0-face_a', True) | |
202 | # self._screenshot(FunctionalTest.screenshot_time, 'supporters_menu') | |
203 | # # back to main | |
204 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
205 | # self._event(FunctionalTest.evt_time, 'joypad0-face_b', True) | |
206 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
207 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
208 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
209 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
8ee66edd | 210 | |
d982c0a5 | 211 | def _do_screenshots_options(self): |
882c058d | 212 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 270), 'left']) |
d982c0a5 FC |
213 | self._screenshot(FunctionalTest.screenshot_time, 'options_menu') |
214 | # languages | |
882c058d | 215 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 50), 'left']) |
d982c0a5 | 216 | self._screenshot(FunctionalTest.screenshot_time, 'open_languages_1') |
882c058d | 217 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(930, 30), 'left']) |
d982c0a5 | 218 | self._screenshot(FunctionalTest.screenshot_time, 'options_menu_english') |
882c058d | 219 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 50), 'left']) |
d982c0a5 | 220 | self._screenshot(FunctionalTest.screenshot_time, 'open_languages_2') |
882c058d | 221 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(930, 110), 'left']) |
d982c0a5 FC |
222 | self._screenshot(FunctionalTest.screenshot_time, 'options_menu_italian') |
223 | # volume | |
882c058d | 224 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(680, 150), (700, 150), 'left']) |
d982c0a5 | 225 | self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_1') |
882c058d | 226 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(700, 150), (680, 150), 'left']) |
d982c0a5 FC |
227 | self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2') |
228 | # fullscreen | |
882c058d | 229 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 240), 'left']) |
d982c0a5 | 230 | self._screenshot(FunctionalTest.screenshot_time, 'fullscreen') |
882c058d FC |
231 | self._event(8 + FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 240), 'left']) |
232 | self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen') | |
d982c0a5 | 233 | # resolution |
882c058d | 234 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 330), 'left']) |
d982c0a5 | 235 | self._screenshot(FunctionalTest.screenshot_time, 'resolutions') |
882c058d | 236 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(950, 470), 'left']) |
d982c0a5 | 237 | self._screenshot(FunctionalTest.screenshot_time, '1440x900') |
882c058d | 238 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(720, 410), 'left']) |
d982c0a5 | 239 | self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2') |
882c058d | 240 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1120, 420), 'left']) |
d982c0a5 FC |
241 | self._screenshot(FunctionalTest.screenshot_time, '1280x720') |
242 | # antialiasing | |
882c058d | 243 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) |
d982c0a5 FC |
244 | self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_no') |
245 | # shadows | |
882c058d | 246 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 510), 'left']) |
d982c0a5 FC |
247 | self._screenshot(FunctionalTest.screenshot_time, 'shadows_no') |
248 | # test aa and shadows | |
882c058d FC |
249 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 630), 'left']) # back |
250 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play | |
251 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino | |
252 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(845, 455), 'left']) # close instructions | |
253 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(25, 695), 'left']) # home | |
254 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 270), 'left']) # options | |
255 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # aa | |
256 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 510), 'left']) # shadows | |
d982c0a5 | 257 | self._screenshot(FunctionalTest.screenshot_time, 'aa_no_shadows_no') |
882c058d | 258 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 630), 'left']) # back |
d982c0a5 | 259 | |
edeef6f9 FC |
260 | # # go to options |
261 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
262 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
263 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
264 | # self._screenshot(FunctionalTest.screenshot_time, 'options_menu') | |
265 | # # language | |
266 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
267 | # self._screenshot(FunctionalTest.screenshot_time, 'language_open') | |
268 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
269 | # self._screenshot(FunctionalTest.screenshot_time, 'language_highlight') | |
270 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
271 | # self._screenshot(FunctionalTest.screenshot_time, 'language_it') | |
272 | # # volume | |
273 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
274 | # self._event(FunctionalTest.evt_time, 'arrow_right') | |
275 | # self._event(FunctionalTest.evt_time, 'arrow_right') | |
276 | # self._screenshot(FunctionalTest.screenshot_time, 'volume') | |
277 | # # car's number | |
278 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
279 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
280 | # self._screenshot(FunctionalTest.screenshot_time, 'cars_open') | |
281 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
282 | # self._screenshot(FunctionalTest.screenshot_time, 'cars_changed') | |
283 | # # back | |
284 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
285 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
286 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
287 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
288 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
289 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
8ee66edd | 290 | |
882c058d FC |
291 | def _do_screenshots_play(self): |
292 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play | |
293 | self._screenshot(FunctionalTest.screenshot_time, 'play_menu') | |
294 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino scene | |
295 | self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_instructions') | |
296 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(845, 455), 'left']) # close instructions | |
297 | self._screenshot(FunctionalTest.screenshot_time, 'scene_domino') | |
298 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(25, 695), 'left']) # home | |
299 | self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_scene') | |
300 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play | |
301 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino | |
302 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(845, 455), 'left']) # close instructions | |
303 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(60, 695), 'left']) # info | |
304 | self._screenshot(FunctionalTest.screenshot_time, 'info') | |
305 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(845, 455), 'left']) # close instructions | |
306 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (370, 220), 'left']) # drag a piece | |
307 | self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged') | |
308 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(500, 340), 'left']) # rewind | |
309 | self._screenshot(FunctionalTest.screenshot_time, 'rewind') | |
310 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (525, 350), 'left']) # drag a piece | |
311 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 510), (670, 350), 'left']) # drag a piece | |
312 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
313 | self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_domino') | |
314 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(590, 420), 'left']) # home | |
315 | self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_fail') | |
316 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 130), 'left']) # play | |
317 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(220, 150), 'left']) # domino | |
318 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(845, 455), 'left']) # close instructions | |
319 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (525, 350), 'left']) # drag a piece | |
320 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (670, 350), 'left']) # drag a piece | |
321 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
322 | self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_domino_2') | |
323 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay | |
324 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (540, 140), 'left']) # drag a piece | |
325 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(540, 130), (600, 130), 'right']) # rotate the piece | |
326 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (665, 355), 'left']) # drag a piece | |
327 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
328 | self._screenshot(10 + FunctionalTest.screenshot_time, 'win_domino') | |
329 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next | |
330 | self._screenshot(FunctionalTest.screenshot_time, 'scene_box') | |
4f15e3fc FC |
331 | # scene 2 |
332 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 585), 'left']) # drag a box | |
333 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 515), 'left']) # drag a box | |
334 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
335 | self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_box') | |
336 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay | |
337 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 585), 'left']) # drag a box | |
338 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 515), 'left']) # drag a box | |
339 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (660, 430), 'left']) # drag a box | |
340 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
341 | self._screenshot(10 + FunctionalTest.screenshot_time, 'win_box') | |
342 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next | |
343 | self._screenshot(FunctionalTest.screenshot_time, 'scene_box_domino') | |
344 | # scene 3 | |
345 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (865, 415), 'left']) # drag a box | |
346 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (865, 330), 'left']) # drag a box | |
347 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
348 | self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_box_domino') | |
349 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay | |
350 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (860, 415), 'left']) # drag a box | |
351 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (775, 235), '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_domino') | |
354 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next | |
355 | self._screenshot(FunctionalTest.screenshot_time, 'scene_basketball') | |
356 | # scene 4 | |
357 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (630, 300), 'left']) # drag a ball | |
358 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
359 | self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_basketball') | |
360 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay | |
361 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (360, 150), 'left']) # drag a ball | |
362 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
363 | self._screenshot(10 + FunctionalTest.screenshot_time, 'win_basketball') | |
364 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next | |
365 | self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_box_basketball') | |
366 | # scene 5 | |
367 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (550, 415), 'left']) # drag a box | |
368 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (560, 340), 'left']) # drag a piece | |
369 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
370 | self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_domino_box_basketball') | |
371 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay | |
372 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (550, 415), 'left']) # drag a box | |
373 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 50), (620, 410), 'left']) # drag a piece | |
374 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(620, 430), (665, 425), 'right']) # rotate a piece | |
375 | self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(615, 415), (615, 420), 'left']) # drag a piece | |
376 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
377 | self._screenshot(10 + FunctionalTest.screenshot_time, 'win_domino_box_basketball') | |
378 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next | |
379 | # self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_tooter') | |
380 | # # scene 6 | |
381 | # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (490, 300), 'left']) # drag a box | |
382 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
383 | # self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_teeter_tooter') | |
384 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay | |
385 | # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (490, 150), 'left']) # drag a box | |
386 | # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(515, 115), (515, 122), 'right']) # rotate a box | |
387 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
388 | # self._screenshot(10 + FunctionalTest.screenshot_time, 'win_teeter_tooter') | |
389 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(690, 420), 'left']) # next | |
390 | # self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_domino_box_basketball') | |
391 | # scene 7 | |
392 | # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (155, 180), 'left']) # drag a box | |
393 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
394 | # self._screenshot(10 + FunctionalTest.screenshot_time, 'fail_teeter_domino_box_basketball') | |
395 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 420), 'left']) # replay | |
396 | # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(60, 60), (170, 80), 'left']) # drag a box | |
397 | # self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(195, 50), (195, 80), 'right']) # rotate a box | |
398 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1260, 695), 'left']) # play | |
399 | # self._screenshot(10 + FunctionalTest.screenshot_time, 'win_teeter_domino_box_basketball') | |
400 | # self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(590, 420), 'left']) # home | |
401 | self._screenshot(FunctionalTest.screenshot_time, 'home_from_play') | |
882c058d | 402 | |
8ee66edd | 403 | def _do_screenshots_exit(self): |
edeef6f9 FC |
404 | # self._event(FunctionalTest.evt_time, 'arrow_down') |
405 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
406 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
407 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
408 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
409 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
410 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
8ee66edd | 411 | self._verify() |
edeef6f9 FC |
412 | # self._event(FunctionalTest.evt_time, 'rcontrol') |
413 | # self._exit() | |
882c058d | 414 | self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(640, 560), 'left']) |
edeef6f9 | 415 | |
8ee66edd FC |
416 | |
417 | def _do_screenshots_2(self): | |
418 | info('_do_screenshots_2') | |
edeef6f9 FC |
419 | # self._do_screenshots_restore_options() |
420 | # self._do_screenshots_game() | |
421 | # self._do_screenshots_end() | |
8ee66edd | 422 | |
edeef6f9 FC |
423 | # def _do_screenshots_restore_options(self): |
424 | # # go to options | |
425 | # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True) | |
426 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
427 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
428 | # self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored') | |
429 | # # # language | |
430 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
431 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
432 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
433 | # self._screenshot(FunctionalTest.screenshot_time, 'language_en_restored') | |
434 | # # # volume | |
435 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
436 | # self._event(FunctionalTest.evt_time, 'arrow_left') | |
437 | # self._event(FunctionalTest.evt_time, 'arrow_left') | |
438 | # self._screenshot(FunctionalTest.screenshot_time, 'volume_restored') | |
439 | # # car's number | |
440 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
441 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
442 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
443 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
444 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
445 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
446 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
447 | # self._screenshot(FunctionalTest.screenshot_time, 'cars_restored') | |
448 | # # graphics settings | |
449 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
450 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
451 | # self._screenshot(FunctionalTest.screenshot_time, 'graphics_settings') | |
452 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
453 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
454 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
455 | # self._screenshot(FunctionalTest.screenshot_time, 'antialiasing') | |
456 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
457 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
458 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
459 | # self._screenshot(FunctionalTest.screenshot_time, 'shadows') | |
460 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
461 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
462 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
463 | # self._screenshot(FunctionalTest.screenshot_time, 'fog') | |
464 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
465 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
466 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
467 | # self._screenshot(FunctionalTest.screenshot_time, 'normal_mapping') | |
468 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
469 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
470 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
471 | # self._screenshot(FunctionalTest.screenshot_time, 'occlusion') | |
472 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
473 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
474 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
475 | # # input | |
476 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
477 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
478 | # self._screenshot(FunctionalTest.screenshot_time, 'input') | |
479 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
480 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1') | |
481 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
482 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_rec') | |
483 | # self._event(FunctionalTest.evt_time, '8', True, False) | |
484 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_changed') | |
485 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
486 | # self._event(FunctionalTest.evt_time, 'arrow_up', True, False) | |
487 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_restored') | |
488 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
489 | # self._event(FunctionalTest.evt_time, 'w', True, False) | |
490 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already') | |
491 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
492 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already_closed') | |
493 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
494 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
495 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
496 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
497 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
498 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p2') | |
499 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
500 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
501 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
502 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
503 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
504 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p3') | |
505 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
506 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
507 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
508 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
509 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
510 | # self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p4') | |
511 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
512 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
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._event(FunctionalTest.evt_time, 'arrow_down') | |
517 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
518 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
519 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
520 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
521 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
522 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
523 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
524 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
525 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
526 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
527 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
8ee66edd | 528 | |
edeef6f9 FC |
529 | # def _do_screenshots_game(self): |
530 | # # single player | |
531 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
532 | # self._screenshot(FunctionalTest.screenshot_time, 'single_player_menu') | |
533 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
534 | # self._screenshot(FunctionalTest.screenshot_time, 'track_page') | |
535 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
536 | # self._screenshot(FunctionalTest.screenshot_time, 'car_page_start') | |
537 | # self._event(FunctionalTest.evt_time, 'arrow_left') | |
538 | # self._screenshot(FunctionalTest.screenshot_time, 'car_page_sel') | |
539 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
540 | # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_start') | |
541 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
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, 'arrow_down') | |
546 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
547 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
548 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
549 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
550 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
551 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
552 | # self._event(FunctionalTest.evt_time, 'arrow_left') | |
553 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
554 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
555 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
556 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
557 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
558 | # self._event(FunctionalTest.evt_time, 'arrow_left') | |
559 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
560 | # self._event(FunctionalTest.evt_time, 'arrow_up') | |
561 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
562 | # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry') | |
563 | # self._event(FunctionalTest.evt_time, 'backspace') | |
564 | # self._event(FunctionalTest.evt_time, 'backspace') | |
565 | # self._event(FunctionalTest.evt_time, 'backspace') | |
566 | # self._event(FunctionalTest.evt_time, 'backspace') | |
567 | # self._event(FunctionalTest.evt_time, 'backspace') | |
568 | # self._event(FunctionalTest.evt_time, 'backspace') | |
569 | # self._event(FunctionalTest.evt_time, 'backspace') | |
570 | # self._event(FunctionalTest.evt_time, 'backspace') | |
571 | # self._event(FunctionalTest.evt_time, 'backspace') | |
572 | # self._event(FunctionalTest.evt_time, 'backspace') | |
573 | # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_empty') | |
574 | # self._event(FunctionalTest.evt_time, 'f') | |
575 | # self._event(FunctionalTest.evt_time, 'l') | |
576 | # self._event(FunctionalTest.evt_time, 'a') | |
577 | # self._event(FunctionalTest.evt_time, 'v') | |
578 | # self._event(FunctionalTest.evt_time, 'i') | |
579 | # self._event(FunctionalTest.evt_time, 'o') | |
580 | # self._event(FunctionalTest.evt_time, 'enter') | |
581 | # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_full') | |
582 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
583 | # self._event(FunctionalTest.evt_time, 'arrow_right') | |
584 | # self._screenshot(FunctionalTest.screenshot_time, 'driver_page_sel') | |
585 | # # some ai tests | |
586 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
587 | # self._event(40, 'escape-up') | |
588 | # self._screenshot(FunctionalTest.screenshot_time, 'ingame_menu') | |
589 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
590 | # self._screenshot(FunctionalTest.screenshot_time, 'race_back') | |
591 | # self._event(FunctionalTest.evt_time, 'escape-up') | |
592 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
593 | # self._screenshot(FunctionalTest.screenshot_time, 'ingame_sel') | |
594 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
595 | # self._screenshot(FunctionalTest.screenshot_time, 'main_page_back_race') | |
8ee66edd | 596 | |
edeef6f9 FC |
597 | # def _do_screenshots_end(self): |
598 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
599 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
600 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
601 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
602 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
603 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
604 | # self._screenshot(FunctionalTest.screenshot_time, 'exit_page') | |
605 | # self._event(FunctionalTest.evt_time, 'arrow_down') | |
606 | # self._screenshot(FunctionalTest.screenshot_time, 'exit_page_sel') | |
607 | # self._verify() | |
608 | # self._event(FunctionalTest.evt_time, 'rcontrol') | |
609 | # self._exit() | |
8ee66edd FC |
610 | |
611 | def _do_screenshots(self, idx): | |
612 | [self._do_screenshots_1, self._do_screenshots_2][int(idx) - 1]() |