[Merge] lp:~canonical-platform-qa/ubuntu-keyboard/fix-1467449-autopilot-key-names into lp:ubuntu-keyboard

Sergio Cazzolato sergio.cazzolato at canonical.com
Fri Jun 26 16:52:00 UTC 2015


Review: Needs Information

Minor comment

Diff comments:

> === modified file 'tests/autopilot/ubuntu_keyboard/emulators/keyboard.py'
> --- tests/autopilot/ubuntu_keyboard/emulators/keyboard.py	2015-06-02 10:22:09 +0000
> +++ tests/autopilot/ubuntu_keyboard/emulators/keyboard.py	2015-06-26 09:09:40 +0000
> @@ -52,6 +52,10 @@
>          '?123': 'symbols',
>          ' ': 'space',
>          '\n': 'return',
> +        'Enter': 'return',
> +        'Backspace': 'backspace',
> +        'Space': 'space',
> +        'Shift': 'shift',
>      }
>  
>      __maliit = None
> @@ -227,15 +231,20 @@
>              or self._stored_active_keypad_name != self._current_keypad_name
>          ):
>              self._stored_active_keypad_name = self._current_keypad_name
> -            loader = self.maliit.select_single(
> -                "QQuickLoader",
> -                objectName='characterKeyPadLoader'
> -            )
>              logger.debug("Keypad lookup")
> -            self._active_keypad = loader.select_single(KeyPad)
> +            self._active_keypad = self._keypad_loader.select_single(KeyPad)
>          return self._active_keypad
>  
>      @property
> +    def _keypad_loader(self):
> +        return self.maliit.select_single(
> +            "QQuickLoader", objectName='characterKeyPadLoader')
> +
> +    @property
> +    def _plugin_source(self):
> +        return self._keypad_loader.source
> +
> +    @property
>      def _current_keypad_name(self):
>          return self._keyboard_container.state
>  
> 
> === modified file 'tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py'
> --- tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py	2015-05-29 12:23:52 +0000
> +++ tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py	2015-06-26 09:09:40 +0000
> @@ -75,7 +75,7 @@
>  
>      def launch_test_input_area(self, label="", input_hints=None):
>          self.app = self._launch_simple_input(label, input_hints)
> -        text_area = self.app.select_single("QQuickTextInput")
> +        text_area = self.app.select_single("TextArea")
>  
>          return text_area
>  
> @@ -155,11 +155,12 @@
>                  }
>              }
>  
> -            TextField {
> +            TextArea {
>                  id: input;
>                  objectName: "input"
>                  anchors.centerIn: parent
>                  inputMethodHints: %(input_method)s
> +                autoSize: true
>              }
>          }
>  
> @@ -174,7 +175,7 @@
>          keyboard = Keyboard()
>          self.addCleanup(keyboard.dismiss)
>          app = self._launch_simple_input(input_hints=['Qt.ImhNoPredictiveText'])
> -        text_rectangle = app.select_single("QQuickTextInput")
> +        text_rectangle = app.select_single("TextArea")
>  
>          self.pointer.click_object(text_rectangle)
>  
> @@ -227,6 +228,133 @@
>          self.assertThat(text_area.text, Eventually(Equals(self.input)))
>  
>  
> +class UbuntuKeyboardKeyMappingTests(UbuntuKeyboardTests):
> +
> +    scenarios = [
> +        (
> +            'backspace',
> +            dict(
> +                starting_text='Start text',
> +                input_sequence=['Backspace', '\b', 'backspace'],
> +                expected_text=['Start tex', 'Start te', 'Start t']
> +            )
> +        ),
> +        (
> +            'space',
> +            dict(
> +                starting_text='',
> +                input_sequence=['Space', ' ', 'space'],
> +                expected_text=[' ', '  ', '   ']
> +            )
> +        ),
> +        (
> +            'return',
> +            dict(
> +                starting_text='',
> +                input_sequence=['Enter', '\n', 'return'],
> +                expected_text=['\n', '\n\n', '\n\n\n']
> +            )
> +        )
> +    ]
> +
> +    def setUp(self):
> +        super().setUp()
> +        self._disable_double_space_full_stop()
> +
> +    def _disable_double_space_full_stop(self):
> +        gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
> +        gsettings.set_boolean("double-space-full-stop", False)
> +
> +    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)))
> +
> +
> +class UbuntuKeyboardStateKeyMappingTests(UbuntuKeyboardTests):
> +
> +    scenarios = [
> +        (
> +            'Shift',
> +            dict(
> +                key='Shift',
> +                expected_state=KeyPadState.SHIFTED,
> +                expected_keypad_name='CHARACTERS'
> +            )
> +        ),
> +        (
> +            'SHIFT',
> +            dict(
> +                key='SHIFT',
> +                expected_state=KeyPadState.SHIFTED,
> +                expected_keypad_name='CHARACTERS'
> +            )
> +        ),
> +        (
> +            'shift',
> +            dict(
> +                key='shift',
> +                expected_state=KeyPadState.SHIFTED,
> +                expected_keypad_name='CHARACTERS'
> +            )
> +        ),
> +        (
> +            'ABC',
> +            dict(
> +                key='ABC',
> +                expected_state=KeyPadState.NORMAL,
> +                expected_keypad_name='SYMBOLS'
> +            )
> +        ),
> +        (
> +            '?123',
> +            dict(
> +                key='?123',
> +                expected_state=KeyPadState.NORMAL,
> +                expected_keypad_name='SYMBOLS'
> +            )
> +        ),
> +        (
> +            'symbols',
> +            dict(
> +                key='symbols',
> +                expected_state=KeyPadState.NORMAL,
> +                expected_keypad_name='SYMBOLS'
> +            )
> +        )
> +    ]
> +
> +    def _assert_keypad_name_and_state(self, keyboard, name, state):
> +        self.assertThat(
> +            keyboard._current_keypad_name,
> +            Eventually(Equals(name))
> +        )
> +        self.assertThat(
> +            keyboard.active_keypad_state,
> +            Eventually(Equals(state))
> +        )
> +
> +    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)
> +
> +
>  class UbuntuKeyboardStateChanges(UbuntuKeyboardTests):
>  
>      def test_keyboard_layout_starts_shifted(self):
> @@ -897,31 +1025,47 @@
>  
>  class UbuntuKeyboardLanguageMenu(UbuntuKeyboardTests):
>  
> +    def setUp(self):
> +        super().setUp()
> +        self.gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
> +
> +    def _set_keyboard_language(self, language):
> +        self.gsettings.set_string("active-language", language)
> +
> +    def _get_keyboard_language(self):
> +        return self.gsettings.get_string("active-language")
> +
> +    def _get_plugin_path(self, language):
> +        path = ("file:///usr/share/maliit/plugins/com/ubuntu/lib/{lang}/"
> +                "Keyboard_{lang}.qml")
> +        return path.format(lang=language)
> +
>      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)
>  
> -        gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
> -        self.assertThat(
> -            gsettings.get_string("active-language"),
> -            Equals('en')
> -        )
> +        # 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")
>  
> -        sleep(5)
> -
>          self.assertThat(
> -            gsettings.get_string("active-language"),
> -            Equals('es')
> -        )
> +            keyboard._plugin_source,
> +            Eventually(Equals(self._get_plugin_path("es"))))
>  
>      def test_long_press(self):
>          """Holding down the language menu key should switch display the
> @@ -934,11 +1078,7 @@
>          keyboard = Keyboard()
>          self.addCleanup(keyboard.dismiss)
>  
> -        gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
> -        self.assertThat(
> -            gsettings.get_string("active-language"),
> -            Equals('en')
> -        )
> +        self.assertThat(self._get_keyboard_language(), Equals("en"))

is required here an eventually? or you could use an assertTrue instead

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


-- 
https://code.launchpad.net/~canonical-platform-qa/ubuntu-keyboard/fix-1467449-autopilot-key-names/+merge/262576
Your team Ubuntu Phablet Team is requested to review the proposed merge of lp:~canonical-platform-qa/ubuntu-keyboard/fix-1467449-autopilot-key-names into lp:ubuntu-keyboard.



More information about the Ubuntu-reviews mailing list