[Merge] lp:~canonical-platform-qa/ubuntu-keyboard/fix-1467449-autopilot-key-names into lp:ubuntu-keyboard
Sergio Cazzolato
sergio.cazzolato at canonical.com
Thu Jun 25 21:49:46 UTC 2015
Review: Needs Information
Some questions inline
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-24 16:39:31 +0000
> @@ -52,6 +52,10 @@
> '?123': 'symbols',
> ' ': 'space',
> '\n': 'return',
> + 'Enter': 'return',
> + 'Backspace': 'backspace',
> + 'Space': 'space',
> + 'Shift': 'shift',
> }
>
> __maliit = None
>
> === 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-24 16:39:31 +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,6 +1025,16 @@
>
> 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 test_tapping(self):
> """Tapping the language menu key should switch to the previously
> used language.
> @@ -908,20 +1046,16 @@
> 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(self._get_keyboard_language(), Equals("es"))
Why you are not using assertEqual instead?
> + sleep(1)
Is this sleep required and enough? Is any other thing to wait for instead of sleep?
> + self._set_keyboard_language("en")
> + self.assertThat(self._get_keyboard_language(), Equals("en"))
same about assertEqual
> + sleep(1)
> keyboard.press_key("language")
> -
> - sleep(5)
> -
> - self.assertThat(
> - gsettings.get_string("active-language"),
> - Equals('es')
> - )
> + sleep(1)
> + self.assertThat(self._get_keyboard_language(), Equals("es"))
Here could be used eventually instead of make an sleep?
>
> def test_long_press(self):
> """Holding down the language menu key should switch display the
> @@ -934,11 +1068,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"))
same about assertEqual
>
> 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