ya2 · news · projects · code · about

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