Merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix-1483668-osk-remove-simulated-keyboard into lp:ubuntu-ui-toolkit/staging

Proposed by Richard Huddie
Status: Merged
Approved by: Cris Dywan
Approved revision: 1601
Merged at revision: 1607
Proposed branch: lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix-1483668-osk-remove-simulated-keyboard
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 191 lines (+49/-72)
3 files modified
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textarea.py (+16/-20)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textfield.py (+33/-46)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_textfield.py (+0/-6)
To merge this branch: bzr merge lp:~canonical-platform-qa/ubuntu-ui-toolkit/fix-1483668-osk-remove-simulated-keyboard
Reviewer Review Type Date Requested Status
Cris Dywan Approve
PS Jenkins bot continuous-integration Approve
Ubuntu SDK team Pending
Review via email: mp+267844@code.launchpad.net

Commit message

Remove all usage of the autopilot simulated keyboard when the OSK is being used.

Description of the change

Remove all usage of the autopilot simulated keyboard when the OSK is being used, to stop unity8 from hiding the OSK.

This updates both textfield and textarea helpers to use some new helper methods added to the ubuntu_keyboard Keyboard class which allow some cursor movements to be sent through maliit-server, rather than having to create a temporary instance of the autopilot simulated keyboard.

This change also includes the 'select all' method which can be used with the OSK, and re-enables 2 tests on touch which were previously desktop only.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1600. By Richard Huddie

Use _select_all to delete text using keys.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
1601. By Richard Huddie

Update text area to remove use of simulated keyboard when using osk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Cris Dywan (kalikiana) wrote :

