Merge lp:~hiroshidi/ubuntu-terminal-app/autopilot-tests-panels into lp:ubuntu-terminal-app
- autopilot-tests-panels
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Dmitry Zagnoyko |
Approved revision: | 17 |
Merged at revision: | 15 |
Proposed branch: | lp:~hiroshidi/ubuntu-terminal-app/autopilot-tests-panels |
Merge into: | lp:ubuntu-terminal-app |
Diff against target: |
352 lines (+233/-25) 5 files modified
Terminal.qml (+6/-0) tests/autopilot/ubuntu_terminal_app/emulators/main_window.py (+15/-12) tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py (+154/-0) tests/autopilot/ubuntu_terminal_app/tests/__init__.py (+7/-1) tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py (+51/-12) |
To merge this branch: | bzr merge lp:~hiroshidi/ubuntu-terminal-app/autopilot-tests-panels |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Nicholas Skaggs (community) | Approve | ||
Ubuntu Phone Apps Jenkins Bot | continuous-integration | Approve | |
Review via email: mp+170388@code.launchpad.net |
Commit message
add autopilot test for panels and the circle menu
add ubuntusdk emu from lp:~nskaggs/+junk/ubuntusdk_autopilot_emulator
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
Nicholas Skaggs (nskaggs) wrote : | # |
Looks good Dmitry! Can you incorporate the emulator WIP for this? lp:~nskaggs/+junk/ubuntusdk_autopilot_emulator. We're going to continue to iterate on this to have many of the common functions (like tab switching, toolbar access, etc) and we want to be able to keep tests up to date on best practices as they continue to evolve :-)
That said, this is otherwise a nice basic testcase -- good base to build on.
- 17. By Dmitry Zagnoyko
-
Merged ubuntusdk autopilot testcase emulator. Merged branch: lp:~nskaggs/+junk/ubuntusdk_autopilot_emulator
Ubuntu Phone Apps Jenkins Bot (ubuntu-phone-apps-jenkins-bot) wrote : | # |
PASSED: Continuous integration, rev:17
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Nicholas Skaggs (nskaggs) wrote : | # |
Let's push this in. I need to add the popover function to the sdk somehow.. work for me to gt right :-) Thanks Dmitry!
Preview Diff
1 | === modified file 'Terminal.qml' | |||
2 | --- Terminal.qml 2013-05-24 16:18:10 +0000 | |||
3 | +++ Terminal.qml 2013-06-19 18:58:26 +0000 | |||
4 | @@ -82,6 +82,7 @@ | |||
5 | 82 | 82 | ||
6 | 83 | CtrlKeys { | 83 | CtrlKeys { |
7 | 84 | id: kbCtrl | 84 | id: kbCtrl |
8 | 85 | objectName: "kbCtrl" | ||
9 | 85 | visible: false | 86 | visible: false |
10 | 86 | width: parent.width | 87 | width: parent.width |
11 | 87 | anchors{ | 88 | anchors{ |
12 | @@ -97,6 +98,7 @@ | |||
13 | 97 | 98 | ||
14 | 98 | FnKeys { | 99 | FnKeys { |
15 | 99 | id: kbFn | 100 | id: kbFn |
16 | 101 | objectName: "kbFn" | ||
17 | 100 | visible: false | 102 | visible: false |
18 | 101 | width: parent.width | 103 | width: parent.width |
19 | 102 | anchors{ | 104 | anchors{ |
20 | @@ -113,6 +115,7 @@ | |||
21 | 113 | 115 | ||
22 | 114 | ScrlKeys { | 116 | ScrlKeys { |
23 | 115 | id: kbScrl | 117 | id: kbScrl |
24 | 118 | objectName: "kbScrl" | ||
25 | 116 | visible: false | 119 | visible: false |
26 | 117 | width: parent.width | 120 | width: parent.width |
27 | 118 | anchors{ | 121 | anchors{ |
28 | @@ -141,6 +144,7 @@ | |||
29 | 141 | 144 | ||
30 | 142 | CircleMenu { | 145 | CircleMenu { |
31 | 143 | id: cmenu | 146 | id: cmenu |
32 | 147 | objectName: "cmenu" | ||
33 | 144 | z: 99 | 148 | z: 99 |
34 | 145 | visible: false | 149 | visible: false |
35 | 146 | anchors.centerIn: parent | 150 | anchors.centerIn: parent |
36 | @@ -181,6 +185,7 @@ | |||
37 | 181 | 185 | ||
38 | 182 | KTerminal { | 186 | KTerminal { |
39 | 183 | id: kterm | 187 | id: kterm |
40 | 188 | objectName: "kterm" | ||
41 | 184 | 189 | ||
42 | 185 | ////////////////////////////////////// | 190 | ////////////////////////////////////// |
43 | 186 | /// FONT SIZE = 24 (FINE FOR GNEXUS) | 191 | /// FONT SIZE = 24 (FINE FOR GNEXUS) |
44 | @@ -195,6 +200,7 @@ | |||
45 | 195 | 200 | ||
46 | 196 | session: KSession { | 201 | session: KSession { |
47 | 197 | id: ksession | 202 | id: ksession |
48 | 203 | objectName: "ksession" | ||
49 | 198 | kbScheme: "linux" | 204 | kbScheme: "linux" |
50 | 199 | } | 205 | } |
51 | 200 | } | 206 | } |
52 | 201 | 207 | ||
53 | === modified file 'tests/autopilot/ubuntu_terminal_app/emulators/main_window.py' | |||
54 | --- tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 2013-05-31 13:10:55 +0000 | |||
55 | +++ tests/autopilot/ubuntu_terminal_app/emulators/main_window.py 2013-06-19 18:58:26 +0000 | |||
56 | @@ -7,18 +7,21 @@ | |||
57 | 7 | 7 | ||
58 | 8 | """Terminal app autopilot emulators.""" | 8 | """Terminal app autopilot emulators.""" |
59 | 9 | 9 | ||
60 | 10 | |||
61 | 11 | class MainWindow(object): | 10 | class MainWindow(object): |
62 | 12 | """An emulator class that makes it easy to interact with the | 11 | """An emulator class that makes it easy to interact with the |
67 | 13 | terminal-app. | 12 | terminal-app.""" |
68 | 14 | 13 | def __init__(self, autopilot, app): | |
65 | 15 | """ | ||
66 | 16 | def __init__(self, app): | ||
69 | 17 | self.app = app | 14 | self.app = app |
77 | 18 | 15 | self.autopilot = autopilot | |
78 | 19 | def get_qml_view(self): | 16 | |
79 | 20 | """Get the main QML view""" | 17 | def click_popup_item(self, popupLable): |
80 | 21 | return self.app.select_single("QQuickView") | 18 | """Clicks the toolbar popup item with popupLable""" |
81 | 22 | 19 | li = self.app.select_single("ActionSelectionPopover") | |
82 | 23 | def get_toolbar(self): | 20 | row = li.select_single("QQuickColumn") |
83 | 24 | return self.app.select_single("Toolbar") | 21 | loaderList = row.select_many("QQuickLoader") |
84 | 22 | for loader in loaderList: | ||
85 | 23 | labelList = loader.select_many("Label") | ||
86 | 24 | for label in labelList: | ||
87 | 25 | if label.text == popupLable: | ||
88 | 26 | self.autopilot.pointing_device.click_object(label) | ||
89 | 27 | |||
90 | 25 | 28 | ||
91 | === added file 'tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py' | |||
92 | --- tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py 1970-01-01 00:00:00 +0000 | |||
93 | +++ tests/autopilot/ubuntu_terminal_app/emulators/ubuntusdk.py 2013-06-19 18:58:26 +0000 | |||
94 | @@ -0,0 +1,154 @@ | |||
95 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
96 | 2 | # | ||
97 | 3 | # Copyright (C) 2013 Canonical Ltd | ||
98 | 4 | # | ||
99 | 5 | # This program is free software: you can redistribute it and/or modify | ||
100 | 6 | # it under the terms of the GNU General Public License version 3 as | ||
101 | 7 | # published by the Free Software Foundation. | ||
102 | 8 | # | ||
103 | 9 | # This program is distributed in the hope that it will be useful, | ||
104 | 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
105 | 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
106 | 12 | # GNU General Public License for more details. | ||
107 | 13 | # | ||
108 | 14 | # You should have received a copy of the GNU General Public License | ||
109 | 15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
110 | 16 | # | ||
111 | 17 | # Authored by: Nicholas Skaggs <nicholas.skaggs@canonical.com> | ||
112 | 18 | |||
113 | 19 | from testtools.matchers import Equals, NotEquals, Not, Is | ||
114 | 20 | from autopilot.matchers import Eventually | ||
115 | 21 | |||
116 | 22 | class ubuntusdk(object): | ||
117 | 23 | """An emulator class that makes it easy to interact with the ubuntu sdk applications.""" | ||
118 | 24 | |||
119 | 25 | def __init__(self, autopilot, app): | ||
120 | 26 | self.app = app | ||
121 | 27 | self.autopilot = autopilot | ||
122 | 28 | |||
123 | 29 | def get_qml_view(self): | ||
124 | 30 | """Get the main QML view""" | ||
125 | 31 | return self.app.select_single("QQuickView") | ||
126 | 32 | |||
127 | 33 | def get_object(self, typeName, name): | ||
128 | 34 | """Get a specific object""" | ||
129 | 35 | return self.app.select_single(typeName, objectName=name) | ||
130 | 36 | |||
131 | 37 | def get_objects(self, typeName, name): | ||
132 | 38 | """Get more than one object""" | ||
133 | 39 | return self.app.select_many(typeName, objectName=name) | ||
134 | 40 | |||
135 | 41 | def switch_to_tab(self, tab): | ||
136 | 42 | """Switch to the specified tab number""" | ||
137 | 43 | tabs = self.get_tabs() | ||
138 | 44 | currentTab = tabs.selectedTabIndex | ||
139 | 45 | |||
140 | 46 | #perform operations until tab == currentTab | ||
141 | 47 | while tab != currentTab: | ||
142 | 48 | if tab > currentTab: | ||
143 | 49 | self._previous_tab() | ||
144 | 50 | if tab < currentTab: | ||
145 | 51 | self._next_tab() | ||
146 | 52 | currentTab = tabs.selectedTabIndex | ||
147 | 53 | |||
148 | 54 | def toggle_toolbar(self): | ||
149 | 55 | """Toggle the toolbar between revealed and hidden""" | ||
150 | 56 | #check and see if the toolbar is open or not | ||
151 | 57 | if self.get_toolbar().opened: | ||
152 | 58 | self.hide_toolbar() | ||
153 | 59 | else: | ||
154 | 60 | self.open_toolbar() | ||
155 | 61 | |||
156 | 62 | def get_toolbar(self): | ||
157 | 63 | """Returns the toolbar in the main events view.""" | ||
158 | 64 | return self.app.select_single("Toolbar") | ||
159 | 65 | |||
160 | 66 | def get_toolbar_button(self, buttonLabel): | ||
161 | 67 | """Returns the toolbar button at position index""" | ||
162 | 68 | toolbar = self.get_toolbar() | ||
163 | 69 | if not toolbar.opened: | ||
164 | 70 | self.open_toolbar() | ||
165 | 71 | row = toolbar.select_single("QQuickRow") | ||
166 | 72 | loaderList = row.select_many("QQuickLoader") | ||
167 | 73 | for loader in loaderList: | ||
168 | 74 | buttonList = loader.select_many("Button") | ||
169 | 75 | for button in buttonList: | ||
170 | 76 | if button.text == buttonLabel: | ||
171 | 77 | return button | ||
172 | 78 | |||
173 | 79 | def click_toolbar_button(self, buttonLabel): | ||
174 | 80 | """Clicks the toolbar button with buttonLabel""" | ||
175 | 81 | #The toolbar button is assumed to be the following format | ||
176 | 82 | #ToolbarActions { | ||
177 | 83 | # Action { | ||
178 | 84 | # objectName: "name" | ||
179 | 85 | # text: value | ||
180 | 86 | button = self.get_toolbar_button(buttonLabel) | ||
181 | 87 | self.autopilot.pointing_device.click_object(button) | ||
182 | 88 | |||
183 | 89 | def open_toolbar(self): | ||
184 | 90 | """Open the toolbar""" | ||
185 | 91 | qmlView = self.get_qml_view() | ||
186 | 92 | |||
187 | 93 | lineX = qmlView.x + qmlView.width * 0.50 | ||
188 | 94 | startY = qmlView.y + qmlView.height - 1 | ||
189 | 95 | stopY = qmlView.y + qmlView.height * 0.95 | ||
190 | 96 | |||
191 | 97 | self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY) | ||
192 | 98 | |||
193 | 99 | def hide_toolbar(self): | ||
194 | 100 | """Hide the toolbar""" | ||
195 | 101 | qmlView = self.get_qml_view() | ||
196 | 102 | |||
197 | 103 | lineX = qmlView.x + qmlView.width * 0.50 | ||
198 | 104 | startY = qmlView.y + qmlView.height * 0.95 | ||
199 | 105 | stopY = qmlView.y + qmlView.height - 1 | ||
200 | 106 | |||
201 | 107 | self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY) | ||
202 | 108 | |||
203 | 109 | def set_popup_value(self, popover, button, value): | ||
204 | 110 | """Changes the given popover selector to the request value | ||
205 | 111 | At the moment this only works for values that are currently visible. To | ||
206 | 112 | access the remaining items, a help method to drag and recheck is needed.""" | ||
207 | 113 | #The popover is assumed to be the following format | ||
208 | 114 | # Popover { | ||
209 | 115 | # Column { | ||
210 | 116 | # ListView { | ||
211 | 117 | # delegate: Standard { | ||
212 | 118 | # objectName: "name" | ||
213 | 119 | # text: value | ||
214 | 120 | |||
215 | 121 | self.autopilot.pointing_device.click_object(button) | ||
216 | 122 | #we'll get all matching objects, incase the popover is reused between buttons | ||
217 | 123 | itemList = lambda: self.get_objects("Standard", popover) | ||
218 | 124 | |||
219 | 125 | for item in itemList(): | ||
220 | 126 | if item.get_properties()['text'] == value: | ||
221 | 127 | self.autopilot.pointing_device.click_object(item) | ||
222 | 128 | |||
223 | 129 | def get_tabs(self): | ||
224 | 130 | """Return all tabs""" | ||
225 | 131 | return self.get_object("Tabs", "rootTabs") | ||
226 | 132 | |||
227 | 133 | def _previous_tab(self): | ||
228 | 134 | """Switch to the previous tab""" | ||
229 | 135 | qmlView = self.get_qml_view() | ||
230 | 136 | |||
231 | 137 | startX = qmlView.x + qmlView.width * 0.35 | ||
232 | 138 | stopX = qmlView.x + qmlView.width * 0.50 | ||
233 | 139 | lineY = qmlView.y + qmlView.height * 0.05 | ||
234 | 140 | |||
235 | 141 | self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY) | ||
236 | 142 | self.autopilot.pointing_device.click() | ||
237 | 143 | self.autopilot.pointing_device.click() | ||
238 | 144 | |||
239 | 145 | def _next_tab(self): | ||
240 | 146 | """Switch to the next tab""" | ||
241 | 147 | qmlView = self.get_qml_view() | ||
242 | 148 | |||
243 | 149 | startX = qmlView.x + qmlView.width * 0.50 | ||
244 | 150 | stopX = qmlView.x + qmlView.width * 0.35 | ||
245 | 151 | lineY = qmlView.y + qmlView.height * 0.05 | ||
246 | 152 | |||
247 | 153 | self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY) | ||
248 | 154 | self.autopilot.pointing_device.click() | ||
249 | 0 | 155 | ||
250 | === modified file 'tests/autopilot/ubuntu_terminal_app/tests/__init__.py' | |||
251 | --- tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2013-05-31 13:10:55 +0000 | |||
252 | +++ tests/autopilot/ubuntu_terminal_app/tests/__init__.py 2013-06-19 18:58:26 +0000 | |||
253 | @@ -14,6 +14,7 @@ | |||
254 | 14 | from autopilot.testcase import AutopilotTestCase | 14 | from autopilot.testcase import AutopilotTestCase |
255 | 15 | 15 | ||
256 | 16 | from ubuntu_terminal_app.emulators.main_window import MainWindow | 16 | from ubuntu_terminal_app.emulators.main_window import MainWindow |
257 | 17 | from ubuntu_terminal_app.emulators.ubuntusdk import ubuntusdk | ||
258 | 17 | 18 | ||
259 | 18 | 19 | ||
260 | 19 | class TerminalTestCase(AutopilotTestCase): | 20 | class TerminalTestCase(AutopilotTestCase): |
261 | @@ -52,4 +53,9 @@ | |||
262 | 52 | 53 | ||
263 | 53 | @property | 54 | @property |
264 | 54 | def main_window(self): | 55 | def main_window(self): |
266 | 55 | return MainWindow(self.app) | 56 | return MainWindow(self, self.app) |
267 | 57 | |||
268 | 58 | @property | ||
269 | 59 | def ubuntu_sdk(self): | ||
270 | 60 | return ubuntusdk(self, self.app) | ||
271 | 61 | |||
272 | 56 | 62 | ||
273 | === modified file 'tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py' | |||
274 | --- tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2013-05-31 13:10:55 +0000 | |||
275 | +++ tests/autopilot/ubuntu_terminal_app/tests/test_terminal.py 2013-06-19 18:58:26 +0000 | |||
276 | @@ -14,25 +14,64 @@ | |||
277 | 14 | 14 | ||
278 | 15 | from ubuntu_terminal_app.tests import TerminalTestCase | 15 | from ubuntu_terminal_app.tests import TerminalTestCase |
279 | 16 | 16 | ||
280 | 17 | import time | ||
281 | 17 | 18 | ||
282 | 18 | class TestMainWindow(TerminalTestCase): | 19 | class TestMainWindow(TerminalTestCase): |
283 | 19 | 20 | ||
284 | 20 | def setUp(self): | 21 | def setUp(self): |
285 | 21 | super(TestMainWindow, self).setUp() | 22 | super(TestMainWindow, self).setUp() |
286 | 22 | self.assertThat( | 23 | self.assertThat( |
288 | 23 | self.main_window.get_qml_view().visible, Eventually(Equals(True))) | 24 | self.ubuntu_sdk.get_qml_view().visible, Eventually(Equals(True))) |
289 | 24 | 25 | ||
290 | 25 | def tearDown(self): | 26 | def tearDown(self): |
291 | 26 | super(TestMainWindow, self).tearDown() | 27 | super(TestMainWindow, self).tearDown() |
292 | 27 | 28 | ||
304 | 28 | def test_toolbar_shows(self): | 29 | def test_Control_Panel_shows(self): |
305 | 29 | """Make sure that dragging from the bottom reveals the hidden | 30 | """Make sure that Control Keys Panel is visible |
306 | 30 | toolbar.""" | 31 | when clicking the toolbar popup items.""" |
307 | 31 | toolbar = self.main_window.get_toolbar() | 32 | self.ubuntu_sdk.click_toolbar_button("Panels") |
308 | 32 | 33 | self.main_window.click_popup_item("Control keys") | |
309 | 33 | x, y, w, h = toolbar.globalRect | 34 | panelCtrl = self.ubuntu_sdk.get_object("CtrlKeys", "kbCtrl") |
310 | 34 | tx = x + (w / 2) | 35 | self.assertThat(panelCtrl.visible, Eventually(Equals(True))) |
311 | 35 | ty = y + (h - 2) | 36 | |
312 | 36 | 37 | def test_Function_Panel_shows(self): | |
313 | 37 | self.pointing_device.drag(tx, ty, tx, ty - h) | 38 | """Make sure that Function Keys Panel is visible |
314 | 38 | self.assertThat(toolbar.state, Eventually(Equals("spread"))) | 39 | when clicking the toolbar popup items.""" |
315 | 40 | self.ubuntu_sdk.click_toolbar_button("Panels") | ||
316 | 41 | self.main_window.click_popup_item("Function keys") | ||
317 | 42 | panelFunc = self.ubuntu_sdk.get_object("FnKeys", "kbFn") | ||
318 | 43 | self.assertThat(panelFunc.visible, Eventually(Equals(True))) | ||
319 | 44 | |||
320 | 45 | def test_TextCtrl_Panel_shows(self): | ||
321 | 46 | """Make sure that Text Control Keys Panel is visible | ||
322 | 47 | when clicking the toolbar popup items.""" | ||
323 | 48 | self.ubuntu_sdk.click_toolbar_button("Panels") | ||
324 | 49 | self.main_window.click_popup_item("Text ctrl keys") | ||
325 | 50 | panelScrl = self.ubuntu_sdk.get_object("ScrlKeys", "kbScrl") | ||
326 | 51 | self.assertThat(panelScrl.visible, Eventually(Equals(True))) | ||
327 | 52 | |||
328 | 53 | def test_Panels_hide(self): | ||
329 | 54 | """Make sure that all panels are hide | ||
330 | 55 | when clicking the toolbar popup items.""" | ||
331 | 56 | self.ubuntu_sdk.click_toolbar_button("Panels") | ||
332 | 57 | self.main_window.click_popup_item("Hide extra panel") | ||
333 | 58 | panelCtrl = self.ubuntu_sdk.get_object("CtrlKeys", "kbCtrl") | ||
334 | 59 | panelFunc = self.ubuntu_sdk.get_object("FnKeys", "kbFn") | ||
335 | 60 | panelScrl = self.ubuntu_sdk.get_object("ScrlKeys", "kbScrl") | ||
336 | 61 | self.assertThat(panelCtrl.visible, Eventually(Equals(False))) | ||
337 | 62 | self.assertThat(panelFunc.visible, Eventually(Equals(False))) | ||
338 | 63 | self.assertThat(panelScrl.visible, Eventually(Equals(False))) | ||
339 | 64 | |||
340 | 65 | def test_CircleMenu_shows(self): | ||
341 | 66 | """Make sure that Circle Menu is visible | ||
342 | 67 | on long tap""" | ||
343 | 68 | kterm = self.ubuntu_sdk.get_object("KTerminalDisplay", "kterm") | ||
344 | 69 | menu = self.ubuntu_sdk.get_object("CircleMenu", "cmenu") | ||
345 | 70 | self.pointing_device.click_object(kterm) | ||
346 | 71 | self.pointing_device.press() | ||
347 | 72 | time.sleep(1) | ||
348 | 73 | self.pointing_device.release() | ||
349 | 74 | self.assertThat(menu.visible, Eventually(Equals(True))) | ||
350 | 75 | |||
351 | 76 | |||
352 | 77 |
PASSED: Continuous integration, rev:16 91.189. 93.125: 8080/job/ ubuntu- terminal- app-ci/ 5/ 91.189. 93.125: 8080/job/ ubuntu- terminal- app-quantal- amd64-ci/ 4 91.189. 93.125: 8080/job/ ubuntu- terminal- app-raring- amd64-ci/ 5
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: 91.189. 93.125: 8080/job/ ubuntu- terminal- app-ci/ 5/rebuild
http://