on xenial help sign in
First pass of autopilot updates for new scopes.

lp:~elopio/unity8/new-scopes-cleanup-autopilot

commit20166868d28b287618a2482d3f8bef3c84cc433c authorAlbert Astals <albert.astals@canonical.com> dateMon 3 Mar 2014, 16:21 (13 years ago) parentc4337557c193a6
5 files changed+29−79
tests/autopilot/unity8/shell/emulators/dash.py+14−15 tests/autopilot/unity8/shell/emulators/main_window.py−4 tests/autopilot/unity8/shell/tests/__init__.py+1−1 tests/autopilot/unity8/shell/tests/test_emulators.py+14−21 tests/autopilot/unity8/shell/tests/test_greeter.py−38
tests/autopilot/unity8/shell/emulators/dash.py+14−15
@@ -36,11 +36,9 @@ class Dash(emulators.UnityEmulatorBase):
3636 self.dash_content_list = self.wait_select_single(
3737 'QQuickListView', objectName='dashContentList')
3838
39− def get_home_applications_grid(self):
40− get_grid = self.get_scope('home').wait_select_single(
41− "GenericFilterGrid",
42− objectName="applications.scope"
43− )
39+ def get_applications_grid(self):
40+ get_grid = self.get_scope('clickscope').wait_select_single(
41+ 'DashFilterGrid', objectName='local')
4442 return get_grid
4543
4644 def get_application_icon(self, text):
@@ -50,24 +48,22 @@ class Dash(emulators.UnityEmulatorBase):
5048 :param text: String containing the text of the icon to search for.
5149
5250 """
53− app_grid = self.get_home_applications_grid()
51+ app_grid = self.get_applications_grid()
5452 resp_grid = app_grid.wait_select_single('ResponsiveGridView')
5553 return resp_grid.select_single('Tile', text=text)
5654
57− def get_scope(self, scope_name='home'):
58− scope_id = "%s.scope" % scope_name
55+ def get_scope(self, scope_name='clickscope'):
5956 return self.dash_content_list.select_single(
60− 'QQuickLoader', scopeId=scope_id)
57+ 'QQuickLoader', scopeId=scope_name)
6158
6259 @autopilot_logging.log_action(logger.info)
63− def open_scope(self, scope_name):
60+ def open_scope(self, scope_id):
6461 """Open a dash scope.
6562
66− :parameter scope_name: The name of the scope.
63+ :parameter scope_id: The id of the scope.
6764 :return: The scope.
6865
6966 """
70− scope_id = "%s.scope" % scope_name
7167 scope_loader = self._get_scope_loader(scope_id)
7268 if scope_loader.isCurrent:
7369 logger.info('The scope is already open.')
@@ -84,7 +80,7 @@ class Dash(emulators.UnityEmulatorBase):
8480 'No scope found with id {0}'.format(scope_id))
8581
8682 def _get_scope_from_loader(self, loader):
87− if loader.scopeId == 'applications.scope':
83+ if loader.scopeId == 'clickscope':
8884 return loader.select_single(DashApps)
8985 else:
9086 return loader.select_single(GenericScopeView)
@@ -115,7 +111,7 @@ class Dash(emulators.UnityEmulatorBase):
115111 original_index = self.dash_content_list.currentIndex
116112 # Scroll on the border of the page header, because some scopes have
117113 # contents that can be scrolled horizontally.
118− page_header = self.select_single('PageHeader')
114+ page_header = self._get_page_header()
119115 border = page_header.select_single('QQuickBorderImage')
120116 start_x = border.width / 3
121117 stop_x = border.width / 3 * 2
@@ -123,12 +119,15 @@ class Dash(emulators.UnityEmulatorBase):
123119 self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
124120 self.dash_content_list.currentIndex.wait_for(original_index - 1)
125121
122+ def _get_page_header(self):
123+ return self.select_single('PageHeader', objectName='pageHeader')
124+
126125 @autopilot_logging.log_action(logger.info)
127126 def _scroll_to_right_scope(self):
128127 original_index = self.dash_content_list.currentIndex
129128 # Scroll on the border of the page header, because some scopes have
130129 # contents that can be scrolled horizontally.
131− page_header = self.select_single('PageHeader')
130+ page_header = self._get_page_header()
132131 border = page_header.select_single('QQuickBorderImage')
133132 start_x = border.width / 3 * 2
134133 stop_x = border.width / 3
tests/autopilot/unity8/shell/emulators/main_window.py−4
@@ -42,10 +42,6 @@ class QQuickView(emulators.UnityEmulatorBase):
4242 objectName="greeterContentLoader"
4343 )
4444
45− def get_greeter_background(self):
46− return self.select_single(
47− "CrossFadeImage", objectName="greeterBackground")
48−
4945 def get_login_loader(self):
5046 return self.select_single("QQuickLoader", objectName="loginLoader")
5147
tests/autopilot/unity8/shell/tests/__init__.py+1−1
@@ -377,7 +377,7 @@ class UnityTestCase(AutopilotTestCase):
377377
378378 def assertUnityReady(self):
379379 dash = self.get_dash()
380− home_scope = dash.get_scope('home')
380+ home_scope = dash.get_scope('clickscope')
381381
382382 # FIXME! There is a huge timeout here for when we're doing CI on
383383 # VMs. See lp:1203715
tests/autopilot/unity8/shell/tests/test_emulators.py+14−21
@@ -57,14 +57,13 @@ class DashEmulatorTestCase(DashBaseTestCase):
5757 self.dash.open_scope, scope_name)
5858
5959 self.assertEqual(
60− 'No scope found with id unexisting.scope', str(exception))
60+ 'No scope found with id unexisting', str(exception))
6161 self.assertFalse(mock_pointer.called)
6262
6363 def test_open_already_opened_scope(self):
6464 scope_id = self._get_current_scope_id()
6565 with mock.patch.object(self.dash, 'pointing_device') as mock_pointer:
66− scope = self.dash.open_scope(self._get_scope_name_from_id(
67− scope_id))
66+ scope = self.dash.open_scope(scope_id)
6867
6968 self.assertFalse(mock_pointer.called)
7069 self._assert_scope_is_opened(scope, scope_id)
@@ -80,12 +79,11 @@ class DashEmulatorTestCase(DashBaseTestCase):
8079 return scope.scopeId
8180
8281 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()
8583 self.dash.open_scope(leftmost_scope)
8684
8785 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)
8987 self._assert_scope_is_opened(scope, scope_id)
9088
9189 def _get_leftmost_scope_id(self):
@@ -101,10 +99,6 @@ class DashEmulatorTestCase(DashBaseTestCase):
10199 'QQuickItem')[0]
102100 return item.get_children_by_type('QQuickLoader')
103101
104− def _get_scope_name_from_id(self, scope_id):
105− if scope_id.endswith('.scope'):
106− return scope_id[:-6]
107−
108102 def _get_rightmost_scope_id(self):
109103 scope_loaders = self._get_scope_loaders()
110104 rightmost_scope_loader = scope_loaders[0]
@@ -114,23 +108,22 @@ class DashEmulatorTestCase(DashBaseTestCase):
114108 return rightmost_scope_loader.scopeId
115109
116110 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()
119112 self.dash.open_scope(rightmost_scope)
120113
121114 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)
123116 self._assert_scope_is_opened(scope, scope_id)
124117
125118 def test_open_generic_scope(self):
126− scope_id = 'home.scope'
127− scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
119+ scope_id = 'scopes'
120+ scope = self.dash.open_scope(scope_id)
128121 self._assert_scope_is_opened(scope, scope_id)
129122 self.assertIsInstance(scope, dash_emulators.GenericScopeView)
130123
131124 def test_open_applications_scope(self):
132− scope_id = 'applications.scope'
133− scope = self.dash.open_scope(self._get_scope_name_from_id(scope_id))
125+ scope_id = 'clickscope'
126+ scope = self.dash.open_scope(scope_id)
134127 self._assert_scope_is_opened(scope, scope_id)
135128 self.assertIsInstance(scope, dash_emulators.DashApps)
136129
@@ -141,10 +134,10 @@ class GenericScopeViewEmulatorTestCase(DashBaseTestCase):
141134 # Set up the fake scopes before launching unity.
142135 self.useFixture(fixture_setup.FakeScopes())
143136 super(GenericScopeViewEmulatorTestCase, self).setUp()
144− self.home_scope = self.dash.open_scope('home')
137+ self.generic_scope = self.dash.open_scope('MockScope1')
145138
146139 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')
148141 self.assertIsInstance(preview, dash_emulators.DashPreview)
149142 self.assertTrue(preview.isCurrent)
150143 self.assertFalse(preview.showProcessingAction)
@@ -153,7 +146,7 @@ class GenericScopeViewEmulatorTestCase(DashBaseTestCase):
153146 expected_details = dict(
154147 title='Title', subtitle='Subtitle', description='Description')
155148
156− preview = self.home_scope.open_preview('0', 'Title.0')
149+ preview = self.generic_scope.open_preview('0', 'Title.0')
157150 details = preview.get_details()
158151
159152 self.assertEqual(expected_details, details)
@@ -170,7 +163,7 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
170163 # Set up the fake scopes before launching unity.
171164 self.useFixture(fixture_setup.FakeScopes())
172165 super(DashAppsEmulatorTestCase, self).setUp()
173− self.applications_scope = self.dash.open_scope('applications')
166+ self.applications_scope = self.dash.open_scope('clickscope')
174167
175168 def test_get_applications_with_unexisting_category(self):
176169 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))