Merge lp:~om26er/notes-app/remove_autopilot_workaround into lp:notes-app

Proposed by Omer Akram
Status: Merged
Approved by: Olivier Tilloy
Approved revision: 161
Merged at revision: 165
Proposed branch: lp:~om26er/notes-app/remove_autopilot_workaround
Merge into: lp:notes-app
Diff against target: 209 lines (+102/-38)
5 files modified
KeyboardRectangle.qml (+81/-0)
NotesApp.qml (+1/-35)
tests/autopilot/notes_app/emulators/main_window.py (+3/-0)
tests/autopilot/notes_app/tests/__init__.py (+14/-0)
tests/autopilot/notes_app/tests/test_parts.py (+3/-3)
To merge this branch: bzr merge lp:~om26er/notes-app/remove_autopilot_workaround
Reviewer Review Type Date Requested Status
Olivier Tilloy Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+176788@code.launchpad.net

Commit message

added the functionality to make sure the keyboard appears before changing focus to another field.

Description of the change

added the functionality to make sure the keyboard appears before changing focus to another field.

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

199 + if model() != 'Desktop':

209 + if model() != 'Desktop':

Those are not needed, as the check on model() is done already in assert_osk_eventually_shown() and assert_osk_eventually_hidden().

review: Needs Fixing
159. By Omer Akram

fix per suggestions

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Omer Akram (om26er) wrote :

> 199 + if model() != 'Desktop':
>
> 209 + if model() != 'Desktop':
>
> Those are not needed, as the check on model() is done already in
> assert_osk_eventually_shown() and assert_osk_eventually_hidden().

fixed.

Revision history for this message
Olivier Tilloy (osomon) wrote :

There is a conflict when merging in the latest trunk. Please merge and resolve.

review: Needs Fixing
160. By Omer Akram

merge trunk, fix conflicts

Revision history for this message
Omer Akram (om26er) wrote :

> There is a conflict when merging in the latest trunk. Please merge and
> resolve.

Done. Thanks

Revision history for this message
Olivier Tilloy (osomon) wrote :

129 + KeyboardRectangle {
130 + id: osk
131 }

The id is not needed, as it’s not used anywhere, so it can be safely removed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
161. By Omer Akram

remove id for KeyboardRectangle, we don't use it

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Olivier Tilloy (osomon) wrote :

