Exemplo n.º 1
0
class IBusTestsHangul(IBusWidgetScenariodTests):
    """Tests for the Hangul(Korean) input engine."""

    engine_name = "hangul"

    scenarios = multiply_scenarios(IBusWidgetScenariodTests.scenarios, [
        ('transmission', {
            'input': 'xmfostmaltus ',
            'result': u'\ud2b8\ub79c\uc2a4\ubbf8\uc158 '
        }),
        ('social', {
            'input': 'httuf ',
            'result': u'\uc18c\uc15c '
        }),
        ('document', {
            'input': 'anstj ',
            'result': u'\ubb38\uc11c '
        }),
    ])

    def setUp(self):
        super(IBusTestsHangul, self).setUp()
        self.activate_input_engine_or_skip(self.engine_name)

    def test_hangul(self):
        self.do_ibus_test()
Exemplo n.º 2
0
class IBusTestsAnthy(IBusWidgetScenariodTests):
    """Tests for the Anthy(Japanese) input engine."""

    engine_name = "anthy"

    scenarios = multiply_scenarios(IBusWidgetScenariodTests.scenarios, [
        ('system', {
            'input': 'shisutemu ',
            'result': u'\u30b7\u30b9\u30c6\u30e0'
        }),
        ('game', {
            'input': 'ge-mu ',
            'result': u'\u30b2\u30fc\u30e0'
        }),
        ('user', {
            'input': 'yu-za- ',
            'result': u'\u30e6\u30fc\u30b6\u30fc'
        }),
    ], [
        ('commit_enter', {
            'commit_key': 'Enter'
        }),
    ])

    def setUp(self):
        super(IBusTestsAnthy, self).setUp()
        self.activate_input_engine_or_skip(self.engine_name)

    def test_anthy(self):
        self.do_ibus_test()
Exemplo n.º 3
0
class IBusTestsPinyin(IBusWidgetScenariodTests):
    """Tests for the Pinyin(Chinese) input engine."""

    engine_name = "pinyin"

    scenarios = multiply_scenarios(IBusWidgetScenariodTests.scenarios, [
        ('photo', {
            'input': 'zhaopian ',
            'result': u'\u7167\u7247'
        }),
        ('internet', {
            'input': 'hulianwang ',
            'result': u'\u4e92\u8054\u7f51'
        }),
        ('hello', {
            'input': 'ninhao ',
            'result': u'\u60a8\u597d'
        }),
        ('management', {
            'input': 'guanli ',
            'result': u'\u7ba1\u7406'
        }),
    ])

    def setUp(self):
        super(IBusTestsPinyin, self).setUp()
        self.activate_input_engine_or_skip(self.engine_name)

    def test_pinyin(self):
        self.do_ibus_test()
Exemplo n.º 4
0
class HudLauncherInteractionsTests(HudTestsBase):

    launcher_modes = [('Launcher never hide', {'launcher_autohide': False}),
                      ('Launcher autohide', {'launcher_autohide': True})]

    scenarios = multiply_scenarios(_make_monitor_scenarios(), launcher_modes)

    def setUp(self):
        super(HudLauncherInteractionsTests, self).setUp()
        # Launchers on all monitors
        self.set_unity_option('num_launchers', 0)
        self.set_unity_option('launcher_hide_mode', int(self.launcher_autohide))

        move_mouse_to_screen(self.hud_monitor)
        sleep(0.5)

    def test_multiple_hud_reveal_does_not_break_launcher(self):
        """Multiple Hud reveals must not cause the launcher to set multiple
        apps as active.

        """
        launcher = self.unity.launcher.get_launcher_for_monitor(self.hud_monitor)

        # We need an app to switch to:
        self.process_manager.start_app('Character Map')
        # We need an application to play with - I'll use the calculator.
        self.process_manager.start_app('Calculator')
        sleep(1)

        # before we start, make sure there's zero or one active icon:
        num_active = self.get_num_active_launcher_icons()
        self.assertThat(num_active, LessThan(2), "Invalid number of launcher icons active before test has run!")

        # reveal and hide hud several times over:
        for i in range(3):
            self.unity.hud.ensure_visible()
            self.unity.hud.ensure_hidden()

        # click application icons for running apps in the launcher:
        icon = self.unity.launcher.model.get_icon(desktop_id="gucharmap.desktop")
        launcher.click_launcher_icon(icon)

        # see how many apps are marked as being active:
        num_active = self.get_num_active_launcher_icons()
        self.assertLessEqual(num_active, 1, "More than one launcher icon active after test has run!")

    def test_hud_does_not_change_launcher_status(self):
        """Opening the HUD must not change the launcher visibility."""

        launcher = self.unity.launcher.get_launcher_for_monitor(self.hud_monitor)

        launcher_shows_pre = launcher.is_showing
        self.unity.hud.ensure_visible()
        launcher_shows_post = launcher.is_showing
        self.assertThat(launcher_shows_pre, Equals(launcher_shows_post))
