ya2 · news · projects · code · about

functional tests: credits
authorFlavio Calva <f.calva@gmail.com>
Mon, 21 Mar 2022 18:55:05 +0000 (19:55 +0100)
committerFlavio Calva <f.calva@gmail.com>
Mon, 21 Mar 2022 18:55:05 +0000 (19:55 +0100)
game/app.py
lib/engine/functional.py
prj.org
tests/test_functional.py

index 1437e0cc279acbbf6eeb4ed8ec7e6c827f740bdf..f3fa8737343941d2858d9690432a2c35b0cf2ad5 100755 (executable)
@@ -27,6 +27,7 @@ from game.scenes.scene_teeter_tooter import SceneTeeterTooter
 from lib.dictfile import DctFile
 from lib.lib.p3d.p3d import LibP3d
 from lib.engine.lang import LangMgr
+from lib.engine.functional import FunctionalTest
 
 
 class MainFsm(FSM):
@@ -70,6 +71,8 @@ class PmachinesApp:
         self.version = args.version
         if args.update:
             return
+        if args.functional_test and int(args.functional_test) == 1:
+            self._options['settings']['volume'] = 0
         self._music = MusicMgr(self._options['settings']['volume'])
         self.lang_mgr = LangMgr(self._options['settings']['language'],
                                 'pmachines',
@@ -90,6 +93,8 @@ class PmachinesApp:
             self._fsm.demand('Scene', cls)
         else:
             self._fsm.demand('Menu')
+        if args.functional_test or args.functional_ref:
+            FunctionalTest(args.functional_test, args.functional_ref)
 
     def on_menu_enter(self):
         self._menu_bg = Background()
@@ -136,6 +141,8 @@ class PmachinesApp:
         parser.add_argument('--version', action='store_true')
         parser.add_argument('--optfile')
         parser.add_argument('--screenshot')
+        parser.add_argument('--functional-test')
+        parser.add_argument('--functional-ref', action='store_true')
         cmd_line = [arg for arg in iter(argv[1:]) if not arg.startswith('-psn_')]
         args = parser.parse_args(cmd_line)
         return args
@@ -190,9 +197,13 @@ class PmachinesApp:
             resolutions = [
                 _res(idx) for idx in range(d_i.get_total_display_modes())]
             res = sorted(resolutions)[-1]
+        fullscreen = self._options['settings']['fullscreen']
+        if args.functional_test or args.functional_ref:
+            res = 1280, 720
+            fullscreen = False
         props = WindowProperties()
         props.set_size(res)
-        props.set_fullscreen(self._options['settings']['fullscreen'])
+        props.set_fullscreen(fullscreen)
         props.set_icon_filename('assets/images/icon/pmachines.ico')
         if not args.screenshot:
             base.win.request_properties(props)
index 3492f4112025231ed6fd3614840c3bd09438b9d9..8c1f01916d8a82a181cd48146c8eb33be60014ce 100644 (file)
@@ -4,6 +4,8 @@
 * python main.py --functional-test 1 --functional-ref
 * python main.py --functional-test 2 --functional-ref
 * M-x fla-unset-fun-test'''
+import datetime
+from os import getcwd, system
 from logging import debug, info
 from pathlib import Path
 from shutil import rmtree
@@ -29,7 +31,7 @@ class FunctionalTest(GameObject):
         #self._path = ''
         #if self.eng.is_appimage:
         self._path = str(Filename().get_user_appdata_directory())
-        self._path += '/yocto_racer/'
+        self._path += '/pmachines/'
         self._path += 'tests/functional%s/' % ('_ref' if ref else '')
         home = '/home/flavio'  # we must force this for wine
         # if self._path.startswith('/c/users/') and exists(str(Path.home()) + '/.local/share/flatpak-wine601/default/'):
@@ -39,7 +41,7 @@ class FunctionalTest(GameObject):
         if ref:
             self._path = join(
                 Filename().get_user_appdata_directory(),
-                'yocto_racer/tests/functional_ref_%s/' % _branch())
+                'pmachines/tests/functional_ref_%s/' % _branch())
         self._curr_time = 0
         if int(idx) == 1:
             rmtree(self._path, ignore_errors=True)
@@ -48,14 +50,22 @@ class FunctionalTest(GameObject):
         self._fnames = []
         self._tasks = []
         self._prev_time = 0
-        self.eng.attach_obs(self.on_frame_unpausable)
+        #self.eng.attach_obs(self.on_frame_unpausable)
+        taskMgr.add(self.on_frame_unpausable, 'on-frame-unpausable')
         self._do_screenshots(idx)
 
+    def _do_screenshot(self, path=None):
+        time = datetime.datetime.now().strftime('%y%m%d%H%M%S')
+        #res = base.win.save_screenshot(Filename(path or ("yocto%s.png" % time)))
+        #debug('screenshot %s (%s)' % (path or ("yocto%s.png" % time), res))
+        res = base.screenshot(path or ("pmachines%s.png" % time), False)
+        info('screenshot %s (%s; %s)' % (path or ("pmachines%s.png" % time), res, getcwd()))
+
     def _screenshot(self, time, name):
         self._fnames += [self._path + name + '.png']
         self._tasks += [(
             self._curr_time + time,
-            lambda: self.eng.gfx.gfx_mgr.screenshot(self._path + name + '.png'),
+            lambda: self._do_screenshot(self._path + name + '.png'),
             'screenshot: %s' % name)]
         def txt(show_hide):
             self.txt['text'] = name
@@ -81,7 +91,26 @@ class FunctionalTest(GameObject):
         dev = base.win.getInputDevice(0)
         dev.keystroke(ord(char))
 
-    def _event(self, time, evt, messenger_evt=False, append_up=True):
+    def __mouse_click(self, pos, btn):
+        center = base.pipe.get_display_width() / 2, base.pipe.get_display_height() / 2
+        tgt = pos[0] + center[0], pos[1] + center[1]
+        btn = 3 if btn == 'right' else 1
+        system('xdotool mousemove %s %s click %s' % (tgt[0], tgt[1], btn))
+
+    def __mouse_move(self, pos):
+        center = base.pipe.get_display_width() / 2, base.pipe.get_display_height() / 2
+        tgt = pos[0] + center[0], pos[1] + center[1]
+        system('xdotool mousemove %s %s' % tgt)
+
+    def __mouse_drag(self, start, end, btn):
+        center = base.pipe.get_display_width() / 2, base.pipe.get_display_height() / 2
+        start = start[0] + center[0], start[1] + center[1]
+        end = end[0] + center[0], end[1] + center[1]
+        btn = 3 if btn == 'right' else 1
+        system('xdotool mousemove %s %s mousedown %s mousemove %s %s mouseup %s' % (
+            start[0], start[1], btn, end[0], end[1], btn))
+
+    def _event(self, time, evt, messenger_evt=False, append_up=True, mouse_args=None):
         def _append_up(evt_name):
             return evt + ('' if evt.endswith('-up') or not append_up else '-up')
         def cback_char(_evt):
@@ -90,6 +119,13 @@ class FunctionalTest(GameObject):
             self.__keypress(_evt)
             self.__keypress('raw-' + _evt)
         cback = lambda: (cback_char(evt) if len(evt) == 1 else cback_keyp(evt))
+        if evt in ['mousemove', 'mouseclick', 'mousedrag']:
+            if evt == 'mousemove':
+                cback = lambda: self.__mouse_move(*mouse_args)
+            elif evt == 'mouseclick':
+                cback = lambda: self.__mouse_click(*mouse_args)
+            elif evt == 'mousedrag':
+                cback = lambda: self.__mouse_drag(*mouse_args)
         if messenger_evt:
             cback = lambda: messenger.send(_append_up(evt))
         self._tasks += [(
@@ -127,277 +163,285 @@ class FunctionalTest(GameObject):
             lambda: exit(),
             'exit')]
 
-    def on_frame_unpausable(self):
+    def on_frame_unpausable(self, task):
         for tsk in self._tasks:
-            if self._prev_time <= tsk[0] < self.eng.event.unpaused_time:
+            #if self._prev_time <= tsk[0] < self.eng.event.unpaused_time:
+            if self._prev_time <= tsk[0] < globalClock.getFrameTime():
                 debug('%s %s' % (tsk[0], tsk[2]))
                 tsk[1]()
-        self._prev_time = self.eng.event.unpaused_time
+        self._prev_time = globalClock.getFrameTime()  # self.eng.event.unpaused_time
+        return task.cont
 
     def _do_screenshots_1(self):
         info('_do_screenshots_1')
         self._screenshot(FunctionalTest.start_time, 'main_menu')
         self._do_screenshots_credits()
-        self._do_screenshots_options()
+        self._do_screenshots_options()
         self._do_screenshots_exit()
 
     def _do_screenshots_credits(self):
-        # go to credits
-        self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._screenshot(FunctionalTest.screenshot_time, 'main_menu_highlight')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, 50), 'left'])
         self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
-        # go to supporters
-        self._event(FunctionalTest.evt_time, 'joypad0-face_a', True)
-        self._screenshot(FunctionalTest.screenshot_time, 'supporters_menu')
-        # back to main
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'joypad0-face_b', True)
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, 280), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'main_menu_back_from_credits')
+        # # go to credits
+        # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
+        # self._event(FunctionalTest.evt_time, 'arrow_down')
+        # self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
+        # self._event(FunctionalTest.evt_time, 'arrow_down')
+        # self._screenshot(FunctionalTest.screenshot_time, 'main_menu_highlight')
+        # self._event(FunctionalTest.evt_time, 'rcontrol')
+        # self._screenshot(FunctionalTest.screenshot_time, 'credits_menu')
+        # # go to supporters
+        # self._event(FunctionalTest.evt_time, 'joypad0-face_a', True)
+        # self._screenshot(FunctionalTest.screenshot_time, 'supporters_menu')
+        # # back to main
+        # self._event(FunctionalTest.evt_time, 'rcontrol')
+        # self._event(FunctionalTest.evt_time, 'joypad0-face_b', True)
+        # self._event(FunctionalTest.evt_time, 'arrow_up')
+        # self._event(FunctionalTest.evt_time, 'arrow_up')
+        # self._event(FunctionalTest.evt_time, 'arrow_up')
+        # self._event(FunctionalTest.evt_time, 'arrow_up')
 
-    def _do_screenshots_options(self):
-        # go to options
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
-        # language
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'language_open')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._screenshot(FunctionalTest.screenshot_time, 'language_highlight')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'language_it')
-        # volume
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_right')
-        self._event(FunctionalTest.evt_time, 'arrow_right')
-        self._screenshot(FunctionalTest.screenshot_time, 'volume')
-        # car's number
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'cars_open')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'cars_changed')
-        # back
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
+    def _do_screenshots_options(self):
+        # go to options
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'options_menu')
+        # language
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'language_open')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._screenshot(FunctionalTest.screenshot_time, 'language_highlight')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'language_it')
+        # volume
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_right')
+        self._event(FunctionalTest.evt_time, 'arrow_right')
+        self._screenshot(FunctionalTest.screenshot_time, 'volume')
+        # car's number
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'cars_open')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'cars_changed')
+        # back
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_up')
+        self._event(FunctionalTest.evt_time, 'arrow_up')
 
     def _do_screenshots_exit(self):
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
         self._verify()
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._exit()
+        # self._event(FunctionalTest.evt_time, 'rcontrol')
+        # self._exit()
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, 200), 'left'])
+
 
     def _do_screenshots_2(self):
         info('_do_screenshots_2')
-        self._do_screenshots_restore_options()
-        self._do_screenshots_game()
-        self._do_screenshots_end()
+        self._do_screenshots_restore_options()
+        self._do_screenshots_game()
+        self._do_screenshots_end()
 
-    def _do_screenshots_restore_options(self):
-        # go to options
-        self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
-        # # language
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'language_en_restored')
-        # # volume
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_left')
-        self._event(FunctionalTest.evt_time, 'arrow_left')
-        self._screenshot(FunctionalTest.screenshot_time, 'volume_restored')
-        # car's number
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'cars_restored')
-        # graphics settings
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'graphics_settings')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'antialiasing')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'shadows')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'fog')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'normal_mapping')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'occlusion')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        # input
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'input')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_rec')
-        self._event(FunctionalTest.evt_time, '8', True, False)
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_changed')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_up', True, False)
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_restored')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'w', True, False)
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already_closed')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p2')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p3')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p4')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
+    def _do_screenshots_restore_options(self):
+        # go to options
+        self._event(FunctionalTest.evt_time, 'joypad0-dpad_down', True)
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'options_menu_restored')
+        # # language
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_up')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'language_en_restored')
+        # # volume
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_left')
+        self._event(FunctionalTest.evt_time, 'arrow_left')
+        self._screenshot(FunctionalTest.screenshot_time, 'volume_restored')
+        # car's number
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'cars_restored')
+        # graphics settings
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'graphics_settings')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'antialiasing')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'shadows')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'fog')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'normal_mapping')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'occlusion')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        # input
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'input')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_rec')
+        self._event(FunctionalTest.evt_time, '8', True, False)
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_changed')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_up', True, False)
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_restored')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'w', True, False)
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p1_already_closed')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p2')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p3')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'keyboard_p4')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_up')
+        self._event(FunctionalTest.evt_time, 'arrow_up')
 
-    def _do_screenshots_game(self):
-        # single player
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'single_player_menu')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'track_page')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'car_page_start')
-        self._event(FunctionalTest.evt_time, 'arrow_left')
-        self._screenshot(FunctionalTest.screenshot_time, 'car_page_sel')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_start')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_left')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_left')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(FunctionalTest.evt_time, 'arrow_up')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._event(FunctionalTest.evt_time, 'backspace')
-        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_empty')
-        self._event(FunctionalTest.evt_time, 'f')
-        self._event(FunctionalTest.evt_time, 'l')
-        self._event(FunctionalTest.evt_time, 'a')
-        self._event(FunctionalTest.evt_time, 'v')
-        self._event(FunctionalTest.evt_time, 'i')
-        self._event(FunctionalTest.evt_time, 'o')
-        self._event(FunctionalTest.evt_time, 'enter')
-        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_full')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_right')
-        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_sel')
-        # some ai tests
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._event(40, 'escape-up')
-        self._screenshot(FunctionalTest.screenshot_time, 'ingame_menu')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'race_back')
-        self._event(FunctionalTest.evt_time, 'escape-up')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._screenshot(FunctionalTest.screenshot_time, 'ingame_sel')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'main_page_back_race')
+    def _do_screenshots_game(self):
+        # single player
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'single_player_menu')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'track_page')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'car_page_start')
+        self._event(FunctionalTest.evt_time, 'arrow_left')
+        self._screenshot(FunctionalTest.screenshot_time, 'car_page_sel')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_start')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_up')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_left')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_left')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(FunctionalTest.evt_time, 'arrow_up')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._event(FunctionalTest.evt_time, 'backspace')
+        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_empty')
+        self._event(FunctionalTest.evt_time, 'f')
+        self._event(FunctionalTest.evt_time, 'l')
+        self._event(FunctionalTest.evt_time, 'a')
+        self._event(FunctionalTest.evt_time, 'v')
+        self._event(FunctionalTest.evt_time, 'i')
+        self._event(FunctionalTest.evt_time, 'o')
+        self._event(FunctionalTest.evt_time, 'enter')
+        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_entry_full')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_right')
+        self._screenshot(FunctionalTest.screenshot_time, 'driver_page_sel')
+        # some ai tests
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._event(40, 'escape-up')
+        self._screenshot(FunctionalTest.screenshot_time, 'ingame_menu')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'race_back')
+        self._event(FunctionalTest.evt_time, 'escape-up')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._screenshot(FunctionalTest.screenshot_time, 'ingame_sel')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'main_page_back_race')
 
-    def _do_screenshots_end(self):
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._screenshot(FunctionalTest.screenshot_time, 'exit_page')
-        self._event(FunctionalTest.evt_time, 'arrow_down')
-        self._screenshot(FunctionalTest.screenshot_time, 'exit_page_sel')
-        self._verify()
-        self._event(FunctionalTest.evt_time, 'rcontrol')
-        self._exit()
+    def _do_screenshots_end(self):
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._screenshot(FunctionalTest.screenshot_time, 'exit_page')
+        self._event(FunctionalTest.evt_time, 'arrow_down')
+        self._screenshot(FunctionalTest.screenshot_time, 'exit_page_sel')
+        self._verify()
+        self._event(FunctionalTest.evt_time, 'rcontrol')
+        self._exit()
 
     def _do_screenshots(self, idx):
         [self._do_screenshots_1, self._do_screenshots_2][int(idx) - 1]()
diff --git a/prj.org b/prj.org
index 00bc21219be6acd432fc234204ecf328947be749..03b8cf01fa66af9772ad2366b7224005398f20c2 100644 (file)
--- a/prj.org
+++ b/prj.org
@@ -2,14 +2,23 @@
 * todo
 ** refactoring
 ** build pipeline
-*** functional tests (evaluate floating window)
+*** functional tests
+    - [X] credits
+    - [ ] options
+    - [ ] play
+    - [ ] code
+    - [ ] appimage
+    - [ ] flatpak
+    - [ ] windows
+    - [ ] itchio
+    - [ ] versions
 *** management of error and success (upload builds, itch.io)
 *** crontab
 ** fix level domino box basketball: it can be solved trivially
 *** place a shelf over the domino pieces
 ** version 0.0.yymmdd
 ** do intro video with moviepy
-** android build
+** android build (test with the emulator of android studio)
 ** intro animation (from target item to start position)
 ** buttons of the scenes enabled sequentially
 *** each scene has a version
index bed48937e361dab8bb85974659a68e6157213abf..09742cf4b4592c23b9a70e239890e65d49a4376b 100644 (file)
@@ -19,18 +19,18 @@ class FunctionalTests(TestCase):
     def __clean(self):
         paths = [
             'tests/functional',
-            str(Path.home()) + '/.local/share/yocto_racer/tests/functional/',
-            str(Path.home()) + '/.var/app/it.ya2.YoctoRacer/data/yocto_racer/tests/functional/',
-            str(Path.home()) + '/.wine/drive_c/users/flavio/AppData/Local/yocto_racer/tests/functional/']
+            str(Path.home()) + '/.local/share/pmachines/tests/functional/',
+            str(Path.home()) + '/.var/app/it.ya2.Pmachines/data/pmachines/tests/functional/',
+            str(Path.home()) + '/.wine/drive_c/users/flavio/AppData/Local/pmachines/tests/functional/']
         for path in paths:
             rmtree(path, ignore_errors=True)
         dirs = [
             Filename().get_user_appdata_directory(),
-            '/home/flavio/.var/app/it.ya2.YoctoRacer/data',
+            '/home/flavio/.var/app/it.ya2.Pmachines/data',
             '/home/flavio/.wine/drive_c/users/flavio/AppData']
         files = [
-            'yocto_racer/options.ini',
-            'yocto_racer/obs_version.txt']
+            'pmachines/options.ini',
+            'pmachines/obs_version.txt']
         for dir_file in product(dirs, files):
             _file = join(*dir_file)
             if exists(_file):
@@ -38,7 +38,7 @@ class FunctionalTests(TestCase):
                 info('%s removed' % _file)
             else:
                 info('%s does not exist' % _file)
-        system('pkill -f "yocto.exe"')
+        system('pkill -f "pmachines.exe"')
 
     def __awake(self):
         system('xdotool key shift')
@@ -50,7 +50,8 @@ class FunctionalTests(TestCase):
         self.__clean()
 
     def test_ref(self):
-        path = 'yocto_racer/tests/functional_ref_%s/*.png' % _branch()
+        info('test_ref')
+        path = 'pmachines/tests/functional_ref_%s/*.png' % _branch()
         files = glob(join(Filename().get_user_appdata_directory(), path))
         self.assertGreater(len(files), 1)
 
@@ -76,97 +77,97 @@ class FunctionalTests(TestCase):
                 self.__similar_images(
                     fname, path + basename(fname)))
 
-    def test_code(self):
-        info('test_code')
-        self.__test_template(
-            '~/venv/bin/python main.py --functional-test 1 ; '
-            '~/venv/bin/python main.py --functional-test 2',
-            str(Path.home()) + '/.local/share/yocto_racer/tests/functional/')
-
-    def test_appimage(self):
-        info('test_appimage')
-        bld_branch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[_branch()]
-        bld_branch = '' if bld_branch == 'stable' else ('-' + bld_branch)
-        self.__test_template(
-            './dist/Yocto%s-x86_64.AppImage --functional-test 1 ;'
-            './dist/Yocto%s-x86_64.AppImage --functional-test 2' % (bld_branch, bld_branch),
-            str(Path.home()) + '/.local/share/yocto_racer/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.YoctoRacer//%s' % bld_branch
-        info('executing: %s' % cmd)
-        system(cmd)
-        info('executed: %s' % cmd)
-        self.__test_template(
-            'flatpak run it.ya2.YoctoRacer//%s --functional-test 1 ;'
-            'flatpak run it.ya2.YoctoRacer//%s --functional-test 2' % (bld_branch, bld_branch),
-            str(Path.home()) + '/.var/app/it.ya2.YoctoRacer/data/yocto_racer/tests/functional/')
-
-    def __update_itchio(self):
-        system('/home/flavio/.itch/itch')
-        sleep(5)
-        system('xdotool mousemove 1280 620')
-        sleep(1)
-        system('xdotool click 1')
-        sleep(300)
-        system('killall itch')
-
-    def test_itchio(self):
-        info('test_itchio')
-        if environ.get('FUNCTIONALPOST') != '1':
-            self.skipTest('skipped functional-post tests')
-        if _branch() != 'master':
-            return
-        self.__update_itchio()
-        self.__test_template(
-            '/home/flavio/.config/itch/apps/yocto-racer/yocto --functional-test 1 ;'
-            '/home/flavio/.config/itch/apps/yocto-racer/yocto --functional-test 2',
-            str(Path.home()) + '/.local/share/yocto_racer/tests/functional/')
-
-    def test_windows(self):
-        info('test_windows')
-        system('pkill -f "yocto.exe"')
-        abspath = str(Path(__file__).parent.parent) + '/build/win_amd64/yocto.exe'
-        self.__test_template(
-            'timeout 720s wine %s --functional-test 1 ; '
-            'timeout 720s wine %s --functional-test 2' % (abspath, abspath),
-            str(Path.home()) + '/.wine/drive_c/users/flavio/AppData/Local/yocto_racer/tests/functional/')
-
-    def test_versions(self):
-        info('test_versions')
-        if environ.get('FUNCTIONAL') != '1':
-            self.skipTest('skipped functional tests')
-        bld_branch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[_branch()]
-        with open('/home/flavio/yocto_builder/last_bld.txt') as f:
-            lines = f.readlines()
-        for line in lines:
-            if line.strip().split()[0] == _branch():
-                commit = line.strip().split()[1][:7]
-        _ver = ver
-        if _branch() == 'stable':
-            with open('/home/flavio/yocto_builder/yocto/assets/version.txt') as fver:
-                _ver = fver.read().strip() + '-'
-        exp = '%s-%s' % (_ver, commit)
-        cmds = [
-            ('./build/manylinux1_x86_64/yocto --version', str(Filename.get_user_appdata_directory()) + '/yocto_racer/obs_version.txt'),
-            ('./dist/Yocto-%s-x86_64.AppImage --version' % bld_branch, str(Filename.get_user_appdata_directory()) + '/yocto_racer/obs_version.txt'),
-            ('timeout 720s wine ./build/win_amd64/yocto.exe --version', '/home/flavio/.wine/drive_c/users/flavio/AppData/Local/yocto_racer/obs_version.txt')
-            ]
-        if environ.get('FUNCTIONALPOST') == '1':
-            if _branch() == 'master':
-                self.__update_itchio()
-                cmds += [('/home/flavio/.config/itch/apps/yocto-racer/yocto --version', str(Filename.get_user_appdata_directory()) + '/yocto_racer/obs_version.txt')]
-            cmds += [('flatpak run it.ya2.YoctoRacer//%s --version' % bld_branch, '/home/flavio/.var/app/it.ya2.YoctoRacer/data/yocto_racer/obs_version.txt')]
-        system('flatpak update -y it.ya2.YoctoRacer//%s' % bld_branch)
-        for cmd in cmds:
-            if exists(cmd[1]):
-                remove(cmd[1])
-            info('launching %s' % cmd[0])
-            exec_cmd(cmd[0])
-            with open(cmd[1]) as f:
-                obs = f.read().strip()
-            self.assertEqual(obs, exp)
+    def test_code(self):
+        info('test_code')
+        self.__test_template(
+            '~/venv/bin/python main.py --functional-test 1 ; '
+            '~/venv/bin/python main.py --functional-test 2',
+    #         str(Path.home()) + '/.local/share/pmachines/tests/functional/')
+
+    def test_appimage(self):
+        info('test_appimage')
+        bld_branch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[_branch()]
+        bld_branch = '' if bld_branch == 'stable' else ('-' + bld_branch)
+        self.__test_template(
+    #         './dist/Pmachines%s-x86_64.AppImage --functional-test 1 ;'
+    #         './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(
+    #         'flatpak run it.ya2.Pmachines//%s --functional-test 1 ;'
+    #         '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')
+        sleep(5)
+        system('xdotool mousemove 1280 620')
+        sleep(1)
+        system('xdotool click 1')
+        sleep(300)
+        system('killall itch')
+
+    def test_itchio(self):
+        info('test_itchio')
+        if environ.get('FUNCTIONALPOST') != '1':
+            self.skipTest('skipped functional-post tests')
+        if _branch() != 'master':
+            return
+        self.__update_itchio()
+        self.__test_template(
+    #         '/home/flavio/.config/itch/apps/pmachines/pmachines --functional-test 1 ;'
+    #         '/home/flavio/.config/itch/apps/pmachines/pmachines --functional-test 2',
+    #         str(Path.home()) + '/.local/share/pmachines/tests/functional/')
+
+    def test_windows(self):
+        info('test_windows')
+    #     system('pkill -f "pmachines.exe"')
+    #     abspath = str(Path(__file__).parent.parent) + '/build/win_amd64/pmachines.exe'
+        self.__test_template(
+            'timeout 720s wine %s --functional-test 1 ; '
+            'timeout 720s wine %s --functional-test 2' % (abspath, abspath),
+    #         str(Path.home()) + '/.wine/drive_c/users/flavio/AppData/Local/pmachines/tests/functional/')
+
+    def test_versions(self):
+        info('test_versions')
+        if environ.get('FUNCTIONAL') != '1':
+            self.skipTest('skipped functional tests')
+        bld_branch = {'master': 'alpha', 'rc': 'rc', 'stable': 'stable'}[_branch()]
+    #     with open('/home/flavio/pmachines_builder/last_bld.txt') as f:
+            lines = f.readlines()
+        for line in lines:
+            if line.strip().split()[0] == _branch():
+                commit = line.strip().split()[1][:7]
+        _ver = ver
+        if _branch() == 'stable':
+    #         with open('/home/flavio/pmachines_builder/pmachines/assets/version.txt') as fver:
+                _ver = fver.read().strip() + '-'
+        exp = '%s-%s' % (_ver, commit)
+        cmds = [
+    #         ('./build/manylinux1_x86_64/pmachines --version', str(Filename.get_user_appdata_directory()) + '/pmachines/obs_version.txt'),
+    #         ('./dist/Pmachines-%s-x86_64.AppImage --version' % bld_branch, str(Filename.get_user_appdata_directory()) + '/pmachines/obs_version.txt'),
+    #         ('timeout 720s wine ./build/win_amd64/pmachines.exe --version', '/home/flavio/.wine/drive_c/users/flavio/AppData/Local/pmachines/obs_version.txt')
+            ]
+        if environ.get('FUNCTIONALPOST') == '1':
+            if _branch() == 'master':
+                self.__update_itchio()
+    #             cmds += [('/home/flavio/.config/itch/apps/pmachines/pmachines --version', str(Filename.get_user_appdata_directory()) + '/pmachines/obs_version.txt')]
+    #         cmds += [('flatpak run it.ya2.Pmachines//%s --version' % bld_branch, '/home/flavio/.var/app/it.ya2.Pmachines/data/pmachines/obs_version.txt')]
+    #     system('flatpak update -y it.ya2.Pmachines//%s' % bld_branch)
+        for cmd in cmds:
+            if exists(cmd[1]):
+                remove(cmd[1])
+            info('launching %s' % cmd[0])
+            exec_cmd(cmd[0])
+            with open(cmd[1]) as f:
+                obs = f.read().strip()
+            self.assertEqual(obs, exp)