Merge lp:~canonical-platform-qa/unity8/edges_demo_test into lp:unity8

Proposed by Leo Arias on 2014-12-16
Status: Merged
Approved by: Albert Astals Cid on 2015-01-07
Approved revision: 1517
Merged at revision: 1545
Proposed branch: lp:~canonical-platform-qa/unity8/edges_demo_test
Merge into: lp:unity8
Diff against target: 254 lines (+230/-0)
3 files modified
tests/autopilot/unity8/shell/emulators/edges_demo.py (+140/-0)
tests/autopilot/unity8/shell/fixture_setup.py (+38/-0)
tests/autopilot/unity8/shell/tests/test_edges_demo.py (+52/-0)
To merge this branch: bzr merge lp:~canonical-platform-qa/unity8/edges_demo_test
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve on 2015-01-07
Albert Astals Cid (community) 2014-12-16 Approve on 2015-01-07
Review via email: mp+244889@code.launchpad.net

Commit Message

Added an autopilot test for the edges demo.

Description of the Change

We want to automate most of the sanity testing process, and this test is one of the easy ones that can be removed from the manual execution if we have a good high level test to confirm the demo works.

 * Are there any related MPs required for this MP to build/function as expected? Please list.

There are no related MPs.

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

Sort of. I ran the tests many times, in the device and desktop, with different starting conditions.

 * Did you make sure that your branch does not contain spurious tags?

I did.

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

No packaging changes.

 * If you changed the UI, has there been a design review?

No UI changes.

To post a comment you must log in.
Albert Astals Cid (aacid) wrote :

