on xenial help sign in
Added the DashPreview autopilot helper.
8d2c328Leo Arias
qml/Dash/Generic/GenericPreview.qml+1
@@ -120,6 +120,7 @@ DashPreview {
120
120
121 Label {
121 Label {
122 id: descriptionLabel
122 id: descriptionLabel
123+ objectName: "descriptionLabel"
123 anchors { left: parent.left; right: parent.right }
124 anchors { left: parent.left; right: parent.right }
124 visible: text != ""
125 visible: text != ""
125 fontSize: "small"
126 fontSize: "small"
tests/autopilot/unity8/shell/emulators/dash.py+48−30
@@ -137,32 +137,23 @@ class Dash(emulators.UnityEmulatorBase):
137 self.dash_content_list.currentIndex.wait_for(original_index + 1)
137 self.dash_content_list.currentIndex.wait_for(original_index + 1)
138
138
139
139
140−class GenericScopeView(emulators.UnityEmulatorBase):
140+class DashPreview(emulators.UnityEmulatorBase):
141− """Autopilot emulator for generic scopes."""
141+ """Autopilot emulator for the generic preview."""
142
142
143+ def get_details(self):
144+ """Return the details of the open preview."""
145+ title = self.select_single('Label', objectName='titleLabel').text
146+ subtitle = self.select_single(
147+ 'Label', objectName='subtitleLabel').text
148+ description = self.select_single(
149+ 'Label', objectName='descriptionLabel').text
150+ return dict(title=title, subtitle=subtitle, description=description)
143
151
144−class DashApps(emulators.UnityEmulatorBase):
145− """Autopilot emulator for the applications scope."""
146−
147− def get_applications(self, category):
148− """Return the list of applications on a category.
149−
150− :parameter category: The name of the category.
151
152
152− """
153+class GenericScopeView(emulators.UnityEmulatorBase):
153− category_element = self._get_category_element(category)
154+ """Autopilot emulator for generic scopes."""
154− application_tiles = category_element.select_many('Tile')
155− # TODO return them on the same order they are displayed.
156− # --elopio - 2014-1-15
157− return [tile.text for tile in application_tiles]
158
155
159− def _get_category_element(self, category):
156+ preview_class = DashPreview
160− try:
161− return self.wait_select_single(
162− 'Base', objectName='dashCategory{}'.format(category))
163− except dbus.StateNotFoundError:
164− raise emulators.UnityEmulatorException(
165− 'No category found with name {}'.format(category))
166
157
167 @autopilot_logging.log_action(logger.info)
158 @autopilot_logging.log_action(logger.info)
168 def open_preview(self, category, app_name):
159 def open_preview(self, category, app_name):
@@ -178,19 +169,46 @@ class DashApps(emulators.UnityEmulatorBase):
178 # Some categories do not show previews, like recent apps.
169 # Some categories do not show previews, like recent apps.
179 # --elopio - 2014-1-14
170 # --elopio - 2014-1-14
180 self.pointing_device.click_object(icon)
171 self.pointing_device.click_object(icon)
181− return self.get_root_instance().wait_select_single(AppPreview)
172+ preview = self.get_root_instance().wait_select_single(
173+ self.preview_class, isCurrent=True)
174+ preview.showProcessingAction.wait_for(False)
175+ return preview
182
176
177+ def _get_category_element(self, category):
178+ try:
179+ return self.wait_select_single(
180+ 'Base', objectName='dashCategory{}'.format(category))
181+ except dbus.StateNotFoundError:
182+ raise emulators.UnityEmulatorException(
183+ 'No category found with name {}'.format(category))
183
184
185+
184−class AppPreview(emulators.UnityEmulatorBase):
186+class AppPreview(DashPreview):
185 """Autopilot emulator for the application preview."""
187 """Autopilot emulator for the application preview."""
186
188
187 def get_details(self):
189 def get_details(self):
188 """Return the details of the application showed in its preview."""
190 """Return the details of the application showed in its preview."""
189− title = self.select_single('Label', objectName='titleLabel').text
191+ details = super(AppPreview, self).get_details()
190− publisher = self.select_single(
191− 'Label', objectName='subtitleLabel').text
192− description = self.select_single(
193− 'Label', objectName='descriptionLabel').text
194 # TODO return screenshots, icon, rating and reviews.
192 # TODO return screenshots, icon, rating and reviews.
195 # --elopio - 2014-1-15
193 # --elopio - 2014-1-15
194+ return dict(
195+ title=details.get('title'), publisher=details.get('subtitle'),
196− return dict(title=title, publisher=publisher, description=description)
196+ description=details.get('description'))
197+
198+
199+class DashApps(GenericScopeView):
200+ """Autopilot emulator for the applications scope."""
201+
202+ preview_class = AppPreview
203+
204+ def get_applications(self, category):
205+ """Return the list of applications on a category.
206+
207+ :parameter category: The name of the category.
208+
209+ """
210+ category_element = self._get_category_element(category)
211+ application_tiles = category_element.select_many('Tile')
212+ # TODO return them on the same order they are displayed.
213+ # --elopio - 2014-1-15
214+ return [tile.text for tile in application_tiles]
tests/autopilot/unity8/shell/tests/test_emulators.py+37−29
@@ -27,17 +27,12 @@ don't break them for those external projects.
27
27
28"""
28"""
29
29
30−import os
31−import sysconfig
32−
33import mock
30import mock
34
31
35−import fixtures
36from testtools.matchers import Contains, HasLength
32from testtools.matchers import Contains, HasLength
37
33
38−import unity8
39from unity8 import process_helpers
34from unity8 import process_helpers
40−from unity8.shell import emulators, tests
35+from unity8.shell import emulators, fixture_setup, tests
41from unity8.shell.emulators import dash as dash_emulators
36from unity8.shell.emulators import dash as dash_emulators
42
37
43
38
@@ -140,6 +135,30 @@ class DashEmulatorTestCase(DashBaseTestCase):
140 self.assertIsInstance(scope, dash_emulators.DashApps)
135 self.assertIsInstance(scope, dash_emulators.DashApps)
141
136
142
137
138+class GenericScopeViewEmulatorTestCase(DashBaseTestCase):
139+
140+ def setUp(self):
141+ # Set up the fake scopes before launching unity.
142+ self.useFixture(fixture_setup.FakeScopes())
143+ super(GenericScopeViewEmulatorTestCase, self).setUp()
144+ self.home_scope = self.dash.open_scope('home')
145+
146+ def test_open_preview(self):
147+ preview = self.home_scope.open_preview('0', 'Title.0')
148+ self.assertIsInstance(preview, dash_emulators.DashPreview)
149+ self.assertTrue(preview.isCurrent)
150+ self.assertFalse(preview.showProcessingAction)
151+
152+ def test_get_details(self):
153+ expected_details = dict(
154+ title='Title', subtitle='Subtitle', description='Description')
155+
156+ preview = self.home_scope.open_preview('0', 'Title.0')
157+ details = preview.get_details()
158+
159+ self.assertEqual(expected_details, details)
160+
161+
143class DashAppsEmulatorTestCase(DashBaseTestCase):
162class DashAppsEmulatorTestCase(DashBaseTestCase):
144
163
145 available_applications = [
164 available_applications = [
@@ -148,32 +167,11 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
148 'Title.201', 'Title.221', 'Title.241', 'Title.261', 'Title.281']
167 'Title.201', 'Title.221', 'Title.241', 'Title.261', 'Title.281']
149
168
150 def setUp(self):
169 def setUp(self):
151− self._use_scope_fakes()
170+ # Set up the fake scopes before launching unity.
171+ self.useFixture(fixture_setup.FakeScopes())
152 super(DashAppsEmulatorTestCase, self).setUp()
172 super(DashAppsEmulatorTestCase, self).setUp()
153 self.applications_scope = self.dash.open_scope('applications')
173 self.applications_scope = self.dash.open_scope('applications')
154
174
155− def _use_scope_fakes(self):
156− self.useFixture(
157− fixtures.EnvironmentVariable(
158− 'QML2_IMPORT_PATH',
159− newvalue=self._get_fake_scopes_library_path()))
160−
161− def _get_fake_scopes_library_path(self):
162− if unity8.running_installed_tests():
163− mock_path = 'qml/scopefakes/'
164− else:
165− mock_path = os.path.join(
166− '../lib/', sysconfig.get_config_var('MULTIARCH'),
167− 'unity8/qml/scopefakes/')
168− lib_path = unity8.get_lib_path()
169− ld_library_path = os.path.abspath(os.path.join(lib_path, mock_path))
170−
171− if not os.path.exists(ld_library_path):
172− raise RuntimeError(
173− 'Expected library path does not exists: %s.' % (
174− ld_library_path))
175− return ld_library_path
176−
177 def test_get_applications_with_unexisting_category(self):
175 def test_get_applications_with_unexisting_category(self):
178 exception = self.assertRaises(
176 exception = self.assertRaises(
179 emulators.UnityEmulatorException,
177 emulators.UnityEmulatorException,
@@ -205,3 +203,13 @@ class DashAppsEmulatorTestCase(DashBaseTestCase):
205 preview = self.applications_scope.open_preview('installed', 'Title.1')
203 preview = self.applications_scope.open_preview('installed', 'Title.1')
206 self.assertIsInstance(preview, dash_emulators.AppPreview)
204 self.assertIsInstance(preview, dash_emulators.AppPreview)
207 self.assertTrue(preview.isCurrent)
205 self.assertTrue(preview.isCurrent)
206+ self.assertFalse(preview.showProcessingAction)
207+
208+ def test_get_details(self):
209+ expected_details = dict(
210+ title='Title', publisher='', description='Description')
211+
212+ preview = self.applications_scope.open_preview('installed', 'Title.1')
213+ details = preview.get_details()
214+
215+ self.assertEqual(expected_details, details)