Merge lp:~elopio/unity8/generic_preview into lp:unity8

Proposed by Leo Arias
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 653
Merged at revision: 676
Proposed branch: lp:~elopio/unity8/generic_preview
Merge into: lp:unity8
Prerequisite: lp:~elopio/unity8/wait_for_category
Diff against target: 287 lines (+143/-63)
4 files modified
qml/Dash/Generic/GenericPreview.qml (+2/-1)
tests/autopilot/unity8/shell/emulators/dash.py (+51/-33)
tests/autopilot/unity8/shell/fixture_setup.py (+53/-0)
tests/autopilot/unity8/shell/tests/test_emulators.py (+37/-29)
To merge this branch: bzr merge lp:~elopio/unity8/generic_preview
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Richard Huddie Pending
Javier Collado Pending
VĂ­ctor R. Ruiz Pending
Review via email: mp+202793@code.launchpad.net

Commit message

Added the DashPreview autopilot helper.

Description of the change

[Copied from comment]

* Are there any related MPs required for this MP to build/function as expected? Yes:
https://code.launchpad.net/~elopio/unity8/wait_for_category

* Did you perform an exploratory manual test run of your code change and any related functionality?
Yes.

* If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Not applicable, no packaging changes.

* If you changed the UI, has there been a design review?
Not applicable, no UI changes.

To post a comment you must log in.
lp:~elopio/unity8/generic_preview updated
651. By Leo Arias

Updated the copyright year.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:651
http://jenkins.qa.ubuntu.com/job/unity8-ci/2111/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/2543
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2349/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/981
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/633
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/635
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/635/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/633
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2219
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2545
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2545/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2350
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2350/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/4792/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3277

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2111/rebuild

review: Needs Fixing (continuous-integration)
lp:~elopio/unity8/generic_preview updated
652. By Leo Arias

Added the missing file.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:652
http://jenkins.qa.ubuntu.com/job/unity8-ci/2112/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/2557
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2360/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/985
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/634
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/636
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/636/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/634
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2233
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2559
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2559/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2361
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2361/artifact/work/output/*zip*/output.zip
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/4804/console
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3294

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2112/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Francis Ginther (fginther) wrote :

Touch tests failed due to an issue with phablet-tools on the adb host. It has been resolved and this build has been restarted.

Revision history for this message
Leo Arias (elopio) wrote :

Thanks Francis.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:652
http://jenkins.qa.ubuntu.com/job/unity8-ci/2114/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/2566
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2368
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/987
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/636
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/638
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/638/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/636
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2242
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2568
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2568/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2369
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2369/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/4812
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3302

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2114/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Leo Arias (elopio) wrote :

Are there any related MPs required for this MP to build/function as expected? Yes:
https://code.launchpad.net/~elopio/unity8/wait_for_category

Did you perform an exploratory manual test run of your code change and any related functionality? Yes.
If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP? Not applicable, no packaging changes.
If you changed the UI, has there been a design review? Not applicable, no UI changes.

lp:~elopio/unity8/generic_preview updated
653. By Leo Arias

Merged with trunk.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:653
http://jenkins.qa.ubuntu.com/job/unity8-ci/2145/
Executed test runs:
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty/2675
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-trusty-touch/2454
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-trusty/1018
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-amd64-ci/667
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/669
        deb: http://jenkins.qa.ubuntu.com/job/unity8-trusty-armhf-ci/669/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-trusty-i386-ci/667
    UNSTABLE: http://jenkins.qa.ubuntu.com/job/autopilot-testrunner-otto-trusty/2343
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2677
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-amd64/2677/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2455
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-trusty-armhf/2455/artifact/work/output/*zip*/output.zip
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-runner-mako/4894
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/3414

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/2145/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
Albert Astals Cid (aacid) wrote :

* Did you perform an exploratory manual test run of the code change and any related functionality?
It's all test code, so N/A

