Status: | Superseded |
---|---|
Proposed branch: | lp:~elopio/unity8/open_scope |
Merge into: | lp:unity8 |
Diff against target: |
363 lines (+242/-23) 6 files modified
debian/control (+1/-0) tests/autopilot/unity8/shell/emulators/__init__.py (+13/-6) tests/autopilot/unity8/shell/emulators/dash.py (+106/-12) tests/autopilot/unity8/shell/emulators/greeter.py (+2/-5) tests/autopilot/unity8/shell/tests/__init__.py (+1/-0) tests/autopilot/unity8/shell/tests/test_emulators.py (+119/-0) |
To merge this branch: | bzr merge lp:~elopio/unity8/open_scope |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Needs Fixing | |
Albert Astals Cid (community) | Approve | ||
Richard Huddie (community) | Approve | ||
Unity Team | Pending | ||
Review via email: mp+200426@code.launchpad.net |
This proposal has been superseded by a proposal from 2014-01-09.
Commit message
Added methods to scroll to other scopes on autopilot tests.
Description of the change
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:614
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:615
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Richard Huddie (rhuddie) wrote : | # |
Regarding the last 2 tests, test_open_
Leo Arias (elopio) wrote : | # |
What I wanted to test in those two is just that the returned scope is of the right type. If it's open or not didn't seem relevant for me, as the opening is tested in the other tests.
Richard Huddie (rhuddie) wrote : | # |
Agreed, just wanted to clarify the scope of the test.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:616
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:617
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:618
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Leo Arias (elopio) wrote : | # |
back to work in progress because now there is no bottom bar, and the header has the toolkit tabs.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:619
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:619
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Leo Arias (elopio) wrote : | # |
Back to work in progress. Now I won't use indexes.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:620
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:621
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:620
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:621
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:623
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:623
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Looks good to me, tests pass in my machine, wonder why not in CI :_/
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:623
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:624
http://
Executed test runs:
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
deb: http://
FAILURE: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Unmerged revisions
Preview Diff
1 | === modified file 'debian/control' | |||
2 | --- debian/control 2013-12-20 15:37:27 +0000 | |||
3 | +++ debian/control 2014-01-09 21:28:09 +0000 | |||
4 | @@ -104,6 +104,7 @@ | |||
5 | 104 | libqt5widgets5, | 104 | libqt5widgets5, |
6 | 105 | python-evdev, | 105 | python-evdev, |
7 | 106 | python-gi, | 106 | python-gi, |
8 | 107 | python-mock, | ||
9 | 107 | unity8 (>= ${source:Version}), | 108 | unity8 (>= ${source:Version}), |
10 | 108 | unity8-fake-env (>= ${source:Version}), | 109 | unity8-fake-env (>= ${source:Version}), |
11 | 109 | ${misc:Depends}, | 110 | ${misc:Depends}, |
12 | 110 | 111 | ||
13 | === modified file 'tests/autopilot/unity8/shell/emulators/__init__.py' | |||
14 | --- tests/autopilot/unity8/shell/emulators/__init__.py 2013-10-02 09:01:12 +0000 | |||
15 | +++ tests/autopilot/unity8/shell/emulators/__init__.py 2014-01-09 21:28:09 +0000 | |||
16 | @@ -1,7 +1,7 @@ | |||
17 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
18 | 2 | # | 2 | # |
19 | 3 | # Unity Autopilot Test Suite | 3 | # Unity Autopilot Test Suite |
21 | 4 | # Copyright (C) 2012-2013 Canonical | 4 | # Copyright (C) 2012, 2013, 2014 Canonical |
22 | 5 | # | 5 | # |
23 | 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
24 | 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
25 | @@ -17,9 +17,16 @@ | |||
26 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
27 | 18 | # | 18 | # |
28 | 19 | 19 | ||
34 | 20 | 20 | from autopilot import input, introspection | |
35 | 21 | from autopilot.introspection import CustomEmulatorBase | 21 | |
36 | 22 | 22 | ||
37 | 23 | 23 | class UnityEmulatorBase(introspection.CustomEmulatorBase): | |
33 | 24 | class UnityEmulatorBase(CustomEmulatorBase): | ||
38 | 25 | """A base class for all unity emulators.""" | 24 | """A base class for all unity emulators.""" |
39 | 25 | |||
40 | 26 | def __init__(self, *args): | ||
41 | 27 | super(UnityEmulatorBase, self).__init__(*args) | ||
42 | 28 | self.pointing_device = input.Touch.create() | ||
43 | 29 | |||
44 | 30 | |||
45 | 31 | class UnityEmulatorException(Exception): | ||
46 | 32 | """Exception raised when there is an error with the Unity emulators.""" | ||
47 | 26 | 33 | ||
48 | === modified file 'tests/autopilot/unity8/shell/emulators/dash.py' | |||
49 | --- tests/autopilot/unity8/shell/emulators/dash.py 2013-11-01 13:59:50 +0000 | |||
50 | +++ tests/autopilot/unity8/shell/emulators/dash.py 2014-01-09 21:28:09 +0000 | |||
51 | @@ -1,7 +1,7 @@ | |||
52 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
53 | 2 | # | 2 | # |
54 | 3 | # Unity Autopilot Test Suite | 3 | # Unity Autopilot Test Suite |
56 | 4 | # Copyright (C) 2012-2013 Canonical | 4 | # Copyright (C) 2012, 2013, 2014 Canonical |
57 | 5 | # | 5 | # |
58 | 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
59 | 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
60 | @@ -17,13 +17,25 @@ | |||
61 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. |
62 | 18 | # | 18 | # |
63 | 19 | 19 | ||
69 | 20 | from unity8.shell.emulators import UnityEmulatorBase | 20 | import logging |
70 | 21 | 21 | ||
71 | 22 | 22 | from unity8.shell import emulators | |
72 | 23 | class Dash(UnityEmulatorBase): | 23 | |
73 | 24 | 24 | from autopilot import logging as autopilot_logging | |
74 | 25 | from autopilot.introspection import dbus | ||
75 | 26 | |||
76 | 27 | |||
77 | 28 | logger = logging.getLogger(__name__) | ||
78 | 29 | |||
79 | 30 | |||
80 | 31 | class Dash(emulators.UnityEmulatorBase): | ||
81 | 25 | """An emulator that understands the Dash.""" | 32 | """An emulator that understands the Dash.""" |
82 | 26 | 33 | ||
83 | 34 | def __init__(self, *args): | ||
84 | 35 | super(Dash, self).__init__(*args) | ||
85 | 36 | self.dash_content_list = self.wait_select_single( | ||
86 | 37 | 'QQuickListView', objectName='dashContentList') | ||
87 | 38 | |||
88 | 27 | def get_home_applications_grid(self): | 39 | def get_home_applications_grid(self): |
89 | 28 | get_grid = self.get_scope('home').wait_select_single( | 40 | get_grid = self.get_scope('home').wait_select_single( |
90 | 29 | "GenericFilterGrid", | 41 | "GenericFilterGrid", |
91 | @@ -43,9 +55,91 @@ | |||
92 | 43 | return resp_grid.select_single('Tile', text=text) | 55 | return resp_grid.select_single('Tile', text=text) |
93 | 44 | 56 | ||
94 | 45 | def get_scope(self, scope_name='home'): | 57 | def get_scope(self, scope_name='home'): |
101 | 46 | dash_content = self.wait_select_single( | 58 | scope_id = "%s.scope" % scope_name |
102 | 47 | 'QQuickListView', | 59 | return self.dash_content_list.select_single( |
103 | 48 | objectName='dashContentList' | 60 | 'QQuickLoader', scopeId=scope_id) |
104 | 49 | ) | 61 | |
105 | 50 | scope_id = "%s.scope" % scope_name | 62 | @autopilot_logging.log_action(logger.info) |
106 | 51 | return dash_content.select_single('QQuickLoader', scopeId=scope_id) | 63 | def open_scope(self, scope_name): |
107 | 64 | """Open a dash scope. | ||
108 | 65 | |||
109 | 66 | :parameter scope_name: The name of the scope. | ||
110 | 67 | :return: The scope. | ||
111 | 68 | |||
112 | 69 | """ | ||
113 | 70 | scope_id = "%s.scope" % scope_name | ||
114 | 71 | scope_loader = self._get_scope_loader(scope_id) | ||
115 | 72 | if scope_loader.isCurrent: | ||
116 | 73 | logger.info('The scope is already open.') | ||
117 | 74 | return self._get_scope_from_loader(scope_loader) | ||
118 | 75 | else: | ||
119 | 76 | return self._open_scope_scrolling(scope_loader) | ||
120 | 77 | |||
121 | 78 | def _get_scope_loader(self, scope_id): | ||
122 | 79 | try: | ||
123 | 80 | return self.dash_content_list.select_single( | ||
124 | 81 | 'QQuickLoader', scopeId=scope_id) | ||
125 | 82 | except dbus.StateNotFoundError: | ||
126 | 83 | raise emulators.UnityEmulatorException( | ||
127 | 84 | 'No scope found with id {0}'.format(scope_id)) | ||
128 | 85 | |||
129 | 86 | def _get_scope_from_loader(self, loader): | ||
130 | 87 | if loader.scopeId == 'applications.scope': | ||
131 | 88 | return loader.select_single(DashApps) | ||
132 | 89 | else: | ||
133 | 90 | return loader.select_single(GenericScopeView) | ||
134 | 91 | |||
135 | 92 | def _open_scope_scrolling(self, scope_loader): | ||
136 | 93 | scroll = self._get_scroll_direction(scope_loader) | ||
137 | 94 | |||
138 | 95 | while not scope_loader.isCurrent: | ||
139 | 96 | scroll() | ||
140 | 97 | |||
141 | 98 | scope = self._get_scope_from_loader(scope_loader) | ||
142 | 99 | scope.moving.wait_for(False) | ||
143 | 100 | scope.isCurrent.wait_for(True) | ||
144 | 101 | return scope | ||
145 | 102 | |||
146 | 103 | def _get_scroll_direction(self, scope_loader): | ||
147 | 104 | current_scope_loader = self.dash_content_list.select_single( | ||
148 | 105 | 'QQuickLoader', isCurrent=True) | ||
149 | 106 | if scope_loader.globalRect.x < current_scope_loader.globalRect.x: | ||
150 | 107 | return self._scroll_to_left_scope | ||
151 | 108 | elif scope_loader.globalRect.x > current_scope_loader.globalRect.x: | ||
152 | 109 | return self._scroll_to_right_scope | ||
153 | 110 | else: | ||
154 | 111 | raise emulators.UnityEmulatorException('The scope is already open') | ||
155 | 112 | |||
156 | 113 | @autopilot_logging.log_action(logger.info) | ||
157 | 114 | def _scroll_to_left_scope(self): | ||
158 | 115 | original_index = self.dash_content_list.currentIndex | ||
159 | 116 | # Scroll on the border of the page header, because some scopes have | ||
160 | 117 | # contents that can be scrolled horizontally. | ||
161 | 118 | page_header = self.select_single('PageHeader') | ||
162 | 119 | border = page_header.select_single('QQuickBorderImage') | ||
163 | 120 | start_x = border.width / 3 | ||
164 | 121 | stop_x = border.width / 3 * 2 | ||
165 | 122 | start_y = stop_y = border.globalRect.y + border.height / 2 | ||
166 | 123 | self.pointing_device.drag(start_x, start_y, stop_x, stop_y) | ||
167 | 124 | self.dash_content_list.currentIndex.wait_for(original_index - 1) | ||
168 | 125 | |||
169 | 126 | @autopilot_logging.log_action(logger.info) | ||
170 | 127 | def _scroll_to_right_scope(self): | ||
171 | 128 | original_index = self.dash_content_list.currentIndex | ||
172 | 129 | # Scroll on the border of the page header, because some scopes have | ||
173 | 130 | # contents that can be scrolled horizontally. | ||
174 | 131 | page_header = self.select_single('PageHeader') | ||
175 | 132 | border = page_header.select_single('QQuickBorderImage') | ||
176 | 133 | start_x = border.width / 3 * 2 | ||
177 | 134 | stop_x = border.width / 3 | ||
178 | 135 | start_y = stop_y = border.globalRect.y + border.height / 2 | ||
179 | 136 | self.pointing_device.drag(start_x, start_y, stop_x, stop_y) | ||
180 | 137 | self.dash_content_list.currentIndex.wait_for(original_index + 1) | ||
181 | 138 | |||
182 | 139 | |||
183 | 140 | class GenericScopeView(emulators.UnityEmulatorBase): | ||
184 | 141 | """Autopilot emulators for generic scopes.""" | ||
185 | 142 | |||
186 | 143 | |||
187 | 144 | class DashApps(emulators.UnityEmulatorBase): | ||
188 | 145 | """Autopilot emulators for the applications scope.""" | ||
189 | 52 | 146 | ||
190 | === modified file 'tests/autopilot/unity8/shell/emulators/greeter.py' | |||
191 | --- tests/autopilot/unity8/shell/emulators/greeter.py 2013-11-01 13:59:50 +0000 | |||
192 | +++ tests/autopilot/unity8/shell/emulators/greeter.py 2014-01-09 21:28:09 +0000 | |||
193 | @@ -1,7 +1,7 @@ | |||
194 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
195 | 2 | # | 2 | # |
196 | 3 | # Unity Autopilot Test Suite | 3 | # Unity Autopilot Test Suite |
198 | 4 | # Copyright (C) 2012-2013 Canonical | 4 | # Copyright (C) 2012, 2013, 2014 Canonical |
199 | 5 | # | 5 | # |
200 | 6 | # This program is free software: you can redistribute it and/or modify | 6 | # This program is free software: you can redistribute it and/or modify |
201 | 7 | # it under the terms of the GNU General Public License as published by | 7 | # it under the terms of the GNU General Public License as published by |
202 | @@ -18,24 +18,21 @@ | |||
203 | 18 | # | 18 | # |
204 | 19 | 19 | ||
205 | 20 | from unity8.shell.emulators import UnityEmulatorBase | 20 | from unity8.shell.emulators import UnityEmulatorBase |
206 | 21 | from autopilot.input import Touch | ||
207 | 22 | 21 | ||
208 | 23 | 22 | ||
209 | 24 | class Greeter(UnityEmulatorBase): | 23 | class Greeter(UnityEmulatorBase): |
210 | 25 | |||
211 | 26 | """An emulator that understands the greeter screen.""" | 24 | """An emulator that understands the greeter screen.""" |
212 | 27 | 25 | ||
213 | 28 | def swipe(self): | 26 | def swipe(self): |
214 | 29 | """Swipe the greeter screen away.""" | 27 | """Swipe the greeter screen away.""" |
215 | 30 | self.created.wait_for(True) | 28 | self.created.wait_for(True) |
216 | 31 | touch = Touch.create() | ||
217 | 32 | 29 | ||
218 | 33 | rect = self.globalRect | 30 | rect = self.globalRect |
219 | 34 | start_x = rect[0] + rect[2] - 3 | 31 | start_x = rect[0] + rect[2] - 3 |
220 | 35 | start_y = int(rect[1] + rect[3] / 2) | 32 | start_y = int(rect[1] + rect[3] / 2) |
221 | 36 | stop_x = int(rect[0] + rect[2] * 0.2) | 33 | stop_x = int(rect[0] + rect[2] * 0.2) |
222 | 37 | stop_y = start_y | 34 | stop_y = start_y |
224 | 38 | touch.drag(start_x, start_y, stop_x, stop_y) | 35 | self.pointing_device.drag(start_x, start_y, stop_x, stop_y) |
225 | 39 | 36 | ||
226 | 40 | self.created.wait_for(False) | 37 | self.created.wait_for(False) |
227 | 41 | 38 | ||
228 | 42 | 39 | ||
229 | === modified file 'tests/autopilot/unity8/shell/tests/__init__.py' | |||
230 | --- tests/autopilot/unity8/shell/tests/__init__.py 2013-11-14 03:36:01 +0000 | |||
231 | +++ tests/autopilot/unity8/shell/tests/__init__.py 2014-01-09 21:28:09 +0000 | |||
232 | @@ -147,6 +147,7 @@ | |||
233 | 147 | if model() != "Desktop": | 147 | if model() != "Desktop": |
234 | 148 | from autopilot.input import _uinput | 148 | from autopilot.input import _uinput |
235 | 149 | _uinput._touch_device = _uinput.create_touch_device() | 149 | _uinput._touch_device = _uinput.create_touch_device() |
236 | 150 | self.addCleanup(_uinput._touch_device.close) | ||
237 | 150 | #### | 151 | #### |
238 | 151 | 152 | ||
239 | 152 | self.touch = Touch.create() | 153 | self.touch = Touch.create() |
240 | 153 | 154 | ||
241 | === added file 'tests/autopilot/unity8/shell/tests/test_emulators.py' | |||
242 | --- tests/autopilot/unity8/shell/tests/test_emulators.py 1970-01-01 00:00:00 +0000 | |||
243 | +++ tests/autopilot/unity8/shell/tests/test_emulators.py 2014-01-09 21:28:09 +0000 | |||
244 | @@ -0,0 +1,119 @@ | |||
245 | 1 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- | ||
246 | 2 | # | ||
247 | 3 | # Unity Autopilot Test Suite | ||
248 | 4 | # Copyright (C) 2014 Canonical | ||
249 | 5 | # | ||
250 | 6 | # This program is free software: you can redistribute it and/or modify | ||
251 | 7 | # it under the terms of the GNU General Public License as published by | ||
252 | 8 | # the Free Software Foundation, either version 3 of the License, or | ||
253 | 9 | # (at your option) any later version. | ||
254 | 10 | # | ||
255 | 11 | # This program is distributed in the hope that it will be useful, | ||
256 | 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
257 | 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
258 | 14 | # GNU General Public License for more details. | ||
259 | 15 | # | ||
260 | 16 | # You should have received a copy of the GNU General Public License | ||
261 | 17 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
262 | 18 | # | ||
263 | 19 | |||
264 | 20 | import mock | ||
265 | 21 | |||
266 | 22 | from unity8.shell import emulators, tests | ||
267 | 23 | from unity8.shell.emulators import dash as dash_emulators | ||
268 | 24 | |||
269 | 25 | |||
270 | 26 | class DashEmulatorTestCase(tests.UnityTestCase): | ||
271 | 27 | |||
272 | 28 | scenarios = tests._get_device_emulation_scenarios() | ||
273 | 29 | |||
274 | 30 | def setUp(self): | ||
275 | 31 | super(DashEmulatorTestCase, self).setUp() | ||
276 | 32 | self.launch_unity() | ||
277 | 33 | self.main_window.get_greeter().swipe() | ||
278 | 34 | self.dash = self.main_window.get_dash() | ||
279 | 35 | |||
280 | 36 | def test_open_unexisting_scope(self): | ||
281 | 37 | scope_name = 'unexisting' | ||
282 | 38 | with mock.patch.object(self.dash, 'pointing_device') as mock_pointer: | ||
283 | 39 | exception = self.assertRaises( | ||
284 | 40 | emulators.UnityEmulatorException, | ||
285 | 41 | self.dash.open_scope, scope_name) | ||
286 | 42 | |||
287 | 43 | self.assertEqual( | ||
288 | 44 | 'No scope found with id unexisting.scope', str(exception)) | ||
289 | 45 | self.assertFalse(mock_pointer.called) | ||
290 | 46 | |||
291 | 47 | def test_open_already_opened_scope(self): | ||
292 | 48 | scope_id = self._get_current_scope_id() | ||
293 | 49 | with mock.patch.object(self.dash, 'pointing_device') as mock_pointer: | ||
294 | 50 | scope = self.dash.open_scope(self._get_scope_name_from_id( | ||
295 | 51 | scope_id)) | ||
296 | 52 | |||
297 | 53 | self.assertFalse(mock_pointer.called) | ||
298 | 54 | self._assert_scope_is_opened(scope, scope_id) | ||
299 | 55 | |||
300 | 56 | def _assert_scope_is_opened(self, scope, scope_id): | ||
301 | 57 | self.assertTrue(scope.isCurrent) | ||
302 | 58 | scope_loader = scope.get_parent() | ||
303 | 59 | self.assertEqual(scope_loader.scopeId, scope_id) | ||
304 | 60 | |||
305 | 61 | def _get_current_scope_id(self): | ||
306 | 62 | scope = self.dash.dash_content_list.select_single( | ||
307 | 63 | 'QQuickLoader', isCurrent=True) | ||
308 | 64 | return scope.scopeId | ||
309 | 65 | |||
310 | 66 | def test_open_scope_to_the_right(self): | ||
311 | 67 | leftmost_scope = self._get_scope_name_from_id( | ||
312 | 68 | self._get_leftmost_scope_id()) | ||
313 | 69 | self.dash.open_scope(leftmost_scope) | ||
314 | 70 | |||
315 | 71 | scope_id = self._get_rightmost_scope_id() | ||
316 | 72 | scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id)) | ||
317 | 73 | self._assert_scope_is_opened(scope, scope_id) | ||
318 | 74 | |||
319 | 75 | def _get_leftmost_scope_id(self): | ||
320 | 76 | scope_loaders = self._get_scope_loaders() | ||
321 | 77 | leftmost_scope_loader = scope_loaders[0] | ||
322 | 78 | for loader in scope_loaders[1:]: | ||
323 | 79 | if loader.globalRect.x < leftmost_scope_loader.globalRect.x: | ||
324 | 80 | leftmost_scope_loader = loader | ||
325 | 81 | return leftmost_scope_loader.scopeId | ||
326 | 82 | |||
327 | 83 | def _get_scope_loaders(self): | ||
328 | 84 | item = self.dash.dash_content_list.get_children_by_type( | ||
329 | 85 | 'QQuickItem')[0] | ||
330 | 86 | return item.get_children_by_type('QQuickLoader') | ||
331 | 87 | |||
332 | 88 | def _get_scope_name_from_id(self, scope_id): | ||
333 | 89 | if scope_id.endswith('.scope'): | ||
334 | 90 | return scope_id[:-6] | ||
335 | 91 | |||
336 | 92 | def _get_rightmost_scope_id(self): | ||
337 | 93 | scope_loaders = self._get_scope_loaders() | ||
338 | 94 | rightmost_scope_loader = scope_loaders[0] | ||
339 | 95 | for loader in scope_loaders[1:]: | ||
340 | 96 | if loader.globalRect.x > rightmost_scope_loader.globalRect.x: | ||
341 | 97 | rightmost_scope_loader = loader | ||
342 | 98 | return rightmost_scope_loader.scopeId | ||
343 | 99 | |||
344 | 100 | def test_open_scope_to_the_left(self): | ||
345 | 101 | rightmost_scope = self._get_scope_name_from_id( | ||
346 | 102 | self._get_rightmost_scope_id()) | ||
347 | 103 | self.dash.open_scope(rightmost_scope) | ||
348 | 104 | |||
349 | 105 | scope_id = self._get_leftmost_scope_id() | ||
350 | 106 | scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id)) | ||
351 | 107 | self._assert_scope_is_opened(scope, scope_id) | ||
352 | 108 | |||
353 | 109 | def test_open_generic_scope(self): | ||
354 | 110 | scope_id = 'home.scope' | ||
355 | 111 | scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id)) | ||
356 | 112 | self._assert_scope_is_opened(scope, scope_id) | ||
357 | 113 | self.assertIsInstance(scope, dash_emulators.GenericScopeView) | ||
358 | 114 | |||
359 | 115 | def test_open_applications_scope(self): | ||
360 | 116 | scope_id = 'applications.scope' | ||
361 | 117 | scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id)) | ||
362 | 118 | self._assert_scope_is_opened(scope, scope_id) | ||
363 | 119 | self.assertIsInstance(scope, dash_emulators.DashApps) |
FAILED: Continuous integration, rev:613 jenkins. qa.ubuntu. com/job/ unity8- ci/1983/ jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty/ 1988/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- trusty- touch/1902/ console jenkins. qa.ubuntu. com/job/ unity-phablet- qmluitests- trusty/ 800/console jenkins. qa.ubuntu. com/job/ unity8- trusty- amd64-ci/ 505/console jenkins. qa.ubuntu. com/job/ unity8- trusty- armhf-ci/ 507/console jenkins. qa.ubuntu. com/job/ unity8- trusty- i386-ci/ 505/console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- amd64/1988/ console jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- trusty- armhf/1902/ console
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/unity8- ci/1983/ rebuild
http://