on xenial help sign in
Update autopilot
commitaf1f8ef461dddbaec6b74f3bc6f12d7f20c0b1eb authorMichael Terry <michael.terry@canonical.com> dateTue 3 Feb 2015, 10:16 (12 years ago) parent1e7f11b
4 files changed+75−162
tests/autopilot/unity8/shell/emulators/edges_demo.py−140 tests/autopilot/unity8/shell/emulators/tutorial.py+54 tests/autopilot/unity8/shell/fixture_setup.py+6−6 tests/autopilot/unity8/shell/tests/test_edges_demo.py → tests/autopilot/unity8/shell/tests/test_tutorial.py+15−16
tests/autopilot/unity8/shell/emulators/edges_demo.pydeleted−140
@@ -1,140 +0,0 @@
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−import logging
21−import time
22−
23−import ubuntuuitoolkit
24−
25−import autopilot
26−from autopilot import introspection
27−
28−
29−logger = logging.getLogger(__name__)
30−
31−
32−class RightEdgeDemoOverlay(
33− ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
34−
35− @classmethod
36− def validate_dbus_object(cls, path, state):
37− name = introspection.get_classname_from_path(path)
38− if name == b'EdgeDemoOverlay':
39− if state['edge'][1] == 'right':
40− return True
41− return False
42−
43− @autopilot.logging.log_action(logger.info)
44− def swipe(self):
45− """Swipe to the left to complete this demo step."""
46− x, y, width, height = self.globalRect
47− start_x = x + width
48− stop_x = x
49− start_y = stop_y = y + height // 2
50− self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
51− return self.get_root_instance().wait_select_single(
52− edge='top', active=True)
53−
54−
55−class TopEdgeDemoOverlay(
56− ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
57−
58− @classmethod
59− def validate_dbus_object(cls, path, state):
60− name = introspection.get_classname_from_path(path)
61− if name == b'EdgeDemoOverlay':
62− if state['edge'][1] == 'top':
63− return True
64− return False
65−
66− @autopilot.logging.log_action(logger.info)
67− def swipe(self):
68− """Swipe to the bottom to complete this demo step."""
69− x, y, width, height = self.globalRect
70− start_x = stop_x = x + width // 2
71− start_y = y
72− stop_y = y + height
73− self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
74− return self.get_root_instance().wait_select_single(
75− edge='bottom', active=True)
76−
77−
78−class BottomEdgeDemoOverlay(
79− ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
80−
81− @classmethod
82− def validate_dbus_object(cls, path, state):
83− name = introspection.get_classname_from_path(path)
84− if name == b'EdgeDemoOverlay':
85− if state['edge'][1] == 'bottom':
86− return True
87− return False
88−
89− @autopilot.logging.log_action(logger.info)
90− def swipe(self):
91− """Swipe to the top to complete this demo step."""
92− x, y, width, height = self.globalRect
93− start_x = stop_x = x + width // 2
94− start_y = y + height
95− stop_y = y
96− self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
97− return self.get_root_instance().wait_select_single(
98− edge='left', active=True)
99−
100−
101−class LeftEdgeDemoOverlay(
102− ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
103−
104− @classmethod
105− def validate_dbus_object(cls, path, state):
106− name = introspection.get_classname_from_path(path)
107− if name == b'EdgeDemoOverlay':
108− if state['edge'][1] == 'left':
109− return True
110− return False
111−
112− @autopilot.logging.log_action(logger.info)
113− def swipe(self):
114− """Swipe to the right to complete this demo step."""
115− x, y, width, height = self.globalRect
116− start_x = x
117− stop_x = x + width
118− start_y = stop_y = y + height // 2
119− self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
120− return self.get_root_instance().wait_select_single(
121− edge='none', active=True)
122−
123−
124−class FinalEdgeDemoOverlay(
125− ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
126−
127− @classmethod
128− def validate_dbus_object(cls, path, state):
129− name = introspection.get_classname_from_path(path)
130− if name == b'EdgeDemoOverlay':
131− if state['edge'][1] == 'none':
132− return True
133− return False
134−
135− @autopilot.logging.log_action(logger.info)
136− def tap_to_start(self):
137− """Tap to finish the demo and start using the Ubuntu Touch."""
138− time.sleep(1)
139− self.pointing_device.click_object(self)
140− self.shown.wait_for(False)
tests/autopilot/unity8/shell/emulators/tutorial.pynew file+54
@@ -0,0 +1,54 @@
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+import logging
21+import time
22+
23+import ubuntuuitoolkit
24+
25+import autopilot
26+from autopilot import introspection
27+
28+
29+logger = logging.getLogger(__name__)
30+
31+
32+class TutorialPage(
33+ ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
34+
35+ @classmethod
36+ def validate_dbus_object(cls, path, state):
37+ name = introspection.get_classname_from_path(path)
38+ return name == b'TutorialPage' or name == b'TutorialLeft'
39+
40+ @autopilot.logging.log_action(logger.info)
41+ def short_swipe_right(self):
42+ x, y, width, height = self.globalRect
43+ start_x = x
44+ stop_x = x + width // 3
45+ start_y = stop_y = y + height // 2
46+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
47+ self.shown.wait_for(False)
48+
49+ @autopilot.logging.log_action(logger.info)
50+ def tap(self):
51+ """Tap the tick button to complete this step."""
52+ button = self.select_single(objectName="tick")
53+ self.pointing_device.click_object(button)
54+ self.shown.wait_for(False)
tests/autopilot/unity8/shell/fixture_setup.py+6−6
@@ -54,7 +54,7 @@ class FakeScopes(fixtures.Fixture):
5454 return ld_library_path
5555
5656
57−class EdgesDemo(fixtures.Fixture):
57+class Tutorial(fixtures.Fixture):
5858
5959 def __init__(self, enable):
6060 super().__init__()
@@ -62,12 +62,12 @@ class EdgesDemo(fixtures.Fixture):
6262
6363 def setUp(self):
6464 super().setUp()
65− original_state = self._is_edges_demo_enabled()
65+ original_state = self._is_tutorial_enabled()
6666 if self.enable != original_state:
67− self.addCleanup(self._set_edges_demo, original_state)
68− self._set_edges_demo(self.enable)
67+ self.addCleanup(self._set_tutorial, original_state)
68+ self._set_tutorial(self.enable)
6969
70− def _is_edges_demo_enabled(self):
70+ def _is_tutorial_enabled(self):
7171 command = [
7272 'dbus-send', '--system', '--print-reply',
7373 '--dest=org.freedesktop.Accounts',
@@ -79,7 +79,7 @@ class EdgesDemo(fixtures.Fixture):
7979 output = subprocess.check_output(command, universal_newlines=True)
8080 return True if output.count('true') else False
8181
82− def _set_edges_demo(self, value):
82+ def _set_tutorial(self, value):
8383 value_string = 'true' if value else 'false'
8484 command = [
8585 'dbus-send', '--system', '--print-reply',
tests/autopilot/unity8/shell/tests/test_edges_demo.py → tests/autopilot/unity8/shell/tests/test_tutorial.pyrenamed+15−16
@@ -24,29 +24,28 @@ from unity8.shell import (
2424 fixture_setup,
2525 tests
2626)
27−# unused import to load the edge emulators custom proxy objects.
28−from unity8.shell.emulators import edges_demo # NOQA
27+# unused import to load the tutorial emulators custom proxy objects.
28+from unity8.shell.emulators import tutorial # NOQA
2929
3030
31−class EdgesDemoTestCase(tests.UnityTestCase):
31+class TutorialTestCase(tests.UnityTestCase):
3232
3333 def setUp(self):
34− super(EdgesDemoTestCase, self).setUp()
34+ super(TutorialTestCase, self).setUp()
3535 self._qml_mock_enabled = False
3636 self._data_dirs_mock_enabled = False
3737 self._lightdm_mock_type = False
3838
39− self.useFixture(fixture_setup.EdgesDemo(True))
39+ self.useFixture(fixture_setup.Tutorial(True))
4040 self.unity = self.launch_unity()
4141
42− def test_complete_edge_demo(self):
43− edge_demo = self.unity.select_single('EdgeDemo')
44− self.assertThat(edge_demo.running, Eventually(Equals(True)))
45− right_edge_overlay = self.unity.wait_select_single(
46− edge='right', active=True)
47− top_edge_overlay = right_edge_overlay.swipe()
48− bottom_edge_overlay = top_edge_overlay.swipe()
49− left_edge_overlay = bottom_edge_overlay.swipe()
50− final_overlay = left_edge_overlay.swipe()
51− final_overlay.tap_to_start()
52− self.assertThat(edge_demo.running, Eventually(Equals(False)))
42+ def test_complete_tutorial(self):
43+ greeter = self.main_window.get_greeter()
44+ tutorial = self.unity.select_single('Tutorial')
45+ self.assertThat(tutorial.running, Eventually(Equals(True)))
46+ greeter.swipe()
47+ page = self.unity.wait_select_single(objectName='tutorialLeft')
48+ page.short_swipe_right()
49+ page = self.unity.wait_select_single(objectName='tutorialLeftFinish')
50+ page.tap()
51+ self.assertThat(tutorial.running, Eventually(Equals(False)))