Merge lp:~michael-sheldon/ubuntu-keyboard/autopilot-cursor-movement into lp:ubuntu-keyboard

Proposed by Michael Sheldon
Status: Superseded
Proposed branch: lp:~michael-sheldon/ubuntu-keyboard/autopilot-cursor-movement
Merge into: lp:ubuntu-keyboard
Diff against target: 182 lines (+90/-10)
7 files modified
qml/Keyboard.qml (+21/-0)
src/lib/logic/eventhandler.cpp (+12/-0)
src/lib/models/key.h (+2/-0)
src/plugin/ubuntuapplicationapiwrapper.cpp (+0/-10)
src/view/abstracttexteditor.cpp (+8/-0)
tests/autopilot/ubuntu_keyboard/emulators/keyboard.py (+18/-0)
tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py (+29/-0)
To merge this branch: bzr merge lp:~michael-sheldon/ubuntu-keyboard/autopilot-cursor-movement
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Richard Huddie Pending
Ubuntu Phablet Team Pending
Review via email: mp+264992@code.launchpad.net

This proposal has been superseded by a proposal from 2015-07-17.

Commit message

Allow autopilot to perform cursor movement via maliit

Description of the change

Allow autopilot to perform cursor movement via maliit (required for replacing fake keyboard input with real OSK)

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
392. By Michael Sheldon

