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
1=== modified file 'qml/Dash/Generic/GenericPreview.qml'
2--- qml/Dash/Generic/GenericPreview.qml 2013-10-11 13:54:24 +0000
3+++ qml/Dash/Generic/GenericPreview.qml 2014-01-28 14:43:06 +0000
4@@ -1,5 +1,5 @@
5 /*
6- * Copyright (C) 2013 Canonical, Ltd.
7+ * Copyright (C) 2013, 2014 Canonical, Ltd.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11@@ -120,6 +120,7 @@
12
13 Label {
14 id: descriptionLabel
15+ objectName: "descriptionLabel"
16 anchors { left: parent.left; right: parent.right }
17 visible: text != ""
18 fontSize: "small"
19
20=== modified file 'tests/autopilot/unity8/shell/emulators/dash.py'
21--- tests/autopilot/unity8/shell/emulators/dash.py 2014-01-28 14:43:06 +0000
22+++ tests/autopilot/unity8/shell/emulators/dash.py 2014-01-28 14:43:06 +0000
23@@ -137,32 +137,23 @@
24 self.dash_content_list.currentIndex.wait_for(original_index + 1)
25
26
27+class DashPreview(emulators.UnityEmulatorBase):
28+ """Autopilot emulator for the generic preview."""
29+
30+ def get_details(self):
31+ """Return the details of the open preview."""
32+ title = self.select_single('Label', objectName='titleLabel').text
33+ subtitle = self.select_single(
34+ 'Label', objectName='subtitleLabel').text
35+ description = self.select_single(
36+ 'Label', objectName='descriptionLabel').text
37+ return dict(title=title, subtitle=subtitle, description=description)
38+
39+
40 class GenericScopeView(emulators.UnityEmulatorBase):
41 """Autopilot emulator for generic scopes."""
42
43-
44-class DashApps(emulators.UnityEmulatorBase):
45- """Autopilot emulator for the applications scope."""
46-
47- def get_applications(self, category):
48- """Return the list of applications on a category.
49-
50- :parameter category: The name of the category.
51-
52- """
53- category_element = self._get_category_element(category)
54- application_tiles = category_element.select_many('Tile')
55- # TODO return them on the same order they are displayed.
56- # --elopio - 2014-1-15
57- return [tile.text for tile in application_tiles]
58-
59- def _get_category_element(self, category):
60- try:
61- return self.wait_select_single(
62- 'Base', objectName='dashCategory{}'.format(category))
63- except dbus.StateNotFoundError:
64- raise emulators.UnityEmulatorException(
65- 'No category found with name {}'.format(category))
66+ preview_class = DashPreview
67
68 @autopilot_logging.log_action(logger.info)
69 def open_preview(self, category, app_name):
70@@ -178,19 +169,46 @@
71 # Some categories do not show previews, like recent apps.
72 # --elopio - 2014-1-14
73 self.pointing_device.click_object(icon)
74- return self.get_root_instance().wait_select_single(AppPreview)
75-
76-
77-class AppPreview(emulators.UnityEmulatorBase):
78+ preview = self.get_root_instance().wait_select_single(
79+ self.preview_class, isCurrent=True)
80+ preview.showProcessingAction.wait_for(False)
81+ return preview
82+
83+ def _get_category_element(self, category):
84+ try:
85+ return self.wait_select_single(
86+ 'Base', objectName='dashCategory{}'.format(category))
87+ except dbus.StateNotFoundError:
88+ raise emulators.UnityEmulatorException(
89+ 'No category found with name {}'.format(category))
90+
91+
92+class AppPreview(DashPreview):
93 """Autopilot emulator for the application preview."""
94
95 def get_details(self):
96 """Return the details of the application showed in its preview."""
97- title = self.select_single('Label', objectName='titleLabel').text
98- publisher = self.select_single(
99- 'Label', objectName='subtitleLabel').text
100- description = self.select_single(
101- 'Label', objectName='descriptionLabel').text
102+ details = super(AppPreview, self).get_details()
103 # TODO return screenshots, icon, rating and reviews.
104 # --elopio - 2014-1-15
105- return dict(title=title, publisher=publisher, description=description)
106+ return dict(
107+ title=details.get('title'), publisher=details.get('subtitle'),
108+ description=details.get('description'))
109+
110+
111+class DashApps(GenericScopeView):
112+ """Autopilot emulator for the applications scope."""
113+
114+ preview_class = AppPreview
115+
116+ def get_applications(self, category):
117+ """Return the list of applications on a category.
118+
119+ :parameter category: The name of the category.
120+
121+ """
122+ category_element = self._get_category_element(category)
123+ application_tiles = category_element.select_many('Tile')
124+ # TODO return them on the same order they are displayed.
125+ # --elopio - 2014-1-15
126+ return [tile.text for tile in application_tiles]
127
128=== added file 'tests/autopilot/unity8/shell/fixture_setup.py'
129--- tests/autopilot/unity8/shell/fixture_setup.py 1970-01-01 00:00:00 +0000
130+++ tests/autopilot/unity8/shell/fixture_setup.py 2014-01-28 14:43:06 +0000
131@@ -0,0 +1,53 @@
132+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
133+#
134+# Unity Autopilot Test Suite
135+# Copyright (C) 2014 Canonical
136+#
137+# This program is free software: you can redistribute it and/or modify
138+# it under the terms of the GNU General Public License as published by
139+# the Free Software Foundation, either version 3 of the License, or
140+# (at your option) any later version.
141+#
142+# This program is distributed in the hope that it will be useful,
143+# but WITHOUT ANY WARRANTY; without even the implied warranty of
144+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145+# GNU General Public License for more details.
146+#
147+# You should have received a copy of the GNU General Public License
148+# along with this program. If not, see <http://www.gnu.org/licenses/>.
149+#
150+
151+"""Set up and clean up fixtures for the Unity acceptance tests."""
152+
153+import os
154+import sysconfig
155+
156+import fixtures
157+
158+import unity8
159+
160+
161+class FakeScopes(fixtures.Fixture):
162+
163+ def setUp(self):
164+ super(FakeScopes, self).setUp()
165+ self.useFixture(
166+ fixtures.EnvironmentVariable(
167+ 'QML2_IMPORT_PATH',
168+ newvalue=self._get_fake_scopes_library_path()))
169+
170+ def _get_fake_scopes_library_path(self):
171+ if unity8.running_installed_tests():
172+ mock_path = 'qml/scopefakes/'
173+ else:
174+ mock_path = os.path.join(
175+ '../lib/', sysconfig.get_config_var('MULTIARCH'),
176+ 'unity8/qml/scopefakes/')
177+ lib_path = unity8.get_lib_path()
178+ ld_library_path = os.path.abspath(os.path.join(lib_path, mock_path))
179+
180+ if not os.path.exists(ld_library_path):
181+ raise RuntimeError(
182+ 'Expected library path does not exists: %s.' % (
183+ ld_library_path))
184+ return ld_library_path
185
186=== modified file 'tests/autopilot/unity8/shell/tests/test_emulators.py'
187--- tests/autopilot/unity8/shell/tests/test_emulators.py 2014-01-16 17:35:23 +0000
188+++ tests/autopilot/unity8/shell/tests/test_emulators.py 2014-01-28 14:43:06 +0000
189@@ -27,17 +27,12 @@
190
191 """
192
193-import os
194-import sysconfig
195-
196 import mock
197
198-import fixtures
199 from testtools.matchers import Contains, HasLength
200
201-import unity8
202 from unity8 import process_helpers
203-from unity8.shell import emulators, tests
204+from unity8.shell import emulators, fixture_setup, tests
205 from unity8.shell.emulators import dash as dash_emulators
206
207
208@@ -140,6 +135,30 @@
209 self.assertIsInstance(scope, dash_emulators.DashApps)
210
211
212+class GenericScopeViewEmulatorTestCase(DashBaseTestCase):
213+
214+ def setUp(self):
215+ # Set up the fake scopes before launching unity.
216+ self.useFixture(fixture_setup.FakeScopes())
217+ super(GenericScopeViewEmulatorTestCase, self).setUp()
218+ self.home_scope = self.dash.open_scope('home')
219+
220+ def test_open_preview(self):
221+ preview = self.home_scope.open_preview('0', 'Title.0')
222+ self.assertIsInstance(preview, dash_emulators.DashPreview)
223+ self.assertTrue(preview.isCurrent)
224+ self.assertFalse(preview.showProcessingAction)
225+
226+ def test_get_details(self):
227+ expected_details = dict(
228+ title='Title', subtitle='Subtitle', description='Description')
229+
230+ preview = self.home_scope.open_preview('0', 'Title.0')
231+ details = preview.get_details()
232+
233+ self.assertEqual(expected_details, details)
234+
235+
236 class DashAppsEmulatorTestCase(DashBaseTestCase):
237
238 available_applications = [
239@@ -148,32 +167,11 @@
240 'Title.201', 'Title.221', 'Title.241', 'Title.261', 'Title.281']
241
242 def setUp(self):
243- self._use_scope_fakes()
244+ # Set up the fake scopes before launching unity.
245+ self.useFixture(fixture_setup.FakeScopes())
246 super(DashAppsEmulatorTestCase, self).setUp()
247 self.applications_scope = self.dash.open_scope('applications')
248
249- def _use_scope_fakes(self):
250- self.useFixture(
251- fixtures.EnvironmentVariable(
252- 'QML2_IMPORT_PATH',
253- newvalue=self._get_fake_scopes_library_path()))
254-
255- def _get_fake_scopes_library_path(self):
256- if unity8.running_installed_tests():
257- mock_path = 'qml/scopefakes/'
258- else:
259- mock_path = os.path.join(
260- '../lib/', sysconfig.get_config_var('MULTIARCH'),
261- 'unity8/qml/scopefakes/')
262- lib_path = unity8.get_lib_path()
263- ld_library_path = os.path.abspath(os.path.join(lib_path, mock_path))
264-
265- if not os.path.exists(ld_library_path):
266- raise RuntimeError(
267- 'Expected library path does not exists: %s.' % (
268- ld_library_path))
269- return ld_library_path
270-
271 def test_get_applications_with_unexisting_category(self):
272 exception = self.assertRaises(
273 emulators.UnityEmulatorException,
274@@ -205,3 +203,13 @@
275 preview = self.applications_scope.open_preview('installed', 'Title.1')
276 self.assertIsInstance(preview, dash_emulators.AppPreview)
277 self.assertTrue(preview.isCurrent)
278+ self.assertFalse(preview.showProcessingAction)
279+
280+ def test_get_details(self):
281+ expected_details = dict(
282+ title='Title', publisher='', description='Description')
283+
284+ preview = self.applications_scope.open_preview('installed', 'Title.1')
285+ details = preview.get_details()
286+
287+ self.assertEqual(expected_details, details)

Subscribers

People subscribed via source and target branches