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

Proposed by Richard Huddie on 2015-06-22
Status: Merged
Approved by: Michael Sheldon on 2015-06-29
Approved revision: 387
Merged at revision: 384
Proposed branch: lp:~canonical-platform-qa/ubuntu-keyboard/fix-1467449-autopilot-key-names
Merge into: lp:ubuntu-keyboard
Diff against target: 281 lines (+173/-24)
2 files modified
tests/autopilot/ubuntu_keyboard/emulators/keyboard.py (+14/-5)
tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py (+159/-19)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-keyboard/fix-1467449-autopilot-key-names
Reviewer Review Type Date Requested Status
Michael Sheldon (community) 2015-06-25 Approve on 2015-06-29
Sergio Cazzolato (community) Approve on 2015-06-26
PS Jenkins bot continuous-integration Approve on 2015-06-26
Christopher Lee (community) 2015-06-22 Approve on 2015-06-24
Ubuntu Phablet Team 2015-06-22 Pending
Review via email: mp+262576@code.launchpad.net

Commit Message

Add additional aliases for the action keys of the OSK used by the autopilot helpers.

Description of the Change

Add additional aliases for the action keys of the OSK used by the autopilot helpers. This is to improve compatibility with the simulated keyboard.

New autopilot tests are added to test the key mappings and an existing un-reliable test has been updated to make it reliable and give a clean Jenkins run.

    Are there any related MPs required for this MP to build/function as expected? Please list.
        No.

    Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
        Yes.
    Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
        Yes, new autopilot tests added.

    Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
        Yes, all autopilot tests running and passing on device and jenkins.
    If you changed the UI, was the change specified/approved by design?
        No UI changes. Only autopilot changes.
    If you changed UI labels, did you update the pot file?
        No UI changes. Only autopilot changes.
    If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
        No packaging changes.

To post a comment you must log in.
Christopher Lee (veebers) wrote :

Can you add a test for the new button mappings please, probably something in UbuntuKeyboardTypingTests.

review: Needs Fixing
384. By Richard Huddie on 2015-06-24

Add new tests for key mappings. Also change TextField to TextArea to allow Return characters to be entered.

Richard Huddie (rhuddie) wrote :

I've added some new tests which test the custom key mappings. This also required me to change the TextField to a multi-line TextArea, so that Return characters could be entered.

385. By Richard Huddie on 2015-06-24

Make the TextArea autosize, so the default is a single line.

386. By Richard Huddie on 2015-06-24

Fix for unreliable ubuntu_keyboard.tests.test_keyboard.UbuntuKeyboardLanguageMenu.test_tapping

Christopher Lee (veebers) wrote :

Looking good, good fix. Thanks for sorting out the tests.

review: Approve

Some questions inline

review: Needs Information
387. By Richard Huddie on 2015-06-26

Fix review comments. Wait for plugin path to change after changing language rather than using sleep.

Richard Huddie (rhuddie) wrote :

Thanks Sergio, I've made updates to remove the sleeps, it will now wait for the keyboard plugin path to update instead.

Minor comment

review: Needs Information
Richard Huddie (rhuddie) wrote :

Replied to comment inline.

review: Approve
Michael Sheldon (michael-sheldon) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?

 * Yes (ran autopilot tests on mako)

Did CI run pass? If not, please explain why.

 * Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?

 * Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntu_keyboard/emulators/keyboard.py'
