Пример #1
0
    def __init__(self, pointer=None):
        try:
            self.keyboard = self.maliit.select_single(
                "QQuickItem",
                objectName="ubuntuKeyboard"
            )
        except ValueError as e:
            e.args += (
                "There was more than one Keyboard object found, aborting.",
            )
            raise
        except StateNotFoundError:
            logger.error(
                "Unable to find the Ubuntu Keyboard object within the "
                "maliit server, aborting."
            )
            raise

        self._keyboard_container = self.keyboard.select_single(
            "KeyboardContainer"
        )

        self._stored_active_keypad_name = None
        self._active_keypad = None

        self._keys_position = defaultdict(dict)
        self._keys_contained = defaultdict(dict)

        if pointer is None:
            self.pointer = Pointer(Touch.create())
        else:
            self.pointer = pointer
Пример #2
0
    def __init__(self, pointer=None):
        try:
            self.keyboard = self.maliit.select_single(
                "QQuickItem", objectName="lomiriKeyboard")
        except ValueError as e:
            e.args += (
                "There was more than one Keyboard object found, aborting.", )
            raise
        except StateNotFoundError:
            logger.error(
                "Unable to find the Lomiri Keyboard object within the "
                "maliit server, aborting.")
            raise

        self._keyboard_container = self.keyboard.select_single(
            "KeyboardContainer")

        self._stored_active_keypad_name = None
        self._active_keypad = None

        self._keys_position = defaultdict(dict)
        self._keys_contained = defaultdict(dict)

        if pointer is None:
            self.pointer = Pointer(Touch.create())
        else:
            self.pointer = pointer
Пример #3
0
 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())
Пример #4
0
 def _long_press_key(self, key_rect, pointer=None):
     if pointer is None:
         pointer = Pointer(Touch.create())
     pointer.move(key_rect.x + key_rect.w / 2.0,
                  key_rect.y + key_rect.h / 2.0)
     pointer.press()
     sleep(0.5)
     pointer.release()
Пример #5
0
 def _long_press_key(self, key_rect, pointer=None):
     if pointer is None:
         pointer = Pointer(Touch.create())
     pointer.move(
         key_rect.x + key_rect.w / 2.0, key_rect.y + key_rect.h / 2.0)
     pointer.press()
     sleep(0.5)
     pointer.release()
Пример #6
0
    def setUp(self):
        super(TouchTests, self).setUp()
        self.device = Touch.create()

        self.app = self.start_mock_app()
        self.widget = self.app.select_single('MouseTestWidget')
        self.button_status = self.app.select_single(
            'QLabel', objectName='button_status')
Пример #7
0
    def test_hiding(self):
        """Verify that the keyboard remains hidden after being dismissed from
        a field that is no longer enabled.

        """
        qml = dedent("""
        import QtQuick 2.4
        import Ubuntu.Components 1.1
        import Ubuntu.Web 0.2

        Rectangle {
            id: window
            objectName: "windowRectangle"
            color: "lightgrey"

            WebView {
                anchors.fill: parent
                objectName: "webview"
                Component.onCompleted: {
                    loadHtml("
                        <html><body><div id='scroll' style='width: 100%;
                        height: 200%; position: absolute; background: green;
                        visibility: hidden;'></div><input id='input'
                        style='height: 50%; width: 100%' type='text'
                        onkeyup=\\\"if (event.keyCode == 13)
                        {document.getElementById('input').disabled=true;
                        document.getElementById('scroll').style.visibility=
                        'visible';}\\\" style='width: 100%%;
                        height: 100%%;' /></body></html>");
                }
            }
        }

        """)
        app = self._start_qml_script(qml)
        webview = app.select_single(objectName='webview')

        self.ensure_focus_on_input(webview)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.type('Test\n')

        keyboard.dismiss()

        pointer = Pointer(Touch.create())
        pointer.drag(
            webview.width / 2.0,
            webview.height / 2.0,
            webview.width / 2.0,
            webview.height / 2.0 + 100
        )

        self.assertThat(
            keyboard.is_available,
            Eventually(Equals(False))
        )
