ya2 · news · projects · code · about

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