127
133
item = self.select_single('IndicatorItem',
128
134
objectName=indicator_name + '-panelItem')
129
135
return item.hidden
137
def get_greeter(self):
138
return self.select_single('Greeter')
140
def get_login_loader(self):
141
return self.select_single("QQuickLoader", objectName="loginLoader")
143
def get_login_list(self):
144
return self.select_single("LoginList")
146
def get_bottombar(self):
147
return self.select_single("Bottombar")
149
def get_pinPadLoader(self):
150
return self.select_single(
152
objectName="pinPadLoader"
155
def get_lockscreen(self):
156
return self.select_single("Lockscreen")
158
def get_pinentryField(self):
159
return self.select_single(objectName="pinentryField")
161
def _get_indicator_panel_item(self, indicator_name):
162
return self.select_single(
164
objectName=indicator_name + '-panelItem'
167
def _get_indicator_page(self, indicator_name):
168
return self.select_single(
170
objectName=indicator_name + '-page'
173
@autopilot_logging.log_action(logger.info)
174
def open_indicator_page(self, indicator_name):
175
"""Swipe to open the indicator, wait until it's open.
177
:returns: The indicator page.
179
widget = self._get_indicator_panel_item(indicator_name)
180
start_x, start_y = input.get_center_point(widget)
183
self.pointing_device.drag(start_x, start_y, end_x, end_y)
184
self.wait_select_single('IndicatorsMenu', fullyOpened=True)
185
return self._get_indicator_page(indicator_name)
187
@autopilot_logging.log_action(logger.info)
188
def show_dash_swiping(self):
189
"""Show the dash swiping from the left."""
190
x, y, width, height = self._get_shell().globalRect
193
start_y = end_y = y + height // 2
195
self.pointing_device.drag(start_x, start_y, end_x, end_y)
196
self.get_current_focused_app_id().wait_for('unity8-dash')
198
def _get_shell(self):
199
return self.select_single('Shell')
201
def get_current_focused_app_id(self):
202
"""Return the id of the focused application."""
203
return self._get_shell().focusedApplicationId
205
@autopilot_logging.log_action(logger.info)
206
def show_dash_from_launcher(self):
207
"""Open the dash clicking the dash icon on the launcher."""
208
launcher = self.open_launcher()
209
launcher.click_dash_icon()
210
self.get_current_focused_app_id().wait_for('unity8-dash')
211
launcher.shown.wait_for(False)
213
@autopilot_logging.log_action(logger.info)
214
def open_launcher(self):
215
launcher = self._get_launcher()
219
def _get_launcher(self):
220
return self.select_single(Launcher)
222
def is_launcher_open(self):
223
return self._get_launcher().shown
225
@autopilot_logging.log_action(logger.info)
226
def launch_application(self, application_name):
227
"""Launch an application.
229
:parameter application_name: The name of the application to launch.
232
launcher = self.open_launcher()
233
launcher.click_application_launcher_icon(application_name)
234
self.get_current_focused_app_id().wait_for(application_name)
235
launcher.shown.wait_for(False)
237
def enter_pin_code(self, code):
238
"""Enter code 'code' into the single-pin lightdm pincode entry screen.
240
:param code: must be a string of numeric characters.
241
:raises: TypeError if code is not a string.
242
:raises: ValueError if code contains non-numeric characters.
245
if not isinstance(code, str):
247
"'code' parameter must be a string, not %r."
251
if not num.isdigit():
253
"'code' parameter contains non-numeric characters."
255
self.pointing_device.click_object(
256
self._get_pinpad_button(int(num)))
258
def _get_pinpad_button(self, button_id):
259
return self.select_single(
261
objectName='pinPadButton{}'.format(button_id)
264
def get_shell_orientation_angle(self):
265
return self._get_shell().orientationAngle
267
def get_shell_orientation(self):
268
return self._get_shell().orientation
270
def get_shell_primary_orientation(self):
271
return self._get_shell().primaryOrientation
273
def get_shell_native_orientation(self):
274
return self._get_shell().nativeOrientation
276
@autopilot_logging.log_action(logger.info)
277
def wait_for_notification(self):
278
"""Wait for a notification dialog to appear.
280
:return: An object for the notification dialog data.
281
:raise StateNotFoundError: if the timeout expires when the
282
notification has not appeared.
285
notify_list = self.select_single('Notifications',
286
objectName='notificationList')
287
visible_notification = notify_list.wait_select_single('Notification',
289
return {'summary': visible_notification.summary,
290
'body': visible_notification.body,
291
'iconSource': visible_notification.iconSource}
294
class Launcher(UbuntuUIToolkitCustomProxyObjectBase):
296
"""A helper that understands the Launcher."""
299
"""Show the launcher swiping it to the right."""
301
self._swipe_to_show_launcher()
302
self.shown.wait_for(True)
304
logger.debug('The launcher is already opened.')
306
def _swipe_to_show_launcher(self):
307
view = self.get_root_instance().select_single('ShellView')
308
start_y = stop_y = view.y + view.height // 2
311
stop_x = start_x + self.panelWidth - 1
313
self.pointing_device.drag(start_x, start_y, stop_x, stop_y)
315
def click_dash_icon(self):
317
dash_icon = self.select_single(
318
'QQuickImage', objectName='dashItem')
319
self.pointing_device.click_object(dash_icon)
321
raise UnityException('The launcher is closed.')
323
def click_application_launcher_icon(self, application_name):
324
launcher_delegate = self.select_single(
325
'LauncherDelegate', appId=application_name)
326
self.pointing_device.click_object(launcher_delegate)