Пример #8
0
def pinch(center, vector_start, vector_end):
    """Perform a two finger pinch (zoom) gesture.

    :param center: The coordinates (x,y) of the center of the pinch gesture.
    :param vector_start: The (x,y) values to move away from the center for the
     start.
    :param vector_end: The (x,y) values to move away from the center for the
     end.

    The fingers will move in 100 steps between the start and the end points.
    If start is smaller than end, the gesture will zoom in, otherwise it
    will zoom out.

    """

    finger_1_start = [center[0] - vector_start[0], center[1] - vector_start[1]]
    finger_2_start = [center[0] + vector_start[0], center[1] + vector_start[1]]
    finger_1_end = [center[0] - vector_end[0], center[1] - vector_end[1]]
    finger_2_end = [center[0] + vector_end[0], center[1] + vector_end[1]]

    dx = 1.0 * (finger_1_end[0] - finger_1_start[0]) / 100
    dy = 1.0 * (finger_1_end[1] - finger_1_start[1]) / 100

    finger_1 = Touch.create()
    finger_2 = Touch.create()

    finger_1.press(*finger_1_start)
    finger_2.press(*finger_2_start)

    finger_1_cur = [finger_1_start[0] + dx, finger_1_start[1] + dy]
    finger_2_cur = [finger_2_start[0] - dx, finger_2_start[1] - dy]

    for i in range(0, 100):
        finger_1.move(*finger_1_cur)
        finger_2.move(*finger_2_cur)
        sleep(0.005)

        finger_1_cur = [finger_1_cur[0] + dx, finger_1_cur[1] + dy]
        finger_2_cur = [finger_2_cur[0] - dx, finger_2_cur[1] - dy]

    finger_1.move(*finger_1_end)
    finger_2.move(*finger_2_end)
    finger_1.release()
    finger_2.release()
Пример #9
0
    def _select_extended_key(self, key_rect, offset, pointer=None):
        if pointer is None:
            pointer = Pointer(Touch.create())

        gu = float(os.environ.get('GRID_UNIT_PX', 8))

        pointer.drag(key_rect.x + key_rect.w / 2.0,
                     key_rect.y + key_rect.h / 2.0,
                     key_rect.x + key_rect.w / 2.0 + offset,
                     key_rect.y + key_rect.h / 2.0,
                     rate=2.77 * gu,
                     time_between_events=2)
Пример #10
0
    def _select_extended_key(self, key_rect, offset, pointer=None):
        if pointer is None:
            pointer = Pointer(Touch.create())

        gu = float(os.environ.get('GRID_UNIT_PX', 8))

        pointer.drag(
            key_rect.x + key_rect.w / 2.0,
            key_rect.y + key_rect.h / 2.0,
            key_rect.x + key_rect.w / 2.0 + offset,
            key_rect.y + key_rect.h / 2.0,
            rate=2.77 * gu, time_between_events=2)
Пример #11
0
    def test_can_type_string(self):
        """Typing text must produce the expected characters in the input
        field.

        """

        text_area = self.launch_test_input_area()
        keyboard = Keyboard.create('OSK')
        pointer = Pointer(Touch.create())
        pointer.click_object(text_area)
        keyboard._keyboard.wait_for_keyboard_ready()

        keyboard.type(self.input)

        self.assertThat(text_area.text, Eventually(Equals(self.input)))
Пример #12
0
    def setUp(self):
        self.setup_base_path()
        if platform.model() == "Desktop":
            self.pointer = Pointer(Mouse.create())
        else:
            self.pointer = Pointer(Touch.create())

        params = [self.BROWSER_QML_APP_LAUNCHER,
                  self.get_browser_container_path()]
        if (platform.model() != 'Desktop'):
            params.append(
                '--desktop_file_hint=/usr/share/" \
                + "applications/unitywebappsqmllauncher.desktop')

        self.app = self.launch_test_application(
            *params,
            app_type='qt')

        self.webviewContainer = self.get_webviewContainer()
        self.watcher = self.webviewContainer.watch_signal(
            'resultUpdated(QString)')
        super(UbuntuHTML5TestCaseBase, self).setUp()
Пример #13
0
 def setUp(self):
     super(GottenGeographyTestCase, self).setUp()
     self.pointer = Pointer(Touch.create())
     self.app = self.launch_gg()
     self.main_window = self.get_widget('GtkApplicationWindow')
Пример #14
0
 def setUp(self):
     super(GottenGeographyTestCase, self).setUp()
     self.pointer = Pointer(Touch.create())
     self.app = self.launch_gg()
     self.main_window = self.get_widget('GtkApplicationWindow')
Пример #15
0
 def _tap_key(self, key_rect, pointer=None):
     if pointer is None:
         pointer = Pointer(Touch.create())
     pointer.click_object(key_rect)
Пример #16
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())
Пример #17
0
 def _tap_key(self, key_rect, pointer=None):
     if pointer is None:
         pointer = Pointer(Touch.create())
     pointer.click_object(key_rect)
Пример #18
0
    def test_can_move_touch_wrapper(self):
        device = Pointer(Touch.create())
        device.move(34, 56)

        self.assertThat(device.x, Equals(34))
        self.assertThat(device.y, Equals(56))