'''Create ref:
* M-x fla-set-fun-test
* rm options.ini
-* python main.py --functional-test 1 --functional-ref
-* python main.py --functional-test 2 --functional-ref
+* python main.py --functional-test --functional-ref & python -m lib.tools.functional_test.py 1
+* python main.py --functional-test --functional-ref & python -m lib.tools.functional_test.py 2
* M-x fla-unset-fun-test'''
from panda3d.core import load_prc_file_data
load_prc_file_data('', 'window-type none')
drag_time = 1.0
start_time = 2
- def __init__(self, idx):
+ def __init__(self, idx, offset):
super().__init__()
info('test idx: %s' % idx)
+ self._offset = offset
sleep(5)
address = ('localhost', 6000)
self._conn = Client(address)
self._tasks = []
self._prev_time = 0
taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable')
+ self._conn.send(['set_idx', idx])
self._do_screenshots(idx)
def _do_screenshot(self, name):
self._curr_time += time
def __mouse_click(self, pos, btn):
- offset_x = int((1920 - 1360) / 2) + 1 # xfce decorations
- offset_y = int((1080 - 768) / 2) + 24 # xfce decorations
+ offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations
+ offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations
btn = 3 if btn == 'right' else 1
system('xdotool mousemove %s %s' % (offset_x + pos[0], offset_y + pos[1]))
def click(task):
system('xdotool click %s' % btn)
- taskMgr.do_method_later(.01, click, 'click')
+ taskMgr.do_method_later(.28, click, 'click')
def __mouse_drag(self, start, end, btn):
- offset_x = int((1920 - 1360) / 2) + 1 # xfce decorations
- offset_y = int((1080 - 768) / 2) + 24 # xfce decorations
+ offset_x = int((1920 - 1360) / 2) #+ 1 # xfce decorations
+ offset_y = int((1080 - 768) / 2) #+ 24 + self._offset # xfce decorations
btn = 3 if btn == 'right' else 1
system('xdotool mousemove %s %s' % (offset_x + start[0], offset_y + start[1]))
def mousedown(task):
'enforce res: %s' % res)]
self._curr_time += time
+ def _enforce_resolution(self, time, res):
+ def cback():
+ self._conn.send(['enforce_resolution', res])
+ info('enforce_resolution %s (send)' % res)
+ self._tasks += [(
+ self._curr_time + time,
+ cback,
+ 'enforce resolution: %s' % res)]
+ self._curr_time += time
+
def _verify(self):
def __verify():
self._conn.send(['verify'])
self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2')
# fullscreen
# the first one is because of the windowed mode in test
- # self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
- # self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
- # self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
- # self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
- # self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
- # self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen')
+ self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
+ self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
+ self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
+ self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
+ #self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(440, 120), 'left'])
+ self._event(8 + FunctionalTest.evt_time, 'mouseclick', [(680, 250), 'left'])
+ self._screenshot(8 + FunctionalTest.screenshot_time, 'back_from_fullscreen')
# resolution
- # self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 340), 'left'])
- # self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
- # self._event(FunctionalTest.evt_time, 'mouseclick', [(1020, 160), 'left'])
- # self._screenshot(FunctionalTest.screenshot_time, '1440x900')
- # self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 400), 'left'])
- # self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
- # self._event(FunctionalTest.evt_time, 'mouseclick', [(1110, 80), 'left'])
- # self._screenshot(FunctionalTest.screenshot_time, '1360x768')
+ self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 340), 'left'])
+ self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
+ self._enforce_resolution(FunctionalTest.evt_time, '1440x900')
+ self._event(FunctionalTest.evt_time, 'mouseclick', [(1000, 440), 'left'])
+ self._screenshot(FunctionalTest.screenshot_time, '1440x900')
+ self._event(FunctionalTest.evt_time, 'mouseclick', [(740, 400), 'left'])
+ self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
+ self._enforce_resolution(FunctionalTest.evt_time, '1360x768')
+ self._event(FunctionalTest.evt_time, 'mouseclick', [(1110, 80), 'left'])
+ self._screenshot(FunctionalTest.screenshot_time, '1360x768')
# antialiasing
self._event(FunctionalTest.evt_time, 'mouseclick', [(680, 440), 'left'])
self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_yes')
self._event(FunctionalTest.evt_time, 'mouseclick', [(70, 740), 'left']) # info
self._screenshot(FunctionalTest.screenshot_time, 'info')
self._event(FunctionalTest.evt_time, 'mouseclick', [(850, 490), 'left']) # close instructions
- self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (430, 280), 'left']) # drag a piece
- self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged')
- self._event(FunctionalTest.evt_time, 'mouseclick', [(1220, 740), 'left']) # rewind
- self._screenshot(FunctionalTest.screenshot_time, 'rewind')
+ # self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (430, 280), 'left']) # drag a piece
+ # self._screenshot(FunctionalTest.screenshot_time, 'domino_dragged')
+ # self._event(FunctionalTest.evt_time, 'mouseclick', [(1220, 740), 'left']) # rewind
+ # self._screenshot(FunctionalTest.screenshot_time, 'rewind')
self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (550, 380), 'left']) # drag a piece
# self._event(FunctionalTest.drag_time, 'mousedrag', [(35, 60), (715, 380), 'left']) # drag a piece
self._event(FunctionalTest.evt_time, 'mouseclick', [(1340, 740), 'left']) # play
def __init__(self):
ShowBase.__init__(self)
- fun_test = FunctionalTest(int(argv[1]))
+ offset = int(argv[2]) if len(argv) >= 3 else 0
+ fun_test = FunctionalTest(int(argv[1]), offset)
TestApp().run()