* Did CI run pass? If not, please explain why.
No, sd test broken, the rest and new ones work

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'qml/Dash/Generic/GenericPreview.qml'
--- qml/Dash/Generic/GenericPreview.qml 2013-10-11 13:54:24 +0000
+++ qml/Dash/Generic/GenericPreview.qml 2014-01-28 14:43:06 +0000
@@ -1,5 +1,5 @@
1/*1/*
2 * Copyright (C) 2013 Canonical, Ltd.2 * Copyright (C) 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 General Public License as published by5 * it under the terms of the GNU General Public License as published by
@@ -120,6 +120,7 @@
120120
121 Label {121 Label {
122 id: descriptionLabel122 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"
126127
=== modified file 'tests/autopilot/unity8/shell/emulators/dash.py'
--- tests/autopilot/unity8/shell/emulators/dash.py 2014-01-28 14:43:06 +0000
+++ tests/autopilot/unity8/shell/emulators/dash.py 2014-01-28 14:43:06 +0000
@@ -137,32 +137,23 @@
137 self.dash_content_list.currentIndex.wait_for(original_index + 1)137 self.dash_content_list.currentIndex.wait_for(original_index + 1)
138138
139139
140class DashPreview(emulators.UnityEmulatorBase):
141 """Autopilot emulator for the generic preview."""
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)
151
152
140class GenericScopeView(emulators.UnityEmulatorBase):153class GenericScopeView(emulators.UnityEmulatorBase):
141 """Autopilot emulator for generic scopes."""154 """Autopilot emulator for generic scopes."""
142155
143156 preview_class = DashPreview
144class 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 """
153 category_element = self._get_category_element(category)
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
159 def _get_category_element(self, category):
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))
166157
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 @@
178 # Some categories do not show previews, like recent apps.169 # Some categories do not show previews, like recent apps.
179 # --elopio - 2014-1-14170 # --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(
182173 self.preview_class, isCurrent=True)
183174 preview.showProcessingAction.wait_for(False)
184class AppPreview(emulators.UnityEmulatorBase):175 return preview
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))
184
185
186class AppPreview(DashPreview):
185 """Autopilot emulator for the application preview."""187 """Autopilot emulator for the application preview."""
186188
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').text191 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-15193 # --elopio - 2014-1-15
196 return dict(title=title, publisher=publisher, description=description)194 return dict(
195 title=details.get('title'), publisher=details.get('subtitle'),
196 description=details.get('description'))
197
198
199class 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]
197215
=== added file 'tests/autopilot/unity8/shell/fixture_setup.py'
--- tests/autopilot/unity8/shell/fixture_setup.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/unity8/shell/fixture_setup.py 2014-01-28 14:43:06 +0000
@@ -0,0 +1,53 @@
1# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2#
3# Unity Autopilot Test Suite
4# Copyright (C) 2014 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"""Set up and clean up fixtures for the Unity acceptance tests."""
21
22import os
23import sysconfig
24
25import fixtures
26
27import unity8
28
29
30class FakeScopes(fixtures.Fixture):
31
32 def setUp(self):
33 super(FakeScopes, self).setUp()
34 self.useFixture(
35 fixtures.EnvironmentVariable(
36 'QML2_IMPORT_PATH',
37 newvalue=self._get_fake_scopes_library_path()))
38
39 def _get_fake_scopes_library_path(self):
40 if unity8.running_installed_tests():
41 mock_path = 'qml/scopefakes/'
42 else:
43 mock_path = os.path.join(
44 '../lib/', sysconfig.get_config_var('MULTIARCH'),
45 'unity8/qml/scopefakes/')
46 lib_path = unity8.get_lib_path()
47 ld_library_path = os.path.abspath(os.path.join(lib_path, mock_path))
48
49 if not os.path.exists(ld_library_path):
50 raise RuntimeError(
51 'Expected library path does not exists: %s.' % (
52 ld_library_path))
53 return ld_library_path
054
=== modified file 'tests/autopilot/unity8/shell/tests/test_emulators.py'
--- tests/autopilot/unity8/shell/tests/test_emulators.py 2014-01-16 17:35:23 +0000
+++ tests/autopilot/unity8/shell/tests/test_emulators.py 2014-01-28 14:43:06 +0000
@@ -27,17 +27,12 @@
2727
28"""28"""
2929
30import os
31import sysconfig
32
33import mock30import mock
3431
35import fixtures
36from testtools.matchers import Contains, HasLength32from testtools.matchers import Contains, HasLength
3733
38import unity8
39from unity8 import process_helpers34from unity8 import process_helpers
40from unity8.shell import emulators, tests35from unity8.shell import emulators, fixture_setup, tests
41from unity8.shell.emulators import dash as dash_emulators36from unity8.shell.emulators import dash as dash_emulators
4237
4338
@@ -140,6 +135,30 @@
140 self.assertIsInstance(scope, dash_emulators.DashApps)135 self.assertIsInstance(scope, dash_emulators.DashApps)
141136
142137
138class 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):
144163
145 available_applications = [164 available_applications = [
@@ -148,32 +167,11 @@
148 'Title.201', 'Title.221', 'Title.241', 'Title.261', 'Title.281']167 'Title.201', 'Title.221', 'Title.241', 'Title.261', 'Title.281']
149168
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')
154174
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 @@
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)

Subscribers

People subscribed via source and target branches