Exemplo n.º 5
0
class LauncherTestCase(UnityTestCase):
    """A base class for all launcher tests that uses scenarios to run on
    each launcher (for multi-monitor setups).
    """
    scenarios = multiply_scenarios(_make_scenarios(), [
        ('left', {
            'launcher_position': LauncherPosition.LEFT
        }),
        ('bottom', {
            'launcher_position': LauncherPosition.BOTTOM
        }),
    ])

    def setUp(self):
        super(LauncherTestCase, self).setUp()
        self.set_unity_log_level("unity.launcher", "DEBUG")
        self.addCleanup(self.set_unity_log_level, "unity.launcher", "INFO")

        self.set_unity_option('num_launchers', int(self.only_primary))
        self.launcher_instance = self.get_launcher()

        old_pos = self.call_gsettings_cmd('get',
                                          'com.canonical.Unity.Launcher',
                                          'launcher-position')
        self.call_gsettings_cmd('set', 'com.canonical.Unity.Launcher',
                                'launcher-position',
                                '"%s"' % self.launcher_position)
        self.addCleanup(self.call_gsettings_cmd, 'set',
                        'com.canonical.Unity.Launcher', 'launcher-position',
                        old_pos)

        if not self.launcher_instance:
            self.skipTest("Cannot run test with no Launcher on monitor %d." %
                          self.launcher_monitor)

        if self.only_primary:
            try:
                old_primary_screen = self.display.get_primary_screen()
                set_primary_monitor(self.launcher_monitor)
                self.addCleanup(set_primary_monitor, old_primary_screen)
            except Display.BlacklistedDriverError:
                self.skipTest("Impossible to set the monitor %d as primary" %
                              self.launcher_monitor)

        self.launcher_instance.move_mouse_to_screen_of_current_launcher()

    def get_launcher(self):
        """Get the launcher for the current scenario."""
        return self.unity.launcher.get_launcher_for_monitor(
            self.launcher_monitor)
Exemplo n.º 6
0
def _make_scenarios():
    """Make scenarios for launcher test cases based on the number of configured
    monitors.
    """
    num_monitors = Display.create().get_num_screens()

    # it doesn't make sense to set only_primary when we're running in a single-monitor setup.
    if num_monitors == 1:
        return [('Single Monitor', {'launcher_monitor': 0, 'only_primary': False})]

    monitor_scenarios = [('Monitor %d' % (i), {'launcher_monitor': i}) for i in range(num_monitors)]
    launcher_mode_scenarios = [('launcher_on_primary', {'only_primary': True}),
                                ('launcher on all', {'only_primary': False})]
    return multiply_scenarios(monitor_scenarios, launcher_mode_scenarios)
