Merge lp:~elopio/ubuntu-ui-toolkit/slider-autopilot_helper into lp:ubuntu-ui-toolkit/staging

Proposed by Leo Arias
Status: Superseded
Proposed branch: lp:~elopio/ubuntu-ui-toolkit/slider-autopilot_helper
Merge into: lp:ubuntu-ui-toolkit/staging
Diff against target: 643 lines (+236/-170)
13 files modified
modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml (+4/-1)
tests/autopilot/ubuntuuitoolkit/__init__.py (+2/-0)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py (+2/-0)
tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_slider.py (+63/-0)
tests/autopilot/ubuntuuitoolkit/tests/__init__.py (+1/-112)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.SliderTestCase.qml (+32/-0)
tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.py (+95/-0)
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 (+10/-30)
tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py (+1/-3)
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/slider-autopilot_helper
Reviewer Review Type Date Requested Status
Ubuntu SDK team Pending
Review via email: mp+222310@code.launchpad.net

This proposal has been superseded by a proposal from 2014-06-06.

To post a comment you must log in.
1096. By Leo Arias

Remove the unused method.

1097. By Leo Arias

Fixed pep8.

1098. By Leo Arias

Added the last part of tests and checks to the slider helper.

1099. By Leo Arias

Added the docstring and logging.

1100. By Leo Arias

Removed the TODOs.

1101. By Leo Arias

Added a test for a negative float.

1102. By Leo Arias

Merged with staging.

1103. By Leo Arias

Changed the way we check for values not selectable, first try to select them.

1104. By Leo Arias

Merged with staging.

1105. By Leo Arias

Merged with staging.

1106. By Leo Arias

Use the device simulation scenarios to reproduce slider problems.

Unmerged revisions

1106. By Leo Arias

Use the device simulation scenarios to reproduce slider problems.

1105. By Leo Arias

Merged with staging.

1104. By Leo Arias

Merged with staging.

1103. By Leo Arias

Changed the way we check for values not selectable, first try to select them.

1102. By Leo Arias

Merged with staging.

1101. By Leo Arias

Added a test for a negative float.

1100. By Leo Arias

Removed the TODOs.

1099. By Leo Arias

Added the docstring and logging.

1098. By Leo Arias

Added the last part of tests and checks to the slider helper.

1097. By Leo Arias

