ya2 · news · projects · code · about

functional tests: options
[pmachines.git] / lib / engine / functional.py
index 3492f4112025231ed6fd3614840c3bd09438b9d9..87211b8011124c9aadf09f9bb07a12f8f87b6a5e 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
@@ -21,7 +23,7 @@ class FunctionalTest(GameObject):
 
     screenshot_time = 1.2
     evt_time = 1.0
-    start_time = 5
+    start_time = 2
 
     def __init__(self, idx, ref):
         super().__init__()
@@ -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,12 +163,14 @@ 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')
@@ -142,262 +180,316 @@ class FunctionalTest(GameObject):
         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._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, -80), 'left'])
         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')
+        # languages
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, -300), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'open_languages_1')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(280, -324), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'options_menu_english')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, -300), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'open_languages_2')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(280, -240), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'options_menu_italian')
         # 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')
+        self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(44, -207), (67, -207), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_1')
+        self._event(FunctionalTest.evt_time, 'mousedrag', False, False, [(67, -207), (44, -207), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'options_menu_drag_2')
+        # fullscreen
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, -120), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'fullscreen')
+        self._event(8 + FunctionalTest.evt_time, 'mouseclick', False, False, [(-320, -300), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'back_from_fullscreen')
+        # resolution
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, -24), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'resolutions')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(314, 116), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, '1440x900')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(98, 47), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'resolutions_2')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(478, 59), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, '1280x720')
+        # antialiasing
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(12, 62), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'antialiasing_no')
+        # shadows
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(12, 145), 'left'])
+        self._screenshot(FunctionalTest.screenshot_time, 'shadows_no')
+        # test aa and shadows
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, 270), 'left'])  # back
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, -230), 'left'])  # play
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(-430, -210), 'left'])  # domino
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(200, 100), 'left'])  # close instructions
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(-620, 336), 'left'])  # home
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, -80), 'left'])  # options
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(12, 62), 'left'])  # aa
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(12, 145), 'left'])  # shadows
+        self._screenshot(FunctionalTest.screenshot_time, 'aa_no_shadows_no')
+        self._event(FunctionalTest.evt_time, 'mouseclick', False, False, [(0, 270), 'left'])  # back
+
+    #     # 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]()