@@ -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}