ya2 · news · projects · code · about

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