Seems the test failed can you have a look? (Only at yours, i'll check the other ones)

review: Needs Fixing
1516. By Leo Arias on 2014-12-17

Fixed the emulators import.

Leo Arias (elopio) wrote :

Thanks for looking at it Albert. I was missing a import that loads the autopilot cache. Now the test passed.

1517. By Leo Arias on 2015-01-05

Merged with trunk.

Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
No, it's only a test improvement. I checked the test succeeds

 * Did CI run pass?
No, fails in an unrelated test and since this only adds a different test can't be the cause

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve
1518. By Leo Arias on 2015-01-09

Make the test work with python2.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'tests/autopilot/unity8/shell/emulators/edges_demo.py'
2--- tests/autopilot/unity8/shell/emulators/edges_demo.py 1970-01-01 00:00:00 +0000
3+++ tests/autopilot/unity8/shell/emulators/edges_demo.py 2015-01-09 16:59:23 +0000
4@@ -0,0 +1,140 @@
5+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
6+#
7+# Unity Autopilot Test Suite
8+# Copyright (C) 2014 Canonical
9+#
10+# This program is free software: you can redistribute it and/or modify
11+# it under the terms of the GNU General Public License as published by
12+# the Free Software Foundation, either version 3 of the License, or
13+# (at your option) any later version.
14+#
15+# This program is distributed in the hope that it will be useful,
16+# but WITHOUT ANY WARRANTY; without even the implied warranty of
17+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18+# GNU General Public License for more details.
19+#
20+# You should have received a copy of the GNU General Public License
21+# along with this program. If not, see <http://www.gnu.org/licenses/>.
22+#
23+
24+import logging
25+import time
26+
27+import ubuntuuitoolkit
28+
29+import autopilot
30+from autopilot import introspection
31+
32+
33+logger = logging.getLogger(__name__)
34+
35+
36+class RightEdgeDemoOverlay(
37+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
38+
39+ @classmethod
40+ def validate_dbus_object(cls, path, state):
41+ name = introspection.get_classname_from_path(path)
42+ if name == b'EdgeDemoOverlay':
43+ if state['edge'][1] == 'right':
44+ return True
45+ return False
46+
47+ @autopilot.logging.log_action(logger.info)
48+ def swipe(self):
49+ """Swipe to the left to complete this demo step."""
50+ x, y, width, height = self.globalRect
51+ start_x = x + width
52+ stop_x = x
53+ start_y = stop_y = y + height // 2
54+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
55+ return self.get_root_instance().wait_select_single(
56+ edge='top', active=True)
57+
58+
59+class TopEdgeDemoOverlay(
60+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
61+
62+ @classmethod
63+ def validate_dbus_object(cls, path, state):
64+ name = introspection.get_classname_from_path(path)
65+ if name == b'EdgeDemoOverlay':
66+ if state['edge'][1] == 'top':
67+ return True
68+ return False
69+
70+ @autopilot.logging.log_action(logger.info)
71+ def swipe(self):
72+ """Swipe to the bottom to complete this demo step."""
73+ x, y, width, height = self.globalRect
74+ start_x = stop_x = x + width // 2
75+ start_y = y
76+ stop_y = y + height
77+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
78+ return self.get_root_instance().wait_select_single(
79+ edge='bottom', active=True)
80+
81+
82+class BottomEdgeDemoOverlay(
83+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
84+
85+ @classmethod
86+ def validate_dbus_object(cls, path, state):
87+ name = introspection.get_classname_from_path(path)
88+ if name == b'EdgeDemoOverlay':
89+ if state['edge'][1] == 'bottom':
90+ return True
91+ return False
92+
93+ @autopilot.logging.log_action(logger.info)
94+ def swipe(self):
95+ """Swipe to the top to complete this demo step."""
96+ x, y, width, height = self.globalRect
97+ start_x = stop_x = x + width // 2
98+ start_y = y + height
99+ stop_y = y
100+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
101+ return self.get_root_instance().wait_select_single(
102+ edge='left', active=True)
103+
104+
105+class LeftEdgeDemoOverlay(
106+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
107+
108+ @classmethod
109+ def validate_dbus_object(cls, path, state):
110+ name = introspection.get_classname_from_path(path)
111+ if name == b'EdgeDemoOverlay':
112+ if state['edge'][1] == 'left':
113+ return True
114+ return False
115+
116+ @autopilot.logging.log_action(logger.info)
117+ def swipe(self):
118+ """Swipe to the right to complete this demo step."""
119+ x, y, width, height = self.globalRect
120+ start_x = x
121+ stop_x = x + width
122+ start_y = stop_y = y + height // 2
123+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
124+ return self.get_root_instance().wait_select_single(
125+ edge='none', active=True)
126+
127+
128+class FinalEdgeDemoOverlay(
129+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
130+
131+ @classmethod
132+ def validate_dbus_object(cls, path, state):
133+ name = introspection.get_classname_from_path(path)
134+ if name == b'EdgeDemoOverlay':
135+ if state['edge'][1] == 'none':
136+ return True
137+ return False
138+
139+ @autopilot.logging.log_action(logger.info)
140+ def tap_to_start(self):
141+ """Tap to finish the demo and start using the Ubuntu Touch."""
142+ time.sleep(1)
143+ self.pointing_device.click_object(self)
144+ self.shown.wait_for(False)
145
146=== modified file 'tests/autopilot/unity8/shell/fixture_setup.py'
147--- tests/autopilot/unity8/shell/fixture_setup.py 2014-01-23 14:40:17 +0000
148+++ tests/autopilot/unity8/shell/fixture_setup.py 2015-01-09 16:59:23 +0000
149@@ -20,6 +20,7 @@
150 """Set up and clean up fixtures for the Unity acceptance tests."""
151
152 import os
153+import subprocess
154 import sysconfig
155
156 import fixtures
157@@ -51,3 +52,40 @@
158 'Expected library path does not exists: %s.' % (
159 ld_library_path))
160 return ld_library_path
161+
162+
163+class EdgesDemo(fixtures.Fixture):
164+
165+ def __init__(self, enable):
166+ super().__init__()
167+ self.enable = enable
168+
169+ def setUp(self):
170+ super().setUp()
171+ original_state = self._is_edges_demo_enabled()
172+ if self.enable != original_state:
173+ self.addCleanup(self._set_edges_demo, original_state)
174+ self._set_edges_demo(self.enable)
175+
176+ def _is_edges_demo_enabled(self):
177+ command = [
178+ 'dbus-send', '--system', '--print-reply',
179+ '--dest=org.freedesktop.Accounts',
180+ '/org/freedesktop/Accounts/User32011',
181+ 'org.freedesktop.DBus.Properties.Get',
182+ 'string:com.canonical.unity.AccountsService',
183+ 'string:demo-edges'
184+ ]
185+ output = subprocess.check_output(command, universal_newlines=True)
186+ return True if output.count('true') else False
187+
188+ def _set_edges_demo(self, value):
189+ value_string = 'true' if value else 'false'
190+ command = [
191+ 'dbus-send', '--system', '--print-reply',
192+ '--dest=com.canonical.PropertyService',
193+ '/com/canonical/PropertyService',
194+ 'com.canonical.PropertyService.SetProperty',
195+ 'string:edge', 'boolean:{}'.format(value_string)
196+ ]
197+ subprocess.check_output(command)
198
199=== added file 'tests/autopilot/unity8/shell/tests/test_edges_demo.py'
200--- tests/autopilot/unity8/shell/tests/test_edges_demo.py 1970-01-01 00:00:00 +0000
201+++ tests/autopilot/unity8/shell/tests/test_edges_demo.py 2015-01-09 16:59:23 +0000
202@@ -0,0 +1,52 @@
203+# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
204+#
205+# Unity Autopilot Test Suite
206+# Copyright (C) 2014 Canonical
207+#
208+# This program is free software: you can redistribute it and/or modify
209+# it under the terms of the GNU General Public License as published by
210+# the Free Software Foundation, either version 3 of the License, or
211+# (at your option) any later version.
212+#
213+# This program is distributed in the hope that it will be useful,
214+# but WITHOUT ANY WARRANTY; without even the implied warranty of
215+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
216+# GNU General Public License for more details.
217+#
218+# You should have received a copy of the GNU General Public License
219+# along with this program. If not, see <http://www.gnu.org/licenses/>.
220+#
221+
222+from autopilot.matchers import Eventually
223+from testtools.matchers import Equals
224+
225+from unity8.shell import (
226+ fixture_setup,
227+ tests
228+)
229+# unused import to load the edge emulators custom proxy objects.
230+from unity8.shell.emulators import edges_demo # NOQA
231+
232+
233+class EdgesDemoTestCase(tests.UnityTestCase):
234+
235+ def setUp(self):
236+ super(EdgesDemoTestCase, self).setUp()
237+ self._qml_mock_enabled = False
238+ self._data_dirs_mock_enabled = False
239+ self._lightdm_mock_type = False
240+
241+ self.useFixture(fixture_setup.EdgesDemo(True))
242+ self.unity = self.launch_unity()
243+
244+ def test_complete_edge_demo(self):
245+ edge_demo = self.unity.select_single('EdgeDemo')
246+ self.assertThat(edge_demo.running, Eventually(Equals(True)))
247+ right_edge_overlay = self.unity.wait_select_single(
248+ edge='right', active=True)
249+ top_edge_overlay = right_edge_overlay.swipe()
250+ bottom_edge_overlay = top_edge_overlay.swipe()
251+ left_edge_overlay = bottom_edge_overlay.swipe()
252+ final_overlay = left_edge_overlay.swipe()
253+ final_overlay.tap_to_start()
254+ self.assertThat(edge_demo.running, Eventually(Equals(False)))

Subscribers

People subscribed via source and target branches