Exemplo n.º 7
0
class TestResultLogMessageTests(WithScenarios, TestCase):

    scenarios = multiply_scenarios(
        # Scenarios for each format we support:
        [(f, dict(format=f)) for f in testresult.get_output_formats().keys()],
        # Scenarios for each test outcome:
        [
            ('success', dict(outcome='addSuccess', log='OK: %s')),
            ('error', dict(outcome='addError', log='ERROR: %s')),
            ('fail', dict(outcome='addFailure', log='FAIL: %s')),
            (
                'unexpected success',
                dict(
                    outcome='addUnexpectedSuccess',
                    log='UNEXPECTED SUCCESS: %s',
                )
            ),
            ('skip', dict(outcome='addSkip', log='SKIP: %s')),
            (
                'expected failure',
                dict(
                    outcome='addExpectedFailure',
                    log='EXPECTED FAILURE: %s',
                )
            ),

        ]
    )

    def make_result_object(self):
        output_path = tempfile.mktemp()
        self.addCleanup(remove_if_exists, output_path)
        result_constructor = testresult.get_output_formats()[self.format]
        return result_constructor(
            stream=run.get_output_stream(self.format, output_path),
            failfast=False,
        )

    def test_outcome_logs(self):
        test_id = self.getUniqueString()
        test = PlaceHolder(test_id, outcome=self.outcome)
        result = self.make_result_object()
        result.startTestRun()
        self.useFixture(AutopilotVerboseLogging())
        with FakeLogger() as log:
            test.run(result)
            self.assertThat(log.output, Contains(self.log % test_id))
Exemplo n.º 8
0
def _make_scenarios():
    """Make scenarios for launcher test cases based on the number of configured
    monitors.
    """
    num_monitors = Display.create().get_num_screens()

    # it doesn't make sense to set only_primary when we're running in a single-monitor setup.
    if num_monitors == 1:
        return [('Single Monitor', {
            'launcher_monitor': 0,
            'only_primary': False
        })]

    monitor_scenarios = [('Monitor %d' % (i), {
        'launcher_monitor': i
    }) for i in range(num_monitors)]
    launcher_mode_scenarios = [('launcher_on_primary', {
        'only_primary': True
    }), ('launcher on all', {
        'only_primary': False
    })]
    return multiply_scenarios(monitor_scenarios, launcher_mode_scenarios)
