from os.path import exists
from os import makedirs
from glob import glob
+from logging import debug
from importlib import import_module
from inspect import isclass
from panda3d.core import AmbientLight, DirectionalLight, Point3, Texture, \
self._dbg_items = dbg_items
self._reload_cb = reload_cb
self._scenes = scenes
+ self._enforce_res = ''
+ self.accept('enforce_res', self.enforce_res)
self._set_camera()
self._cursor = MouseCursor(
'assets/images/buttons/arrowUpLeft.dds', (.04, 1, .04), (.5, .5, .5, 1),
del self._success_txt
self.__right_btn['state'] = NORMAL
+ def enforce_res(self, val):
+ self._enforce_res = val
+ debug('enforce res: ' + val)
+
def destroy(self):
+ self.ignore('enforce_res')
self._unset_gui()
self._unset_lights()
self._unset_input()
if self._dbg_items:
self._update_info(items_hit[0] if items_hit else None)
if self._win_condition():
- self._set_win()
+ self._set_fail() if self._enforce_res == 'fail' else self._set_win()
elif self._state == 'playing' and self._fail_condition():
- self._set_fail()
+ self._set_win() if self._enforce_res == 'win' else self._set_fail()
if any(itm._overlapping for itm in self.items):
self._cursor.cursor_img.img.set_color(.9, .1, .1, 1)
else:
'event: %s (hide)' % evt)]
self._curr_time += time
+ def _enforce_res(self, time, res):
+ cback = lambda: messenger.send('enforce_res', [res])
+ self._tasks += [(
+ self._curr_time + time,
+ cback,
+ 'enforce res: %s' % res)]
+ self._curr_time += time
+
def _verify(self):
def __verify():
files = glob(self._path + '*')
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (570, 380), 'left']) # drag a piece
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(570, 355), (605, 355), 'right']) # rotate the piece
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(35, 60), (715, 380), 'left']) # drag a piece
+ self._enforce_res(FunctionalTest.evt_time, 'win')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino')
+ self._enforce_res(FunctionalTest.evt_time, '')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
self._screenshot(FunctionalTest.screenshot_time, 'scene_box')
# scene 2
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (710, 620), 'left']) # drag a box
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (710, 540), 'left']) # drag a box
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (705, 460), 'left']) # drag a box
+ self._enforce_res(FunctionalTest.evt_time, 'win')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box')
+ self._enforce_res(FunctionalTest.evt_time, '')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
self._screenshot(FunctionalTest.screenshot_time, 'scene_box_domino')
# scene 3
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left']) # replay
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (910, 440), 'left']) # drag a box
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(65, 60), (835, 250), 'left']) # drag a box
+ self._enforce_res(FunctionalTest.evt_time, 'win')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
self._screenshot(16 + FunctionalTest.screenshot_time, 'win_box_domino')
+ self._enforce_res(FunctionalTest.evt_time, '')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
self._screenshot(FunctionalTest.screenshot_time, 'scene_basketball')
# scene 4
self._screenshot(16 + FunctionalTest.screenshot_time, 'fail_basketball')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(680, 450), 'left']) # replay
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(55, 50), (380, 50), 'left']) # drag a ball
+ self._enforce_res(FunctionalTest.evt_time, 'win')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
self._screenshot(16 + FunctionalTest.screenshot_time, 'win_basketball')
+ self._enforce_res(FunctionalTest.evt_time, '')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
self._screenshot(FunctionalTest.screenshot_time, 'scene_domino_box_basketball')
# scene 5
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(30, 60), (660, 440), 'left']) # drag a piece
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(660, 425), (625, 425), 'right']) # rotate a piece
self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(660, 435), (650, 445), 'left']) # drag a piece
+ self._enforce_res(FunctionalTest.evt_time, 'win')
self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(1340, 740), 'left']) # play
self._screenshot(16 + FunctionalTest.screenshot_time, 'win_domino_box_basketball')
+ self._enforce_res(FunctionalTest.evt_time, '')
# self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(735, 450), 'left']) # next
# self._screenshot(FunctionalTest.screenshot_time, 'scene_teeter_tooter')
# # scene 6
'timeout 720s ./dist/Pmachines%s-x86_64.AppImage --functional-test 2' % (bld_branch, bld_branch),
str(Path.home()) + '/.local/share/pmachines/tests/functional/')
- # def test_flatpak(self):
- # info('test_flatpak')
- # if environ.get('FUNCTIONALPOST') != '1':
- # self.skipTest('skipped functional-post tests')
- # bld_branch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[_branch()]
- # cmd = 'flatpak update -y it.ya2.Pmachines//%s' % bld_branch
- # info('executing: %s' % cmd)
- # system(cmd)
- # info('executed: %s' % cmd)
- # self.__test_template(
- # 'timeout 720s flatpak run it.ya2.Pmachines//%s --functional-test 1 ;'
- # 'timeout 720s flatpak run it.ya2.Pmachines//%s --functional-test 2' % (bld_branch, bld_branch),
- # str(Path.home()) + '/.var/app/it.ya2.Pmachines/data/pmachines/tests/functional/')
+ def test_flatpak(self):
+ info('test_flatpak')
+ if environ.get('FUNCTIONALPOST') != '1':
+ self.skipTest('skipped functional-post tests')
+ bld_branch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[_branch()]
+ cmd = 'flatpak update -y it.ya2.Pmachines//%s' % bld_branch
+ info('executing: %s' % cmd)
+ system(cmd)
+ info('executed: %s' % cmd)
+ self.__test_template(
+ 'timeout 720s flatpak run it.ya2.Pmachines//%s --functional-test 1 ;'
+ 'timeout 720s flatpak run it.ya2.Pmachines//%s --functional-test 2' % (bld_branch, bld_branch),
+ str(Path.home()) + '/.var/app/it.ya2.Pmachines/data/pmachines/tests/functional/')
# def __update_itchio(self):
# system('/home/flavio/.itch/itch')