예제 #1
0
    def test_layouts(self):
        """Test all layout plugins in freetext, url and email mode.

        """
        text_area = self.launch_test_input_area(
            self.layout + " - " + self.expected_activeview,
            self.hints
        )
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
        gsettings.set_string("active-language", self.layout)

        self.assertThat(
            gsettings.get_string("active-language"),
            Equals(self.layout)
        )

        sleep(2)

        if self.text[-len(self.tld):] == self.tld:
            keyboard.type(self.text[:-len(self.tld)])
            keyboard.press_key(self.tld)
        else:
            keyboard.type(self.text)

        self.assertThat(
            text_area.text,
            Eventually(Equals(self.text))
        )
예제 #2
0
    def test_tapping(self):
        """Tapping the language menu key should switch to the previously
        used language.

        """
        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        # Make sure the previous language is es and the current language is en
        self._set_keyboard_language("es")
        self.assertThat(
            keyboard._plugin_source,
            Eventually(Equals(self._get_plugin_path("es"))))

        self._set_keyboard_language("en")
        self.assertThat(
            keyboard._plugin_source,
            Eventually(Equals(self._get_plugin_path("en"))))

        keyboard.press_key("language")

        self.assertThat(
            keyboard._plugin_source,
            Eventually(Equals(self._get_plugin_path("es"))))
예제 #3
0
    def test_shift_state_returns_to_default_after_letter_typed(self):
        """Pushing shift and then typing an uppercase letter must automatically
        shift the keyboard back into the default state.

        """
        text_area = self.launch_test_input_area(
            input_hints=['Qt.ImhNoPredictiveText'])
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        # Normally, type and (press_key) take care of shifting into the correct
        # state, we do it manually here as that's what we're testing.
        keyboard.type('abc')
        keyboard.press_key('SHIFT')
        keyboard.type('A')

        # Once the capital letter has been typed, we must be able to access the
        # lowercase letters, otherwise it's not in the correct state.
        self.assertThat(
            keyboard.active_keypad_state,
            Eventually(Equals(KeyPadState.NORMAL))
        )

        self.assertThat(text_area.text, Eventually(Equals('abcA')))
예제 #4
0
    def test_keyboard_layout(self):
        """The Keyboard must respond to the input type and change to be the
        correct state.

        """
        text_area = self.launch_test_input_area(self.label, self.hints)
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        self.assertThat(
            keyboard.keyboard.layoutId,
            Eventually(Equals(self.expected_activeview))
        )

        if self.text[-4:] == ".com":
            keyboard.type(self.text[:-4])
            keyboard.press_key(".com")
        else:
            keyboard.type(self.text)

        self.assertThat(
            text_area.text,
            Eventually(Equals(self.text))
        )
예제 #5
0
    def test_shift_latch(self):
        """Double tap of the shift key must lock it 'On' until the shift key
        tapped again.

        Normally hitting shift then a letter reverts from the shifted state
        back to the default. If double clicked it should stay in the shifted
        until the shift key is clicked again.

        """
        self.skip(
            "Skipping due to bug in emulator: lp:1237846"
        )

        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.type('abc')
        # Bug lp:1229003 and lp:1229001
        sleep(.2)
        keyboard.press_key('shift')
        keyboard.press_key('shift')

        self.assertThat(
            keyboard.active_keypad_state,
            Eventually(Equals(KeyPadState.CAPSLOCK))
        )
예제 #6
0
    def test_can_type_using_key_mapping(self):
        text_area = self.launch_test_input_area(
            input_hints=['Qt.ImhNoPredictiveText'])
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.type(self.starting_text)
        for key, result in zip(self.input_sequence, self.expected_text):
            keyboard.press_key(key)
            self.assertThat(text_area.text, Eventually(Equals(result)))
예제 #7
0
 def test_can_type_using_state_key_mapping(self):
     text_area = self.launch_test_input_area(
         input_hints=['Qt.ImhNoPredictiveText', 'Qt.ImhNoAutoUppercase'])
     self.ensure_focus_on_input(text_area)
     keyboard = Keyboard()
     self.addCleanup(keyboard.dismiss)
     self._assert_keypad_name_and_state(keyboard,
                                        'CHARACTERS', KeyPadState.NORMAL)
     keyboard.press_key(self.key)
     self._assert_keypad_name_and_state(keyboard,
                                        self.expected_keypad_name,
                                        self.expected_state)
예제 #8
0
    def test_long_press(self):
        """Long pressing a key should enter the default extended character.

        """
        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.press_key('t', long_press=True)

        expected = "5"
        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )
예제 #9
0
    def test_typing(self):
        """Test that typing works using a plugin loaded from a custom location.

        """
        text_area = self.launch_test_input_area(
            input_hints=['Qt.ImhNoPredictiveText'])
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        # The test layout has a single key that enters the word 'Test'
        keyboard.press_key("Test")

        expected = "Test"
        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )
예제 #10
0
    def test_japanese_input(self):
        """Test top level keys on Japanese layout.

        """
        text_area = self.launch_test_input_area(
            input_hints=['Qt.ImhNoPredictiveText'])
        self.pointer.click_object(text_area)
        keyboard = Keyboard()
        self.assertThat(keyboard.is_available, Eventually(Equals(True)))

        text = "あかさたなはまやら"
        keyboard.type(text)
        keyboard.press_key('\n')

        self.assertThat(
            text_area.text,
            Eventually(Equals(text))
        )
