Merge lp:~elopio/ubuntu-ui-toolkit/clean_gallery_tests2 into lp:ubuntu-ui-toolkit/staging
- clean_gallery_tests2
- Merge into staging
Status: | Merged |
---|---|
Approved by: | Tim Peeters |
Approved revision: | 1095 |
Merged at revision: | 1103 |
Proposed branch: | lp:~elopio/ubuntu-ui-toolkit/clean_gallery_tests2 |
Merge into: | lp:ubuntu-ui-toolkit/staging |
Diff against target: |
379 lines (+39/-172) 8 files modified
tests/autopilot/ubuntuuitoolkit/tests/__init__.py (+1/-112) tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py (+21/-7) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py (+1/-3) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py (+9/-29) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py (+1/-3) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_scrollbar.py (+2/-4) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py (+2/-6) tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py (+2/-8) |
To merge this branch: | bzr merge lp:~elopio/ubuntu-ui-toolkit/clean_gallery_tests2 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Approve | |
Tim Peeters | Approve | ||
Review via email: mp+221884@code.launchpad.net |
Commit message
More clean ups to the autopilot tests for the widget gallery.
Description of the change
Tim Peeters (tpeeters) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1093
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Tim Peeters (tpeeters) wrote : | # |
the removed functions are not private, are we sure they are not being called by app tests?
Tim Peeters (tpeeters) wrote : | # |
150 +import ubuntuuitoolkit
151 from ubuntuuitoolkit import tests
do we need two imports of ubuntuuitoolkit?
Leo Arias (elopio) wrote : | # |
I didn't run all the tests of the apps, but no test outside the toolkit should use the class QMLFileAppTestCase. Actually, we should turn that into private, not export anything from the tests module and if something is needed by the apps move it to ubuntuuitoolkit
With the import, you are right. I've made the change and IMO it looks better.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1094
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1094
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Autolanding.
More details in the following jenkins job:
http://
Executed test runs:
UNSTABLE: http://
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1095
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/__init__.py' |
2 | --- tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-05-29 16:17:56 +0000 |
3 | +++ tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-06-09 17:21:28 +0000 |
4 | @@ -1,6 +1,6 @@ |
5 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
6 | # |
7 | -# Copyright (C) 2012, 2013 Canonical Ltd. |
8 | +# Copyright (C) 2012, 2013, 2014 Canonical Ltd. |
9 | # |
10 | # This program is free software; you can redistribute it and/or modify |
11 | # it under the terms of the GNU Lesser General Public License as published by |
12 | @@ -142,91 +142,6 @@ |
13 | def main_view(self): |
14 | return self.app.select_single(emulators.MainView) |
15 | |
16 | - def checkListItem(self, itemText): |
17 | - item = self.getListItem(itemText) |
18 | - self.assertThat(item, Not(Is(None))) |
19 | - |
20 | - def getListItem(self, itemText): |
21 | - # XXX We shouldn't access the elements by text, because that's likely |
22 | - # to change often and might be translated. We should always use the |
23 | - # objectName instead. --elopio - 2013-06-26216 |
24 | - return self.main_view.select_single("Standard", text=itemText) |
25 | - |
26 | - def getWidgetLoaderAndListView(self): |
27 | - contentLoader = self.main_view.select_single( |
28 | - "QQuickLoader", objectName="contentLoader") |
29 | - listView = self.main_view.select_single( |
30 | - "QQuickListView", objectName="widgetList") |
31 | - self.assertThat(listView, Not(Is(None))) |
32 | - self.assertThat(listView.visible, Eventually(Equals(True))) |
33 | - return (contentLoader, listView) |
34 | - |
35 | - def loadItem(self, item): |
36 | - self.selectItem(item) |
37 | - contentLoader = self.main_view.select_single( |
38 | - "QQuickLoader", objectName="contentLoader") |
39 | - self.assertThat(contentLoader.progress, Eventually(Equals(1.0))) |
40 | - loadedPage = self.getListItem(item) |
41 | - self.assertThat(loadedPage, Not(Is(None))) |
42 | - #loadedPage is not a page, it is the list item which goes in |
43 | - #background when the item is selected, which changes the visible |
44 | - #property of item in list itself to False. So followin check |
45 | - #fails on Nexus 4. Commenting it for now. |
46 | - #self.assertThat(loadedPage.visible, Eventually(Equals(True))) |
47 | - |
48 | - def drag(self, itemText, itemTextTo): |
49 | - item = self.getListItem(itemText) |
50 | - itemTo = self.getListItem(itemTextTo) |
51 | - |
52 | - self.pointing_device.move_to_object(item) |
53 | - self.pointing_device.press() |
54 | - self.pointing_device.move_to_object(itemTo) |
55 | - self.pointing_device.release() |
56 | - |
57 | - def reveal_item_by_flick(self, item, flickable, direction): |
58 | - x1, y1, w1, h1 = item.globalRect |
59 | - x2, y2, w2, h2 = flickable.globalRect |
60 | - if direction is FlickDirection.UP: |
61 | - while y1 + h1 > y2 + h2: |
62 | - self.flick(flickable, direction) |
63 | - x1, y1, w1, h1 = item.globalRect |
64 | - elif direction is FlickDirection.DOWN: |
65 | - while y1 < y2: |
66 | - self.flick(flickable, direction) |
67 | - x1, y1, w1, h1 = item.globalRect |
68 | - |
69 | - def flick(self, flickable, direction, delta=40): |
70 | - """This funcito flicks the page from middle to the given direction.""" |
71 | - x, y, w, h = flickable.globalRect |
72 | - if direction == FlickDirection.UP: |
73 | - self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2, |
74 | - y + h / 2 - delta) |
75 | - flickable.flicking.wait_for(False) |
76 | - elif direction == FlickDirection.DOWN: |
77 | - self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2, |
78 | - y + h / 2 + delta) |
79 | - flickable.flicking.wait_for(False) |
80 | - else: |
81 | - raise ValueError("Invalid direction or not implementd yet") |
82 | - |
83 | - def selectItem(self, itemText): |
84 | - item = self.getListItem(itemText) |
85 | - x1, y1, w1, h1 = item.globalRect |
86 | - x2, y2, w2, h2 = self.main_view.globalRect |
87 | - |
88 | - orientationHelper = self.getOrientationHelper() |
89 | - rot = orientationHelper.rotation |
90 | - scrollTo = h2 / 2 - (y1 - h2 - h1) |
91 | - if rot == 0.0 and y1 > h2: |
92 | - self.pointing_device.drag(w2 / 2, h2 / 2, w2 / 2, scrollTo) |
93 | - |
94 | - self.assertThat(item.selected, Eventually(Equals(False))) |
95 | - |
96 | - self.pointing_device.move_to_object(item) |
97 | - self.pointing_device.click() |
98 | - |
99 | - self.assertThat(item.selected, Eventually(Equals(True))) |
100 | - |
101 | def getOrientationHelper(self): |
102 | orientationHelper = self.main_view.select_many( |
103 | "OrientationHelper")[0] |
104 | @@ -249,29 +164,3 @@ |
105 | obj = self.getObject(objectName) |
106 | self.pointing_device.move_to_object(obj) |
107 | self.pointing_device.click() |
108 | - |
109 | - def mousePress(self, objectName): |
110 | - obj = self.getObject(objectName) |
111 | - self.pointing_device.move_to_object(obj) |
112 | - self.pointing_device.press() |
113 | - |
114 | - def mouseRelease(self): |
115 | - self.pointing_device.release() |
116 | - |
117 | - def type_string(self, string): |
118 | - self.keyboard.type(string) |
119 | - |
120 | - def type_key(self, key): |
121 | - self.keyboard.key(key) |
122 | - |
123 | - def tap_clearButton(self, objectName): |
124 | - textField = self.getObject(objectName) |
125 | - self.assertIsNotNone(textField) |
126 | - self.pointing_device.click_object(textField) |
127 | - self.assertThat(textField.focus, Eventually(Equals(True))) |
128 | - self.assertThat(textField.hasClearButton, Eventually(Equals(True))) |
129 | - btn = textField.select_single("AbstractButton") |
130 | - self.assertIsNotNone(btn) |
131 | - self.assertThat(btn.visible, Eventually(Equals(True))) |
132 | - self.pointing_device.click_object(btn) |
133 | - self.assertThat(btn.pressed, Eventually(Equals(False))) |
134 | |
135 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py' |
136 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2013-10-24 11:01:03 +0000 |
137 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2014-06-09 17:21:28 +0000 |
138 | @@ -1,6 +1,6 @@ |
139 | # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
140 | # |
141 | -# Copyright (C) 2012, 2013 Canonical Ltd. |
142 | +# Copyright (C) 2012, 2013, 2014 Canonical Ltd. |
143 | # |
144 | # This program is free software; you can redistribute it and/or modify |
145 | # it under the terms of the GNU Lesser General Public License as published by |
146 | @@ -19,10 +19,10 @@ |
147 | import os |
148 | import shutil |
149 | |
150 | -from ubuntuuitoolkit import tests |
151 | - |
152 | - |
153 | -class GalleryTestCase(tests.QMLFileAppTestCase): |
154 | +import ubuntuuitoolkit |
155 | + |
156 | + |
157 | +class GalleryTestCase(ubuntuuitoolkit.tests.QMLFileAppTestCase): |
158 | """Base class for gallery test cases.""" |
159 | |
160 | local_desktop_file_path = None |
161 | @@ -39,7 +39,7 @@ |
162 | |
163 | def _get_path_to_gallery_source(self): |
164 | return os.path.join( |
165 | - tests.get_path_to_source_root(), 'examples', |
166 | + ubuntuuitoolkit.tests.get_path_to_source_root(), 'examples', |
167 | 'ubuntu-ui-toolkit-gallery') |
168 | |
169 | def _application_source_exists(self): |
170 | @@ -58,7 +58,8 @@ |
171 | self.test_source_path, |
172 | 'ubuntu-ui-toolkit-gallery.desktop') |
173 | if self._application_source_exists(): |
174 | - local_desktop_file_dir = tests.get_local_desktop_file_directory() |
175 | + local_desktop_file_dir = ( |
176 | + ubuntuuitoolkit.tests.get_local_desktop_file_directory()) |
177 | if not os.path.exists(local_desktop_file_dir): |
178 | os.makedirs(local_desktop_file_dir) |
179 | local_desktop_file_path = os.path.join( |
180 | @@ -71,6 +72,19 @@ |
181 | else: |
182 | return desktop_file_path |
183 | |
184 | + def open_page(self, page): |
185 | + """Open a page of the widget gallery. |
186 | + |
187 | + :param page: The objectName of the element in the index list that opens |
188 | + the page. |
189 | + |
190 | + """ |
191 | + list_view = self.main_view.select_single( |
192 | + ubuntuuitoolkit.QQuickListView, objectName="widgetList") |
193 | + list_view.click_element(page) |
194 | + element = self.main_view.select_single('Standard', objectName=page) |
195 | + element.selected.wait_for(True) |
196 | + |
197 | def tearDown(self): |
198 | super(GalleryTestCase, self).tearDown() |
199 | # We can't delete the desktop file before we close the application, |
200 | |
201 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py' |
202 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-02-11 01:55:49 +0000 |
203 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-06-09 17:21:28 +0000 |
204 | @@ -45,9 +45,7 @@ |
205 | ] |
206 | |
207 | def test_buttons(self): |
208 | - item = "Buttons" |
209 | - self.loadItem(item) |
210 | - self.checkPageHeader(item) |
211 | + self.open_page('buttonsElement') |
212 | |
213 | button = self.app.select_single(objectName=self.button_name) |
214 | self.assertIsNot(button, None) |
215 | |
216 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py' |
217 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-06-04 08:18:44 +0000 |
218 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-06-09 17:21:28 +0000 |
219 | @@ -16,32 +16,19 @@ |
220 | |
221 | """Tests for the Ubuntu UI Toolkit Gallery""" |
222 | |
223 | -from autopilot.matchers import Eventually |
224 | -from testtools.matchers import Is, Not, Equals |
225 | - |
226 | -from ubuntuuitoolkit import emulators |
227 | +import ubuntuuitoolkit |
228 | from ubuntuuitoolkit.tests import gallery |
229 | |
230 | |
231 | -class GenericTests(gallery.GalleryTestCase): |
232 | +class GalleryAppTestCase(gallery.GalleryTestCase): |
233 | """Generic tests for the Gallery""" |
234 | |
235 | - def test_0_can_select_mainwindow(self): |
236 | - """Must be able to select the main window.""" |
237 | - |
238 | - rootItem = self.main_view |
239 | - self.assertThat(rootItem, Not(Is(None))) |
240 | - self.assertThat(rootItem.visible, Eventually(Equals(True))) |
241 | - |
242 | - def test_navigation(self): |
243 | - item = "Navigation" |
244 | - self.loadItem(item) |
245 | - self.checkPageHeader(item) |
246 | + def test_select_main_view_must_return_main_window_emulator(self): |
247 | + main_view = self.main_view |
248 | + self.assertIsInstance(main_view, ubuntuuitoolkit.MainView) |
249 | |
250 | def test_slider(self): |
251 | - item = "Slider" |
252 | - self.loadItem(item) |
253 | - self.checkPageHeader(item) |
254 | + self.open_page('slidersElement') |
255 | |
256 | item_data = [ |
257 | ["slider_standard"], |
258 | @@ -57,9 +44,7 @@ |
259 | # TODO: move slider value |
260 | |
261 | def test_progress_and_activity(self): |
262 | - item = "Progress and activity" |
263 | - self.loadItem(item) |
264 | - self.checkPageHeader(item) |
265 | + self.open_page('progressBarsElement') |
266 | |
267 | item_data = [ |
268 | ["progressbar_standard"], |
269 | @@ -79,9 +64,7 @@ |
270 | # FIXME: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1308979 |
271 | return |
272 | |
273 | - item = "Ubuntu Shape" |
274 | - self.loadItem(item) |
275 | - self.checkPageHeader(item) |
276 | + self.open_page('ubuntuShapesElement') |
277 | |
278 | item_data = [ |
279 | ["ubuntushape_color_hex"], |
280 | @@ -115,12 +98,9 @@ |
281 | ] |
282 | |
283 | def test_open_page(self): |
284 | - list_view = self.main_view.select_single( |
285 | - emulators.QQuickListView, objectName="widgetList") |
286 | - list_view.click_element(self.element_name) |
287 | + self.open_page(self.element_name) |
288 | element = self.main_view.select_single( |
289 | 'Standard', objectName=self.element_name) |
290 | - element.selected.wait_for(True) |
291 | self.checkPageHeader(element.text) |
292 | if self.template_name == 'textinputsTemplate': |
293 | page_type = 'TextInputs' |
294 | |
295 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py' |
296 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-05-23 09:50:42 +0000 |
297 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-06-09 17:21:28 +0000 |
298 | @@ -24,9 +24,7 @@ |
299 | |
300 | def setUp(self): |
301 | super(OptionSelectorTestCase, self).setUp() |
302 | - item = "Option Selector" |
303 | - self.loadItem(item) |
304 | - self.checkPageHeader(item) |
305 | + self.open_page('optionSelectorsElement') |
306 | |
307 | def test_select_option_from_collapsed_optionselector(self): |
308 | collapsed_option_selector = self.main_view.select_single( |
309 | |
310 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_scrollbar.py' |
311 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_scrollbar.py 2014-05-07 09:23:39 +0000 |
312 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_scrollbar.py 2014-06-09 17:21:28 +0000 |
313 | @@ -23,10 +23,8 @@ |
314 | |
315 | def setUp(self): |
316 | super(ScrollBarTestCase, self).setUp() |
317 | - item = 'Navigation' |
318 | - self.loadItem(item) |
319 | - self.checkPageHeader(item) |
320 | - self.scrollbar = self.main_view.select_single( |
321 | + self.open_page('navigationElement') |
322 | + self.scrollbar = self.main_view.wait_select_single( |
323 | 'Scrollbar', objectName="TemplateScrollbar") |
324 | |
325 | def move_mouse_to_thumb(self): |
326 | |
327 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py' |
328 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-04-30 09:40:17 +0000 |
329 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-06-09 17:21:28 +0000 |
330 | @@ -54,9 +54,7 @@ |
331 | # Apply the user locale from the environment |
332 | # The UITK does the same, so the test must be localized |
333 | locale.setlocale(locale.LC_ALL, "") |
334 | - item = 'Text Field' |
335 | - self.loadItem(item) |
336 | - self.checkPageHeader(item) |
337 | + self.open_page('textinputsElement') |
338 | |
339 | def test_write_on_textfield_must_update_text(self): |
340 | textfield = self.main_view.select_single( |
341 | @@ -78,9 +76,7 @@ |
342 | |
343 | def setUp(self): |
344 | super(DisabledTextInputTestCase, self).setUp() |
345 | - item = 'Text Field' |
346 | - self.loadItem(item) |
347 | - self.checkPageHeader(item) |
348 | + self.open_page('textinputsElement') |
349 | |
350 | def test_textfield_disabled(self): |
351 | textfield_disabled = self.main_view.select_single( |
352 | |
353 | === modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py' |
354 | --- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2013-11-01 15:15:30 +0000 |
355 | +++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2014-06-09 17:21:28 +0000 |
356 | @@ -35,10 +35,7 @@ |
357 | |
358 | def setUp(self): |
359 | super(EnabledTogglesTestCase, self).setUp() |
360 | - item = "Toggles" |
361 | - self.checkListItem(item) |
362 | - self.loadItem(item) |
363 | - self.checkPageHeader(item) |
364 | + self.open_page('togglesElement') |
365 | |
366 | def test_change_toggles_state(self): |
367 | toggle = self.main_view.select_single( |
368 | @@ -65,10 +62,7 @@ |
369 | |
370 | def setUp(self): |
371 | super(DisabledTogglesTestCase, self).setUp() |
372 | - item = "Toggles" |
373 | - self.checkListItem(item) |
374 | - self.loadItem(item) |
375 | - self.checkPageHeader(item) |
376 | + self.open_page('togglesElement') |
377 | |
378 | def test_change_toggles_state(self): |
379 | toggle = self.main_view.select_single( |
did you run the AP tests for the applications to make sure none of the removed functions are used there?