Fixed pep8.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml'
2--- modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2014-04-23 08:50:20 +0000
3+++ modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2014-06-06 11:20:51 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright 2013 Canonical Ltd.
7+ * Copyright 2013, 2014 Canonical Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published by
11@@ -35,6 +35,8 @@
12
13 UbuntuShape {
14 id: background
15+ objectName: 'sliderBar'
16+
17 anchors {
18 verticalCenter: parent.verticalCenter
19 right: parent.right
20@@ -56,6 +58,7 @@
21
22 UbuntuShape {
23 id: thumb
24+ objectName: 'sliderThumb'
25
26 anchors {
27 verticalCenter: parent.verticalCenter
28
29=== modified file 'tests/autopilot/ubuntuuitoolkit/__init__.py'
30--- tests/autopilot/ubuntuuitoolkit/__init__.py 2014-05-09 04:12:25 +0000
31+++ tests/autopilot/ubuntuuitoolkit/__init__.py 2014-06-06 11:20:51 +0000
32@@ -34,6 +34,7 @@
33 'popups',
34 'QQuickFlickable',
35 'QQuickListView',
36+ 'Slider',
37 'TabBar',
38 'Tabs',
39 'tests',
40@@ -64,6 +65,7 @@
41 popups,
42 QQuickFlickable,
43 QQuickListView,
44+ Slider,
45 TabBar,
46 Tabs,
47 TextField,
48
49=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py'
50--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2014-05-09 04:12:25 +0000
51+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2014-06-06 11:20:51 +0000
52@@ -30,6 +30,7 @@
53 'popups',
54 'QQuickFlickable',
55 'QQuickListView',
56+ 'Slider',
57 'TabBar',
58 'Tabs',
59 'TextField',
60@@ -58,6 +59,7 @@
61 from ubuntuuitoolkit._custom_proxy_objects._qquicklistview import (
62 QQuickListView
63 )
64+from ubuntuuitoolkit._custom_proxy_objects._slider import Slider
65 from ubuntuuitoolkit._custom_proxy_objects._tabbar import TabBar
66 from ubuntuuitoolkit._custom_proxy_objects._tabs import Tabs
67 from ubuntuuitoolkit._custom_proxy_objects._textfield import TextField
68
69=== added file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_slider.py'
70--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_slider.py 1970-01-01 00:00:00 +0000
71+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_slider.py 2014-06-06 11:20:51 +0000
72@@ -0,0 +1,63 @@
73+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
74+#
75+# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
76+#
77+# This program is free software; you can redistribute it and/or modify
78+# it under the terms of the GNU Lesser General Public License as published by
79+# the Free Software Foundation; version 3.
80+#
81+# This program is distributed in the hope that it will be useful,
82+# but WITHOUT ANY WARRANTY; without even the implied warranty of
83+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84+# GNU Lesser General Public License for more details.
85+#
86+# You should have received a copy of the GNU Lesser General Public License
87+# along with this program. If not, see <http://www.gnu.org/licenses/>.
88+
89+from ubuntuuitoolkit._custom_proxy_objects import _common
90+
91+
92+class Slider(_common.UbuntuUIToolkitCustomProxyObjectBase):
93+ """Autopilot helper for the Slider."""
94+
95+ def set_value(self, value):
96+ if value < self.minimumValue:
97+ raise _common.ToolkitException(
98+ 'The value is lower than the minimum permitted by the slider.')
99+ elif value > self.maximumValue:
100+ raise _common.ToolkitException(
101+ 'The value is higher than the maximum permitted by the '
102+ 'slider.')
103+ else:
104+ self._set_valid_value(value)
105+
106+ def _set_valid_value(self, value):
107+ x, y = self._get_value_point_in_bar(value)
108+ self.pointing_device.move(x, y)
109+ self.pointing_device.click()
110+
111+ def _get_value_point_in_bar(self, value):
112+ bar_start, bar_end = self._get_bar_start_and_end()
113+ # We have two points: (min, bar_start) and (max, bar_end).
114+ # With that we can use linear interpolation to get the x coordinate to
115+ # click.
116+ p_x_from_slider = (
117+ bar_start +
118+ (bar_end - bar_start) *
119+ (value - self.minimumValue) /
120+ (self.maximumValue - self.minimumValue))
121+ p_x = p_x_from_slider + self.globalRect.x
122+ # The point to click on the y coordinate is the center of the slider.
123+ p_y = self.globalRect.y + self.globalRect.height // 2
124+ return p_x, p_y
125+
126+ def _get_bar_start_and_end(self):
127+ # We subtract from the bar width the width of the thumb because the
128+ # center of the thumb never reaches the start or the end of the bar,
129+ # so we have to scale down the range of values that we can select.
130+ thumb = self.select_single(objectName='sliderThumb')
131+ half_thumb_width = thumb.globalRect.width / 2
132+ bar = self.select_single(objectName='sliderBar')
133+ bar_start = half_thumb_width
134+ bar_end = bar.globalRect.width - half_thumb_width
135+ return bar_start, bar_end
136
137=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/__init__.py'
138--- tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-05-29 16:17:56 +0000
139+++ tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-06-06 11:20:51 +0000
140@@ -1,6 +1,6 @@
141 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
142 #
143-# Copyright (C) 2012, 2013 Canonical Ltd.
144+# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
145 #
146 # This program is free software; you can redistribute it and/or modify
147 # it under the terms of the GNU Lesser General Public License as published by
148@@ -142,91 +142,6 @@
149 def main_view(self):
150 return self.app.select_single(emulators.MainView)
151
152- def checkListItem(self, itemText):
153- item = self.getListItem(itemText)
154- self.assertThat(item, Not(Is(None)))
155-
156- def getListItem(self, itemText):
157- # XXX We shouldn't access the elements by text, because that's likely
158- # to change often and might be translated. We should always use the
159- # objectName instead. --elopio - 2013-06-26216
160- return self.main_view.select_single("Standard", text=itemText)
161-
162- def getWidgetLoaderAndListView(self):
163- contentLoader = self.main_view.select_single(
164- "QQuickLoader", objectName="contentLoader")
165- listView = self.main_view.select_single(
166- "QQuickListView", objectName="widgetList")
167- self.assertThat(listView, Not(Is(None)))
168- self.assertThat(listView.visible, Eventually(Equals(True)))
169- return (contentLoader, listView)
170-
171- def loadItem(self, item):
172- self.selectItem(item)
173- contentLoader = self.main_view.select_single(
174- "QQuickLoader", objectName="contentLoader")
175- self.assertThat(contentLoader.progress, Eventually(Equals(1.0)))
176- loadedPage = self.getListItem(item)
177- self.assertThat(loadedPage, Not(Is(None)))
178- #loadedPage is not a page, it is the list item which goes in
179- #background when the item is selected, which changes the visible
180- #property of item in list itself to False. So followin check
181- #fails on Nexus 4. Commenting it for now.
182- #self.assertThat(loadedPage.visible, Eventually(Equals(True)))
183-
184- def drag(self, itemText, itemTextTo):
185- item = self.getListItem(itemText)
186- itemTo = self.getListItem(itemTextTo)
187-
188- self.pointing_device.move_to_object(item)
189- self.pointing_device.press()
190- self.pointing_device.move_to_object(itemTo)
191- self.pointing_device.release()
192-
193- def reveal_item_by_flick(self, item, flickable, direction):
194- x1, y1, w1, h1 = item.globalRect
195- x2, y2, w2, h2 = flickable.globalRect
196- if direction is FlickDirection.UP:
197- while y1 + h1 > y2 + h2:
198- self.flick(flickable, direction)
199- x1, y1, w1, h1 = item.globalRect
200- elif direction is FlickDirection.DOWN:
201- while y1 < y2:
202- self.flick(flickable, direction)
203- x1, y1, w1, h1 = item.globalRect
204-
205- def flick(self, flickable, direction, delta=40):
206- """This funcito flicks the page from middle to the given direction."""
207- x, y, w, h = flickable.globalRect
208- if direction == FlickDirection.UP:
209- self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2,
210- y + h / 2 - delta)
211- flickable.flicking.wait_for(False)
212- elif direction == FlickDirection.DOWN:
213- self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2,
214- y + h / 2 + delta)
215- flickable.flicking.wait_for(False)
216- else:
217- raise ValueError("Invalid direction or not implementd yet")
218-
219- def selectItem(self, itemText):
220- item = self.getListItem(itemText)
221- x1, y1, w1, h1 = item.globalRect
222- x2, y2, w2, h2 = self.main_view.globalRect
223-
224- orientationHelper = self.getOrientationHelper()
225- rot = orientationHelper.rotation
226- scrollTo = h2 / 2 - (y1 - h2 - h1)
227- if rot == 0.0 and y1 > h2:
228- self.pointing_device.drag(w2 / 2, h2 / 2, w2 / 2, scrollTo)
229-
230- self.assertThat(item.selected, Eventually(Equals(False)))
231-
232- self.pointing_device.move_to_object(item)
233- self.pointing_device.click()
234-
235- self.assertThat(item.selected, Eventually(Equals(True)))
236-
237 def getOrientationHelper(self):
238 orientationHelper = self.main_view.select_many(
239 "OrientationHelper")[0]
240@@ -249,29 +164,3 @@
241 obj = self.getObject(objectName)
242 self.pointing_device.move_to_object(obj)
243 self.pointing_device.click()
244-
245- def mousePress(self, objectName):
246- obj = self.getObject(objectName)
247- self.pointing_device.move_to_object(obj)
248- self.pointing_device.press()
249-
250- def mouseRelease(self):
251- self.pointing_device.release()
252-
253- def type_string(self, string):
254- self.keyboard.type(string)
255-
256- def type_key(self, key):
257- self.keyboard.key(key)
258-
259- def tap_clearButton(self, objectName):
260- textField = self.getObject(objectName)
261- self.assertIsNotNone(textField)
262- self.pointing_device.click_object(textField)
263- self.assertThat(textField.focus, Eventually(Equals(True)))
264- self.assertThat(textField.hasClearButton, Eventually(Equals(True)))
265- btn = textField.select_single("AbstractButton")
266- self.assertIsNotNone(btn)
267- self.assertThat(btn.visible, Eventually(Equals(True)))
268- self.pointing_device.click_object(btn)
269- self.assertThat(btn.pressed, Eventually(Equals(False)))
270
271=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.SliderTestCase.qml'
272--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.SliderTestCase.qml 1970-01-01 00:00:00 +0000
273+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.SliderTestCase.qml 2014-06-06 11:20:51 +0000
274@@ -0,0 +1,32 @@
275+/*
276+ * Copyright 2014 Canonical Ltd.
277+ *
278+ * This program is free software; you can redistribute it and/or modify
279+ * it under the terms of the GNU Lesser General Public License as published by
280+ * the Free Software Foundation; version 3.
281+ *
282+ * This program is distributed in the hope that it will be useful,
283+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
284+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
285+ * GNU Lesser General Public License for more details.
286+ *
287+ * You should have received a copy of the GNU Lesser General Public License
288+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
289+ */
290+
291+import QtQuick 2.0
292+import Ubuntu.Components 1.1
293+
294+MainView {
295+
296+ width: units.gu(48)
297+ height: units.gu(60)
298+
299+ Slider {
300+ objectName: 'testSlider'
301+
302+ minimumValue: -10
303+ maximumValue: 10
304+ value: 0.0
305+ }
306+}
307
308=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.py'
309--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.py 1970-01-01 00:00:00 +0000
310+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.py 2014-06-06 11:20:51 +0000
311@@ -0,0 +1,95 @@
312+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
313+#
314+# Copyright (C) 2014 Canonical Ltd.
315+#
316+# This program is free software; you can redistribute it and/or modify
317+# it under the terms of the GNU Lesser General Public License as published by
318+# the Free Software Foundation; version 3.
319+#
320+# This program is distributed in the hope that it will be useful,
321+# but WITHOUT ANY WARRANTY; without even the implied warranty of
322+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
323+# GNU Lesser General Public License for more details.
324+#
325+# You should have received a copy of the GNU Lesser General Public License
326+# along with this program. If not, see <http://www.gnu.org/licenses/>.
327+
328+import os
329+
330+try:
331+ from unittest import mock
332+except ImportError:
333+ import mock
334+
335+import ubuntuuitoolkit
336+
337+
338+class SliderTestCase(ubuntuuitoolkit.tests.QMLFileAppTestCase):
339+
340+ path = os.path.abspath(__file__)
341+ dir_path = os.path.dirname(path)
342+ test_qml_file_path = os.path.join(
343+ dir_path, 'test_slider.SliderTestCase.qml')
344+
345+ def setUp(self):
346+ super(SliderTestCase, self).setUp()
347+ # The test slider has a minimum value = -10, maximum value = 10 and
348+ # starts with value = 0.
349+ self.slider = self.main_view.select_single(
350+ ubuntuuitoolkit.Slider, objectName='testSlider')
351+
352+ def test_get_slider_must_return_custom_proxy_object(self):
353+ """Test the type of the returned object after selecting the slider.
354+
355+ It must be the custom proxy object for the Slider.
356+
357+ """
358+ self.assertIsInstance(self.slider, ubuntuuitoolkit.Slider)
359+
360+ def test_set_value_below_minimum_must_raise_exception(self):
361+ """Test to set a value that is below the slider minimum.
362+
363+ It must raise a ToolkitException.
364+
365+ """
366+ error = self.assertRaises(
367+ ubuntuuitoolkit.ToolkitException, self.slider.set_value, -15)
368+ self.assertEqual(
369+ 'The value is lower than the minimum permitted by the slider.',
370+ str(error))
371+
372+ def test_set_value_above_maximum_must_raise_exception(self):
373+ """Test to set a value that is above the slider maximum.
374+
375+ It must raise a ToolkitException.
376+
377+ """
378+ error = self.assertRaises(
379+ ubuntuuitoolkit.ToolkitException, self.slider.set_value, 15)
380+ self.assertEqual(
381+ 'The value is higher than the maximum permitted by the slider.',
382+ str(error))
383+
384+ def test_set_current_value_must_do_nothing(self):
385+ """Test setting the current value on the slider.
386+
387+ The value must be kept the same and the slider should not be touched.
388+
389+ """
390+ with mock.patch.object(self.slider, 'pointing_device') as mock_device:
391+ self.slider.set_value(0)
392+
393+ self.assertFalse(mock_device.called)
394+ self.assertEqual(self.slider.value, 0)
395+
396+ def test_set_valid_value_must_update_slider_value(self):
397+ """Test that setting a valid value on the slider must update it."""
398+ self.slider.set_value(5)
399+ self.assertEqual(self.slider.value, 5)
400+
401+ # TODO test set minimum.
402+ # TODO test set maximum.
403+ # TODO file a bug because the docs doesn't say if min and max are
404+ # exclusive or inclusive.
405+ # TODO test set a value that's not selectable with the mouse
406+ # TODO send Julia the test double post.
407
408=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py'
409--- tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2013-10-24 11:01:03 +0000
410+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2014-06-06 11:20:51 +0000
411@@ -1,6 +1,6 @@
412 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
413 #
414-# Copyright (C) 2012, 2013 Canonical Ltd.
415+# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
416 #
417 # This program is free software; you can redistribute it and/or modify
418 # it under the terms of the GNU Lesser General Public License as published by
419@@ -19,10 +19,10 @@
420 import os
421 import shutil
422
423-from ubuntuuitoolkit import tests
424-
425-
426-class GalleryTestCase(tests.QMLFileAppTestCase):
427+import ubuntuuitoolkit
428+
429+
430+class GalleryTestCase(ubuntuuitoolkit.tests.QMLFileAppTestCase):
431 """Base class for gallery test cases."""
432
433 local_desktop_file_path = None
434@@ -39,7 +39,7 @@
435
436 def _get_path_to_gallery_source(self):
437 return os.path.join(
438- tests.get_path_to_source_root(), 'examples',
439+ ubuntuuitoolkit.tests.get_path_to_source_root(), 'examples',
440 'ubuntu-ui-toolkit-gallery')
441
442 def _application_source_exists(self):
443@@ -58,7 +58,8 @@
444 self.test_source_path,
445 'ubuntu-ui-toolkit-gallery.desktop')
446 if self._application_source_exists():
447- local_desktop_file_dir = tests.get_local_desktop_file_directory()
448+ local_desktop_file_dir = (
449+ ubuntuuitoolkit.tests.get_local_desktop_file_directory())
450 if not os.path.exists(local_desktop_file_dir):
451 os.makedirs(local_desktop_file_dir)
452 local_desktop_file_path = os.path.join(
453@@ -71,6 +72,19 @@
454 else:
455 return desktop_file_path
456
457+ def open_page(self, page):
458+ """Open a page of the widget gallery.
459+
460+ :param page: The objectName of the element in the index list that opens
461+ the page.
462+
463+ """
464+ list_view = self.main_view.select_single(
465+ ubuntuuitoolkit.QQuickListView, objectName="widgetList")
466+ list_view.click_element(page)
467+ element = self.main_view.select_single('Standard', objectName=page)
468+ element.selected.wait_for(True)
469+
470 def tearDown(self):
471 super(GalleryTestCase, self).tearDown()
472 # We can't delete the desktop file before we close the application,
473
474=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py'
475--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-02-11 01:55:49 +0000
476+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-06-06 11:20:51 +0000
477@@ -45,9 +45,7 @@
478 ]
479
480 def test_buttons(self):
481- item = "Buttons"
482- self.loadItem(item)
483- self.checkPageHeader(item)
484+ self.open_page('buttonsElement')
485
486 button = self.app.select_single(objectName=self.button_name)
487 self.assertIsNot(button, None)
488
489=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py'
490--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-05-26 12:37:32 +0000
491+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-06-06 11:20:51 +0000
492@@ -1,6 +1,6 @@
493 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
494 #
495-# Copyright (C) 2012, 2013 Canonical Ltd.
496+# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
497 #
498 # This program is free software; you can redistribute it and/or modify
499 # it under the terms of the GNU Lesser General Public License as published by
500@@ -16,32 +16,19 @@
501
502 """Tests for the Ubuntu UI Toolkit Gallery"""
503
504-from autopilot.matchers import Eventually
505-from testtools.matchers import Is, Not, Equals
506-
507-from ubuntuuitoolkit import emulators
508+import ubuntuuitoolkit
509 from ubuntuuitoolkit.tests import gallery
510
511
512-class GenericTests(gallery.GalleryTestCase):
513+class GalleryAppTestCase(gallery.GalleryTestCase):
514 """Generic tests for the Gallery"""
515
516- def test_0_can_select_mainwindow(self):
517- """Must be able to select the main window."""
518-
519- rootItem = self.main_view
520- self.assertThat(rootItem, Not(Is(None)))
521- self.assertThat(rootItem.visible, Eventually(Equals(True)))
522-
523- def test_navigation(self):
524- item = "Navigation"
525- self.loadItem(item)
526- self.checkPageHeader(item)
527+ def test_select_main_view_must_return_main_window_emulator(self):
528+ main_view = self.main_view
529+ self.assertIsInstance(main_view, ubuntuuitoolkit.MainView)
530
531 def test_slider(self):
532- item = "Slider"
533- self.loadItem(item)
534- self.checkPageHeader(item)
535+ self.open_page('slidersElement')
536
537 item_data = [
538 ["slider_standard"],
539@@ -57,9 +44,7 @@
540 # TODO: move slider value
541
542 def test_progress_and_activity(self):
543- item = "Progress and activity"
544- self.loadItem(item)
545- self.checkPageHeader(item)
546+ self.open_page('progressBarsElement')
547
548 item_data = [
549 ["progressbar_standard"],
550@@ -79,9 +64,7 @@
551 # FIXME: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1308979
552 return
553
554- item = "Ubuntu Shape"
555- self.loadItem(item)
556- self.checkPageHeader(item)
557+ self.open_page('ubuntuShapesElement')
558
559 item_data = [
560 ["ubuntushape_color_hex"],
561@@ -115,12 +98,9 @@
562 ]
563
564 def test_open_page(self):
565- list_view = self.main_view.select_single(
566- emulators.QQuickListView, objectName="widgetList")
567- list_view.click_element(self.element_name)
568+ self.open_page(self.element_name)
569 element = self.main_view.select_single(
570 'Standard', objectName=self.element_name)
571- element.selected.wait_for(True)
572 self.checkPageHeader(element.text)
573 if self.template_name == 'textinputsTemplate':
574 page_type = 'TextInputs'
575
576=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py'
577--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-05-23 09:50:42 +0000
578+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-06-06 11:20:51 +0000
579@@ -24,9 +24,7 @@
580
581 def setUp(self):
582 super(OptionSelectorTestCase, self).setUp()
583- item = "Option Selector"
584- self.loadItem(item)
585- self.checkPageHeader(item)
586+ self.open_page('optionSelectorsElement')
587
588 def test_select_option_from_collapsed_optionselector(self):
589 collapsed_option_selector = self.main_view.select_single(
590
591=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py'
592--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-04-30 09:40:17 +0000
593+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-06-06 11:20:51 +0000
594@@ -54,9 +54,7 @@
595 # Apply the user locale from the environment
596 # The UITK does the same, so the test must be localized
597 locale.setlocale(locale.LC_ALL, "")
598- item = 'Text Field'
599- self.loadItem(item)
600- self.checkPageHeader(item)
601+ self.open_page('textinputsElement')
602
603 def test_write_on_textfield_must_update_text(self):
604 textfield = self.main_view.select_single(
605@@ -78,9 +76,7 @@
606
607 def setUp(self):
608 super(DisabledTextInputTestCase, self).setUp()
609- item = 'Text Field'
610- self.loadItem(item)
611- self.checkPageHeader(item)
612+ self.open_page('textinputsElement')
613
614 def test_textfield_disabled(self):
615 textfield_disabled = self.main_view.select_single(
616
617=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py'
618--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2013-11-01 15:15:30 +0000
619+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2014-06-06 11:20:51 +0000
620@@ -35,10 +35,7 @@
621
622 def setUp(self):
623 super(EnabledTogglesTestCase, self).setUp()
624- item = "Toggles"
625- self.checkListItem(item)
626- self.loadItem(item)
627- self.checkPageHeader(item)
628+ self.open_page('togglesElement')
629
630 def test_change_toggles_state(self):
631 toggle = self.main_view.select_single(
632@@ -65,10 +62,7 @@
633
634 def setUp(self):
635 super(DisabledTogglesTestCase, self).setUp()
636- item = "Toggles"
637- self.checkListItem(item)
638- self.loadItem(item)
639- self.checkPageHeader(item)
640+ self.open_page('togglesElement')
641
642 def test_change_toggles_state(self):
643 toggle = self.main_view.select_single(

Subscribers

People subscribed via source and target branches