class TestPageInitiatedFullscreen(TestFullscreenBase):
    def setUp(self):
        super(TestPageInitiatedFullscreen, self).setUp(path="/fullscreen")
        self.assert_webview_fullscreen(False)
        self.assert_window_fullscreen(False)
        webview = self.main_window.get_current_webview()
        self.pointing_device.click_object(webview)
        self.assert_webview_fullscreen(True)
        self.assert_window_fullscreen(True)

    def test_page_initiated_exit(self):
        webview = self.main_window.get_current_webview()
        hint = webview.wait_select_single(objectName="fullscreenExitHint")
        self.pointing_device.click_object(webview)
        self.assert_webview_fullscreen(False)
        self.assert_window_fullscreen(False)
        hint.wait_until_destroyed()

    @testtools.skipIf(model() == "Desktop", "on touch devices only")
    def test_user_exit_swipe_up(self):
        self.open_tabs_view()
        self.assert_webview_fullscreen(False)
        self.assert_window_fullscreen(False)

    @testtools.skipIf(model() != "Desktop", "on desktop only")
    def test_user_exit_ESC(self):
        self.main_window.press_key('Escape')
        self.assert_webview_fullscreen(False)
        self.assert_window_fullscreen(False)

    @testtools.skipIf(model() != "Desktop", "on desktop only")
    def test_user_exit_F11(self):
        self.main_window.press_key('F11')
        self.assert_webview_fullscreen(False)
        self.assert_window_fullscreen(False)
Esempio n. 2
0
class PublicAPITests(TestCase):
    @skipIf(platform.model() != "Desktop", "Only available on desktop.")
    def test_get_display_server_returns_x11(self):
        self.assertEqual(platform.get_display_server(), "X11")

    @skipIf(platform.model() == "Desktop", "Only available on device.")
    def test_get_display_server_returns_mir(self):
        self.assertEqual(platform.get_display_server(), "MIR")
Esempio n. 3
0
class TestUbuntuUIToolkitAppTestCase(testtools.TestCase):
    @testtools.skipIf(platform.model() != 'Desktop', 'Desktop only')
    def test_desktop_input_device_class(self):
        test = AppTestCase('_runTest')
        test.setUp()
        self.assertIs(test.input_device_class, input.Mouse)

    @testtools.skipIf(platform.model() == 'Desktop', 'Phablet only')
    def test_phablet_input_device_class(self):
        test = AppTestCase('_runTest')
        test.setUp()
        self.assertIs(test.input_device_class, input.Touch)
Esempio n. 4
0
 def setUp(self):
     super(TestPlayerWithVideo, self).setUp()
     logger.info(platform.model())
     if platform.model() in ('Nexus 4', 'Galaxy Nexus',
                             "Nexus 7 (2013) Wi-Fi", "Nexus 10",
                             "Aquaris E4.5 Ubuntu Edition"):
         self.launch_app("h264.avi")
     else:
         self.launch_app("small.ogg")
     self.assertThat(self.main_window.get_qml_view().visible,
                     Eventually(Equals(True)))
     # wait for video player to start
     player = self.main_window.get_player()
     self.assertThat(player.playing, Eventually(Equals(True)))
def get_device_simulation_scenarios(devices=DEFAULT_DEVICES):
    """Return a list of devices to be simulated on tests.

    :param devices: The device or devices to simulate. Default value is all the
        officially supported devices.
    :type devices: string or sequence of strings.
    :return: A list of scenarios to be used with the testscenarios python
        module, with the values of app_width, app_height and grid_unit
        corresponding to the selected device.

    """
    if platform.model() == 'Desktop':
        return _get_device_simulation_scenarios_for_desktop(devices)
    else:
        return [(platform.model(), {})]
 def drag_bottom_edge_upwards(self, fraction):
     self.assertThat(model(), NotEquals('Desktop'))
     hint = self.main_window.get_bottom_edge_hint()
     x = hint.globalRect.x + hint.globalRect.width // 2
     y0 = hint.globalRect.y + hint.globalRect.height // 2
     y1 = y0 - int(self.main_window.height * fraction)
     self.pointing_device.drag(x, y0, x, y1)
Esempio n. 7
0
    def focused_type(self, input_target, pointer=None):
        """Type into an input widget.

        This context manager takes care of making sure a particular
        *input_target* UI control is selected before any text is entered.

        Some backends extend this method to perform cleanup actions at the end
        of the context manager block. For example, the OSK backend dismisses
        the keyboard.

        If the *pointer* argument is None (default) then either a Mouse or
        Touch pointer will be created based on the current platform.

        An example of using the context manager (with an OSK backend)::

            from autopilot.input import Keyboard

            text_area = self._launch_test_input_area()
            keyboard = Keyboard.create('OSK')
            with keyboard.focused_type(text_area) as kb:
                kb.type("Hello World.")
                self.assertThat(text_area.text, Equals("Hello World"))
            # Upon leaving the context managers scope the keyboard is dismissed
            # with a swipe

        """
        if pointer is None:
            from autopilot.platform import model
            if model() == 'Desktop':
                pointer = Pointer(Mouse.create())
            else:
                pointer = Pointer(Touch.create())

        pointer.click_object(input_target)
        yield self
