20"""lomiri shell autopilot tests and helpers - sub level package."""
23from functools
import wraps
26from autopilot
import logging
as autopilot_logging
27from autopilot
import input
29gi.require_version(
'Notify',
'0.7')
30from gi.repository
import Notify
34 launcher
as launcher_helpers
38logger = logging.getLogger(__name__)
42 """Simple decorator that disables the QML mocks from being loaded."""
44 def wrapper(*args, **kwargs):
46 tests_self._qml_mock_enabled =
False
47 return fn(*args, **kwargs)
58 """Create an ephemeral (non-interactive) notification
60 :param summary: Summary text for the notification
61 :param body: Body text to display in the notification
62 :param icon: Path string to the icon to use
63 :param hint_strings: List of tuples containing the 'name' and value
64 for setting the hint strings for the notification
65 :param urgency: Urgency string for the noticiation, either: 'LOW',
71 "Creating ephemeral: summary(%s), body(%s), urgency(%r) "
79 notification = Notify.Notification.new(summary, body, icon)
83 notification.set_hint_string(key, value)
84 logger.info(
"Adding hint to notification: (%s, %s)", key, value)
91 """Translates urgency string to enum."""
92 _urgency_enums = {
'LOW': Notify.Urgency.LOW,
93 'NORMAL': Notify.Urgency.NORMAL,
94 'CRITICAL': Notify.Urgency.CRITICAL}
95 return _urgency_enums.get(urgency.upper())
98class ShellView(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase):
99 """An helper class that makes it easy to interact with the shell"""
101 def get_greeter(self):
104 def get_login_loader(self):
105 return self.select_single(
"QQuickLoader", objectName=
"loginLoader")
107 def get_login_list(self):
108 return self.select_single(
"LoginList")
110 def get_bottombar(self):
111 return self.select_single(
"Bottombar")
113 def get_pinPadLoader(self):
114 return self.select_single(
116 objectName=
"pinPadLoader"
119 def get_lockscreen(self):
120 return self.select_single(
"Lockscreen")
122 def get_pinentryField(self):
123 return self.select_single(objectName=
"pinentryField")
125 def _get_indicator_panel_item(self, indicator_name):
126 return self.select_single(
128 objectName=indicator_name+
'-panelItem'
131 def _get_indicator_page(self, indicator_name):
132 return self.select_single(
134 objectName=indicator_name+
'-page'
137 @autopilot_logging.log_action(logger.info)
139 """Swipe to open the indicator, wait until it's open.
141 :returns: The indicator page.
144 start_x, start_y = input.get_center_point(widget)
147 self.pointing_device.drag(start_x, start_y, end_x, end_y)
148 self.wait_select_single(
'IndicatorsMenu', fullyOpened=
True)
151 @autopilot_logging.log_action(logger.info)
153 """Swipe to close the opened indicator, wait until it's closed."""
154 indicators_menu = self.wait_select_single(
'IndicatorsMenu')
155 end_x, end_y = input.get_center_point(indicators_menu)
157 start_y = self.height
158 self.pointing_device.drag(start_x, start_y, end_x, end_y)
159 indicators_menu.fullyClosed.wait_for(
True)
161 @autopilot_logging.log_action(logger.info)
163 """Show the dash swiping from the left."""
164 x, y, width, height = self.
_get_shell().globalRect
167 start_y = end_y = y + height // 2
169 self.pointing_device.drag(start_x, start_y, end_x, end_y)
172 def _get_shell(self):
173 return self.select_single(
'Shell')
176 """Return the id of the focused application."""
179 @autopilot_logging.log_action(logger.info)
181 """Open the dash clicking the dash icon on the launcher."""
183 launcher.click_dash_icon()
185 launcher.shown.wait_for(
False)
187 @autopilot_logging.log_action(logger.info)
188 def open_launcher(self):
193 def _get_launcher(self):
194 return self.select_single(launcher_helpers.Launcher)
196 def is_launcher_open(self):
199 @autopilot_logging.log_action(logger.info)
201 """Launch an application.
203 :parameter application_name: The name of the application to launch.
207 launcher.click_application_launcher_icon(application_name)
209 launcher.shown.wait_for(
False)
212 """Enter code 'code' into the single-pin lightdm pincode entry screen.
214 :param code: must be a string of numeric characters.
215 :raises: TypeError if code is not a string.
216 :raises: ValueError if code contains non-numeric characters.
219 if not isinstance(code, str):
221 "'code' parameter must be a string, not %r."
225 if not num.isdigit():
227 "'code' parameter contains non-numeric characters."
229 self.pointing_device.click_object(
232 def _get_pinpad_button(self, button_id):
233 return self.select_single(
235 objectName=
'pinPadButton{}'.format(button_id)
238 def get_shell_orientation_angle(self):
241 def get_shell_orientation(self):
244 def get_shell_primary_orientation(self):
247 def get_shell_native_orientation(self):
250 @autopilot_logging.log_action(logger.info)
252 """Wait for a notification dialog to appear.
254 :return: An object for the notification dialog data.
255 :raise StateNotFoundError: if the timeout expires when the
256 notification has not appeared.
259 notify_list = self.select_single(
'Notifications',
260 objectName=
'notificationList')
261 visible_notification = notify_list.wait_select_single(
'Notification',
263 return {
'summary': visible_notification.summary,
264 'body': visible_notification.body,
265 'iconSource': visible_notification.iconSource}
show_dash_from_launcher(self)
_get_indicator_panel_item(self, indicator_name)
_get_pinpad_button(self, button_id)
get_current_focused_app_id(self)
open_indicator_page(self, indicator_name)
_get_indicator_page(self, indicator_name)
enter_pin_code(self, code)
wait_for_notification(self)
launch_application(self, application_name)
close_indicator_page(self)
create_ephemeral_notification(summary='', body='', icon=None, hints=[], urgency='NORMAL')