on xenial help sign in
Reorganized the python test helper modules.

Deprecated the unity8.shell.emulators namespace. Fixes: #1306340 Approved by: PS Jenkins bot, Michael Zanetti, Brendan Donegan, Sergio Cazzolato

commit5201c80aca3b1170dedcb0e81fcbc0d9a59f24f8 authorLeo Arias <leo.arias@canonical.com> dateThu 2 Jul 2015, 16:09 (11 years ago) parent8eccae4f4e4fcc
20 files changed+310−323
tests/autopilot/unity8/__init__.py+6−2 tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+4−2 tests/autopilot/unity8/shell/emulators/dash.py → tests/autopilot/unity8/dash.py+7−7 tests/autopilot/unity8/fixture_setup.py+6−16 tests/autopilot/unity8/greeter/__init__.py+42−1 tests/autopilot/unity8/greeter/tests/__init__.py+2−2 tests/autopilot/unity8/shell/emulators/launcher.py → tests/autopilot/unity8/launcher.py+3−3 tests/autopilot/unity8/process_helpers.py+2−1 tests/autopilot/unity8/sensors.py+1−1 tests/autopilot/unity8/shell/__init__.py+181−2 tests/autopilot/unity8/shell/emulators/create_interactive_notification.py → tests/autopilot/unity8/shell/create_interactive_notification.py tests/autopilot/unity8/shell/emulators/__init__.py → tests/autopilot/unity8/shell/emulators.py+33−3 tests/autopilot/unity8/shell/emulators/greeter.py−60 tests/autopilot/unity8/shell/emulators/main_window.py−199 tests/autopilot/unity8/shell/tests/__init__.py+3−3 tests/autopilot/unity8/shell/tests/test_emulators.py → tests/autopilot/unity8/shell/tests/test_helpers.py+15−16 tests/autopilot/unity8/shell/tests/test_notifications.py+1−1 tests/autopilot/unity8/shell/tests/test_rotation.py+2−2 tests/autopilot/unity8/shell/tests/test_tutorial.py+2−2 tests/autopilot/unity8/shell/emulators/tutorial.py → tests/autopilot/unity8/tutorial.py
tests/autopilot/unity8/__init__.py+6−2
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2012, 2013, 2014 Canonical
4+# Copyright (C) 2012, 2013, 2014, 2015 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -17,13 +17,17 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20−"""unity autopilot tests and emulators - top level package."""
20+"""unity autopilot tests and helpers - top level package."""
2121import os
2222import os.path
2323import subprocess
2424import sysconfig
2525
2626
27+class UnityException(Exception):
28+ """Exception raised when there is an error with the Unity test helpers."""
29+
30+
2731def running_installed_tests():
2832 binary_path = get_binary_path()
2933 return binary_path.startswith('/usr')
tests/autopilot/unity8/application_lifecycle/tests/test_application_lifecycle.py+4−2
@@ -92,14 +92,16 @@ class ApplicationLifecycleTests(tests.ApplicationLifeCycleTestCase):
9292 process_helpers.lock_unity()
9393
9494 # FIXME - this is because the device greeter uses a password.
95− # Need to be able to selectively enable mocks so that we can use the fake greeter.
95+ # Need to be able to selectively enable mocks so that we can use the
96+ # fake greeter.
9697 def unlock_thread_worker(greeter):
9798 greeter.wait_swiped_away()
9899 process_helpers.unlock_unity()
99100 greeter.created.wait_for(False)
100101
101102 greeter = self.main_window.get_greeter()
102− unlock_thread = threading.Thread(target=unlock_thread_worker, args=(greeter,))
103+ unlock_thread = threading.Thread(
104+ target=unlock_thread_worker, args=(greeter,))
103105 unlock_thread.start()
104106 application_name = self.launch_fake_app()
105107 unlock_thread.join(10)
tests/autopilot/unity8/shell/emulators/dash.py → tests/autopilot/unity8/dash.pyrenamed+7−7
@@ -23,7 +23,7 @@ import ubuntuuitoolkit
2323from autopilot import logging as autopilot_logging
2424from autopilot.introspection import dbus
2525
26−from unity8.shell import emulators
26+import unity8
2727
2828
2929logger = logging.getLogger(__name__)
@@ -41,7 +41,7 @@ class DashApp():
4141
4242
4343class Dash(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
44− """An emulator that understands the Dash."""
44+ """A helper that understands the Dash."""
4545
4646 def __init__(self, *args):
4747 super().__init__(*args)
@@ -93,10 +93,10 @@ class Dash(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
9393 for l in aux.get_children_by_type('QQuickLoader'):
9494 if (l.scopeId == scope_id):
9595 return l
96− raise emulators.UnityEmulatorException(
96+ raise unity8.UnityException(
9797 'No scope found with id {0}'.format(scope_id))
9898 except dbus.StateNotFoundError:
99− raise emulators.UnityEmulatorException(
99+ raise unity8.UnityException(
100100 'No scope found with id {0}'.format(scope_id))
101101
102102 def _get_scope_from_loader(self, loader):
@@ -121,7 +121,7 @@ class Dash(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
121121 elif scope_loader.globalRect.x > current_scope_loader.globalRect.x:
122122 return self._scroll_to_right_scope
123123 else:
124− raise emulators.UnityEmulatorException('The scope is already open')
124+ raise unity8.UnityException('The scope is already open')
125125
126126 @autopilot_logging.log_action(logger.info)
127127 def _scroll_to_left_scope(self):
@@ -190,7 +190,7 @@ class ListViewWithPageHeader(ubuntuuitoolkit.QQuickFlickable):
190190
191191
192192class GenericScopeView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
193− """Autopilot emulator for generic scopes."""
193+ """Autopilot helper for generic scopes."""
194194
195195 @autopilot_logging.log_action(logger.info)
196196 def open_preview(self, category, app_name, press_duration=0.10):
@@ -237,7 +237,7 @@ class GenericScopeView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
237237 'DashCategoryBase',
238238 objectName='dashCategory{}'.format(category))
239239 except dbus.StateNotFoundError:
240− raise emulators.UnityEmulatorException(
240+ raise unity8.UnityException(
241241 'No category found with name {}'.format(category))
242242
243243 def get_applications(self, category):
tests/autopilot/unity8/fixture_setup.py+6−16
@@ -31,21 +31,14 @@ from ubuntuuitoolkit import fixture_setup
3131
3232from unity8 import (
3333 get_binary_path,
34+ get_mocks_library_path,
35+ get_default_extra_mock_libraries,
36+ get_data_dirs,
3437 sensors,
38+ shell,
3539 process_helpers
3640)
3741
38−from unity8.shell import emulators
39−
40−from unity8.shell.emulators import (
41− main_window as main_window_emulator
42−)
43−
44−from unity8 import (
45− get_mocks_library_path,
46− get_default_extra_mock_libraries,
47− get_data_dirs
48−)
4942
5043logger = logging.getLogger(__name__)
5144
@@ -140,8 +133,7 @@ class LaunchUnityWithFakeSensors(fixtures.Fixture):
140133 args = [binary_arg] + env_args
141134 self.unity_proxy = process_helpers.restart_unity_with_testability(
142135 *args)
143− self.main_win = self.unity_proxy.select_single(
144− main_window_emulator.QQuickView)
136+ self.main_win = self.unity_proxy.select_single(shell.QQuickView)
145137
146138 def _create_sensors(self):
147139 # Wait for unity to start running.
@@ -150,7 +142,7 @@ class LaunchUnityWithFakeSensors(fixtures.Fixture):
150142
151143 # Wait for the sensors fifo file to be created.
152144 fifo_path = '/tmp/sensor-fifo-{0}'.format(
153− process_helpers.get_unity_pid())
145+ process_helpers._get_unity_pid())
154146 Eventually(Equals(True)).match(
155147 lambda: os.path.exists(fifo_path))
156148
@@ -159,8 +151,6 @@ class LaunchUnityWithFakeSensors(fixtures.Fixture):
159151 fifo.write('create light 0 10 1\n')
160152 fifo.write('create proximity\n')
161153
162−logger = logging.getLogger(__name__)
163−
164154
165155class RestartUnityWithTestability(fixtures.Fixture):
166156
tests/autopilot/unity8/greeter/__init__.py+42−1
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2015 Canonical
4+# Copyright (C) 2012, 2013, 2014, 2015 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -19,8 +19,10 @@
1919
2020import dbus
2121
22+import ubuntuuitoolkit
2223from autopilot.matchers import Eventually
2324from testtools.matchers import Equals
25+from autopilot.utilities import sleep
2426
2527
2628def hide_greeter_with_dbus():
@@ -50,3 +52,42 @@ def _is_greeter_active():
5052 return dbus_proxy.Get('com.canonical.UnityGreeter', 'IsActive')
5153 except:
5254 return False
55+
56+
57+class Greeter(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
58+ """A helper that understands the greeter screen."""
59+
60+ def wait_swiped_away(self):
61+ # We have to be careful here, because coverPage can go away at any time
62+ # if there isn't a lockscreen behind it (it hides completely, then
63+ # the greeter disposes it). But if there *is* a lockscreen, then we
64+ # need a different check, by looking at its showProgress. So make our
65+ # own wait_for loop and check both possibilities.
66+ for i in range(10):
67+ if not self.required:
68+ return
69+ coverPage = self.select_single(objectName='coverPage')
70+ if coverPage.showProgress == 0:
71+ return
72+ sleep(1)
73+
74+ raise AssertionError("Greeter cover page still up after 10s")
75+
76+ def swipe(self):
77+ """Swipe the greeter screen away."""
78+ self.waiting.wait_for(False)
79+ coverPage = self.select_single(objectName='coverPage')
80+ coverPage.showProgress.wait_for(1)
81+
82+ rect = self.globalRect
83+ start_x = rect[0] + rect[2] - 3
84+ start_y = int(rect[1] + rect[3] / 2)
85+ stop_x = int(rect[0] + rect[2] * 0.2)
86+ stop_y = start_y
87+ self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
88+
89+ self.wait_swiped_away()
90+
91+ def get_prompt(self):
92+ return self.select_single(
93+ ubuntuuitoolkit.TextField, objectName='passwordInput')
tests/autopilot/unity8/greeter/tests/__init__.py+2−2
@@ -17,12 +17,12 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20−from unity8.shell.emulators import main_window as main_window_emulator
20+from unity8 import shell
2121from unity8.shell.tests import UnityTestCase
2222
2323
2424class GreeterTestCase(UnityTestCase):
2525 def get_shell(self, unity_proxy):
2626 main_window = (
27− unity_proxy.select_single(main_window_emulator.QQuickView))
27+ unity_proxy.select_single(shell.QQuickView))
2828 return main_window.select_single('Shell')
tests/autopilot/unity8/shell/emulators/launcher.py → tests/autopilot/unity8/launcher.pyrenamed+3−3
@@ -22,7 +22,7 @@ import logging
2222import autopilot.logging
2323import ubuntuuitoolkit
2424
25−from unity8.shell import emulators
25+import unity8
2626
2727
2828logger = logging.getLogger(__name__)
@@ -30,7 +30,7 @@ logger = logging.getLogger(__name__)
3030
3131class Launcher(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
3232
33− """An emulator that understands the Launcher."""
33+ """A helper that understands the Launcher."""
3434
3535 @autopilot.logging.log_action(logger.debug)
3636 def show(self):
@@ -57,7 +57,7 @@ class Launcher(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
5757 'QQuickImage', objectName='dashItem')
5858 self.pointing_device.click_object(dash_icon)
5959 else:
60− raise emulators.UnityEmulatorException('The launcher is closed.')
60+ raise unity8.UnityException('The launcher is closed.')
6161
6262 @autopilot.logging.log_action(logger.debug)
6363 def click_application_launcher_icon(self, application_name):
tests/autopilot/unity8/process_helpers.py+2−1
@@ -25,6 +25,7 @@ from autopilot.introspection import get_proxy_object_for_existing_process
2525
2626from unity8 import greeter
2727
28+
2829logger = logging.getLogger(__name__)
2930
3031
@@ -175,7 +176,7 @@ def _get_unity_status():
175176 raise CannotAccessUnity(str(error))
176177
177178
178−def get_unity_pid():
179+def _get_unity_pid():
179180 try:
180181 return get_job_pid('unity8')
181182 except JobError as error:
tests/autopilot/unity8/sensors.py+1−1
@@ -25,7 +25,7 @@ from unity8 import process_helpers
2525class FakePlatformSensors:
2626
2727 def __init__(self, pid=None):
28− self.pid = pid or process_helpers.get_unity_pid()
28+ self.pid = pid or process_helpers._get_unity_pid()
2929
3030 def set_orientation(self, action):
3131 if action == 'top_up':
tests/autopilot/unity8/shell/__init__.py+181−2
@@ -17,12 +17,21 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20−"""unity shell autopilot tests and emulators - sub level package."""
20+"""unity shell autopilot tests and helpers - sub level package."""
2121
22+import logging
2223from functools import wraps
24+
25+import ubuntuuitoolkit
26+from autopilot import logging as autopilot_logging
27+from autopilot import input
2328from gi.repository import Notify
2429
25−import logging
30+from unity8 import (
31+ greeter,
32+ launcher as launcher_helpers
33+)
34+
2635
2736logger = logging.getLogger(__name__)
2837
@@ -82,3 +91,173 @@ def _get_urgency(urgency):
8291 'NORMAL': Notify.Urgency.NORMAL,
8392 'CRITICAL': Notify.Urgency.CRITICAL}
8493 return _urgency_enums.get(urgency.upper())
94+
95+
96+class QQuickView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
97+ """An helper class that makes it easy to interact with the shell"""
98+
99+ def get_greeter(self):
100+ return self.select_single(greeter.Greeter)
101+
102+ def get_login_loader(self):
103+ return self.select_single("QQuickLoader", objectName="loginLoader")
104+
105+ def get_login_list(self):
106+ return self.select_single("LoginList")
107+
108+ def get_bottombar(self):
109+ return self.select_single("Bottombar")
110+
111+ def get_pinPadLoader(self):
112+ return self.select_single(
113+ "QQuickLoader",
114+ objectName="pinPadLoader"
115+ )
116+
117+ def get_lockscreen(self):
118+ return self.select_single("Lockscreen")
119+
120+ def get_pinentryField(self):
121+ return self.select_single(objectName="pinentryField")
122+
123+ def _get_indicator_panel_item(self, indicator_name):
124+ return self.select_single(
125+ 'IndicatorItem',
126+ objectName=indicator_name+'-panelItem'
127+ )
128+
129+ def _get_indicator_page(self, indicator_name):
130+ return self.select_single(
131+ 'IndicatorPage',
132+ objectName=indicator_name+'-page'
133+ )
134+
135+ @autopilot_logging.log_action(logger.info)
136+ def open_indicator_page(self, indicator_name):
137+ """Swipe to open the indicator, wait until it's open.
138+
139+ :returns: The indicator page.
140+ """
141+ widget = self._get_indicator_panel_item(indicator_name)
142+ start_x, start_y = input.get_center_point(widget)
143+ end_x = start_x
144+ end_y = self.height
145+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
146+ self.wait_select_single('IndicatorsMenu', fullyOpened=True)
147+ return self._get_indicator_page(indicator_name)
148+
149+ @autopilot_logging.log_action(logger.info)
150+ def close_indicator_page(self):
151+ """Swipe to close the opened indicator, wait until it's closed."""
152+ indicators_menu = self.wait_select_single('IndicatorsMenu')
153+ end_x, end_y = input.get_center_point(indicators_menu)
154+ start_x = end_x
155+ start_y = self.height
156+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
157+ indicators_menu.fullyClosed.wait_for(True)
158+
159+ @autopilot_logging.log_action(logger.info)
160+ def show_dash_swiping(self):
161+ """Show the dash swiping from the left."""
162+ x, y, width, height = self._get_shell().globalRect
163+ start_x = x
164+ end_x = x + width
165+ start_y = end_y = y + height // 2
166+
167+ self.pointing_device.drag(start_x, start_y, end_x, end_y)
168+ self.get_current_focused_app_id().wait_for('unity8-dash')
169+
170+ def _get_shell(self):
171+ return self.select_single('Shell')
172+
173+ def get_current_focused_app_id(self):
174+ """Return the id of the focused application."""
175+ return self._get_shell().focusedApplicationId
176+
177+ @autopilot_logging.log_action(logger.info)
178+ def show_dash_from_launcher(self):
179+ """Open the dash clicking the dash icon on the launcher."""
180+ launcher = self.open_launcher()
181+ launcher.click_dash_icon()
182+ self.get_current_focused_app_id().wait_for('unity8-dash')
183+ launcher.shown.wait_for(False)
184+
185+ @autopilot_logging.log_action(logger.info)
186+ def open_launcher(self):
187+ launcher = self._get_launcher()
188+ launcher.show()
189+ return launcher
190+
191+ def _get_launcher(self):
192+ return self.select_single(launcher_helpers.Launcher)
193+
194+ def is_launcher_open(self):
195+ return self._get_launcher().shown
196+
197+ @autopilot_logging.log_action(logger.info)
198+ def launch_application(self, application_name):
199+ """Launch an application.
200+
201+ :parameter application_name: The name of the application to launch.
202+
203+ """
204+ launcher = self.open_launcher()
205+ launcher.click_application_launcher_icon(application_name)
206+ self.get_current_focused_app_id().wait_for(application_name)
207+ launcher.shown.wait_for(False)
208+
209+ def enter_pin_code(self, code):
210+ """Enter code 'code' into the single-pin lightdm pincode entry screen.
211+
212+ :param code: must be a string of numeric characters.
213+ :raises: TypeError if code is not a string.
214+ :raises: ValueError if code contains non-numeric characters.
215+
216+ """
217+ if not isinstance(code, str):
218+ raise TypeError(
219+ "'code' parameter must be a string, not %r."
220+ % type(code)
221+ )
222+ for num in code:
223+ if not num.isdigit():
224+ raise ValueError(
225+ "'code' parameter contains non-numeric characters."
226+ )
227+ self.pointing_device.click_object(
228+ self._get_pinpad_button(int(num)))
229+
230+ def _get_pinpad_button(self, button_id):
231+ return self.select_single(
232+ 'PinPadButton',
233+ objectName='pinPadButton{}'.format(button_id)
234+ )
235+
236+ def get_shell_orientation_angle(self):
237+ return self._get_shell().orientationAngle
238+
239+ def get_shell_orientation(self):
240+ return self._get_shell().orientation
241+
242+ def get_shell_primary_orientation(self):
243+ return self._get_shell().primaryOrientation
244+
245+ def get_shell_native_orientation(self):
246+ return self._get_shell().nativeOrientation
247+
248+ @autopilot_logging.log_action(logger.info)
249+ def wait_for_notification(self):
250+ """Wait for a notification dialog to appear.
251+
252+ :return: An object for the notification dialog data.
253+ :raise StateNotFoundError: if the timeout expires when the
254+ notification has not appeared.
255+
256+ """
257+ notify_list = self.select_single('Notifications',
258+ objectName='notificationList')
259+ visible_notification = notify_list.wait_select_single('Notification',
260+ visible=True)
261+ return {'summary': visible_notification.summary,
262+ 'body': visible_notification.body,
263+ 'iconSource': visible_notification.iconSource}
tests/autopilot/unity8/shell/emulators/create_interactive_notification.py → tests/autopilot/unity8/shell/create_interactive_notification.pyrenamed

The content is the same.

tests/autopilot/unity8/shell/emulators/__init__.py → tests/autopilot/unity8/shell/emulators.pyrenamed+33−3
@@ -1,7 +1,7 @@
11# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
22#
33# Unity Autopilot Test Suite
4−# Copyright (C) 2012, 2013, 2014, 2015 Canonical
4+# Copyright (C) 2015 Canonical
55#
66# This program is free software: you can redistribute it and/or modify
77# it under the terms of the GNU General Public License as published by
@@ -17,6 +17,36 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20+"""Emulators was the old name for the custom proxy objects."""
2021
21−class UnityEmulatorException(Exception):
22− """Exception raised when there is an error with the Unity emulators."""
22+import logging
23+
24+
25+logger = logging.getLogger(__name__)
26+
27+
28+logger.warning(
29+ 'The unity8.shell.emulators module is deprecated. Import the autopilot '
30+ 'helpers from the top-level unity8 module.')
31+
32+
33+__all__ = [
34+ 'create_interactive_notification',
35+ 'dash',
36+ 'greeter',
37+ 'launcher',
38+ 'main_window',
39+ 'tutorial',
40+ 'UnityEmulatorException',
41+]
42+
43+
44+from unity8 import (
45+ greeter,
46+ dash,
47+ launcher,
48+ shell as main_window,
49+ tutorial,
50+ UnityException as UnityEmulatorException
51+)
52+from unity8.shell import create_interactive_notification
tests/autopilot/unity8/shell/emulators/greeter.pydeleted−60
@@ -1,60 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−#
3−# Unity Autopilot Test Suite
4−# Copyright (C) 2012, 2013, 2014, 2015 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 ubuntuuitoolkit
21−from autopilot.utilities import sleep
22−
23−
24−class Greeter(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
25− """An emulator that understands the greeter screen."""
26−
27− def wait_swiped_away(self):
28− # We have to be careful here, because coverPage can go away at any time
29− # if there isn't a lockscreen behind it (it hides completely, then
30− # the greeter disposes it). But if there *is* a lockscreen, then we
31− # need a different check, by looking at its showProgress. So make our
32− # own wait_for loop and check both possibilities.
33− for i in range(10):
34− if not self.required:
35− return
36− coverPage = self.select_single(objectName='coverPage')
37− if coverPage.showProgress == 0:
38− return
39− sleep(1)
40−
41− raise AssertionError("Greeter cover page still up after 10s")
42−
43− def swipe(self):
44− """Swipe the greeter screen away."""
45− self.waiting.wait_for(False)
46− coverPage = self.select_single(objectName='coverPage')
47− coverPage.showProgress.wait_for(1)
48−
49− rect = self.globalRect
50− start_x = rect[0] + rect[2] - 3
51− start_y = int(rect[1] + rect[3] / 2)
52− stop_x = int(rect[0] + rect[2] * 0.2)
53− stop_y = start_y
54− self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
55−
56− self.wait_swiped_away()
57−
58− def get_prompt(self):
59− return self.select_single(
60− ubuntuuitoolkit.TextField, objectName='passwordInput')
tests/autopilot/unity8/shell/emulators/main_window.pydeleted−199
@@ -1,199 +0,0 @@
1−# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2−#
3−# Unity Autopilot Test Suite
4−# Copyright (C) 2012, 2013, 2014, 2015 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−
22−import ubuntuuitoolkit
23−from autopilot import logging as autopilot_logging
24−from autopilot import input
25−
26−from unity8.shell.emulators.greeter import Greeter
27−from unity8.shell.emulators.launcher import Launcher
28−
29−logger = logging.getLogger(__name__)
30−
31−
32−class QQuickView(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
33− """An emulator class that makes it easy to interact with the shell"""
34−
35− def get_greeter(self):
36− return self.select_single(Greeter)
37−
38− def get_login_loader(self):
39− return self.select_single("QQuickLoader", objectName="loginLoader")
40−
41− def get_login_list(self):
42− return self.select_single("LoginList")
43−
44− def get_bottombar(self):
45− return self.select_single("Bottombar")
46−
47− def get_pinPadLoader(self):
48− return self.select_single(
49− "QQuickLoader",
50− objectName="pinPadLoader"
51− )
52−
53− def get_lockscreen(self):
54− return self.select_single("Lockscreen")
55−
56− def get_pinentryField(self):
57− return self.select_single(objectName="pinentryField")
58−
59− def _get_indicator_panel_item(self, indicator_name):
60− return self.select_single(
61− 'IndicatorItem',
62− objectName=indicator_name+'-panelItem'
63− )
64−
65− def _get_indicator_page(self, indicator_name):
66− return self.select_single(
67− 'IndicatorPage',
68− objectName=indicator_name+'-page'
69− )
70−
71− @autopilot_logging.log_action(logger.info)
72− def open_indicator_page(self, indicator_name):
73− """Swipe to open the indicator, wait until it's open.
74−
75− :returns: The indicator page.
76− """
77− widget = self._get_indicator_panel_item(indicator_name)
78− start_x, start_y = input.get_center_point(widget)
79− end_x = start_x
80− end_y = self.height
81− self.pointing_device.drag(start_x, start_y, end_x, end_y)
82− self.wait_select_single('IndicatorsMenu', fullyOpened=True)
83− return self._get_indicator_page(indicator_name)
84−
85− @autopilot_logging.log_action(logger.info)
86− def close_indicator_page(self):
87− """Swipe to close the opened indicator, wait until it's closed."""
88− indicators_menu = self.wait_select_single('IndicatorsMenu')
89− end_x, end_y = input.get_center_point(indicators_menu)
90− start_x = end_x
91− start_y = self.height
92− self.pointing_device.drag(start_x, start_y, end_x, end_y)
93− indicators_menu.fullyClosed.wait_for(True)
94−
95− @autopilot_logging.log_action(logger.info)
96− def show_dash_swiping(self):
97− """Show the dash swiping from the left."""
98− x, y, width, height = self._get_shell().globalRect
99− start_x = x
100− end_x = x + width
101− start_y = end_y = y + height // 2
102−
103− self.pointing_device.drag(start_x, start_y, end_x, end_y)
104− self.get_current_focused_app_id().wait_for('unity8-dash')
105−
106− def _get_shell(self):
107− return self.select_single('Shell')
108−
109− def get_current_focused_app_id(self):
110− """Return the id of the focused application."""
111− return self._get_shell().focusedApplicationId
112−
113− @autopilot_logging.log_action(logger.info)
114− def show_dash_from_launcher(self):
115− """Open the dash clicking the dash icon on the launcher."""
116− launcher = self.open_launcher()
117− launcher.click_dash_icon()
118− self.get_current_focused_app_id().wait_for('unity8-dash')
119− launcher.shown.wait_for(False)
120−
121− @autopilot_logging.log_action(logger.info)
122− def open_launcher(self):
123− launcher = self._get_launcher()
124− launcher.show()
125− return launcher
126−
127− def _get_launcher(self):
128− return self.select_single(Launcher)
129−
130− def is_launcher_open(self):
131− return self._get_launcher().shown
132−
133− @autopilot_logging.log_action(logger.info)
134− def launch_application(self, application_name):
135− """Launch an application.
136−
137− :parameter application_name: The name of the application to launch.
138−
139− """
140− launcher = self.open_launcher()
141− launcher.click_application_launcher_icon(application_name)
142− self.get_current_focused_app_id().wait_for(application_name)
143− launcher.shown.wait_for(False)
144−
145− def enter_pin_code(self, code):
146− """Enter code 'code' into the single-pin lightdm pincode entry screen.
147−
148− :param code: must be a string of numeric characters.
149− :raises: TypeError if code is not a string.
150− :raises: ValueError if code contains non-numeric characters.
151−
152− """
153− if not isinstance(code, str):
154− raise TypeError(
155− "'code' parameter must be a string, not %r."
156− % type(code)
157− )
158− for num in code:
159− if not num.isdigit():
160− raise ValueError(
161− "'code' parameter contains non-numeric characters."
162− )
163− self.pointing_device.click_object(
164− self._get_pinpad_button(int(num)))
165−
166− def _get_pinpad_button(self, button_id):
167− return self.select_single(
168− 'PinPadButton',
169− objectName='pinPadButton{}'.format(button_id)
170− )
171−
172− def get_shell_orientation_angle(self):
173− return self._get_shell().orientationAngle
174−
175− def get_shell_orientation(self):
176− return self._get_shell().orientation
177−
178− def get_shell_primary_orientation(self):
179− return self._get_shell().primaryOrientation
180−
181− def get_shell_native_orientation(self):
182− return self._get_shell().nativeOrientation
183−
184− @autopilot_logging.log_action(logger.info)
185− def wait_for_notification(self):
186− """Wait for a notification dialog to appear.
187−
188− :return: An object for the notification dialog data.
189− :raise StateNotFoundError: if the timeout expires when the
190− notification has not appeared.
191−
192− """
193− notify_list = self.select_single('Notifications',
194− objectName='notificationList')
195− visible_notification = notify_list.wait_select_single('Notification',
196− visible=True)
197− return {'summary': visible_notification.summary,
198− 'body': visible_notification.body,
199− 'iconSource': visible_notification.iconSource}
tests/autopilot/unity8/shell/tests/__init__.py+3−3
@@ -51,9 +51,9 @@ from unity8 import (
5151 fixture_setup,
5252 process_helpers
5353)
54−from unity8.shell.emulators import (
54+from unity8 import (
5555 dash as dash_helpers,
56− main_window as main_window_emulator,
56+ shell
5757)
5858
5959
@@ -297,7 +297,7 @@ class UnityTestCase(AutopilotTestCase):
297297
298298 @property
299299 def main_window(self):
300− return self._proxy.select_single(main_window_emulator.QQuickView)
300+ return self._proxy.select_single(shell.QQuickView)
301301
302302
303303class DashBaseTestCase(AutopilotTestCase):
tests/autopilot/unity8/shell/tests/test_emulators.py → tests/autopilot/unity8/shell/tests/test_helpers.pyrenamed+15−16
@@ -17,13 +17,13 @@
1717# along with this program. If not, see <http://www.gnu.org/licenses/>.
1818#
1919
20−"""Tests for the Dash autopilot emulators.
20+"""Tests for the Dash autopilot custom proxy objects.
2121
22−The autopilot emulators are helpers for tests that check a user journey that
23−involves the dash. The code for some of those tests will not be inside this
24−branch, but in projects that depend on unity or that test the whole system
25−integration. So, we need to test the helpers in order to make sure that we
26−don't break them for those external projects.
22+The autopilot custom proxy objects are helpers for tests that check a user
23+journey that involves the dash. The code for some of those tests will not be
24+inside this branch, but in projects that depend on unity or that test the
25+whole system integration. So, we need to test the helpers in order to make
26+sure that we don't break them for those external projects.
2727
2828"""
2929
@@ -31,8 +31,7 @@ from ubuntuuitoolkit import ubuntu_scenarios
3131
3232from unity8 import process_helpers
3333from unity8.shell import fixture_setup, tests
34−from unity8.shell.emulators import dash as dash_emulators
35−from unity8.shell.emulators.dash import ListViewWithPageHeader
34+from unity8 import dash as dash_helpers
3635
3736
3837class MainWindowTestCase(tests.UnityTestCase):
@@ -45,7 +44,7 @@ class MainWindowTestCase(tests.UnityTestCase):
4544 process_helpers.unlock_unity()
4645
4746
48−class DashEmulatorTestCase(tests.DashBaseTestCase):
47+class DashHelperTestCase(tests.DashBaseTestCase):
4948
5049 def test_search(self):
5150 self.dash.enter_search_query('Test')
@@ -98,16 +97,16 @@ class DashEmulatorTestCase(tests.DashBaseTestCase):
9897 scope_id = 'musicaggregator'
9998 scope = self.dash.open_scope(scope_id)
10099 self._assert_scope_is_opened(scope, scope_id)
101− self.assertIsInstance(scope, dash_emulators.GenericScopeView)
100+ self.assertIsInstance(scope, dash_helpers.GenericScopeView)
102101
103102 def test_open_applications_scope(self):
104103 scope_id = 'clickscope'
105104 scope = self.dash.open_scope(scope_id)
106105 self._assert_scope_is_opened(scope, scope_id)
107− self.assertIsInstance(scope, dash_emulators.GenericScopeView)
106+ self.assertIsInstance(scope, dash_helpers.GenericScopeView)
108107
109108
110−class GenericScopeViewEmulatorTestCase(tests.DashBaseTestCase):
109+class GenericScopeViewHelperTestCase(tests.DashBaseTestCase):
111110
112111 def setUp(self):
113112 # Set up the fake scopes before launching unity.
@@ -117,17 +116,17 @@ class GenericScopeViewEmulatorTestCase(tests.DashBaseTestCase):
117116
118117 def test_open_preview(self):
119118 preview = self.generic_scope.open_preview('0', 'Title.0.0')
120− self.assertIsInstance(preview, dash_emulators.Preview)
119+ self.assertIsInstance(preview, dash_helpers.Preview)
121120 self.assertTrue(preview.isCurrent)
122121
123122 def test_open_preview_of_non_visible_item(self):
124123 """Open an item that requires swiping to make it visible."""
125124 preview = self.generic_scope.open_preview('2', 'Title.2.0')
126− self.assertIsInstance(preview, dash_emulators.Preview)
125+ self.assertIsInstance(preview, dash_helpers.Preview)
127126 self.assertTrue(preview.isCurrent)
128127
129128
130−class DashAppsEmulatorTestCase(tests.DashBaseTestCase):
129+class DashAppsHelperTestCase(tests.DashBaseTestCase):
131130
132131 available_applications = [
133132 'Title.2.0', 'Title.2.1', 'Title.2.2', 'Title.2.3', 'Title.2.4',
@@ -145,7 +144,7 @@ class DashAppsEmulatorTestCase(tests.DashBaseTestCase):
145144 category_element = self.applications_scope._get_category_element(
146145 category)
147146 list_view = self.dash.get_scope('clickscope')\
148− .select_single(ListViewWithPageHeader)
147+ .select_single(dash_helpers.ListViewWithPageHeader)
149148 expected_apps_count = self._get_number_of_application_slots(category)
150149 expected_applications = self.available_applications[
151150 :expected_apps_count]
tests/autopilot/unity8/shell/tests/test_notifications.py+1−1
@@ -362,7 +362,7 @@ class InteractiveNotificationBase(NotificationsBase):
362362 """Returns the path to the interactive notification
363363 creation script.
364364 """
365− file_path = "../../emulators/create_interactive_notification.py"
365+ file_path = "../../create_interactive_notification.py"
366366
367367 the_path = os.path.abspath(
368368 os.path.join(__file__, file_path))
tests/autopilot/unity8/shell/tests/test_rotation.py+2−2
@@ -58,7 +58,7 @@ class TestFakeSensor(RotationBase):
5858 def test_fake_sensor(self):
5959 unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
6060 self.useFixture(unity_with_sensors)
61− process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
61+ process_helpers.unlock_unity()
6262 fake_sensors = unity_with_sensors.fake_sensors
6363 o_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
6464
@@ -84,7 +84,7 @@ class TestRotationWithApp(RotationBase):
8484
8585 unity_with_sensors = fixture_setup.LaunchUnityWithFakeSensors()
8686 self.useFixture(unity_with_sensors)
87− process_helpers.unlock_unity(unity_with_sensors.unity_proxy)
87+ process_helpers.unlock_unity()
8888 fake_sensors = unity_with_sensors.fake_sensors
8989 o_proxy = unity_with_sensors.main_win.select_single('OrientedShell')
9090 self.shell_proxy = unity_with_sensors.main_win.select_single('Shell')
tests/autopilot/unity8/shell/tests/test_tutorial.py+2−2
@@ -24,8 +24,8 @@ from unity8.shell import (
2424 fixture_setup,
2525 tests
2626)
27−# unused import to load the tutorial emulators custom proxy objects.
28−from unity8.shell.emulators import tutorial as tutorial_emulator # NOQA
27+# unused import to load the tutorial helpers custom proxy objects.
28+from unity8 import tutorial as tutorial_helpers # NOQA
2929
3030
3131class TutorialTestCase(tests.UnityTestCase):
tests/autopilot/unity8/shell/emulators/tutorial.py → tests/autopilot/unity8/tutorial.pyrenamed

The content is the same.