Esempio n. 8
0
    def ensure_app_has_quit(self):
        """Terminate as gracefully as possible the application and ensure
        that it has fully quit before returning"""

        if model() == "Desktop":
            # On desktop to cleanly quit an app we just do the
            # equivalent of clicking on the close button in the window.
            self.keyboard.press_and_release("Alt+F4")
        else:
            # On unity8 at the moment we have no clean way to close the app.
            # So we ask the shell first to show the home, unfocusing our app,
            # which will save its state. Then we simply send it a SIGTERM to
            # force it to quit.
            # See bug https://bugs.launchpad.net/unity8/+bug/1261720 for more
            # details.
            from unity8 import process_helpers
            pid = process_helpers._get_unity_pid()
            unity8 = get_proxy_object_for_existing_process(pid=pid)
            shell = unity8.select_single("Shell")
            shell.slots.showHome()
            self.assertThat(shell.focusedApplicationId,
                            Eventually(NotEquals("gallery-app")))
            self.app.process.send_signal(signal.SIGTERM)

        # Either way, we wait for the underlying process to be fully finished.
        self.app.process.wait()
        self.assertIsNotNone(self.app.process.returncode)
 def setUp(self):
     if model() == "Desktop":
         self.skipTest("Ubuntu Keyboard tests only run on device.")
     super(UbuntuKeyboardTests, self).setUp()
     self.set_test_settings()
     sleep(5)  # Have to give time for gsettings change to propogate
     self.pointer = Pointer(Touch.create())
Esempio n. 10
0
    def ensure_app_has_quit(self):
        """Terminate as gracefully as possible the application and ensure
        that it has fully quit before returning"""

        if model() == "Desktop":
            # On desktop to cleanly quit an app we just do the
            # equivalent of clicking on the close button in the window.
            self.keyboard.press_and_release("Alt+F4")
        else:
            # On unity8 at the moment we have no clean way to close the app.
            # So we ask the shell first to show the home, unfocusing our app,
            # which will save its state. Then we simply send it a SIGTERM to
            # force it to quit.
            # See bug https://bugs.launchpad.net/unity8/+bug/1261720 for more
            # details.
            from unity8 import process_helpers
            pid = process_helpers._get_unity_pid()
            unity8 = get_proxy_object_for_existing_process(pid=pid)
            shell = unity8.select_single("Shell")
            shell.slots.showHome()
            self.assertThat(shell.focusedApplicationId,
                            Eventually(NotEquals("gallery-app")))
            self.app.process.send_signal(signal.SIGTERM)

        # Either way, we wait for the underlying process to be fully finished.
        self.app.process.wait()
        self.assertIsNotNone(self.app.process.returncode)
    def test_launch_fake_application_from_url_dispatcher(self):
        if platform.model() == 'Desktop':
            self.skipTest('Not yet working on desktop')

        path = os.path.abspath(__file__)
        dir_path = os.path.dirname(path)
        qml_file_path = os.path.join(
            dir_path, 'test_fixture_setup.LaunchFakeApplicationTestCase.qml')
        with open(qml_file_path) as qml_file:
            qml_file_contents = qml_file.read()

        fake_application = fixture_setup.FakeApplication(
            qml_file_contents=qml_file_contents,
            url_dispatcher_protocols=['testprotocol'])
        self.useFixture(fake_application)

        self.useFixture(fixture_setup.InitctlEnvironmentVariable(
            QT_LOAD_TESTABILITY=1))

        self.addCleanup(
            subprocess.check_output,
            ['ubuntu-app-stop', fake_application.application_name])

        subprocess.check_output(
            ['url-dispatcher', 'testprotocol://test'])

        pid = int(subprocess.check_output(
            ['ubuntu-app-pid', fake_application.application_name]).strip())

        application = introspection.get_proxy_object_for_existing_process(
            pid=pid)

        # We can select a component from the application.
        application.select_single('Label', objectName='testLabel')
class TestContextMenuLink(TestContextMenuBase):

    def setUp(self):
        super(TestContextMenuLink, self).setUp(path="/link")
        self.assertThat(self.menu.get_title_label().text,
                        Equals(self.base_url + "/test1"))

    def test_open_link_in_new_tab(self):
        self.menu.click_action("OpenLinkInNewTabContextualAction")
        self.verify_link_opened_in_a_new_tab()

    def test_bookmark_link(self):
        self.menu.click_action("BookmarkLinkContextualAction")
        bookmark_options = self.main_window.get_bookmark_options()
        bookmark_options.click_dismiss_button()
        self.verify_link_bookmarked()

    def test_copy_link(self):
        # There is no easy way to test the contents of the clipboard,
        # but we can at least verify that the context menu was dismissed.
        self.menu.click_action("CopyLinkContextualAction")

    @testtools.skipIf(model() == "Desktop", "on devices only")
    def test_share_link(self):
        self.menu.click_action("ShareContextualAction")
        self.main_window.wait_select_single("ContentShareDialog")
