ya2 · news · projects · code · about

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