Very nice. I love that we can unskip those tests now!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textarea.py'
2--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textarea.py 2015-06-17 15:06:48 +0000
3+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textarea.py 2015-08-13 09:14:49 +0000
4@@ -27,30 +27,26 @@
5 self._clear_with_keys()
6 self.text.wait_for('')
7
8- def _go_to_end(self, select_text=False):
9+ def _go_to_end(self):
10 # We override this because the text areas can have more than one line.
11- key = 'Ctrl+End'
12- if select_text:
13- key = 'Shift+' + key
14 if self._is_keyboard_osk():
15- # XXX Here we are cheating because the on-screen keyboard doesn't
16- # have an END key.
17- from autopilot.input import Keyboard
18- keyboard = Keyboard.create()
19+ from ubuntu_keyboard.emulators.keyboard import Keyboard
20+ osk = Keyboard()
21+ while self.cursorPosition != len(self.text):
22+ # Move to the end of the line below
23+ osk.send_down_key()
24+ osk.send_end_key()
25 else:
26- keyboard = self.keyboard
27- keyboard.press_and_release(key)
28+ self.keyboard.press_and_release('Ctrl+End')
29
30- def _go_to_start(self, select_text=False):
31+ def _go_to_start(self):
32 # We override this because the text areas can have more than one line.
33- key = 'Ctrl+Home'
34- if select_text:
35- key = 'Shift+' + key
36 if self._is_keyboard_osk():
37- # XXX Here we are cheating because the on-screen keyboard doesn't
38- # have a HOME key.
39- from autopilot.input import Keyboard
40- keyboard = Keyboard.create()
41+ from ubuntu_keyboard.emulators.keyboard import Keyboard
42+ osk = Keyboard()
43+ while self.cursorPosition != 0:
44+ # Move to the start of the line above
45+ osk.send_up_key()
46+ osk.send_home_key()
47 else:
48- keyboard = self.keyboard
49- keyboard.press_and_release(key)
50+ self.keyboard.press_and_release('Ctrl+Home')
51
52=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textfield.py'
53--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textfield.py 2015-06-17 15:06:48 +0000
54+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_textfield.py 2015-08-13 09:14:49 +0000
55@@ -18,7 +18,7 @@
56
57 from autopilot import logging as autopilot_logging
58
59-from ubuntuuitoolkit._custom_proxy_objects import _common
60+from ubuntuuitoolkit._custom_proxy_objects import _common, _mainview
61
62 logger = logging.getLogger(__name__)
63
64@@ -73,24 +73,30 @@
65
66 @autopilot_logging.log_action(logger.debug)
67 def _clear_with_keys(self):
68- if self._is_keyboard_osk():
69- # Touch tap currently doesn't have a press_duration parameter, so
70- # we can't select all the text.
71- # Reported as bug http://pad.lv/1268782 --elopio - 2014-01-13
72- self._go_to_end()
73- while self.text != '':
74- self._delete_one_character_using_osk()
75- else:
76- self._select_all()
77- self.keyboard.press_and_release('BackSpace')
78+ self._select_all()
79+ self.keyboard.press_and_release('\b')
80 if not self.is_empty():
81 raise _common.ToolkitException('Failed to clear the text field.')
82
83 @autopilot_logging.log_action(logger.debug)
84 def _select_all(self):
85 if not self._is_all_text_selected():
86- self._go_to_start()
87- self._go_to_end(select_text=True)
88+ if self._is_keyboard_osk():
89+ cursor = self.select_single('TextCursor', visible=True)
90+ self.pointing_device.click_object(
91+ cursor, time_between_events=0.5)
92+ self.pointing_device.click_object(
93+ cursor, time_between_events=0.5)
94+ root = self.get_root_instance()
95+ main_view = root.select_single(_mainview.MainView)
96+ popover = main_view.get_text_input_context_menu(
97+ 'text_input_contextmenu')
98+ popover.click_option_by_text('Select All')
99+ else:
100+ self._go_to_start()
101+ self.keyboard.press('Shift')
102+ self._go_to_end()
103+ self.keyboard.release('Shift')
104
105 def _is_all_text_selected(self):
106 return self.text == self.selectedText
107@@ -100,39 +106,20 @@
108 return _common.is_maliit_process_running()
109
110 @autopilot_logging.log_action(logger.debug)
111- def _go_to_end(self, select_text=False):
112- key = 'End'
113- if select_text:
114- key = 'Shift+' + key
115- if self._is_keyboard_osk():
116- # XXX Here we are cheating because the on-screen keyboard doesn't
117- # have an END key. --elopio - 2014-08-20
118- from autopilot.input import Keyboard
119- keyboard = Keyboard.create()
120- else:
121- keyboard = self.keyboard
122- keyboard.press_and_release(key)
123-
124- @autopilot_logging.log_action(logger.debug)
125- def _go_to_start(self, select_text=False):
126- key = 'Home'
127- if select_text:
128- key = 'Shift+' + key
129- if self._is_keyboard_osk():
130- from autopilot.input import Keyboard
131- keyboard = Keyboard.create()
132- else:
133- keyboard = self.keyboard
134- keyboard.press_and_release(key)
135-
136- @autopilot_logging.log_action(logger.debug)
137- def _delete_one_character_using_osk(self):
138- original_text = self.text
139- # We delete with backspace because the on-screen keyboard has
140- # that key.
141- self.keyboard.press_and_release('backspace')
142- if len(self.text) != len(original_text) - 1:
143- raise _common.ToolkitException('Failed to delete one character.')
144+ def _go_to_end(self):
145+ if self._is_keyboard_osk():
146+ from ubuntu_keyboard.emulators.keyboard import Keyboard
147+ Keyboard().send_end_key()
148+ else:
149+ self.keyboard.press_and_release('End')
150+
151+ @autopilot_logging.log_action(logger.debug)
152+ def _go_to_start(self):
153+ if self._is_keyboard_osk():
154+ from ubuntu_keyboard.emulators.keyboard import Keyboard
155+ Keyboard().send_home_key()
156+ else:
157+ self.keyboard.press_and_release('Home')
158
159 @autopilot_logging.log_action(logger.debug)
160 def _ensure_focused(self):
161
162=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_textfield.py'
163--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_textfield.py 2015-06-18 18:56:55 +0000
164+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_textfield.py 2015-08-13 09:14:49 +0000
165@@ -16,8 +16,6 @@
166
167 from unittest import mock
168
169-from autopilot import platform
170-
171 import ubuntuuitoolkit
172 from ubuntuuitoolkit import tests
173
174@@ -98,8 +96,6 @@
175 self.assertFalse(self.simple_text_field.is_empty())
176
177 def test_select_all_selects_all_text(self):
178- if platform.model() != 'Desktop':
179- self.skipTest('Select all is not yet implemented on the phone.')
180 self.simple_text_field.write('Text to select.')
181 self.simple_text_field._select_all()
182
183@@ -107,8 +103,6 @@
184
185 def test_select_all_when_already_selected_must_do_nothing(self):
186 """Test for select all the text when it's already selected."""
187- if platform.model() != 'Desktop':
188- self.skipTest('Select all is not yet implemented on the phone.')
189 self.simple_text_field.write('Text to select.')
190 self.simple_text_field._select_all()
191 with mock.patch.object(

Subscribers

People subscribed via source and target branches