class X11ScreenShotTests(TestCase):
    def get_pixbuf_that_mocks_saving(self, success, data):
        pixbuf_obj = Mock()
        pixbuf_obj.save_to_bufferv.return_value = (success, data)

        return pixbuf_obj

    @skipIf(platform.model() != "Desktop", "Only available on desktop.")
    def test_save_gdk_pixbuf_to_fileobject_raises_error_if_save_failed(self):
        pixbuf_obj = self.get_pixbuf_that_mocks_saving(False, None)
        with patch.object(_ss, 'logger') as p_log:
            self.assertRaises(
                RuntimeError,
                lambda: _ss._save_gdk_pixbuf_to_fileobject(pixbuf_obj))
            p_log.error.assert_called_once_with("Unable to write image data.")

    def test_save_gdk_pixbuf_to_fileobject_returns_data_object(self):
        expected_data = b"Tests Rock"
        pixbuf_obj = self.get_pixbuf_that_mocks_saving(True, expected_data)

        data_object = _ss._save_gdk_pixbuf_to_fileobject(pixbuf_obj)

        self.assertThat(data_object, Not(Equals(None)))
        self.assertEqual(data_object.tell(), 0)
        self.assertEqual(data_object.getvalue(), expected_data)
Esempio n. 14
0
    def launch_webcontainer_app(self, args, envvars={}, is_local_app=False):
        if model() != 'Desktop':
            args.append('--desktop_file_hint=/usr/share/applications/'
                        'webbrowser-app.desktop')

        if next(filter(lambda e: e.startswith('--appid'), args), None) is None:
            args.append('--app-id=running.test')

        if envvars:
            for envvar_key in envvars:
                self.useFixture(
                    fixtures.EnvironmentVariable(envvar_key,
                                                 envvars[envvar_key]))

        try:
            self.app = self.launch_test_application(
                self.get_webcontainer_app_path(),
                *args,
                emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
        except:
            self.app = None

        if not is_local_app:
            webview = self.get_oxide_webview()
            self.assertThat(lambda: webview.activeFocus,
                            Eventually(Equals(True)))
Esempio n. 15
0
 def drag_bottom_edge_upwards(self, fraction):
     self.assertThat(model(), NotEquals('Desktop'))
     handleRect = self.main_window.get_bottom_edge_handle().globalRect
     x = handleRect.x + handleRect.width // 2
     y0 = handleRect.y + handleRect.height // 2
     y1 = y0 - int(self.main_window.height * fraction)
     self.pointing_device.drag(x, y0, x, y1)
Esempio n. 16
0
    def setUpClass(cls):
        try:
            logger.debug("Creating the override file.")
            with open(
                UbuntuKeyboardTests.maliit_override_file, 'w'
            ) as override_file:
                override_file.write("exec maliit-server -testability")

            process_helpers.restart_unity_with_testability()
            _assertUnityReady()
            #### FIXME: This is a work around re: lp:1238417 ####
            if model() != "Desktop":
                from autopilot.input import _uinput
                _uinput._touch_device = _uinput.create_touch_device()
            ####

            #### FIXME: Workaround re: lp:1248902 and lp:1248913
            logger.debug("Waiting for maliit-server to be ready")
            sleep(10)
            ####

        except IOError as e:
            e.args += (
                "Failed attempting to write override file to {file}".format(
                    file=UbuntuKeyboardTests.maliit_override_file
                ),
            )
            raise
    def test_launch_fake_application_from_url_dispatcher(self):
        if platform.model() == 'Desktop':
            self.skipTest('Not yet working on desktop')

        path = os.path.abspath(__file__)
        dir_path = os.path.dirname(path)
        qml_file_path = os.path.join(
            dir_path, 'test_fixture_setup.LaunchFakeApplicationTestCase.qml')
        with open(qml_file_path) as qml_file:
            qml_file_contents = qml_file.read()

        fake_application = fixture_setup.FakeApplication(
            qml_file_contents=qml_file_contents,
            url_dispatcher_protocols=['testprotocol'])
        self.useFixture(fake_application)

        self.addCleanup(subprocess.check_output,
                        ['ubuntu-app-stop', fake_application.application_name])

        subprocess.check_output(['url-dispatcher', 'testprotocol://test'])

        pid = int(
            subprocess.check_output(
                ['ubuntu-app-pid', fake_application.application_name]).strip())
        self.assertGreater(pid, 0)
Esempio n. 18
0
    def setUp(self):
        super().setUp()

        if is_unity7_running():
            self.useFixture(toolkit_fixtures.HideUnity7Launcher())

        if model() != 'Desktop':
            # On the phone, we need unity to be running and unlocked.
            self.addCleanup(process_helpers.stop_job, 'unity8')
            process_helpers.restart_unity_with_testability()
            process_helpers.unlock_unity()

        self.ensure_dash_not_running()

        if self.qml_mock_enabled:
            self.environment['QML2_IMPORT_PATH'] = (
                get_qml_import_path_with_mock())

        if self.should_simulate_device():
            # This sets the grid units, so it should be called before launching
            # the app.
            self.simulate_device()

        binary_path = get_binary_path('unity8-dash')
        dash_proxy = self.launch_dash(binary_path, self.environment)

        self.dash_app = dash_helpers.DashApp(dash_proxy)
        self.dash = self.dash_app.dash
        self.wait_for_dash()
Esempio n. 19
0
    def setUp(self):
        super().setUp()

        if is_unity7_running():
            self.useFixture(toolkit_fixtures.HideUnity7Launcher())

        if model() != 'Desktop':
            # On the phone, we need unity to be running and unlocked.
            self.addCleanup(process_helpers.stop_job, 'unity8')
            process_helpers.restart_unity_with_testability()
            process_helpers.unlock_unity()

        self.ensure_dash_not_running()

        if self.qml_mock_enabled:
            self.environment['QML2_IMPORT_PATH'] = (
                get_qml_import_path_with_mock()
            )

        if self.should_simulate_device():
            # This sets the grid units, so it should be called before launching
            # the app.
            self.simulate_device()

        binary_path = get_binary_path('unity8-dash')
        dash_proxy = self.launch_dash(binary_path, self.environment)

        self.dash_app = dash_helpers.DashApp(dash_proxy)
        self.dash = self.dash_app.dash
        self.wait_for_dash()
Esempio n. 20
0
 def __init__(self, device_class=UInput):
     if not UInputHardwareKeysDevice._device:
         UInputHardwareKeysDevice._device = device_class(
             devnode=_get_devnode_path(),
         )
         # This workaround is not needed on desktop.
         if model() != 'Desktop':
             self._wait_for_device_to_ready()
Esempio n. 21
0
class InputStackCleanup(AutopilotTestCase):

    @skipIf(platform.model() != "Desktop", "Only suitable on Desktop (X11)")
    def test_keyboard_keys_released_X11(self):
        """Cleanup must release any keys that an X11 keyboard has had
        pressed."""
        class FakeTestCase(AutopilotTestCase):
            def test_press_key(self):
                kb = Keyboard.create('X11')
                kb.press('Shift')

        test_result = FakeTestCase("test_press_key").run()

        self.assertThat(test_result.wasSuccessful(), Equals(True))
        from autopilot.input._X11 import _PRESSED_KEYS
        self.assertThat(_PRESSED_KEYS, Equals([]))

    def test_keyboard_keys_released_UInput(self):
        """Cleanup must release any keys that an UInput keyboard has had
        pressed."""
        class FakeTestCase(AutopilotTestCase):
            def test_press_key(self):
                kb = Keyboard.create('UInput')
                kb.press('Shift')

        test_result = FakeTestCase("test_press_key").run()

        self.assertThat(test_result.wasSuccessful(), Equals(True))
        from autopilot.input import _uinput
        self.assertThat(
            _uinput.Keyboard._device._pressed_keys_ecodes, Equals([]))

    @skipIf(platform.model() != "Desktop", "Not suitable for device (X11)")
    @patch('autopilot.input._X11.fake_input', new=lambda *args: None, )
    def test_mouse_button_released(self):
        """Cleanup must release any mouse buttons that have been pressed."""
        class FakeTestCase(AutopilotTestCase):
            def test_press_button(self):
                mouse = Mouse.create('X11')
                mouse.press()

        test_result = FakeTestCase("test_press_button").run()

        from autopilot.input._X11 import _PRESSED_MOUSE_BUTTONS
        self.assertThat(test_result.wasSuccessful(), Equals(True))
        self.assertThat(_PRESSED_MOUSE_BUTTONS, Equals([]))
Esempio n. 22
0
class TestContentPick(StartOpenRemotePageTestCaseBase):
    def setUp(self):
        super(TestContentPick, self).setUp(path="/uploadform")

    @unittest.skipIf(model() == "Desktop", "on devices only")
    def test_picker_dialog_shows_up(self):
        webview = self.main_window.get_current_webview()
        self.pointing_device.click_object(webview)
        dialog = self.main_window.get_content_picker_dialog()
        self.assertThat(dialog.visible, Eventually(Equals(True)))
Esempio n. 23
0
    def click_item(self, item, delay=0.1):
        """Does a mouse click on the passed item, and moved the mouse there
           before"""
        # In jenkins test may fail because we don't wait before clicking the
        # target so we add a little delay before click.
        if model() == 'Desktop' and delay <= 0.25:
            delay = 0.25

        self.pointing_device.move_to_object(item)
        sleep(delay)
        self.pointing_device.click()
Esempio n. 24
0
 def test_cancel_pull_to_refresh_must_not_refresh_model(self):
     if platform.model() != 'Desktop':
         # TODO remove the skip once bug http://pad.lv/1266601 is fixed.
         self.skipTest(
             'Autopilot is not yet able to do a drag on the devices '
             'without releasing the simulated finger.')
     self.flickable_with_pull_to_refresh._cancel_pull_to_refresh()
     # Sleep for some time to make sure that the list is not being
     # refreshed.
     time.sleep(3)
     self.assertEqual(self.label.text, 'Not refreshed.')
Esempio n. 25
0
 def launch_test_installed(self, parameter):
     if model() == 'Desktop':
         self.app = self.launch_test_application(
             'messaging-app',
             parameter,
             emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
     else:
         self.app = self.launch_upstart_application(
             'messaging-app',
             parameter,
             emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
Esempio n. 26
0
    def test_drag_item_must_reorder_list(self):
        if platform.model() != 'Desktop':
            self.skipTest(
                'Drag does not work on the phone because of bug #1266601')

        original_from_text = self._get_item_text(self.from_index)

        self.list_view.drag_item(self.from_index, self.to_index)

        self.assertEqual(
            original_from_text, self._get_item_text(self.to_index))
Esempio n. 27
0
 def open_tabs_view(self):
     if model() == 'Desktop':
         chrome = self.main_window.chrome
         drawer_button = chrome.get_drawer_button()
         self.pointing_device.click_object(drawer_button)
         chrome.get_drawer()
         tabs_action = chrome.get_drawer_action("tabs")
         self.pointing_device.click_object(tabs_action)
     else:
         self.drag_bottom_edge_upwards(0.75)
     return self.main_window.get_tabs_view()
Esempio n. 28
0
class MediaplayerAppTestCase(AutopilotTestCase):

    """A common test case class that provides several useful methods for
    mediaplayer-app tests.

    """

    if model() == 'Desktop':
        scenarios = [('with mouse', dict(input_device_class=Mouse))]
    else:
        scenarios = [('with touch', dict(input_device_class=Touch))]

    def setUp(self):
        self.pointing_device = Pointer(self.input_device_class.create())
        super(MediaplayerAppTestCase, self).setUp()

    def launch_app(self, movie_file=None):
        if movie_file is None:
            movie_file = ""
        # Lets assume we are installed system wide if this file is somewhere
        # in /usr
        if os.path.realpath(__file__).startswith("/usr/"):
            self.launch_test_installed(movie_file)
        else:
            self.launch_test_local(movie_file)

    def launch_test_local(self, movie_file):
        mp_app = os.environ['MEDIAPLAYER_APP']
        mp_data_dir = os.environ['MEDIAPLAYER_DATA_DIR']
        if mp_app:
            self.app = self.launch_test_application(
                mp_app,
                "-w",
                "file://%s/%s" % (mp_data_dir, movie_file))
        else:
            self.app = None

    def launch_test_installed(self, movie_file):
        if model() == 'Desktop':
            self.app = self.launch_test_application(
                "mediaplayer-app",
                "-w",
                "/usr/share/mediaplayer-app/videos/" + movie_file)
        else:
            self.app = self.launch_test_application(
                "mediaplayer-app",
                "file:///usr/share/mediaplayer-app/videos/" + movie_file,
                "--fullscreen",
                "--desktop_file_hint=/usr/share/applications/mediaplayer-app.desktop",
                app_type='qt')

    @property
    def main_window(self):
        return MainWindow(self.app)
 def test_close_last_open_tab(self):
     tabs_view = self.main_window.get_tabs_view()
     tabs_view.get_previews()[0].close()
     tabs_view.visible.wait_for(False)
     self.assert_number_webviews_eventually(1)
     self.main_window.get_new_tab_view()
     if model() == 'Desktop':
         address_bar = self.main_window.address_bar
         self.assertThat(address_bar.activeFocus, Eventually(Equals(True)))
     webview = self.main_window.get_current_webview()
     self.assertThat(webview.url, Equals(""))
Esempio n. 30
0
 def open_item_context_menu_on_item(self, item, menuClass):
     cx = item.globalRect.x + item.globalRect.width // 2
     cy = item.globalRect.y + item.globalRect.height // 2
     self.pointing_device.move(cx, cy)
     if model() == 'Desktop':
         self.pointing_device.click(button=3)
     else:
         self.pointing_device.press()
         time.sleep(1.5)
         self.pointing_device.release()
     return self.wait_select_single(menuClass)
Esempio n. 31
0
 def launch_test_installed(self):
     if model() == 'Desktop':
         self.app = self.launch_test_application(
             "camera-app", emulator_base=CUSTOM_PROXY_OBJECT_BASE)
     else:
         self.app = self.launch_test_application(
             "camera-app",
             "--fullscreen", "--desktop_file_hint="
             "/usr/share/applications/camera-app.desktop",
             app_type='qt',
             emulator_base=CUSTOM_PROXY_OBJECT_BASE)
    def setUp(self):
        self.ARGS = []
        self.envDesktopMode = env.get("DESKTOP_MODE")

        if model() == "Desktop":
            env["DESKTOP_MODE"] = "1"
        else:
            env["DESKTOP_MODE"] = "0"

        super(TestPhotosView, self).setUp()
        self.switch_to_photos_tab()
Esempio n. 33
0
    def setUp(self):
        self.ARGS = []
        self.envDesktopMode = env.get("DESKTOP_MODE")

        if model() == "Desktop":
            env["DESKTOP_MODE"] = "1"
        else:
            env["DESKTOP_MODE"] = "0"

        super(TestPhotosView, self).setUp()
        self.switch_to_photos_tab()
Esempio n. 34
0
    def click_item(self, item, delay=0.1):
        """Does a mouse click on the passed item, and moved the mouse there
           before"""
        # In jenkins test may fail because we don't wait before clicking the
        # target so we add a little delay before click.
        if model() == 'Desktop' and delay <= 0.25:
            delay = 0.25

        self.pointing_device.move_to_object(item)
        sleep(delay)
        self.pointing_device.click()
Esempio n. 35
0
    def setUp(self, parameter=""):
        #self.pointing_device = Pointer(self.input_device_class.create())
        super(TelegramAppTestCase, self).setUp()

        subprocess.call(['pkill', 'telegram-app'])

        #Preconditions: Logged In
        if platform.model() == "Desktop":
            self.app = self.launch_desktop_application(parameter)
        else:
            self.app = self.launch_mobile_application(parameter)
        self.assertThat(self.main_view.visible, Eventually(Equals(True)))
Esempio n. 36
0
 def tearDown(self):
     if self.driver:
         self.page.close()
         self.page.quit()
     # XXX: This should not be there but AP hangs
     # if we dont extra force the process to be killed
     # (although AP already tries to kill part of its teardown)
     if platform.model() == 'Desktop' \
        and self.app_proxy \
        and self.app_proxy.process:
         self.app_proxy.process.kill()
     super(HTML5TestCaseBase, self).tearDown()
Esempio n. 37
0
def get_pointing_device():
    """Return the pointing device depending on the platform.

    If the platform is `Desktop`, the pointing device will be a `Mouse`.
    If not, the pointing device will be `Touch`.

    """
    if platform.model() == 'Desktop':
        input_device_class = input.Mouse
    else:
        input_device_class = input.Touch
    return input.Pointer(device=input_device_class.create())
Esempio n. 38
0
 def _open_context_menu(self, webview):
     gr = webview.globalRect
     x = gr.x + webview.width // 2
     y = gr.y + webview.height // 2
     self.pointing_device.move(x, y)
     if model() == 'Desktop':
         self.pointing_device.click(button=3)
     else:
         self.pointing_device.press()
         time.sleep(1.5)
         self.pointing_device.release()
     return self._get_context_menu()
 def tearDown(self):
     if self.driver:
         self.page.close()
         self.page.quit()
     # XXX: This should not be there but AP hangs
     # if we dont extra force the process to be killed
     # (although AP already tries to kill part of its teardown)
     if platform.model() == 'Desktop' \
        and self.app_proxy \
        and self.app_proxy.process:
         self.app_proxy.process.kill()
     super(HTML5TestCaseBase, self).tearDown()
Esempio n. 40
0
 def launch_test_installed(self):
     if model() == 'Desktop':
         return self.launch_test_application(
             "webbrowser-app",
             *self.ARGS,
             emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
     else:
         return self.launch_test_application(
             "webbrowser-app",
             self.d_f,
             *self.ARGS,
             app_type='qt',
             emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
Esempio n. 41
0
 def launch_test_installed(self):
     if model() == 'Desktop':
         return self.launch_test_application(
             "webbrowser-app",
             *self.ARGS,
             emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
     else:
         return self.launch_test_application(
             "webbrowser-app",
             self.d_f,
             *self.ARGS,
             app_type='qt',
             emulator_base=uitk.UbuntuUIToolkitCustomProxyObjectBase)
Esempio n. 42
0
    def launch_unity(self, mode="full-greeter", *args):
        """
            Launch the unity shell, return a proxy object for it.

        :param str mode: The type of greeter/shell mode to use
        :param args: A list of aguments to pass to unity8

        """
        binary_path = get_binary_path()
        lib_path = get_lib_path()

        logger.info(
            "Lib path is '%s', binary path is '%s'",
            lib_path,
            binary_path
        )

        self.patch_lightdm_mock()

        if self._qml_mock_enabled:
            self._environment['QML2_IMPORT_PATH'] = (
                get_qml_import_path_with_mock()
            )

        if self._data_dirs_mock_enabled:
            self._patch_data_dirs()

        unity8_cli_args_list = ["--mode={}".format(mode)]
        if len(args) != 0:
            unity8_cli_args_list += args

        app_proxy = self._launch_unity_with_upstart(
            binary_path,
            self.unity_geometry_args + unity8_cli_args_list
        )

        self._set_proxy(app_proxy)

        # Ensure that the dash is visible before we return:
        logger.debug("Unity started, waiting for it to be ready.")
        self.wait_for_unity()
        logger.debug("Unity loaded and ready.")

        if model() == 'Desktop':
            # On desktop, close the dash because it's opened in a separate
            # window and it gets in the way.
            process_helpers.stop_job('unity8-dash')

        return app_proxy
 def test_adding_a_video(self):
     if model() == "Desktop":
         before = self.events_view.get_event(0)
         video_file = "video.mp4"
         shutil.copyfile(self.sample_dir+"/option01/"+video_file,
                         self.sample_destination_dir+"/"+video_file)
         video_file = "video.mkv"
         shutil.copyfile(self.sample_dir+"/option01/"+video_file,
                         self.sample_destination_dir+"/"+video_file)
         after = self.events_view.get_event(0)
         self.assertThat(lambda: str(after),
                         Eventually(NotEquals(str(before))))
         self.assertThat(
             lambda: self.events_view.number_of_photos_in_events(),
             Eventually(Equals(4)))
Esempio n. 44
0
    def _get_environment_launch_type(self):
        """Returns the type of the environment in which to setup and launch
        gallery-app.

        """
        # Lets assume we are installed system wide if this file is somewhere
        # in /usr
        if os.path.realpath(__file__).startswith("/usr/"):
            return EnvironmentTypes.installed
        if model() == 'Desktop':
            return EnvironmentTypes.installed
        else:
            if os.path.exists(self.local_location):
                return EnvironmentTypes.local
            else:
                return EnvironmentTypes.click
    def setUp(self):
        self.ARGS = []

        self.envDesktopMode = env.get("DESKTOP_MODE")

        if model() == "Desktop":
            env["DESKTOP_MODE"] = "1"
        else:
            env["DESKTOP_MODE"] = "0"

        # This is needed to wait for the application to start.
        # In the testfarm, the application may take some time to show up.
        super(TestEventsView, self).setUp()
        self.main_view.switch_to_tab("eventsTab")
        """Wait for the data to be loaded and displayed"""
        self.assertThat(lambda: self.events_view.number_of_events(),
                        Eventually(GreaterThan(0)))
Esempio n. 46
0
 def setUp(self):
     self.driver = None
     self.app_proxy = None
     super().setUp()
     if platform.model() == 'Desktop':
         self.patch_environment(
             'UBUNTU_WEBVIEW_DEVTOOLS_HOST',
             DEFAULT_WEBVIEW_INSPECTOR_IP)
         self.patch_environment(
             'UBUNTU_WEBVIEW_DEVTOOLS_PORT',
             str(DEFAULT_WEBVIEW_INSPECTOR_PORT))
     else:
         self.useFixture(fixture_setup.InitctlEnvironmentVariable(
             global_=True,
             UBUNTU_WEBVIEW_DEVTOOLS_HOST=DEFAULT_WEBVIEW_INSPECTOR_IP,
             UBUNTU_WEBVIEW_DEVTOOLS_PORT=str(
                 DEFAULT_WEBVIEW_INSPECTOR_PORT)
         ))
 def setUp(self):
     super(TestSelection, self).setUp()
     url = self.base_url + "/selection"
     self.main_window.go_to_url(url)
     self.main_window.wait_until_page_loaded(url)
     webview = self.main_window.get_current_webview()
     self.pointing_device.move_to_object(webview)
     if model() == 'Desktop':
         self.pointing_device.click(button=3)
     else:
         self.pointing_device.press()
         time.sleep(1.5)
         self.pointing_device.release()
     self.selection = self.main_window.get_selection()
     self.rectangle = self.selection.get_rectangle()
     self.assertThat(self.rectangle.width, LessThan(webview.width))
     self.assertThat(self.rectangle.height, LessThan(webview.height))
     self.actions = self.main_window.get_selection_actions()
     self.assertThat(len(self.actions.select_many("Empty")), Equals(1))
    def test_reset_browser_settings(self):
        settings = self.open_settings()
        reset = settings.get_reset_settings_entry()
        self.pointing_device.click_object(reset)

        searchengine = settings.get_searchengine_entry()
        self.assertThat(searchengine.subText,
                        Eventually(Equals("Google")))

        homepage = settings.get_homepage_entry()
        self.assertThat(homepage.subText,
                        Eventually(Equals("http://start.ubuntu.com")))

        restore_session = settings.get_restore_session_entry()
        checkbox = restore_session.select_single(uitk.CheckBox)
        self.assertThat(checkbox.checked, Eventually(Equals(True)))

        background_tabs = settings.get_background_tabs_entry()
        checkbox = background_tabs.select_single(uitk.CheckBox)
        self.assertThat(checkbox.checked,
                        Eventually(Equals(model() == 'Desktop')))
Esempio n. 49
0
    def setUp(self):
        super(ClickAppTestCase, self).setUp()
        self.pointing_device = input.Pointer(self.input_device_class.create())

        #backup and wipe db's before testing
        self.temp_move_sqlite_db()
        self.addCleanup(self.restore_sqlite_db)

        #turn off the OSK so it doesn't block screen elements
        if model() != 'Desktop':
            os.system("stop maliit-server")
            # adding cleanup step seems to restart
            # service immediately; disabling for now
            # self.addCleanup(os.system("start maliit-server"))

        if os.path.exists(self.local_location):
            self.launch_test_local()
        elif os.path.exists(self.installed_location):
            self.launch_test_installed()
        else:
            self.launch_test_click()
Esempio n. 50
0
 def launch_test_installed(self):
     if model() == 'Desktop':
         logger.debug(
             "Launching installed gallery-app binary for desktop."
         )
         self.ARGS.append(self.sample_destination_dir)
         self.app = self.launch_test_application(
             "gallery-app",
             *self.ARGS,
             emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
     else:
         logger.debug(
             "Launching installed gallery-app binary for device."
         )
         self.ARGS.append("--desktop_file_hint="
                          "/usr/share/applications/gallery-app.desktop")
         self.ARGS.append(self.sample_destination_dir)
         self.app = self.launch_test_application(
             "gallery-app",
             *self.ARGS,
             app_type='qt',
             emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
Esempio n. 51
0
    def open_new_tab(self):
        if (self.main_window.incognito):
            count = len(self.main_window.get_incognito_webviews())
        else:
            count = len(self.main_window.get_webviews())

        # assumes the tabs view is already open
        tabs_view = self.main_window.get_tabs_view()
        self.main_window.get_recent_view_toolbar().click_action("newTabButton")
        tabs_view.visible.wait_for(False)
        max_webviews = self.main_window.maxLiveWebviews
        new_count = (count + 1) if (count < max_webviews) else max_webviews
        if (self.main_window.incognito):
            self.assert_number_incognito_webviews_eventually(new_count)
            new_tab_view = self.main_window.get_new_private_tab_view()
        else:
            self.assert_number_webviews_eventually(new_count)
            new_tab_view = self.main_window.get_new_tab_view()
        if model() == 'Desktop':
            self.assertThat(
                self.main_window.address_bar.activeFocus,
                Eventually(Equals(True)))
        return new_tab_view
Esempio n. 52
0
 def launch_application(self):
     if platform.model() == 'Desktop':
         self._launch_application_from_desktop()
     else:
         self._launch_application_from_phablet()
Esempio n. 53
0
 def setUp(self):
     if platform.model() == 'Desktop':
         self.skipTest('Test cannot be run on the desktop.')
     super().setUp()
 def test_camera_button_visible(self):
     cameraButtonVisible = self.check_header_button_exist("cameraButton")
     if model() == "Desktop":
         self.assertThat(cameraButtonVisible, Equals(False))
     else:
         self.assertThat(cameraButtonVisible, Equals(True))
Esempio n. 55
0
 def setUpClass(cls):
     # FIXME: This is a work around re: lp:1238417 ####
     if model() != "Desktop":
         from autopilot.input import _uinput
         _uinput._touch_device = _uinput.create_touch_device()
Esempio n. 56
0
 def setUp(self):
     if model() == "Desktop":
         self.skipTest("Ubuntu Keyboard tests only run on device.")
     super(UbuntuKeyboardTests, self).setUp()
     self.pointer = Pointer(Touch.create())
            ("http://www.rsc.org/periodic-table/element/77/iridium",
             "Iridium - Element Information")
        ]

        for i, row in enumerate(rows):
            timestamp = int(time.time()) - i * 10
            query = "INSERT INTO bookmarks \
                     VALUES ('{}', '{}', '', {});"
            query = query.format(row[0], row[1], timestamp)
            connection.execute(query)

        connection.commit()
        connection.close()


@testtools.skipIf(model() != "Desktop", "on desktop only")
class TestKeyboard(PrepopulatedDatabaseTestCaseBase):

    """Test keyboard interaction"""

    def setUp(self):
        super(TestKeyboard, self).setUp()
        self.address_bar = self.main_window.address_bar

    def open_tab(self, url):
        self.main_window.press_key('Ctrl+T')
        new_tab_view = self.main_window.get_new_tab_view()
        self.address_bar.go_to_url(url)
        new_tab_view.wait_until_destroyed()
        self.assertThat(lambda: self.main_window.get_current_webview().url,
                        Eventually(Equals(url)))
 def setUp(self):
     if platform.model() == 'Desktop':
         self.skipTest("URL dispatcher doesn't work on the desktop.")
     super().setUp()
Esempio n. 59
0
 def setUp(self):
     if model() == 'Desktop':
         self.skipTest('Test cannot be run on the desktop.')
     super().setUp()
     self._qml_mock_enabled = False
     self._data_dirs_mock_enabled = False