2--- tests/autopilot/ubuntu_keyboard/emulators/keyboard.py 2015-06-02 10:22:09 +0000
3+++ tests/autopilot/ubuntu_keyboard/emulators/keyboard.py 2015-06-26 09:09:40 +0000
4@@ -52,6 +52,10 @@
5 '?123': 'symbols',
6 ' ': 'space',
7 '\n': 'return',
8+ 'Enter': 'return',
9+ 'Backspace': 'backspace',
10+ 'Space': 'space',
11+ 'Shift': 'shift',
12 }
13
14 __maliit = None
15@@ -227,15 +231,20 @@
16 or self._stored_active_keypad_name != self._current_keypad_name
17 ):
18 self._stored_active_keypad_name = self._current_keypad_name
19- loader = self.maliit.select_single(
20- "QQuickLoader",
21- objectName='characterKeyPadLoader'
22- )
23 logger.debug("Keypad lookup")
24- self._active_keypad = loader.select_single(KeyPad)
25+ self._active_keypad = self._keypad_loader.select_single(KeyPad)
26 return self._active_keypad
27
28 @property
29+ def _keypad_loader(self):
30+ return self.maliit.select_single(
31+ "QQuickLoader", objectName='characterKeyPadLoader')
32+
33+ @property
34+ def _plugin_source(self):
35+ return self._keypad_loader.source
36+
37+ @property
38 def _current_keypad_name(self):
39 return self._keyboard_container.state
40
41
42=== modified file 'tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py'
43--- tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-05-29 12:23:52 +0000
44+++ tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-06-26 09:09:40 +0000
45@@ -75,7 +75,7 @@
46
47 def launch_test_input_area(self, label="", input_hints=None):
48 self.app = self._launch_simple_input(label, input_hints)
49- text_area = self.app.select_single("QQuickTextInput")
50+ text_area = self.app.select_single("TextArea")
51
52 return text_area
53
54@@ -155,11 +155,12 @@
55 }
56 }
57
58- TextField {
59+ TextArea {
60 id: input;
61 objectName: "input"
62 anchors.centerIn: parent
63 inputMethodHints: %(input_method)s
64+ autoSize: true
65 }
66 }
67
68@@ -174,7 +175,7 @@
69 keyboard = Keyboard()
70 self.addCleanup(keyboard.dismiss)
71 app = self._launch_simple_input(input_hints=['Qt.ImhNoPredictiveText'])
72- text_rectangle = app.select_single("QQuickTextInput")
73+ text_rectangle = app.select_single("TextArea")
74
75 self.pointer.click_object(text_rectangle)
76
77@@ -227,6 +228,133 @@
78 self.assertThat(text_area.text, Eventually(Equals(self.input)))
79
80
81+class UbuntuKeyboardKeyMappingTests(UbuntuKeyboardTests):
82+
83+ scenarios = [
84+ (
85+ 'backspace',
86+ dict(
87+ starting_text='Start text',
88+ input_sequence=['Backspace', '\b', 'backspace'],
89+ expected_text=['Start tex', 'Start te', 'Start t']
90+ )
91+ ),
92+ (
93+ 'space',
94+ dict(
95+ starting_text='',
96+ input_sequence=['Space', ' ', 'space'],
97+ expected_text=[' ', ' ', ' ']
98+ )
99+ ),
100+ (
101+ 'return',
102+ dict(
103+ starting_text='',
104+ input_sequence=['Enter', '\n', 'return'],
105+ expected_text=['\n', '\n\n', '\n\n\n']
106+ )
107+ )
108+ ]
109+
110+ def setUp(self):
111+ super().setUp()
112+ self._disable_double_space_full_stop()
113+
114+ def _disable_double_space_full_stop(self):
115+ gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
116+ gsettings.set_boolean("double-space-full-stop", False)
117+
118+ def test_can_type_using_key_mapping(self):
119+ text_area = self.launch_test_input_area(
120+ input_hints=['Qt.ImhNoPredictiveText'])
121+ self.ensure_focus_on_input(text_area)
122+ keyboard = Keyboard()
123+ self.addCleanup(keyboard.dismiss)
124+
125+ keyboard.type(self.starting_text)
126+ for key, result in zip(self.input_sequence, self.expected_text):
127+ keyboard.press_key(key)
128+ self.assertThat(text_area.text, Eventually(Equals(result)))
129+
130+
131+class UbuntuKeyboardStateKeyMappingTests(UbuntuKeyboardTests):
132+
133+ scenarios = [
134+ (
135+ 'Shift',
136+ dict(
137+ key='Shift',
138+ expected_state=KeyPadState.SHIFTED,
139+ expected_keypad_name='CHARACTERS'
140+ )
141+ ),
142+ (
143+ 'SHIFT',
144+ dict(
145+ key='SHIFT',
146+ expected_state=KeyPadState.SHIFTED,
147+ expected_keypad_name='CHARACTERS'
148+ )
149+ ),
150+ (
151+ 'shift',
152+ dict(
153+ key='shift',
154+ expected_state=KeyPadState.SHIFTED,
155+ expected_keypad_name='CHARACTERS'
156+ )
157+ ),
158+ (
159+ 'ABC',
160+ dict(
161+ key='ABC',
162+ expected_state=KeyPadState.NORMAL,
163+ expected_keypad_name='SYMBOLS'
164+ )
165+ ),
166+ (
167+ '?123',
168+ dict(
169+ key='?123',
170+ expected_state=KeyPadState.NORMAL,
171+ expected_keypad_name='SYMBOLS'
172+ )
173+ ),
174+ (
175+ 'symbols',
176+ dict(
177+ key='symbols',
178+ expected_state=KeyPadState.NORMAL,
179+ expected_keypad_name='SYMBOLS'
180+ )
181+ )
182+ ]
183+
184+ def _assert_keypad_name_and_state(self, keyboard, name, state):
185+ self.assertThat(
186+ keyboard._current_keypad_name,
187+ Eventually(Equals(name))
188+ )
189+ self.assertThat(
190+ keyboard.active_keypad_state,
191+ Eventually(Equals(state))
192+ )
193+
194+ def test_can_type_using_state_key_mapping(self):
195+ text_area = self.launch_test_input_area(
196+ input_hints=['Qt.ImhNoPredictiveText', 'Qt.ImhNoAutoUppercase'])
197+ self.ensure_focus_on_input(text_area)
198+ keyboard = Keyboard()
199+ self.addCleanup(keyboard.dismiss)
200+ self._assert_keypad_name_and_state(keyboard,
201+ 'CHARACTERS', KeyPadState.NORMAL)
202+ keyboard.press_key(self.key)
203+ self._assert_keypad_name_and_state(keyboard,
204+ self.expected_keypad_name,
205+ self.expected_state)
206+
207+
208 class UbuntuKeyboardStateChanges(UbuntuKeyboardTests):
209
210 def test_keyboard_layout_starts_shifted(self):
211@@ -897,31 +1025,47 @@
212
213 class UbuntuKeyboardLanguageMenu(UbuntuKeyboardTests):
214
215+ def setUp(self):
216+ super().setUp()
217+ self.gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
218+
219+ def _set_keyboard_language(self, language):
220+ self.gsettings.set_string("active-language", language)
221+
222+ def _get_keyboard_language(self):
223+ return self.gsettings.get_string("active-language")
224+
225+ def _get_plugin_path(self, language):
226+ path = ("file:///usr/share/maliit/plugins/com/ubuntu/lib/{lang}/"
227+ "Keyboard_{lang}.qml")
228+ return path.format(lang=language)
229+
230 def test_tapping(self):
231 """Tapping the language menu key should switch to the previously
232 used language.
233
234 """
235-
236 text_area = self.launch_test_input_area()
237 self.ensure_focus_on_input(text_area)
238 keyboard = Keyboard()
239 self.addCleanup(keyboard.dismiss)
240
241- gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
242- self.assertThat(
243- gsettings.get_string("active-language"),
244- Equals('en')
245- )
246+ # Make sure the previous language is es and the current language is en
247+ self._set_keyboard_language("es")
248+ self.assertThat(
249+ keyboard._plugin_source,
250+ Eventually(Equals(self._get_plugin_path("es"))))
251+
252+ self._set_keyboard_language("en")
253+ self.assertThat(
254+ keyboard._plugin_source,
255+ Eventually(Equals(self._get_plugin_path("en"))))
256
257 keyboard.press_key("language")
258
259- sleep(5)
260-
261 self.assertThat(
262- gsettings.get_string("active-language"),
263- Equals('es')
264- )
265+ keyboard._plugin_source,
266+ Eventually(Equals(self._get_plugin_path("es"))))
267
268 def test_long_press(self):
269 """Holding down the language menu key should switch display the
270@@ -934,11 +1078,7 @@
271 keyboard = Keyboard()
272 self.addCleanup(keyboard.dismiss)
273
274- gsettings = Gio.Settings.new("com.canonical.keyboard.maliit")
275- self.assertThat(
276- gsettings.get_string("active-language"),
277- Equals('en')
278- )
279+ self.assertThat(self._get_keyboard_language(), Equals("en"))
280
281 keyboard.press_key("language", long_press=True)
282

Subscribers

People subscribed via source and target branches