예제 #11
0
    def test_emoji_input(self):
        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.press_key("language")

        sleep(5)

        keyboard = Keyboard()

        keyboard.type('😁😆😃😏')

        expected = "😁😆😃😏"
        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )
예제 #12
0
    def test_repeated_long_press(self):
        """The default key should stay in the middle after each long press.

        """

        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.press_key('u', long_press=True)
        keyboard.press_key('u', long_press=True)
        keyboard.press_key('u', long_press=True)

        expected = "777"
        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )
예제 #13
0
    def test_switching_with_preedit(self):
        """Switching languages whilst text is in preedit should result in
        that text being committed.

        """
        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.type('Hello')

        keyboard.press_key("language")

        expected = 'Hello'
        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )
예제 #14
0
    def test_emoji_deletion(self):
        """Emoji characters should be deleted completely, despite being made up
           of multiple bytes.

        """
        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.press_key("language")

        sleep(5)

        keyboard = Keyboard()

        keyboard.type('😁😆😃😏\b')

        expected = "😁😆😃"
        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )
예제 #15
0
    def test_long_press(self):
        """Holding down the language menu key should switch display the
        language switcher menu.

        """

        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        self.assertThat(self._get_keyboard_language(), Equals("en"))

        keyboard.press_key("language", long_press=True)

        menu = keyboard.maliit.select_single("LanguageMenu")

        self.assertThat(
            menu.visible,
            Eventually(Equals(True))
        )

        keyboard.press_key("language")
예제 #16
0
    def test_shift_latch(self):
        """Double tap of the shift key must lock it 'On' until the shift key
        tapped again.

        Normally hitting shift then a letter reverts from the shifted state
        back to the default. If double clicked it should stay in the shifted
        until the shift key is clicked again.

        """
        text_area = self.launch_test_input_area(
            input_hints=['Qt.ImhNoPredictiveText'])
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.type('abc')
        keyboard.press_key('shift')
        keyboard.press_key('shift', True)

        self.assertThat(
            keyboard.active_keypad_state,
            Eventually(Equals(KeyPadState.CAPSLOCK))
        )
예제 #17
0
    def test_capslock_stays_on(self):
        """Capslock should remain on when typing text.

        """
        text_area = self.launch_test_input_area(
            input_hints=['Qt.ImhNoPredictiveText'])
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

        keyboard.press_key('shift')
        keyboard.press_key('shift', True)
        keyboard.press_key('A', True)
        keyboard.press_key('B', True)
        keyboard.press_key('C', True)

        self.assertThat(
            keyboard.active_keypad_state,
            Eventually(Equals(KeyPadState.CAPSLOCK))
        )
예제 #18
0
    def test_japanese_flick(self):
        """Test pop-up flick input characters.

        """
        # centre: あ, up: う, down: お, left: い, right: え
        text_area = self.launch_test_input_area(
            input_hints=['Qt.ImhNoPredictiveText'])
        self.pointer.click_object(text_area)
        keyboard = Keyboard()
        self.assertThat(keyboard.is_available, Eventually(Equals(True)))

        gu = float(os.environ.get('GRID_UNIT_PX', 8))
        keyboard.press_key('あ', slide_offset=4 * gu)
        keyboard.press_key('あ', slide_offset=-4 * gu)
        keyboard.press_key('\n')

        expected = "えい"

        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )
예제 #19
0
    def test_extended_punctuation(self):
        """The characters -_!?+%#/ and ";:'@&() should be available as
        extended keys from the . and , keys.

        """

        text_area = self.launch_test_input_area()
        self.ensure_focus_on_input(text_area)
        keyboard = Keyboard()
        self.addCleanup(keyboard.dismiss)

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

        # The extended key positions aren't accessible until the
        # drag has already started, so we need to provide their
        # offsets manually based on the known extended key cell
        # width
        keyboard.press_key('.', slide_offset=-17.5 * gu)
        keyboard.press_key('.', slide_offset=-14 * gu)
        keyboard.press_key('.', slide_offset=-10.5 * gu)
        keyboard.press_key('.', slide_offset=-7.5 * gu)
        keyboard.press_key('.', slide_offset=-3.5 * gu)
        keyboard.press_key('.', slide_offset=1)
        keyboard.press_key('.', slide_offset=3.5 * gu)
        keyboard.press_key('.', slide_offset=7 * gu)

        keyboard.press_key(',', slide_offset=-10.5 * gu)
        keyboard.press_key(',', slide_offset=-7 * gu)
        keyboard.press_key(',', slide_offset=-3.5 * gu)
        keyboard.press_key(',', slide_offset=-1 * gu)
        keyboard.press_key(',', slide_offset=3.5 * gu)
        keyboard.press_key(',', slide_offset=7 * gu)
        keyboard.press_key(',', slide_offset=10.5 * gu)
        keyboard.press_key(',', slide_offset=14 * gu)

        expected = "-_!?+%#/\";:'@&()"
        self.assertThat(
            text_area.text,
            Eventually(Equals(expected))
        )