Commit | Line | Data |
---|---|---|
361d3942 FC |
1 | '''Create ref: |
2 | * M-x fla-set-fun-test | |
3 | * rm options.ini | |
53ddf3c3 FC |
4 | * python main.py --functional-test --functional-ref & python -m ya2.tools.functional_test.py 1 |
5 | * python main.py --functional-test --functional-ref & python -m ya2.tools.functional_test.py 2 | |
361d3942 FC |
6 | * M-x fla-unset-fun-test''' |
7 | from panda3d.core import load_prc_file_data | |
8 | load_prc_file_data('', 'window-type none') | |
9 | import datetime | |
10 | from time import sleep | |
11 | from os import getcwd, system | |
158b04a8 | 12 | from xmlrpc.client import ServerProxy |
361d3942 FC |
13 | from logging import debug, info |
14 | from pathlib import Path | |
15 | from shutil import rmtree | |
16 | from os import makedirs | |
17 | from os.path import join, exists | |
18 | from glob import glob | |
19 | from sys import exit, argv | |
20 | from panda3d.core import Filename | |
21 | from direct.showbase.ShowBase import ShowBase | |
22 | from direct.gui.OnscreenText import OnscreenText | |
53ddf3c3 | 23 | from ya2.build.build import _branch |
a33967c7 FC |
24 | import asyncio |
25 | import xmlrpc | |
361d3942 FC |
26 | |
27 | ||
aed9737a | 28 | class FunctionalTest: |
361d3942 | 29 | |
a33967c7 FC |
30 | screenshot_time = 2.0 |
31 | evt_time = 2.0 | |
32 | drag_time = 2.0 | |
361d3942 FC |
33 | start_time = 2 |
34 | ||
68f6c184 | 35 | def __init__(self, idx, offset): |
a33967c7 | 36 | debug('creating FunctionalTest (%s)' % id(self)) |
361d3942 FC |
37 | super().__init__() |
38 | info('test idx: %s' % idx) | |
68f6c184 | 39 | self._offset = offset |
a33967c7 FC |
40 | sleep(12) |
41 | self._proxy = ServerProxy('http://localhost:7000') | |
361d3942 FC |
42 | self._curr_time = 0 |
43 | self._tasks = [] | |
44 | self._prev_time = 0 | |
a33967c7 | 45 | #taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable') |
158b04a8 | 46 | self._proxy.set_idx(idx) |
361d3942 FC |
47 | self._do_screenshots(idx) |
48 | ||
49 | def _do_screenshot(self, name): | |
50 | time = datetime.datetime.now().strftime('%y%m%d%H%M%S') | |
51 | name = name + '.png' | |
158b04a8 | 52 | self._proxy.screenshot(name) |
361d3942 FC |
53 | info('screenshot %s' % name) |
54 | ||
a33967c7 FC |
55 | async def _screenshot(self, time, name): |
56 | #self._tasks += [( | |
57 | # self._curr_time + time, | |
58 | # lambda: self._do_screenshot(name), | |
59 | # 'screenshot: %s' % name)] | |
60 | #self._curr_time += time | |
61 | await asyncio.sleep(time) | |
62 | self._do_screenshot(name) | |
361d3942 | 63 | |
a33967c7 FC |
64 | async def __mouse_click(self, tgt, btn): |
65 | await asyncio.sleep(.5) | |
2e5f0efc FC |
66 | offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations |
67 | offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations | |
361d3942 | 68 | btn = 3 if btn == 'right' else 1 |
2d1773b1 | 69 | pos = self._proxy.get_pos(tgt) |
361d3942 | 70 | system('xdotool mousemove %s %s' % (offset_x + pos[0], offset_y + pos[1])) |
a33967c7 FC |
71 | #def click(task): |
72 | # system('xdotool click %s' % tgt) | |
73 | # print('CLICK %s' % str(btn)) | |
74 | #taskMgr.do_method_later(.28, click, 'click') | |
75 | await asyncio.sleep(.5) | |
76 | system('xdotool click %s' % btn) | |
361d3942 | 77 | |
a33967c7 FC |
78 | async def __mouse_drag(self, start, end, btn): |
79 | await asyncio.sleep(.5) | |
2e5f0efc FC |
80 | offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations |
81 | offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations | |
361d3942 | 82 | btn = 3 if btn == 'right' else 1 |
067a36db FC |
83 | start = self._proxy.get_pos(start) |
84 | end = self._proxy.get_pos(end) | |
361d3942 | 85 | system('xdotool mousemove %s %s' % (offset_x + start[0], offset_y + start[1])) |
a33967c7 FC |
86 | await asyncio.sleep(.5) |
87 | system('xdotool mousedown %s' % btn) | |
88 | await asyncio.sleep(.5) | |
89 | system('xdotool mousemove %s %s' % (offset_x + end[0], offset_y + end[1])) | |
90 | await asyncio.sleep(.5) | |
91 | system('xdotool mouseup %s' % btn) | |
92 | # def mousedown(task): | |
93 | # system('xdotool mousedown %s' % btn) | |
94 | # def mousemove(task): | |
95 | # system('xdotool mousemove %s %s' % (offset_x + end[0], offset_y + end[1])) | |
96 | # def mouseup(task): | |
97 | # system('xdotool mouseup %s' % btn) | |
98 | # taskMgr.do_method_later(.28, mouseup, 'mouseup') | |
99 | # taskMgr.do_method_later(.28, mousemove, 'mousemove') | |
100 | # taskMgr.do_method_later(.28, mousedown, 'mousedown') | |
361d3942 | 101 | |
a33967c7 FC |
102 | async def _event(self, time, evt, mouse_args=None): |
103 | await asyncio.sleep(time) | |
361d3942 | 104 | if evt == 'mouseclick': |
a33967c7 FC |
105 | #cback = lambda: self.__mouse_click(*mouse_args) |
106 | await self.__mouse_click(*mouse_args) | |
361d3942 | 107 | elif evt == 'mousedrag': |
a33967c7 FC |
108 | #cback = lambda: self.__mouse_drag(*mouse_args) |
109 | await self.__mouse_drag(*mouse_args) | |
110 | #self._tasks += [( | |
111 | # self._curr_time + time, | |
112 | # cback, | |
113 | # 'event: %s' % evt)] | |
114 | #self._curr_time += time | |
361d3942 | 115 | |
a33967c7 FC |
116 | async def _enforce_res(self, time, res): |
117 | await asyncio.sleep(time) | |
118 | self._proxy.enforce_res(res) | |
119 | #def cback(): | |
120 | # self._proxy.enforce_res(res) | |
121 | # info('enforce_res %s' % res) | |
122 | #self._tasks += [( | |
123 | # self._curr_time + time, | |
124 | # cback, | |
125 | # 'enforce res: %s' % res)] | |
126 | #self._curr_time += time | |
361d3942 | 127 | |
a33967c7 FC |
128 | async def _enforce_resolution(self, time, res): |
129 | await asyncio.sleep(time) | |
130 | self._proxy.enforce_resolution(res) | |
131 | #def cback(): | |
132 | # self._proxy.enforce_resolution(res) | |
133 | # info('enforce_resolution %s (send)' % res) | |
134 | #self._tasks += [( | |
135 | # self._curr_time + time, | |
136 | # cback, | |
137 | # 'enforce resolution: %s' % res)] | |
138 | #self._curr_time += time | |
74ed9732 | 139 | |
a33967c7 FC |
140 | async def _verify(self, time): |
141 | await asyncio.sleep(time) | |
142 | self._proxy.verify() | |
143 | info('verify') | |
144 | #def __verify(): | |
145 | # self._proxy.verify() | |
146 | # info('verify') | |
147 | #self._tasks += [( | |
148 | # self._curr_time + 3, | |
149 | # lambda: __verify(), | |
150 | # 'verify')] | |
151 | #self._curr_time += 3 | |
361d3942 | 152 | |
a33967c7 FC |
153 | async def _exit(self, time): |
154 | await asyncio.sleep(time) | |
155 | try: | |
158b04a8 | 156 | self._proxy.close() |
a33967c7 FC |
157 | except (ConnectionRefusedError, xmlrpc.client.Fault) as e: # the other part has been closed with the exit button |
158 | debug('already closed (%s)' % e) | |
159 | debug('destroying FunctionalTest (%s)' % id(self)) | |
160 | exit() | |
161 | #def do_exit(): | |
162 | # try: | |
163 | # self._proxy.close() | |
164 | # except (ConnectionRefusedError, xmlrpc.client.Fault) as e: # the other part has been closed with the exit button | |
165 | # debug('already closed (%s)' % e) | |
166 | # debug('destroying FunctionalTest (%s)' % id(self)) | |
167 | # exit() | |
168 | #self._tasks += [( | |
169 | # self._curr_time + 3, | |
170 | # lambda: do_exit(), | |
171 | # 'exit')] | |
361d3942 | 172 | |
a33967c7 FC |
173 | # def on_frame_unpausable(self, task): |
174 | # for tsk in self._tasks: | |
175 | # #if self._prev_time <= tsk[0] < self.eng.event.unpaused_time: | |
176 | # if self._prev_time <= tsk[0] < globalClock.getFrameTime(): | |
177 | # debug('%s %s' % (tsk[0], tsk[2])) | |
178 | # tsk[1]() | |
179 | # self._prev_time = globalClock.getFrameTime() # self.eng.event.unpaused_time | |
180 | # return task.cont | |
361d3942 | 181 | |
a33967c7 | 182 | async def _do_screenshots_1(self): |
361d3942 | 183 | info('_do_screenshots_1') |
a33967c7 FC |
184 | await self._screenshot(FunctionalTest.start_time, 'main_menu') |
185 | await self._do_screenshots_credits() | |
186 | await self._do_screenshots_options() | |
187 | await self._do_screenshots_exit() | |
361d3942 | 188 | |
a33967c7 FC |
189 | async def _do_screenshots_credits(self): |
190 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) | |
191 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['credits', 'left']) | |
192 | await self._screenshot(FunctionalTest.screenshot_time, 'credits_menu') | |
193 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) | |
194 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left']) | |
195 | await self._screenshot(FunctionalTest.screenshot_time, 'main_menu_back_from_credits') | |
361d3942 | 196 | |
a33967c7 FC |
197 | async def _do_screenshots_options(self): |
198 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 300), 'left']) | |
199 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['options', 'left']) | |
200 | await self._screenshot(FunctionalTest.screenshot_time, 'options_menu') | |
361d3942 | 201 | # languages |
a33967c7 FC |
202 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 60), 'left']) |
203 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['languages', 'left']) | |
204 | await self._screenshot(FunctionalTest.screenshot_time, 'open_languages') | |
205 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(980, 120), 'left']) | |
206 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['italian', 'left']) | |
207 | await self._screenshot(FunctionalTest.screenshot_time, 'options_menu_italian') | |
361d3942 | 208 | # volume |
a33967c7 FC |
209 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 163), 'left']) |
210 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['volume', 'left']) | |
211 | await self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_1') | |
361d3942 | 212 | # antialiasing |
a33967c7 FC |
213 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 440), 'left']) |
214 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['aa', 'left']) | |
215 | await self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_no') | |
361d3942 | 216 | # shadows |
a33967c7 FC |
217 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 540), 'left']) |
218 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['shadows', 'left']) | |
219 | await self._screenshot(FunctionalTest.screenshot_time, 'shadows_no') | |
361d3942 | 220 | # test aa and shadows |
a33967c7 FC |
221 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back |
222 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left']) # back | |
223 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play | |
224 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left']) # play | |
225 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino | |
226 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left']) # domino | |
227 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(900, 490), 'left']) # close instructions | |
228 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) # close instructions | |
229 | await self._screenshot(FunctionalTest.screenshot_time, 'aa_no_shadows_no') | |
230 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(25, 740), 'left']) # home | |
231 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['home', 'left']) # home | |
361d3942 | 232 | |
a33967c7 FC |
233 | async def _do_screenshots_restore_options(self): |
234 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 300), 'left']) | |
235 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['options', 'left']) | |
236 | await self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored') | |
361d3942 | 237 | # languages |
a33967c7 FC |
238 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 60), 'left']) |
239 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['languages', 'left']) | |
240 | await self._screenshot(FunctionalTest.screenshot_time, 'open_languages_restored') | |
241 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(980, 20), 'left']) | |
242 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['english', 'left']) | |
243 | await self._screenshot(FunctionalTest.screenshot_time, 'options_menu_english') | |
361d3942 | 244 | # volume |
a33967c7 FC |
245 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(719, 163), 'left']) |
246 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['volume_0', 'left']) | |
247 | await self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2') | |
361d3942 FC |
248 | # fullscreen |
249 | # the first one is because of the windowed mode in test | |
a33967c7 FC |
250 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left']) |
251 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left']) | |
252 | await self._screenshot(FunctionalTest.screenshot_time, 'fullscreen') | |
253 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left']) | |
254 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left']) | |
255 | await self._screenshot(FunctionalTest.screenshot_time, 'fullscreen') | |
256 | #await self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(440, 120), 'left']) | |
257 | #await self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left']) | |
258 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['fullscreen', 'left']) | |
259 | await self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen') | |
361d3942 | 260 | # resolution |
a33967c7 FC |
261 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 340), 'left']) |
262 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['resolutions', 'left']) | |
263 | await self._screenshot(FunctionalTest.screenshot_time, 'resolutions') | |
264 | await self._enforce_resolution(FunctionalTest.evt_time, '1440x900') | |
265 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1000, 440), 'left']) | |
266 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['res_1440x900', 'left']) | |
267 | await self._screenshot(FunctionalTest.screenshot_time, '1440x900') | |
268 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 400), 'left']) | |
269 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['resolutions', 'left']) | |
270 | await self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2') | |
271 | await self._enforce_resolution(FunctionalTest.evt_time, '1360x768') | |
272 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1110, 80), 'left']) | |
273 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['res_1360x768', 'left']) | |
274 | await self._screenshot(FunctionalTest.screenshot_time, '1360x768') | |
361d3942 | 275 | # antialiasing |
a33967c7 FC |
276 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 440), 'left']) |
277 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['aa', 'left']) | |
278 | await self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_yes') | |
361d3942 | 279 | # shadows |
a33967c7 FC |
280 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 540), 'left']) |
281 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['shadows', 'left']) | |
282 | await self._screenshot(FunctionalTest.screenshot_time, 'shadows_yes') | |
283 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back | |
284 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left']) | |
361d3942 | 285 | |
a33967c7 FC |
286 | async def _do_screenshots_play(self): |
287 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play | |
288 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left']) | |
289 | await self._screenshot(FunctionalTest.screenshot_time, 'play_menu') | |
290 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 680), 'left']) # back | |
291 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['back', 'left']) | |
292 | await self._screenshot(FunctionalTest.screenshot_time, 'back_from_play') | |
293 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play | |
294 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left']) | |
295 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino scene | |
296 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left']) | |
297 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_instructions') | |
298 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions | |
299 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
300 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_domino') | |
301 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(25, 740), 'left']) # home | |
302 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['home', 'left']) | |
303 | await self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_scene') | |
304 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play | |
305 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left']) | |
306 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino | |
307 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left']) | |
308 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions | |
309 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
310 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(70, 740), 'left']) # info | |
311 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['information', 'left']) | |
312 | await self._screenshot(FunctionalTest.screenshot_time, 'info') | |
313 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions | |
314 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
315 | # await self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (430, 280), 'left']) # drag a piece | |
316 | # await self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged') | |
317 | # await self._event(FunctionalTest.evt_time, 'mouseclick', [(1220, 740), 'left']) # rewind | |
318 | # await self._screenshot(FunctionalTest.screenshot_time, 'rewind') | |
319 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left']) # drag a piece | |
320 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a piece | |
321 | # await self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left']) # drag a piece | |
322 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
323 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play | |
324 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino') | |
325 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(630, 450), 'left']) # home | |
326 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['home_win', 'left']) # home | |
327 | await self._screenshot(FunctionalTest.screenshot_time, 'home_back_from_fail') | |
328 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 140), 'left']) # play | |
329 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['play', 'left']) # play | |
330 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(230, 160), 'left']) # domino | |
331 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['domino', 'left']) | |
332 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions | |
333 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
334 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left']) # drag a piece | |
335 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a piece | |
336 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left']) # drag a piece | |
337 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left']) # drag a piece .49 .06 | |
338 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
339 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play | |
340 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_2') | |
341 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay | |
342 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) # play | |
343 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (570, 380), 'left']) # drag a piece -1.54 .06 | |
344 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_2', 'left']) # drag a piece -1.54 .06 | |
345 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(570, 355), (605, 355), 'right']) # rotate the piece -1.05 .4 | |
346 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_3', 'right']) # rotate the piece -1.54 .4 -1.05 .4 | |
347 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left']) # drag a piece | |
348 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a piece | |
349 | await self._enforce_res(FunctionalTest.evt_time, 'win') | |
350 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
351 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) # play | |
352 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino') | |
353 | await self._enforce_res(FunctionalTest.evt_time, '') | |
354 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next | |
355 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) # play | |
356 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_box') | |
361d3942 | 357 | # scene 2 |
a33967c7 FC |
358 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(880, 490), 'left']) # close instructions |
359 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
360 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left']) # drag a box .42 -3.29 | |
361 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box .42 -3.29 | |
362 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left']) # drag a box .42 -2.18 | |
363 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left']) # drag a box .42 -2.18 | |
364 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
365 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
366 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box') | |
367 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay | |
368 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) | |
369 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 620), 'left']) # drag a box | |
370 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box | |
371 | # await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (710, 540), 'left']) # drag a box | |
372 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left']) # drag a box | |
373 | # await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (705, 460), 'left']) # drag a box .35 -1.06 | |
374 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_2', 'left']) # drag a box .35 -1.06 | |
375 | await self._enforce_res(FunctionalTest.evt_time, 'win') | |
376 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
377 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
378 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box') | |
379 | await self._enforce_res(FunctionalTest.evt_time, '') | |
380 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next | |
381 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) | |
382 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_box_domino') | |
361d3942 | 383 | # scene 3 |
a33967c7 FC |
384 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left']) # close instructions |
385 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
386 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left']) # drag a box 3.21 -.78 | |
387 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box 3.21 -.78 | |
388 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 360), 'left']) # drag a box 3.21 .33 | |
389 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left']) # drag a box 3.21 .33 | |
390 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
391 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
392 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_box_domino') | |
393 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay | |
394 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) | |
395 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (910, 440), 'left']) # drag a box | |
396 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box | |
397 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (835, 250), 'left']) # drag a box 2.16 1.87 | |
398 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_2', 'left']) # drag a box 2.16 1.87 | |
399 | await self._enforce_res(FunctionalTest.evt_time, 'win') | |
400 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
401 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
402 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box_domino') | |
403 | await self._enforce_res(FunctionalTest.evt_time, '') | |
404 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next | |
405 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) | |
406 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_basketball') | |
361d3942 | 407 | # scene 4 |
a33967c7 FC |
408 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 490), 'left']) # close instructions |
409 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
410 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (650, 310), 'left']) # drag a ball -.42 1.03 | |
411 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a ball -.42 1.03 | |
412 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
413 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
414 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_basketball') | |
415 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay | |
416 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) | |
417 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(55, 50), (380, 50), 'left']) # drag a ball -4.19 4.66 | |
418 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left']) # drag a ball -4.19 4.66 | |
419 | await self._enforce_res(FunctionalTest.evt_time, 'win') | |
420 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
421 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
422 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'win_basketball') | |
423 | await self._enforce_res(FunctionalTest.evt_time, '') | |
424 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next | |
425 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) | |
426 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_box_basketball') | |
361d3942 | 427 | # scene 5 |
a33967c7 FC |
428 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(865, 490), 'left']) # close instructions |
429 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
430 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left']) # drag a box -1.4 -.78 | |
431 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box -1.4 -.78 | |
432 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (590, 370), 'left']) # drag a piece -1.26 .2 | |
433 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_1', 'left']) # drag a piece -1.26 .2 | |
434 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
435 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
436 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_domino_box_basketball') | |
437 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay | |
438 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) | |
439 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(65, 60), (580, 440), 'left']) # drag a box | |
440 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box | |
441 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(30, 60), (660, 440), 'left']) # drag a piece -.28 -.78 | |
442 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_2', 'left']) # drag a piece -.28 -.78 | |
443 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 425), (625, 425), 'right']) # rotate a piece -.28 -.57 -.77 -.57 | |
444 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_2', 'drag_stop_3', 'right']) # rotate a piece -.28 -.57 -.77 -.57 | |
445 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(660, 435), (650, 445), 'left']) # drag a piece -.28 -.85 -.42 -.85 | |
446 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_3', 'drag_stop_4', 'left']) # drag a piece -.28 -.85 -.42 -.85 | |
447 | await self._enforce_res(FunctionalTest.evt_time, 'win') | |
448 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
449 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
450 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino_box_basketball') | |
451 | await self._enforce_res(FunctionalTest.evt_time, '') | |
452 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next | |
453 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) | |
454 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_tooter') | |
39a6176f | 455 | # scene 6 |
a33967c7 FC |
456 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(870, 485), 'left']) # close instructions |
457 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
458 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 300), 'left']) # drag a box -2.65 1.18 | |
459 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box -2.65 1.18 | |
460 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
461 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
462 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_tooter') | |
463 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay | |
464 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) | |
465 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (490, 150), 'left']) # drag a box -2.65 3.27 | |
466 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left']) # drag a box -2.65 3.27 | |
467 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(515, 115), (515, 122), 'right']) # rotate a box -2.3 3.75 -2.5 3.66 | |
468 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_2', 'right']) # rotate a box -2.3 3.75 -2.5 3.66 | |
469 | await self._enforce_res(FunctionalTest.evt_time, 'win') | |
470 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
471 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
472 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_tooter') | |
473 | await self._enforce_res(FunctionalTest.evt_time, '') | |
474 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(735, 450), 'left']) # next | |
475 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['next', 'left']) | |
476 | await self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_domino_box_basketball') | |
39a6176f | 477 | # scene 7 |
a33967c7 FC |
478 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(930, 485), 'left']) # close instructions |
479 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['close_instructions', 'left']) | |
480 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (155, 180), 'left']) # drag a box -7.33 4.24 | |
481 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_0', 'left']) # drag a box -7.33 4.24 | |
482 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
483 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
484 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_teeter_domino_box_basketball') | |
485 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 450), 'left']) # replay | |
486 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['replay', 'left']) | |
487 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(60, 60), (170, 80), 'left']) # drag a box -7.12 4.24 | |
488 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_0', 'drag_stop_1', 'left']) # drag a box -7.12 4.24 | |
489 | #await self._event(FunctionalTest.drag_time, 'mousedrag', [(195, 50), (195, 80), 'right']) # rotate a box -6.77 4.66 -6.77 4.24 | |
490 | await self._event(FunctionalTest.drag_time, 'mousedrag', ['drag_start_1', 'drag_stop_2', 'right']) # rotate a box -6.77 4.66 -6.77 4.24 | |
491 | await self._enforce_res(FunctionalTest.evt_time, 'win') | |
492 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play | |
493 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['right', 'left']) | |
494 | await self._screenshot(16 + FunctionalTest.screenshot_time, 'win_teeter_domino_box_basketball') | |
495 | await self._enforce_res(FunctionalTest.evt_time, '') | |
496 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(630, 450), 'left']) # home | |
497 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['home_win', 'left']) | |
498 | await self._screenshot(FunctionalTest.screenshot_time, 'home_from_play') | |
361d3942 | 499 | |
a33967c7 FC |
500 | async def _do_screenshots_exit(self): |
501 | await self._verify(FunctionalTest.evt_time) | |
502 | #await self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 600), 'left']) | |
503 | await self._event(FunctionalTest.evt_time, 'mouseclick', ['exit', 'left']) | |
504 | await self._exit(FunctionalTest.evt_time) | |
361d3942 | 505 | |
a33967c7 | 506 | async def _do_screenshots_2(self): |
361d3942 | 507 | info('_do_screenshots_2') |
a33967c7 FC |
508 | await self._screenshot(FunctionalTest.start_time, 'main_menu_2') |
509 | await self._do_screenshots_restore_options() | |
510 | await self._do_screenshots_play() | |
511 | await self._do_screenshots_exit() | |
361d3942 FC |
512 | |
513 | def _do_screenshots(self, idx): | |
a33967c7 FC |
514 | asyncio.run( |
515 | [self._do_screenshots_1, self._do_screenshots_2][int(idx) - 1]() | |
516 | ) | |
361d3942 FC |
517 | |
518 | ||
519 | class TestApp(ShowBase): | |
520 | ||
521 | def __init__(self): | |
522 | ShowBase.__init__(self) | |
68f6c184 FC |
523 | offset = int(argv[2]) if len(argv) >= 3 else 0 |
524 | fun_test = FunctionalTest(int(argv[1]), offset) | |
361d3942 FC |
525 | |
526 | ||
527 | TestApp().run() |