Merge build fixes from lp:~michael-sheldon/ubuntu-keyboard/fix-build-against-new-libplatform

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'qml/Keyboard.qml'
2--- qml/Keyboard.qml 2015-04-13 12:30:10 +0000
3+++ qml/Keyboard.qml 2015-07-17 14:19:53 +0000
4@@ -287,4 +287,25 @@
5 maliit_geometry.visibleRect = Qt.rect(obj.x, obj.y, obj.width, obj.height);
6 }
7
8+ // Autopilot needs to be able to move the cursor even when the layout
9+ // doesn't provide arrow keys (e.g. in phone mode)
10+ function sendLeftKey() {
11+ event_handler.onKeyReleased("", "left");
12+ }
13+ function sendRightKey() {
14+ event_handler.onKeyReleased("", "right");
15+ }
16+ function sendUpKey() {
17+ event_handler.onKeyReleased("", "up");
18+ }
19+ function sendDownKey() {
20+ event_handler.onKeyReleased("", "down");
21+ }
22+ function sendHomeKey() {
23+ event_handler.onKeyReleased("", "home");
24+ }
25+ function sendEndKey() {
26+ event_handler.onKeyReleased("", "end");
27+ }
28+
29 } // fullScreenItem
30
31=== modified file 'src/lib/logic/eventhandler.cpp'
32--- src/lib/logic/eventhandler.cpp 2015-01-29 05:44:05 +0000
33+++ src/lib/logic/eventhandler.cpp 2015-07-17 14:19:53 +0000
34@@ -90,6 +90,18 @@
35 key.setAction(Key::ActionSpace);
36 else if (action == "shift")
37 key.setAction(Key::ActionShift);
38+ else if (action == "left")
39+ key.setAction(Key::ActionLeft);
40+ else if (action == "right")
41+ key.setAction(Key::ActionRight);
42+ else if (action == "up")
43+ key.setAction(Key::ActionUp);
44+ else if (action == "down")
45+ key.setAction(Key::ActionDown);
46+ else if (action == "home")
47+ key.setAction(Key::ActionHome);
48+ else if (action == "end")
49+ key.setAction(Key::ActionEnd);
50 else
51 key.setAction(Key::ActionInsert);
52
53
54=== modified file 'src/lib/models/key.h'
55--- src/lib/models/key.h 2013-11-07 17:43:22 +0000
56+++ src/lib/models/key.h 2015-07-17 14:19:53 +0000
57@@ -69,6 +69,8 @@
58 ActionDead, //!< Switches keyboard to deadkey variation, using key's label as lookup.
59 ActionLeftLayout, //!< Switch to left/previous language layout.
60 ActionRightLayout, //!< Switch to right/next language layout.
61+ ActionHome, //!< Key moves cursor to beginning of text.
62+ ActionEnd, //!< Key moves cursor to end of text.
63 NumActions
64 };
65
66
67=== modified file 'src/plugin/ubuntuapplicationapiwrapper.cpp'
68--- src/plugin/ubuntuapplicationapiwrapper.cpp 2014-04-16 13:12:34 +0000
69+++ src/plugin/ubuntuapplicationapiwrapper.cpp 2015-07-17 14:19:53 +0000
70@@ -19,12 +19,6 @@
71 // FIXME: this is hacky way of deciding if running on Touch platform or not
72 #include <QtCore/qconfig.h>
73
74-#ifdef QT_OPENGL_ES_2
75-#include <ubuntu/ui/ubuntu_ui_session_service.h>
76-#include <ubuntu/application/ui/window_properties.h>
77- #define HAVE_UBUNTU_PLATFORM_API
78-#endif
79-
80 #include <QByteArray>
81 #include <QDir>
82 #include <QFile>
83@@ -95,11 +89,7 @@
84
85 int UbuntuApplicationApiWrapper::oskWindowRole() const
86 {
87-#ifdef HAVE_UBUNTU_PLATFORM_API
88- return static_cast<int>(U_ON_SCREEN_KEYBOARD_ROLE);
89-#else
90 return 7;
91-#endif
92 }
93
94 void UbuntuApplicationApiWrapper::sendInfoToClientConnection()
95
96=== modified file 'src/view/abstracttexteditor.cpp'
97--- src/view/abstracttexteditor.cpp 2015-04-16 15:32:49 +0000
98+++ src/view/abstracttexteditor.cpp 2015-07-17 14:19:53 +0000
99@@ -546,6 +546,14 @@
100 Q_EMIT rightLayoutSelected();
101 break;
102
103+ case Key::ActionHome:
104+ event_key = Qt::Key_Home;
105+ break;
106+
107+ case Key::ActionEnd:
108+ event_key = Qt::Key_End;
109+ break;
110+
111 default:
112 break;
113 }
114
115=== modified file 'tests/autopilot/ubuntu_keyboard/emulators/keyboard.py'
116--- tests/autopilot/ubuntu_keyboard/emulators/keyboard.py 2015-06-26 09:09:22 +0000
117+++ tests/autopilot/ubuntu_keyboard/emulators/keyboard.py 2015-07-17 14:19:53 +0000
118@@ -235,6 +235,24 @@
119 self._active_keypad = self._keypad_loader.select_single(KeyPad)
120 return self._active_keypad
121
122+ def send_left_key(self):
123+ self.maliit.select_single('Keyboard').slots.sendLeftKey()
124+
125+ def send_right_key(self):
126+ self.maliit.select_single('Keyboard').slots.sendRightKey()
127+
128+ def send_up_key(self):
129+ self.maliit.select_single('Keyboard').slots.sendUpKey()
130+
131+ def send_down_key(self):
132+ self.maliit.select_single('Keyboard').slots.sendDownKey()
133+
134+ def send_home_key(self):
135+ self.maliit.select_single('Keyboard').slots.sendHomeKey()
136+
137+ def send_end_key(self):
138+ self.maliit.select_single('Keyboard').slots.sendEndKey()
139+
140 @property
141 def _keypad_loader(self):
142 return self.maliit.select_single(
143
144=== modified file 'tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py'
145--- tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-06-26 09:09:22 +0000
146+++ tests/autopilot/ubuntu_keyboard/tests/test_keyboard.py 2015-07-17 14:19:53 +0000
147@@ -1361,6 +1361,35 @@
148 )
149
150
151+class UbuntuKeyboardCursorTests(UbuntuKeyboardTests):
152+
153+ def test_cursor_movement(self):
154+ """Test that autopilot is able to move the cursor
155+
156+ """
157+ text_area = self.launch_test_input_area(
158+ input_hints=['Qt.ImhNoPredictiveText'])
159+ self.ensure_focus_on_input(text_area)
160+ keyboard = Keyboard()
161+ self.addCleanup(keyboard.dismiss)
162+
163+ keyboard.type("Cursor Test")
164+
165+ keyboard.send_home_key()
166+ keyboard.send_right_key()
167+ keyboard.send_right_key()
168+ keyboard.type("\b")
169+ keyboard.send_end_key()
170+ keyboard.send_left_key()
171+ keyboard.type("\b")
172+
173+ expected = "Crsor Tet"
174+ self.assertThat(
175+ text_area.text,
176+ Eventually(Equals(expected))
177+ )
178+
179+
180 def maliit_cleanup():
181 presagedir = os.path.expanduser("~/.presage")
182 if os.path.exists(presagedir + ".bak") and os.path.exists(presagedir):

Subscribers

People subscribed via source and target branches