Exemplo n.º 9
0
class HudVisualTests(HudTestsBase):

    launcher_modes = [('Launcher never hide', {'launcher_autohide': False}),
                      ('Launcher autohide', {'launcher_autohide': True})]

    launcher_screen = [('Launcher on all monitors', {'launcher_primary_only': False}),
                       ('Launcher on primary monitor', {'launcher_primary_only': True})]

    scenarios = multiply_scenarios(_make_monitor_scenarios(), launcher_modes, launcher_screen)

    def setUp(self):
        super(HudVisualTests, self).setUp()
        move_mouse_to_screen(self.hud_monitor)
        self.set_unity_option('launcher_hide_mode', int(self.launcher_autohide))
        self.set_unity_option('num_launchers', int(self.launcher_primary_only))
        self.hud_monitor_is_primary = (self.display.get_primary_screen() == self.hud_monitor)
        self.hud_locked = (not self.launcher_autohide and (not self.launcher_primary_only or self.hud_monitor_is_primary))
        sleep(0.5)

    def test_initially_hidden(self):
        self.assertFalse(self.unity.hud.visible)

    def test_hud_is_on_right_monitor(self):
        """HUD must be drawn on the monitor where the mouse is."""
        self.unity.hud.ensure_visible()
        self.assertThat(self.unity.hud.monitor, Eventually(Equals(self.hud_monitor)))
        self.assertTrue(is_rect_on_screen(self.unity.hud.monitor, self.unity.hud.geometry))

    def test_hud_geometries(self):
        """Tests the HUD geometries for the given monitor and status."""
        self.unity.hud.ensure_visible()
        monitor_geo = self.display.get_screen_geometry(self.hud_monitor)
        monitor_x = monitor_geo[0]
        monitor_w = monitor_geo[2]
        hud_x = self.unity.hud.geometry[0]
        hud_w = self.unity.hud.geometry[2]

        if self.hud_locked:
            self.assertThat(hud_x, GreaterThan(monitor_x))
            self.assertThat(hud_x, LessThan(monitor_x + monitor_w))
            self.assertThat(hud_w, Equals(monitor_x + monitor_w - hud_x))
        else:
            self.assertThat(hud_x, Equals(monitor_x))
            self.assertThat(hud_w, Equals(monitor_w))

    def test_hud_is_locked_to_launcher(self):
        """Tests if the HUD is locked to launcher as we expect or not."""
        self.unity.hud.ensure_visible()
        self.assertThat(self.unity.hud.is_locked_launcher, Eventually(Equals(self.hud_locked)))

    def test_hud_icon_is_shown(self):
        """Tests that the correct HUD icon is shown."""
        self.unity.hud.ensure_visible()
        hud_launcher_icon = self.unity.hud.get_launcher_icon()
        hud_embedded_icon = self.unity.hud.get_embedded_icon()

        if self.unity.hud.is_locked_launcher:
            self.assertTrue(hud_launcher_icon.monitors_visibility[self.hud_monitor])
            self.assertTrue(hud_launcher_icon.is_on_monitor(self.hud_monitor))
            self.assertTrue(hud_launcher_icon.monitors_active[self.hud_monitor])
            self.assertThat(hud_launcher_icon.monitor, Equals(self.hud_monitor))
            self.assertFalse(hud_launcher_icon.desaturated)
            self.assertThat(hud_embedded_icon, Equals(None))
        else:
            self.assertThat(hud_launcher_icon.visible, Eventually(Equals(False)))
            self.assertFalse(hud_launcher_icon.monitors_active[self.hud_monitor])
            # the embedded icon has no visible property.
            self.assertThat(hud_embedded_icon, NotEquals(None))

    def test_hud_icon_shows_the_focused_application_emblem(self):
        """Tests that the correct HUD icon is shown."""
        self.process_manager.close_all_app("Calculator")
        calc = self.process_manager.start_app("Calculator")
        self.assertTrue(calc.is_active)
        self.unity.hud.ensure_visible()

        self.assertThat(self.unity.hud.icon.icon_name, Eventually(Equals(calc.icon)))

    def test_hud_icon_shows_the_ubuntu_emblem_on_empty_desktop(self):
        """When in 'show desktop' mode the hud icon must be the BFB icon."""
        self.start_placeholder_app()
        self.unity.window_manager.enter_show_desktop()
        self.addCleanup(self.unity.window_manager.leave_show_desktop)
        self.unity.hud.ensure_visible()

        self.assertThat(self.unity.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png")))

    def test_switch_dash_hud_does_not_break_the_focused_application_emblem(self):
        """Switching from Dash to HUD must still show the correct HUD icon."""
        self.process_manager.close_all_app("Calculator")
        calc = self.process_manager.start_app("Calculator")
        self.assertTrue(calc.is_active)

        self.unity.dash.ensure_visible()
        self.unity.hud.ensure_visible()

        self.assertThat(self.unity.hud.icon.icon_name, Eventually(Equals(calc.icon)))

    def test_switch_hud_dash_does_not_break_the_focused_application_emblem(self):
        """Switching from HUD to Dash and back must still show the correct HUD icon."""
        self.process_manager.close_all_app("Calculator")
        calc = self.process_manager.start_app("Calculator")
        self.assertTrue(calc.is_active)

        self.unity.hud.ensure_visible()
        self.unity.dash.ensure_visible()
        self.unity.hud.ensure_visible()
        self.assertThat(self.unity.hud.icon.icon_name, Eventually(Equals(calc.icon)))

    def test_dash_hud_only_uses_icon_from_current_desktop(self):
        """
        Switching from the dash to Hud must pick an icon from applications
        from the current desktop. As the Hud must go through the entire window
        stack to find the top most window.
        """
        if self.workspace.num_workspaces <= 1:
            self.skipTest("This test requires enabled more than one workspace.")
        self.start_placeholder_app()
        initial_workspace = self.workspace.current_workspace
        self.addCleanup(self.workspace.switch_to, initial_workspace)
        self.unity.window_manager.enter_show_desktop()
        self.addCleanup(self.unity.window_manager.leave_show_desktop)

        calc = self.process_manager.start_app("Calculator")
        self.assertTrue(calc.is_active)
        self.workspace.switch_to((initial_workspace + 1) % self.workspace.num_workspaces)
        self.unity.dash.ensure_visible()
        self.unity.hud.ensure_visible()

        self.assertThat(self.unity.hud.icon.icon_name, Eventually(EndsWith("launcher_bfb.png")))
Exemplo n.º 10
0
class LauncherDragIconsBehavior(LauncherTestCase):
    """Tests dragging icons around the Launcher."""

    scenarios = multiply_scenarios(_make_scenarios(), [
        ('inside', {
            'drag_type': IconDragType.INSIDE
        }),
        ('outside', {
            'drag_type': IconDragType.OUTSIDE
        }),
    ], [
        ('left', {
            'launcher_position': LauncherPosition.LEFT
        }),
        ('bottom', {
            'launcher_position': LauncherPosition.BOTTOM
        }),
    ])

    def setUp(self):
        super(LauncherDragIconsBehavior, self).setUp()

        self.set_unity_option('launcher_hide_mode', 0)

    def ensure_calc_icon_not_in_launcher(self):
        """Wait until the launcher model updates and removes the calc icon."""
        # Normally we'd use get_icon(desktop_id="...") but we're expecting it to
        # not exist, and we don't want to wait for 10 seconds, so we do this
        # the old fashioned way.
        get_icon_fn = lambda: self.unity.launcher.model.get_children_by_type(
            ApplicationLauncherIcon, desktop_id="gcalctool.desktop")
        calc_icon = get_icon_fn()
        if calc_icon:
            self.launcher_instance.unlock_from_launcher(calc_icon[0])

        self.assertThat(get_icon_fn, Eventually(Equals([])))

    def test_can_drag_icon_below_bfb(self):
        """Application icons must be draggable to below the BFB."""

        self.ensure_calc_icon_not_in_launcher()
        calc = self.process_manager.start_app("Calculator")
        calc_icon = self.unity.launcher.model.get_icon(
            desktop_id=calc.desktop_file)
        bfb_icon = self.unity.launcher.model.get_bfb_icon()

        self.launcher_instance.drag_icon_to_position(calc_icon,
                                                     IconDragType.AFTER,
                                                     bfb_icon, self.drag_type,
                                                     self.launcher_position)
        moved_icon = self.unity.launcher.model.\
                     get_launcher_icons_for_monitor(self.launcher_monitor)[1]
        self.assertThat(moved_icon, Equals(calc_icon))

    def test_can_drag_icon_below_window_switcher(self):
        """Application icons must be dragable to below the workspace switcher icon."""

        self.ensure_calc_icon_not_in_launcher()
        calc = self.process_manager.start_app("Calculator")
        calc_icon = self.unity.launcher.model.get_icon(
            desktop_id=calc.desktop_file)
        bfb_icon = self.unity.launcher.model.get_bfb_icon()
        trash_icon = self.unity.launcher.model.get_trash_icon()

        # Move a known icon to the top as it needs to be more than 2 icon
        # spaces away for this test to actually do anything
        self.launcher_instance.drag_icon_to_position(calc_icon,
                                                     IconDragType.AFTER,
                                                     bfb_icon, self.drag_type,
                                                     self.launcher_position)

        sleep(1)
        self.launcher_instance.drag_icon_to_position(calc_icon,
                                                     IconDragType.BEFORE,
                                                     trash_icon,
                                                     self.drag_type,
                                                     self.launcher_position)

        # Must be the last bamf icon - not necessarily the third-from-end icon.
        expected_pos = -2 if self.workspace.num_workspaces < 2 else -1
        refresh_fn = lambda: self.unity.launcher.model.get_launcher_icons()[
            expected_pos].id
        self.assertThat(
            refresh_fn, Eventually(Equals(calc_icon.id)),
            "Launcher icons are: %r" %
            self.unity.launcher.model.get_launcher_icons())
Exemplo n.º 11
0
class InputStackKeyboardTypingTests(InputStackKeyboardBase):

    scenarios = multiply_scenarios(
        InputStackKeyboardBase.scenarios,
        [
            ('lower_alpha', dict(input='abcdefghijklmnopqrstuvwxyz')),
            ('upper_alpha', dict(input='ABCDEFGHIJKLMNOPQRSTUVWXYZ')),
            ('numeric', dict(input='0123456789')),
            ('punctuation', dict(input='`~!@#$%^&*()_-+={}[]|\\:;"\'<>,.?/')),
            ('whitespace', dict(input='\t\n'))
        ]
    )

    def start_mock_app(self):
        window_spec_file = mktemp(suffix='.json')
        window_spec = {"Contents": "TextEdit"}
        json.dump(
            window_spec,
            open(window_spec_file, 'w')
        )
        self.addCleanup(os.remove, window_spec_file)

        return self.launch_test_application(
            'window-mocker',
            window_spec_file,
            app_type='qt'
        )

    def test_text_typing(self):
        """Typing text must produce the correct characters in the target
        app.

        """
        app_proxy = self.start_mock_app()
        text_edit = app_proxy.select_single('QTextEdit')

        # make sure the text edit has keyboard focus:
        self.mouse.click_object(text_edit)
        self.assertThat(text_edit.focus, Eventually(Equals(True)))

        # even though we ensured the textedit has focus, it occasionally
        # does not yet accept keyboard input, causing this test to fail
        # intermittently.  to remedy this, we just add a sleep.
        sleep(2)

        # create keyboard and type the text.
        keyboard = Keyboard.create(self.backend)
        keyboard.type(self.input, 0.01)

        self.assertThat(text_edit.plainText,
                        Eventually(Equals(self.input)),
                        "app shows: " + text_edit.plainText
                        )

    def test_typing_with_contextmanager(self):
        """Typing text must produce the correct characters in the target
        app.

        """
        app_proxy = self.start_mock_app()
        text_edit = app_proxy.select_single('QTextEdit')

        keyboard = Keyboard.create(self.backend)
        with keyboard.focused_type(text_edit) as kb:
            kb.type(self.input, 0.01)

            self.assertThat(
                text_edit.plainText,
                Eventually(Equals(self.input)),
                "app shows: " + text_edit.plainText
            )

    def test_keyboard_keys_are_released(self):
        """Typing characters must not leave keys pressed."""
        app_proxy = self.start_mock_app()
        text_edit = app_proxy.select_single('QTextEdit')

        # make sure the text edit has keyboard focus:
        self.mouse.click_object(text_edit)
        keyboard = Keyboard.create(self.backend)

        for character in self.input:
            self.assertThat(self._get_pressed_keys_list(), Equals([]))
            keyboard.type(character, 0.01)
            self.assertThat(self._get_pressed_keys_list(), Equals([]))

    def _get_pressed_keys_list(self):
        """Get a list of keys pressed, but not released from the backend we're
        using.

        """
        if self.backend == 'X11':
            from autopilot.input._X11 import _PRESSED_KEYS
            return _PRESSED_KEYS
        elif self.backend == 'UInput':
            from autopilot.input import _uinput
            return _uinput.Keyboard._device._pressed_keys_ecodes
        else:
            self.fail(
                "Don't know how to get pressed keys list for {}".format(
                    self.backend
                )
            )
Exemplo n.º 12
0
class SwitcherDetailsModeTests(SwitcherTestCase):
    """Tests for the details mode of the switcher.

    Tests for initiation with both grave (`) and Down arrow.

    """

    scenarios = multiply_scenarios(SwitcherTestCase.scenarios, [
        ('initiate_with_grave', {
            'initiate_keycode': '`'
        }),
        ('initiate_with_down', {
            'initiate_keycode': 'Down'
        }),
    ])

    def setUp(self):
        super(SwitcherDetailsModeTests, self).setUp()
        self.set_timeout_setting(False)

    def test_can_start_details_mode(self):
        """Must be able to switch to details mode using selected scenario keycode.

        """
        self.process_manager.start_app_window("Character Map")
        self.unity.switcher.initiate()
        self.addCleanup(self.unity.switcher.terminate)

        self.keyboard.press_and_release(self.initiate_keycode)

        self.assertProperty(self.unity.switcher, mode=SwitcherMode.DETAIL)

    def test_next_icon_from_last_detail_works(self):
        """Pressing next while showing last switcher item in details mode
        must select first item in the model in non-details mode.

        """
        self.process_manager.start_app("Character Map")
        self.unity.switcher.initiate()
        self.addCleanup(self.unity.switcher.terminate)
        while self.unity.switcher.selection_index < len(
                self.unity.switcher.icons) - 1:
            self.unity.switcher.next_icon()
        self.keyboard.press_and_release(self.initiate_keycode)
        sleep(0.5)
        # Make sure we're at the end of the details list for this icon
        possible_details = self.unity.switcher.detail_current_count - 1
        while self.unity.switcher.detail_selection_index < possible_details:
            self.unity.switcher.next_detail()

        self.unity.switcher.next_icon()
        self.assertThat(self.unity.switcher.selection_index,
                        Eventually(Equals(0)))

    def test_detail_mode_selects_last_active_window(self):
        """The active selection in detail mode must be the last focused window.
        If it was the currently active application type.
        """
        char_win1, char_win2 = self.start_applications("Character Map",
                                                       "Character Map")
        self.assertVisibleWindowStack([char_win2, char_win1])

        self.unity.switcher.initiate()
        while self.unity.switcher.current_icon.tooltip_text != char_win2.application.name:
            self.unity.switcher.next_icon()
        self.keyboard.press_and_release(self.initiate_keycode)
        sleep(0.5)
        self.unity.switcher.select()

        self.assertProperty(char_win1, is_focused=True)

    def test_detail_mode_selects_third_window(self):
        """Pressing Alt+` twice must select the third last used window.
        LP:1061229
        """
        char_win1, char_win2, char_win3 = self.start_applications(
            "Character Map", "Character Map", "Character Map")
        self.assertVisibleWindowStack([char_win3, char_win2, char_win1])

        self.unity.switcher.initiate(SwitcherMode.DETAIL)
        self.unity.switcher.next_detail()

        self.unity.switcher.select()
        self.assertVisibleWindowStack([char_win1, char_win3, char_win2])
Exemplo n.º 13
0
class SwitcherOverlaysInteractionTests(SwitcherInteractionTests):
    """Test the switcher interactions with the shell overlays."""

    scenarios = multiply_scenarios(SwitcherTestCase.scenarios, [
        ('Dash', {
            'overlay': "self.unity.dash"
        }),
        ('Hud', {
            'overlay': "self.unity.hud"
        }),
    ])

    def setUp(self):
        super(SwitcherOverlaysInteractionTests, self).setUp()
        self.overlay = eval(self.overlay)

    def tearDown(self):
        super(SwitcherOverlaysInteractionTests, self).tearDown()

    def test_switcher_shows_on_overlay_opened(self):
        """Tests if switcher shows when overlay is opened"""
        self.open_switcher_after_overlay(self.overlay)

    def test_switcher_tab_key_work_after_overlay_is_closed(self):
        """Tests that the switcher tab key work when initializing the
        switcher after closing the overlay
        """
        self.open_switcher_after_overlay(self.overlay)

        start = self.unity.switcher.selection_index
        next_index = (start + 1) % len(self.unity.switcher.icons)
        self.unity.switcher.next_icon()
        self.assertThat(self.unity.switcher.selection_index,
                        Eventually(Equals(next_index)))

        self.unity.switcher.previous_icon()
        self.assertThat(self.unity.switcher.selection_index,
                        Eventually(Equals(start)))

    def test_switcher_arrow_keys_work_after_overlay_is_closed(self):
        """Tests that the switcher arrow keys work when initializing the
        switcher after closing the overlay
        """
        self.open_switcher_after_overlay(self.overlay)

        start = self.unity.switcher.selection_index
        next_index = (start + 1) % len(self.unity.switcher.icons)
        self.keyboard.press_and_release('Right')
        self.assertThat(self.unity.switcher.selection_index,
                        Eventually(Equals(next_index)))

        self.keyboard.press_and_release('Left')
        self.assertThat(self.unity.switcher.selection_index,
                        Eventually(Equals(start)))

    def test_switcher_detail_mode_works_after_overlay_is_closed(self):
        """Tests that the switcher detail mode through the 'Down' arrow key
        work when initializing the switcher after closing the overlay
        """
        self.open_switcher_after_overlay(self.overlay)

        self.keyboard.press_and_release('Down')
        self.assertProperty(self.unity.switcher, mode=SwitcherMode.DETAIL)

        self.keyboard.press_and_release('Up')
        self.assertProperty(self.unity.switcher, mode=SwitcherMode.NORMAL)