on xenial help sign in
First pass of autopilot updates for new scopes.
2016686Albert Astals
tests/autopilot/unity8/shell/emulators/dash.py+14−15
@@ -36,11 +36,9 @@ class Dash(emulators.UnityEmulatorBase):
36 self.dash_content_list = self.wait_select_single(
36 self.dash_content_list = self.wait_select_single(
37 'QQuickListView', objectName='dashContentList')
37 'QQuickListView', objectName='dashContentList')
38
38
39− def get_home_applications_grid(self):
39+ def get_applications_grid(self):
40− get_grid = self.get_scope('home').wait_select_single(
40+ get_grid = self.get_scope('clickscope').wait_select_single(
41− "GenericFilterGrid",
41+ 'DashFilterGrid', objectName='local')
42− objectName="applications.scope"
43− )
44 return get_grid
42 return get_grid
45
43
46 def get_application_icon(self, text):
44 def get_application_icon(self, text):
@@ -50,24 +48,22 @@ class Dash(emulators.UnityEmulatorBase):
50 :param text: String containing the text of the icon to search for.
48 :param text: String containing the text of the icon to search for.
51
49
52 """
50 """
53− app_grid = self.get_home_applications_grid()
51+ app_grid = self.get_applications_grid()
54 resp_grid = app_grid.wait_select_single('ResponsiveGridView')
52 resp_grid = app_grid.wait_select_single('ResponsiveGridView')
55 return resp_grid.select_single('Tile', text=text)
53 return resp_grid.select_single('Tile', text=text)
56
54
57− def get_scope(self, scope_name='home'):
55+ def get_scope(self, scope_name='clickscope'):
58− scope_id = "%s.scope" % scope_name
59 return self.dash_content_list.select_single(
56 return self.dash_content_list.select_single(
60− 'QQuickLoader', scopeId=scope_id)
57+ 'QQuickLoader', scopeId=scope_name)
61
58
62 @autopilot_logging.log_action(logger.info)
59 @autopilot_logging.log_action(logger.info)
63− def open_scope(self, scope_name):
60+ def open_scope(self, scope_id):
64 """Open a dash scope.
61 """Open a dash scope.
65
62
66− :parameter scope_name: The name of the scope.
63+ :parameter scope_id: The id of the scope.
67 :return: The scope.
64 :return: The scope.
68
65
69 """
66 """
70− scope_id = "%s.scope" % scope_name
71 scope_loader = self._get_scope_loader(scope_id)
67 scope_loader = self._get_scope_loader(scope_id)
72 if scope_loader.isCurrent:
68 if scope_loader.isCurrent:
73 logger.info('The scope is already open.')
69 logger.info('The scope is already open.')
@@ -84,7 +80,7 @@ class Dash(emulators.UnityEmulatorBase):
84 'No scope found with id {0}'.format(scope_id))
80 'No scope found with id {0}'.format(scope_id))
85
81
86 def _get_scope_from_loader(self, loader):
82 def _get_scope_from_loader(self, loader):
87− if loader.scopeId == 'applications.scope':
83+ if loader.scopeId == 'clickscope':
88 return loader.select_single(DashApps)
84 return loader.select_single(DashApps)
89 else:
85 else:
90 return loader.select_single(GenericScopeView)
86 return loader.select_single(GenericScopeView)
@@ -115,7 +111,7 @@ class Dash(emulators.UnityEmulatorBase):
115 original_index = self.dash_content_list.currentIndex
111 original_index = self.dash_content_list.currentIndex
116 # Scroll on the border of the page header, because some scopes have
112 # Scroll on the border of the page header, because some scopes have
117 # contents that can be scrolled horizontally.
113 # contents that can be scrolled horizontally.
118− page_header = self.select_single('PageHeader')
114+ page_header = self._get_page_header()
119 border = page_header.select_single('QQuickBorderImage')
115 border = page_header.select_single('QQuickBorderImage')
120 start_x = border.width / 3
116 start_x = border.width / 3
121 stop_x = border.width / 3 * 2
117 stop_x = border.width / 3 * 2
@@ -123,12 +119,15 @@ class Dash(emulators.UnityEmulatorBase):
123 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
119 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
124 self.dash_content_list.currentIndex.wait_for(original_index - 1)
120 self.dash_content_list.currentIndex.wait_for(original_index - 1)
125
121
122+ def _get_page_header(self):
123+ return self.select_single('PageHeader', objectName='pageHeader')
124+
126 @autopilot_logging.log_action(logger.info)
125 @autopilot_logging.log_action(logger.info)
127 def _scroll_to_right_scope(self):
126 def _scroll_to_right_scope(self):
128 original_index = self.dash_content_list.currentIndex
127 original_index = self.dash_content_list.currentIndex
129 # Scroll on the border of the page header, because some scopes have
128 # Scroll on the border of the page header, because some scopes have
130 # contents that can be scrolled horizontally.
129 # contents that can be scrolled horizontally.
131− page_header = self.select_single('PageHeader')
130+ page_header = self._get_page_header()
132 border = page_header.select_single('QQuickBorderImage')
131 border = page_header.select_single('QQuickBorderImage')
133 start_x = border.width / 3 * 2
132 start_x = border.width / 3 * 2
134 stop_x = border.width / 3
133 stop_x = border.width / 3
tests/autopilot/unity8/shell/emulators/main_window.py−4
@@ -42,10 +42,6 @@ class QQuickView(emulators.UnityEmulatorBase):
42 objectName="greeterContentLoader"
42 objectName="greeterContentLoader"
43 )
43 )
44
44
45− def get_greeter_background(self):
46− return self.select_single(
47− "CrossFadeImage", objectName="greeterBackground")
48−
49 def get_login_loader(self):
45 def get_login_loader(self):
50 return self.select_single("QQuickLoader", objectName="loginLoader")
46 return self.select_single("QQuickLoader", objectName="loginLoader")
51
47
tests/autopilot/unity8/shell/tests/__init__.py+1−1
@@ -377,7 +377,7 @@ class UnityTestCase(AutopilotTestCase):
377
377
378 def assertUnityReady(self):
378 def assertUnityReady(self):
379 dash = self.get_dash()
379 dash = self.get_dash()
380− home_scope = dash.get_scope('home')
380+ home_scope = dash.get_scope('clickscope')
381
381
382 # FIXME! There is a huge timeout here for when we're doing CI on
382 # FIXME! There is a huge timeout here for when we're doing CI on
383 # VMs. See lp:1203715
383 # VMs. See lp:1203715
tests/autopilot/unity8/shell/tests/test_emulators.py+14−21
@@ -57,14 +57,13 @@ class DashEmulatorTestCase(DashBaseTestCase):
57 self.dash.open_scope, scope_name)
57 self.dash.open_scope, scope_name)
58
58
59 self.assertEqual(
59 self.assertEqual(
60− 'No scope found with id unexisting.scope', str(exception))
60+ 'No scope found with id unexisting', str(exception))
61 self.assertFalse(mock_pointer.called)
61 self.assertFalse(mock_pointer.called)
62
62
63 def test_open_already_opened_scope(self):
63 def test_open_already_opened_scope(self):
64 scope_id = self._get_current_scope_id()
64 scope_id = self._get_current_scope_id()
65 with mock.patch.object(self.dash, 'pointing_device') as mock_pointer:
65 with mock.patch.object(self.dash, 'pointing_device') as mock_pointer:
66− scope = self.dash.open_scope(self._get_scope_name_from_id(
66+ scope = self.dash.open_scope(scope_id)
67− scope_id))
68
67
69 self.assertFalse(mock_pointer.called)
68 self.assertFalse(mock_pointer.called)
70 self._assert_scope_is_opened(scope, scope_id)
69 self._assert_scope_is_opened(scope, scope_id)
@@ -80,12 +79,11 @@ class DashEmulatorTestCase(DashBaseTestCase):
80 return scope.scopeId
79 return scope.scopeId
81
80
82 def test_open_scope_to_the_right(self):
81 def test_open_scope_to_the_right(self):
83− leftmost_scope = self._get_scope_name_from_id(
84− self._get_leftmost_scope_id())
82+ leftmost_scope = self._get_leftmost_scope_id()
85 self.dash.open_scope(leftmost_scope)
83 self.dash.open_scope(leftmost_scope)
86
84
87 scope_id = self._get_rightmost_scope_id()
85 scope_id = self._get_rightmost_scope_id()
88− scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
86+ scope = self.dash.open_scope(scope_id)
89 self._assert_scope_is_opened(scope, scope_id)
87 self._assert_scope_is_opened(scope, scope_id)
90
88
91 def _get_leftmost_scope_id(self):
89 def _get_leftmost_scope_id(self):
@@ -101,10 +99,6 @@ class DashEmulatorTestCase(DashBaseTestCase):
101 'QQuickItem')[0]
99 'QQuickItem')[0]
102 return item.get_children_by_type('QQuickLoader')
100 return item.get_children_by_type('QQuickLoader')
103
101
104− def _get_scope_name_from_id(self, scope_id):
105− if scope_id.endswith('.scope'):
106− return scope_id[:-6]
107−
108 def _get_rightmost_scope_id(self):
102 def _get_rightmost_scope_id(self):
109 scope_loaders = self._get_scope_loaders()
103 scope_loaders = self._get_scope_loaders()
110 rightmost_scope_loader = scope_loaders[0]
104 rightmost_scope_loader = scope_loaders[0]
@@ -114,23 +108,22 @@ class DashEmulatorTestCase(DashBaseTestCase):
114 return rightmost_scope_loader.scopeId
108 return rightmost_scope_loader.scopeId
115
109
116 def test_open_scope_to_the_left(self):
110 def test_open_scope_to_the_left(self):
117− rightmost_scope = self._get_scope_name_from_id(
118− self._get_rightmost_scope_id())
111+ rightmost_scope = self._get_rightmost_scope_id()
119 self.dash.open_scope(rightmost_scope)
112 self.dash.open_scope(rightmost_scope)
120
113
121 scope_id = self._get_leftmost_scope_id()
114 scope_id = self._get_leftmost_scope_id()
122− scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
115+ scope = self.dash.open_scope(scope_id)
123 self._assert_scope_is_opened(scope, scope_id)
116 self._assert_scope_is_opened(scope, scope_id)
124
117
125 def test_open_generic_scope(self):
118 def test_open_generic_scope(self):
126− scope_id = 'home.scope'
119+ scope_id = 'scopes'
127− scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
120+ scope = self.dash.open_scope(scope_id)
128 self._assert_scope_is_opened(scope, scope_id)
121 self._assert_scope_is_opened(scope, scope_id)
129 self.assertIsInstance(scope, dash_emulators.GenericScopeView)
122 self.assertIsInstance(scope, dash_emulators.GenericScopeView)
130
123
131 def test_open_applications_scope(self):
124 def test_open_applications_scope(self):
132− scope_id = 'applications.scope'
125+ scope_id = 'clickscope'
133− scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
126+ scope = self.dash.open_scope(scope_id)
134 self._assert_scope_is_opened(scope, scope_id)
127 self._assert_scope_is_opened(scope, scope_id)
135 self.assertIsInstance(scope, dash_emulators.DashApps)
128 self.assertIsInstance(scope, dash_emulators.DashApps)
136
129
@@ -141,10 +134,10 @@ class GenericScopeViewEmulatorTestCase(DashBaseTestCase):
141 # Set up the fake scopes before launching unity.
134 # Set up the fake scopes before launching unity.
142 self.useFixture(fixture_setup.FakeScopes())
135 self.useFixture(fixture_setup.FakeScopes())
143 super(GenericScopeViewEmulatorTestCase, self).setUp()
136 super(GenericScopeViewEmulatorTestCase, self).setUp()
144− self.home_scope = self.dash.open_scope('home')
137+ self.generic_scope = self.dash.open_scope('MockScope1')
145
138
146 def test_open_preview(self):
139 def test_open_preview(self):
147− preview = self.home_scope.open_preview('0', 'Title.0')
140+ preview = self.generic_scope.open_preview('0', 'Title.0')
148 self.assertIsInstance(preview, dash_emulators.DashPreview)
141 self.assertIsInstance(preview, dash_emulators.DashPreview)
149 self.assertTrue(preview.isCurrent)
142 self.assertTrue(preview.isCurrent)
150 self.assertFalse(preview.showProcessingAction)
143 self.assertFalse(preview.showProcessingAction)
@@ -153,7 +146,7 @@ class GenericScopeViewEmulatorTestCase(DashBaseTestCase):
153 expected_details = dict(
146 expected_details = dict(
154 title='Title', subtitle='Subtitle', description='Description')
147 title='Title', subtitle='Subtitle', description='Description')
155
148
156− preview = self.home_scope.open_preview('0', 'Title.0')
149+ preview = self.generic_scope.open_preview('0', 'Title.0')
157 details = preview.get_details()
150 details = preview.get_details()
158
151
159 self.assertEqual(expected_details, details)
152 self.assertEqual(expected_details, details)
@@ -170,7 +163,7 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
170 # Set up the fake scopes before launching unity.
163 # Set up the fake scopes before launching unity.
171 self.useFixture(fixture_setup.FakeScopes())
164 self.useFixture(fixture_setup.FakeScopes())
172 super(DashAppsEmulatorTestCase, self).setUp()
165 super(DashAppsEmulatorTestCase, self).setUp()
173− self.applications_scope = self.dash.open_scope('applications')
166+ self.applications_scope = self.dash.open_scope('clickscope')
174
167
175 def test_get_applications_with_unexisting_category(self):
168 def test_get_applications_with_unexisting_category(self):
176 exception = self.assertRaises(
169 exception = self.assertRaises(
tests/autopilot/unity8/shell/tests/test_greeter.pydeleted−38
@@ -1,38 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−#
3−# Unity Autopilot Test Suite
4−# Copyright (C) 2012-2013 Canonical
5−#
6−# This program is free software: you can redistribute it and/or modify
7−# it under the terms of the GNU General Public License as published by
8−# the Free Software Foundation, either version 3 of the License, or
9−# (at your option) any later version.
10−#
11−# This program is distributed in the hope that it will be useful,
12−# but WITHOUT ANY WARRANTY; without even the implied warranty of
13−# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14−# GNU General Public License for more details.
15−#
16−# You should have received a copy of the GNU General Public License
17−# along with this program. If not, see <http://www.gnu.org/licenses/>.
18−#
19−
20−from unity8.shell.tests import UnityTestCase, _get_device_emulation_scenarios
21−
22−from testtools.matchers import Equals
23−
24−class TestGreeter(UnityTestCase):
25−
26− """Tests the Shell Greeter."""
27−
28− scenarios = _get_device_emulation_scenarios()
29−
30− def test_greeter_background(self):
31− """Test that the background of the greeter and the background of the shell are placed correctly
32−
33− """
34− self.launch_unity()
35− self.main_window.get_greeter()
36− greeter_background = self.main_window.get_greeter_background()
37− shell_background = self.main_window.get_shell_background()
38− self.assertThat(greeter_background.globalRect, Equals(shell_background.globalRect))