ya2 · news · projects · code · about

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