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
=== modified file 'modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml'
--- modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2014-04-23 08:50:20 +0000
+++ modules/Ubuntu/Components/Themes/Ambiance/SliderStyle.qml 2014-06-06 11:20:51 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright 2013 Canonical Ltd.2 * Copyright 2013, 2014 Canonical Ltd.
3 *3 *
4 * This program is free software; you can redistribute it and/or modify4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by5 * it under the terms of the GNU Lesser General Public License as published by
@@ -35,6 +35,8 @@
3535
36 UbuntuShape {36 UbuntuShape {
37 id: background37 id: background
38 objectName: 'sliderBar'
39
38 anchors {40 anchors {
39 verticalCenter: parent.verticalCenter41 verticalCenter: parent.verticalCenter
40 right: parent.right42 right: parent.right
@@ -56,6 +58,7 @@
5658
57 UbuntuShape {59 UbuntuShape {
58 id: thumb60 id: thumb
61 objectName: 'sliderThumb'
5962
60 anchors {63 anchors {
61 verticalCenter: parent.verticalCenter64 verticalCenter: parent.verticalCenter
6265
=== modified file 'tests/autopilot/ubuntuuitoolkit/__init__.py'
--- tests/autopilot/ubuntuuitoolkit/__init__.py 2014-05-09 04:12:25 +0000
+++ tests/autopilot/ubuntuuitoolkit/__init__.py 2014-06-06 11:20:51 +0000
@@ -34,6 +34,7 @@
34 'popups',34 'popups',
35 'QQuickFlickable',35 'QQuickFlickable',
36 'QQuickListView',36 'QQuickListView',
37 'Slider',
37 'TabBar',38 'TabBar',
38 'Tabs',39 'Tabs',
39 'tests',40 'tests',
@@ -64,6 +65,7 @@
64 popups,65 popups,
65 QQuickFlickable,66 QQuickFlickable,
66 QQuickListView,67 QQuickListView,
68 Slider,
67 TabBar,69 TabBar,
68 Tabs,70 Tabs,
69 TextField,71 TextField,
7072
=== modified file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py'
--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2014-05-09 04:12:25 +0000
+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/__init__.py 2014-06-06 11:20:51 +0000
@@ -30,6 +30,7 @@
30 'popups',30 'popups',
31 'QQuickFlickable',31 'QQuickFlickable',
32 'QQuickListView',32 'QQuickListView',
33 'Slider',
33 'TabBar',34 'TabBar',
34 'Tabs',35 'Tabs',
35 'TextField',36 'TextField',
@@ -58,6 +59,7 @@
58from ubuntuuitoolkit._custom_proxy_objects._qquicklistview import (59from ubuntuuitoolkit._custom_proxy_objects._qquicklistview import (
59 QQuickListView60 QQuickListView
60)61)
62from ubuntuuitoolkit._custom_proxy_objects._slider import Slider
61from ubuntuuitoolkit._custom_proxy_objects._tabbar import TabBar63from ubuntuuitoolkit._custom_proxy_objects._tabbar import TabBar
62from ubuntuuitoolkit._custom_proxy_objects._tabs import Tabs64from ubuntuuitoolkit._custom_proxy_objects._tabs import Tabs
63from ubuntuuitoolkit._custom_proxy_objects._textfield import TextField65from ubuntuuitoolkit._custom_proxy_objects._textfield import TextField
6466
=== added file 'tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_slider.py'
--- tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_slider.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_slider.py 2014-06-06 11:20:51 +0000
@@ -0,0 +1,63 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation; version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17from ubuntuuitoolkit._custom_proxy_objects import _common
18
19
20class Slider(_common.UbuntuUIToolkitCustomProxyObjectBase):
21 """Autopilot helper for the Slider."""
22
23 def set_value(self, value):
24 if value < self.minimumValue:
25 raise _common.ToolkitException(
26 'The value is lower than the minimum permitted by the slider.')
27 elif value > self.maximumValue:
28 raise _common.ToolkitException(
29 'The value is higher than the maximum permitted by the '
30 'slider.')
31 else:
32 self._set_valid_value(value)
33
34 def _set_valid_value(self, value):
35 x, y = self._get_value_point_in_bar(value)
36 self.pointing_device.move(x, y)
37 self.pointing_device.click()
38
39 def _get_value_point_in_bar(self, value):
40 bar_start, bar_end = self._get_bar_start_and_end()
41 # We have two points: (min, bar_start) and (max, bar_end).
42 # With that we can use linear interpolation to get the x coordinate to
43 # click.
44 p_x_from_slider = (
45 bar_start +
46 (bar_end - bar_start) *
47 (value - self.minimumValue) /
48 (self.maximumValue - self.minimumValue))
49 p_x = p_x_from_slider + self.globalRect.x
50 # The point to click on the y coordinate is the center of the slider.
51 p_y = self.globalRect.y + self.globalRect.height // 2
52 return p_x, p_y
53
54 def _get_bar_start_and_end(self):
55 # We subtract from the bar width the width of the thumb because the
56 # center of the thumb never reaches the start or the end of the bar,
57 # so we have to scale down the range of values that we can select.
58 thumb = self.select_single(objectName='sliderThumb')
59 half_thumb_width = thumb.globalRect.width / 2
60 bar = self.select_single(objectName='sliderBar')
61 bar_start = half_thumb_width
62 bar_end = bar.globalRect.width - half_thumb_width
63 return bar_start, bar_end
064
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/__init__.py'
--- tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-05-29 16:17:56 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/__init__.py 2014-06-06 11:20:51 +0000
@@ -1,6 +1,6 @@
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 -*-
2#2#
3# Copyright (C) 2012, 2013 Canonical Ltd.3# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
4#4#
5# This program is free software; you can redistribute it and/or modify5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by6# it under the terms of the GNU Lesser General Public License as published by
@@ -142,91 +142,6 @@
142 def main_view(self):142 def main_view(self):
143 return self.app.select_single(emulators.MainView)143 return self.app.select_single(emulators.MainView)
144144
145 def checkListItem(self, itemText):
146 item = self.getListItem(itemText)
147 self.assertThat(item, Not(Is(None)))
148
149 def getListItem(self, itemText):
150 # XXX We shouldn't access the elements by text, because that's likely
151 # to change often and might be translated. We should always use the
152 # objectName instead. --elopio - 2013-06-26216
153 return self.main_view.select_single("Standard", text=itemText)
154
155 def getWidgetLoaderAndListView(self):
156 contentLoader = self.main_view.select_single(
157 "QQuickLoader", objectName="contentLoader")
158 listView = self.main_view.select_single(
159 "QQuickListView", objectName="widgetList")
160 self.assertThat(listView, Not(Is(None)))
161 self.assertThat(listView.visible, Eventually(Equals(True)))
162 return (contentLoader, listView)
163
164 def loadItem(self, item):
165 self.selectItem(item)
166 contentLoader = self.main_view.select_single(
167 "QQuickLoader", objectName="contentLoader")
168 self.assertThat(contentLoader.progress, Eventually(Equals(1.0)))
169 loadedPage = self.getListItem(item)
170 self.assertThat(loadedPage, Not(Is(None)))
171 #loadedPage is not a page, it is the list item which goes in
172 #background when the item is selected, which changes the visible
173 #property of item in list itself to False. So followin check
174 #fails on Nexus 4. Commenting it for now.
175 #self.assertThat(loadedPage.visible, Eventually(Equals(True)))
176
177 def drag(self, itemText, itemTextTo):
178 item = self.getListItem(itemText)
179 itemTo = self.getListItem(itemTextTo)
180
181 self.pointing_device.move_to_object(item)
182 self.pointing_device.press()
183 self.pointing_device.move_to_object(itemTo)
184 self.pointing_device.release()
185
186 def reveal_item_by_flick(self, item, flickable, direction):
187 x1, y1, w1, h1 = item.globalRect
188 x2, y2, w2, h2 = flickable.globalRect
189 if direction is FlickDirection.UP:
190 while y1 + h1 > y2 + h2:
191 self.flick(flickable, direction)
192 x1, y1, w1, h1 = item.globalRect
193 elif direction is FlickDirection.DOWN:
194 while y1 < y2:
195 self.flick(flickable, direction)
196 x1, y1, w1, h1 = item.globalRect
197
198 def flick(self, flickable, direction, delta=40):
199 """This funcito flicks the page from middle to the given direction."""
200 x, y, w, h = flickable.globalRect
201 if direction == FlickDirection.UP:
202 self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2,
203 y + h / 2 - delta)
204 flickable.flicking.wait_for(False)
205 elif direction == FlickDirection.DOWN:
206 self.pointing_device.drag(x + w / 2, y + h / 2, x + w / 2,
207 y + h / 2 + delta)
208 flickable.flicking.wait_for(False)
209 else:
210 raise ValueError("Invalid direction or not implementd yet")
211
212 def selectItem(self, itemText):
213 item = self.getListItem(itemText)
214 x1, y1, w1, h1 = item.globalRect
215 x2, y2, w2, h2 = self.main_view.globalRect
216
217 orientationHelper = self.getOrientationHelper()
218 rot = orientationHelper.rotation
219 scrollTo = h2 / 2 - (y1 - h2 - h1)
220 if rot == 0.0 and y1 > h2:
221 self.pointing_device.drag(w2 / 2, h2 / 2, w2 / 2, scrollTo)
222
223 self.assertThat(item.selected, Eventually(Equals(False)))
224
225 self.pointing_device.move_to_object(item)
226 self.pointing_device.click()
227
228 self.assertThat(item.selected, Eventually(Equals(True)))
229
230 def getOrientationHelper(self):145 def getOrientationHelper(self):
231 orientationHelper = self.main_view.select_many(146 orientationHelper = self.main_view.select_many(
232 "OrientationHelper")[0]147 "OrientationHelper")[0]
@@ -249,29 +164,3 @@
249 obj = self.getObject(objectName)164 obj = self.getObject(objectName)
250 self.pointing_device.move_to_object(obj)165 self.pointing_device.move_to_object(obj)
251 self.pointing_device.click()166 self.pointing_device.click()
252
253 def mousePress(self, objectName):
254 obj = self.getObject(objectName)
255 self.pointing_device.move_to_object(obj)
256 self.pointing_device.press()
257
258 def mouseRelease(self):
259 self.pointing_device.release()
260
261 def type_string(self, string):
262 self.keyboard.type(string)
263
264 def type_key(self, key):
265 self.keyboard.key(key)
266
267 def tap_clearButton(self, objectName):
268 textField = self.getObject(objectName)
269 self.assertIsNotNone(textField)
270 self.pointing_device.click_object(textField)
271 self.assertThat(textField.focus, Eventually(Equals(True)))
272 self.assertThat(textField.hasClearButton, Eventually(Equals(True)))
273 btn = textField.select_single("AbstractButton")
274 self.assertIsNotNone(btn)
275 self.assertThat(btn.visible, Eventually(Equals(True)))
276 self.pointing_device.click_object(btn)
277 self.assertThat(btn.pressed, Eventually(Equals(False)))
278167
=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.SliderTestCase.qml'
--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.SliderTestCase.qml 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.SliderTestCase.qml 2014-06-06 11:20:51 +0000
@@ -0,0 +1,32 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Ubuntu.Components 1.1
19
20MainView {
21
22 width: units.gu(48)
23 height: units.gu(60)
24
25 Slider {
26 objectName: 'testSlider'
27
28 minimumValue: -10
29 maximumValue: 10
30 value: 0.0
31 }
32}
033
=== added file 'tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.py'
--- tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/custom_proxy_objects/test_slider.py 2014-06-06 11:20:51 +0000
@@ -0,0 +1,95 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Copyright (C) 2014 Canonical Ltd.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by
7# the Free Software Foundation; version 3.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17import os
18
19try:
20 from unittest import mock
21except ImportError:
22 import mock
23
24import ubuntuuitoolkit
25
26
27class SliderTestCase(ubuntuuitoolkit.tests.QMLFileAppTestCase):
28
29 path = os.path.abspath(__file__)
30 dir_path = os.path.dirname(path)
31 test_qml_file_path = os.path.join(
32 dir_path, 'test_slider.SliderTestCase.qml')
33
34 def setUp(self):
35 super(SliderTestCase, self).setUp()
36 # The test slider has a minimum value = -10, maximum value = 10 and
37 # starts with value = 0.
38 self.slider = self.main_view.select_single(
39 ubuntuuitoolkit.Slider, objectName='testSlider')
40
41 def test_get_slider_must_return_custom_proxy_object(self):
42 """Test the type of the returned object after selecting the slider.
43
44 It must be the custom proxy object for the Slider.
45
46 """
47 self.assertIsInstance(self.slider, ubuntuuitoolkit.Slider)
48
49 def test_set_value_below_minimum_must_raise_exception(self):
50 """Test to set a value that is below the slider minimum.
51
52 It must raise a ToolkitException.
53
54 """
55 error = self.assertRaises(
56 ubuntuuitoolkit.ToolkitException, self.slider.set_value, -15)
57 self.assertEqual(
58 'The value is lower than the minimum permitted by the slider.',
59 str(error))
60
61 def test_set_value_above_maximum_must_raise_exception(self):
62 """Test to set a value that is above the slider maximum.
63
64 It must raise a ToolkitException.
65
66 """
67 error = self.assertRaises(
68 ubuntuuitoolkit.ToolkitException, self.slider.set_value, 15)
69 self.assertEqual(
70 'The value is higher than the maximum permitted by the slider.',
71 str(error))
72
73 def test_set_current_value_must_do_nothing(self):
74 """Test setting the current value on the slider.
75
76 The value must be kept the same and the slider should not be touched.
77
78 """
79 with mock.patch.object(self.slider, 'pointing_device') as mock_device:
80 self.slider.set_value(0)
81
82 self.assertFalse(mock_device.called)
83 self.assertEqual(self.slider.value, 0)
84
85 def test_set_valid_value_must_update_slider_value(self):
86 """Test that setting a valid value on the slider must update it."""
87 self.slider.set_value(5)
88 self.assertEqual(self.slider.value, 5)
89
90 # TODO test set minimum.
91 # TODO test set maximum.
92 # TODO file a bug because the docs doesn't say if min and max are
93 # exclusive or inclusive.
94 # TODO test set a value that's not selectable with the mouse
95 # TODO send Julia the test double post.
096
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py'
--- tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2013-10-24 11:01:03 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/__init__.py 2014-06-06 11:20:51 +0000
@@ -1,6 +1,6 @@
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 -*-
2#2#
3# Copyright (C) 2012, 2013 Canonical Ltd.3# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
4#4#
5# This program is free software; you can redistribute it and/or modify5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by6# it under the terms of the GNU Lesser General Public License as published by
@@ -19,10 +19,10 @@
19import os19import os
20import shutil20import shutil
2121
22from ubuntuuitoolkit import tests22import ubuntuuitoolkit
2323
2424
25class GalleryTestCase(tests.QMLFileAppTestCase):25class GalleryTestCase(ubuntuuitoolkit.tests.QMLFileAppTestCase):
26 """Base class for gallery test cases."""26 """Base class for gallery test cases."""
2727
28 local_desktop_file_path = None28 local_desktop_file_path = None
@@ -39,7 +39,7 @@
3939
40 def _get_path_to_gallery_source(self):40 def _get_path_to_gallery_source(self):
41 return os.path.join(41 return os.path.join(
42 tests.get_path_to_source_root(), 'examples',42 ubuntuuitoolkit.tests.get_path_to_source_root(), 'examples',
43 'ubuntu-ui-toolkit-gallery')43 'ubuntu-ui-toolkit-gallery')
4444
45 def _application_source_exists(self):45 def _application_source_exists(self):
@@ -58,7 +58,8 @@
58 self.test_source_path,58 self.test_source_path,
59 'ubuntu-ui-toolkit-gallery.desktop')59 'ubuntu-ui-toolkit-gallery.desktop')
60 if self._application_source_exists():60 if self._application_source_exists():
61 local_desktop_file_dir = tests.get_local_desktop_file_directory()61 local_desktop_file_dir = (
62 ubuntuuitoolkit.tests.get_local_desktop_file_directory())
62 if not os.path.exists(local_desktop_file_dir):63 if not os.path.exists(local_desktop_file_dir):
63 os.makedirs(local_desktop_file_dir)64 os.makedirs(local_desktop_file_dir)
64 local_desktop_file_path = os.path.join(65 local_desktop_file_path = os.path.join(
@@ -71,6 +72,19 @@
71 else:72 else:
72 return desktop_file_path73 return desktop_file_path
7374
75 def open_page(self, page):
76 """Open a page of the widget gallery.
77
78 :param page: The objectName of the element in the index list that opens
79 the page.
80
81 """
82 list_view = self.main_view.select_single(
83 ubuntuuitoolkit.QQuickListView, objectName="widgetList")
84 list_view.click_element(page)
85 element = self.main_view.select_single('Standard', objectName=page)
86 element.selected.wait_for(True)
87
74 def tearDown(self):88 def tearDown(self):
75 super(GalleryTestCase, self).tearDown()89 super(GalleryTestCase, self).tearDown()
76 # We can't delete the desktop file before we close the application,90 # We can't delete the desktop file before we close the application,
7791
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py'
--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-02-11 01:55:49 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_buttons.py 2014-06-06 11:20:51 +0000
@@ -45,9 +45,7 @@
45 ]45 ]
4646
47 def test_buttons(self):47 def test_buttons(self):
48 item = "Buttons"48 self.open_page('buttonsElement')
49 self.loadItem(item)
50 self.checkPageHeader(item)
5149
52 button = self.app.select_single(objectName=self.button_name)50 button = self.app.select_single(objectName=self.button_name)
53 self.assertIsNot(button, None)51 self.assertIsNot(button, None)
5452
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py'
--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-05-26 12:37:32 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_gallery.py 2014-06-06 11:20:51 +0000
@@ -1,6 +1,6 @@
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 -*-
2#2#
3# Copyright (C) 2012, 2013 Canonical Ltd.3# Copyright (C) 2012, 2013, 2014 Canonical Ltd.
4#4#
5# This program is free software; you can redistribute it and/or modify5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published by6# it under the terms of the GNU Lesser General Public License as published by
@@ -16,32 +16,19 @@
1616
17"""Tests for the Ubuntu UI Toolkit Gallery"""17"""Tests for the Ubuntu UI Toolkit Gallery"""
1818
19from autopilot.matchers import Eventually19import ubuntuuitoolkit
20from testtools.matchers import Is, Not, Equals
21
22from ubuntuuitoolkit import emulators
23from ubuntuuitoolkit.tests import gallery20from ubuntuuitoolkit.tests import gallery
2421
2522
26class GenericTests(gallery.GalleryTestCase):23class GalleryAppTestCase(gallery.GalleryTestCase):
27 """Generic tests for the Gallery"""24 """Generic tests for the Gallery"""
2825
29 def test_0_can_select_mainwindow(self):26 def test_select_main_view_must_return_main_window_emulator(self):
30 """Must be able to select the main window."""27 main_view = self.main_view
3128 self.assertIsInstance(main_view, ubuntuuitoolkit.MainView)
32 rootItem = self.main_view
33 self.assertThat(rootItem, Not(Is(None)))
34 self.assertThat(rootItem.visible, Eventually(Equals(True)))
35
36 def test_navigation(self):
37 item = "Navigation"
38 self.loadItem(item)
39 self.checkPageHeader(item)
4029
41 def test_slider(self):30 def test_slider(self):
42 item = "Slider"31 self.open_page('slidersElement')
43 self.loadItem(item)
44 self.checkPageHeader(item)
4532
46 item_data = [33 item_data = [
47 ["slider_standard"],34 ["slider_standard"],
@@ -57,9 +44,7 @@
57 # TODO: move slider value44 # TODO: move slider value
5845
59 def test_progress_and_activity(self):46 def test_progress_and_activity(self):
60 item = "Progress and activity"47 self.open_page('progressBarsElement')
61 self.loadItem(item)
62 self.checkPageHeader(item)
6348
64 item_data = [49 item_data = [
65 ["progressbar_standard"],50 ["progressbar_standard"],
@@ -79,9 +64,7 @@
79 # FIXME: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/130897964 # FIXME: https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1308979
80 return65 return
8166
82 item = "Ubuntu Shape"67 self.open_page('ubuntuShapesElement')
83 self.loadItem(item)
84 self.checkPageHeader(item)
8568
86 item_data = [69 item_data = [
87 ["ubuntushape_color_hex"],70 ["ubuntushape_color_hex"],
@@ -115,12 +98,9 @@
115 ]98 ]
11699
117 def test_open_page(self):100 def test_open_page(self):
118 list_view = self.main_view.select_single(101 self.open_page(self.element_name)
119 emulators.QQuickListView, objectName="widgetList")
120 list_view.click_element(self.element_name)
121 element = self.main_view.select_single(102 element = self.main_view.select_single(
122 'Standard', objectName=self.element_name)103 'Standard', objectName=self.element_name)
123 element.selected.wait_for(True)
124 self.checkPageHeader(element.text)104 self.checkPageHeader(element.text)
125 if self.template_name == 'textinputsTemplate':105 if self.template_name == 'textinputsTemplate':
126 page_type = 'TextInputs'106 page_type = 'TextInputs'
127107
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py'
--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-05-23 09:50:42 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_optionselector.py 2014-06-06 11:20:51 +0000
@@ -24,9 +24,7 @@
2424
25 def setUp(self):25 def setUp(self):
26 super(OptionSelectorTestCase, self).setUp()26 super(OptionSelectorTestCase, self).setUp()
27 item = "Option Selector"27 self.open_page('optionSelectorsElement')
28 self.loadItem(item)
29 self.checkPageHeader(item)
3028
31 def test_select_option_from_collapsed_optionselector(self):29 def test_select_option_from_collapsed_optionselector(self):
32 collapsed_option_selector = self.main_view.select_single(30 collapsed_option_selector = self.main_view.select_single(
3331
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py'
--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-04-30 09:40:17 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_textinput.py 2014-06-06 11:20:51 +0000
@@ -54,9 +54,7 @@
54 # Apply the user locale from the environment54 # Apply the user locale from the environment
55 # The UITK does the same, so the test must be localized55 # The UITK does the same, so the test must be localized
56 locale.setlocale(locale.LC_ALL, "")56 locale.setlocale(locale.LC_ALL, "")
57 item = 'Text Field'57 self.open_page('textinputsElement')
58 self.loadItem(item)
59 self.checkPageHeader(item)
6058
61 def test_write_on_textfield_must_update_text(self):59 def test_write_on_textfield_must_update_text(self):
62 textfield = self.main_view.select_single(60 textfield = self.main_view.select_single(
@@ -78,9 +76,7 @@
7876
79 def setUp(self):77 def setUp(self):
80 super(DisabledTextInputTestCase, self).setUp()78 super(DisabledTextInputTestCase, self).setUp()
81 item = 'Text Field'79 self.open_page('textinputsElement')
82 self.loadItem(item)
83 self.checkPageHeader(item)
8480
85 def test_textfield_disabled(self):81 def test_textfield_disabled(self):
86 textfield_disabled = self.main_view.select_single(82 textfield_disabled = self.main_view.select_single(
8783
=== modified file 'tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py'
--- tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2013-11-01 15:15:30 +0000
+++ tests/autopilot/ubuntuuitoolkit/tests/gallery/test_toggles.py 2014-06-06 11:20:51 +0000
@@ -35,10 +35,7 @@
3535
36 def setUp(self):36 def setUp(self):
37 super(EnabledTogglesTestCase, self).setUp()37 super(EnabledTogglesTestCase, self).setUp()
38 item = "Toggles"38 self.open_page('togglesElement')
39 self.checkListItem(item)
40 self.loadItem(item)
41 self.checkPageHeader(item)
4239
43 def test_change_toggles_state(self):40 def test_change_toggles_state(self):
44 toggle = self.main_view.select_single(41 toggle = self.main_view.select_single(
@@ -65,10 +62,7 @@
6562
66 def setUp(self):63 def setUp(self):
67 super(DisabledTogglesTestCase, self).setUp()64 super(DisabledTogglesTestCase, self).setUp()
68 item = "Toggles"65 self.open_page('togglesElement')
69 self.checkListItem(item)
70 self.loadItem(item)
71 self.checkPageHeader(item)
7266
73 def test_change_toggles_state(self):67 def test_change_toggles_state(self):
74 toggle = self.main_view.select_single(68 toggle = self.main_view.select_single(

Subscribers

People subscribed via source and target branches