Looks good now.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file 'KeyboardRectangle.qml'
--- KeyboardRectangle.qml 1970-01-01 00:00:00 +0000
+++ KeyboardRectangle.qml 2013-07-26 18:20:36 +0000
@@ -0,0 +1,81 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This file is part of notes-app.
5 *
6 * webbrowser-app is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 3.
9 *
10 * webbrowser-app is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19// This file was originally part of the telephony application.
20// It is a workaround required to handle interaction with the OSK,
21// until the shell/WM takes care of that on behalf of the applications.
22
23import QtQuick 2.0
24import Ubuntu.Components 0.1
25
26Item {
27 id: keyboardRect
28 anchors.left: parent.left
29 anchors.right: parent.right
30 anchors.bottom: parent.bottom
31 height: Qt.inputMethod.visible ? Qt.inputMethod.keyboardRectangle.height : 0
32
33 Behavior on height {
34 UbuntuNumberAnimation {}
35 }
36
37 states: [
38 State {
39 name: "hidden"
40 when: keyboardRect.height == 0
41 },
42 State {
43 name: "shown"
44 when: keyboardRect.height == Qt.inputMethod.keyboardRectangle.height
45 }
46 ]
47
48 function recursiveFindFocusedItem(parent) {
49 if (parent.activeFocus) {
50 return parent;
51 }
52
53 for (var i in parent.children) {
54 var child = parent.children[i];
55 if (child.activeFocus) {
56 return child;
57 }
58
59 var item = recursiveFindFocusedItem(child);
60
61 if (item != null) {
62 return item;
63 }
64 }
65
66 return null;
67 }
68
69 Connections {
70 target: Qt.inputMethod
71
72 onVisibleChanged: {
73 if (!Qt.inputMethod.visible) {
74 var focusedItem = recursiveFindFocusedItem(keyboardRect.parent);
75 if (focusedItem != null) {
76 focusedItem.focus = false;
77 }
78 }
79 }
80 }
81}
082
=== modified file 'NotesApp.qml'
--- NotesApp.qml 2013-07-24 14:52:07 +0000
+++ NotesApp.qml 2013-07-26 18:20:36 +0000
@@ -118,40 +118,6 @@
118 noteList.setActiveIndex(0);118 noteList.setActiveIndex(0);
119 }119 }
120120
121 // Workaround for https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1201400.121 KeyboardRectangle {
122 // Inspired by the KeyboardRectangle component, originally written for the
123 // telephony application.
124 Connections {
125 target: Qt.inputMethod
126
127 onVisibleChanged: {
128 if (!Qt.inputMethod.visible) {
129 var focusedItem = recursiveFindFocusedItem(window);
130 if (focusedItem != null) {
131 focusedItem.focus = false;
132 }
133 }
134 }
135
136 function recursiveFindFocusedItem(parent) {
137 if (parent.activeFocus) {
138 return parent;
139 }
140
141 for (var i in parent.children) {
142 var child = parent.children[i];
143 if (child.activeFocus) {
144 return child;
145 }
146
147 var item = recursiveFindFocusedItem(child);
148
149 if (item != null) {
150 return item;
151 }
152 }
153
154 return null;
155 }
156 }122 }
157}123}
158124
=== modified file 'tests/autopilot/notes_app/emulators/main_window.py'
--- tests/autopilot/notes_app/emulators/main_window.py 2013-04-08 11:22:07 +0000
+++ tests/autopilot/notes_app/emulators/main_window.py 2013-07-26 18:20:36 +0000
@@ -27,3 +27,6 @@
27 edit = note_item.select_single("MixedEdit")27 edit = note_item.select_single("MixedEdit")
28 parts = edit.select_single("QQuickColumn").get_children_by_type("QQuickLoader")28 parts = edit.select_single("QQuickColumn").get_children_by_type("QQuickLoader")
29 return parts29 return parts
30
31 def get_keyboard_rectangle(self):
32 return self.app.select_single("KeyboardRectangle")
3033
=== modified file 'tests/autopilot/notes_app/tests/__init__.py'
--- tests/autopilot/notes_app/tests/__init__.py 2013-07-23 12:04:26 +0000
+++ tests/autopilot/notes_app/tests/__init__.py 2013-07-26 18:20:36 +0000
@@ -14,8 +14,10 @@
14import base6414import base64
1515
16from autopilot.input import Mouse, Touch, Pointer16from autopilot.input import Mouse, Touch, Pointer
17from autopilot.matchers import Eventually
17from autopilot.platform import model18from autopilot.platform import model
18from autopilot.testcase import AutopilotTestCase19from autopilot.testcase import AutopilotTestCase
20from testtools.matchers import Equals
1921
20from notes_app.emulators.main_window import MainWindow22from notes_app.emulators.main_window import MainWindow
21import imagedata23import imagedata
@@ -77,6 +79,18 @@
77 # the process during regular test setup.79 # the process during regular test setup.
78 self.doCleanups()80 self.doCleanups()
7981
82 def assert_osk_eventually_shown(self):
83 if model() != 'Desktop':
84 keyboardRectangle = self.main_window.get_keyboard_rectangle()
85 self.assertThat(keyboardRectangle.state,
86 Eventually(Equals("shown")))
87
88 def assert_osk_eventually_hidden(self):
89 if model() != 'Desktop':
90 keyboardRectangle = self.main_window.get_keyboard_rectangle()
91 self.assertThat(keyboardRectangle.state,
92 Eventually(Equals("hidden")))
93
80 @property94 @property
81 def main_window(self):95 def main_window(self):
82 return MainWindow(self.app)96 return MainWindow(self.app)
8397
=== modified file 'tests/autopilot/notes_app/tests/test_parts.py'
--- tests/autopilot/notes_app/tests/test_parts.py 2013-07-23 12:21:36 +0000
+++ tests/autopilot/notes_app/tests/test_parts.py 2013-07-26 18:20:36 +0000
@@ -16,7 +16,6 @@
16from notes_app.tests import NotesTestCaseBaseWithHTTPServer, DatabaseMixin16from notes_app.tests import NotesTestCaseBaseWithHTTPServer, DatabaseMixin
1717
18import sqlite318import sqlite3
19from time import sleep
2019
2120
22class TestFocus(NotesTestCaseBaseWithHTTPServer, DatabaseMixin):21class TestFocus(NotesTestCaseBaseWithHTTPServer, DatabaseMixin):
@@ -80,17 +79,18 @@
80 part_x, part_y, part_w, part_h = image.globalRect79 part_x, part_y, part_w, part_h = image.globalRect
81 self.pointing_device.move(part_x + part_w / 2, part_y + 1)80 self.pointing_device.move(part_x + part_w / 2, part_y + 1)
82 self.pointing_device.click()81 self.pointing_device.click()
82 self.assert_osk_eventually_shown()
83 self.assertThat(text.activeFocus, Eventually(Equals(True)))83 self.assertThat(text.activeFocus, Eventually(Equals(True)))
8484
85 # Clicking on the lower half of the image should create a new text area below85 # Clicking on the lower half of the image should create a new text area below
86 # the image and focus it86 # the image and focus it
87 self.pointing_device.move(part_x + part_w / 2, part_y + part_h - 1)87 self.pointing_device.move(part_x + part_w / 2, part_y + part_h - 1)
88 self.pointing_device.click()88 self.pointing_device.click()
89 self.assert_osk_eventually_hidden()
89 # On the phone input focus is lost when the OSK appears so90 # On the phone input focus is lost when the OSK appears so
90 # we click the input box to gain focus again. LP: #120408491 # we click the input box to gain focus again. LP: #1204084
91 if model() != 'Desktop':92 if model() != 'Desktop':
92 sleep(1)93 self.pointing_device.click()
93 self.pointing_device.click()
94 self.assertThat(text.activeFocus, Eventually(Equals(False)))94 self.assertThat(text.activeFocus, Eventually(Equals(False)))
9595
96 parts = self.main_window.get_note_parts(note)96 parts = self.main_window.get_note_parts(note)

Subscribers

People subscribed via source and target branches