| 1 |
|
| 2 |
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*- |
| 3 |
# |
| 4 |
# Copyright (C) 2014-2016 Canonical Ltd. |
| 5 |
# |
| 6 |
# This program is free software; you can redistribute it and/or modify |
| 7 |
# it under the terms of the GNU Lesser General Public License as published by |
| 8 |
# the Free Software Foundation; version 3. |
| 9 |
# |
| 10 |
# This program is distributed in the hope that it will be useful, |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
# GNU Lesser General Public License for more details. |
| 14 |
# |
| 15 |
# You should have received a copy of the GNU Lesser General Public License |
| 16 |
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 17 |
|
| 18 |
from autopilot import introspection |
| 19 |
from autopilot.exceptions import StateNotFoundError |
| 20 |
from lomiri_system_settings.utils.i18n import ugettext as _ |
| 21 |
|
| 22 |
import logging |
| 23 |
from time import sleep |
| 24 |
import autopilot.logging |
| 25 |
import lomiriuitoolkit |
| 26 |
import lomiri_system_settings.utils as utils |
| 27 |
|
| 28 |
# TODO This is a workaround for bug #1327325 that will make phabet-test-run |
| 29 |
# fail if something is printed to stdout. |
| 30 |
logging.basicConfig(filename='warning.log', level=logging.WARNING) |
| 31 |
logger = logging.getLogger(__name__) |
| 32 |
|
| 33 |
|
| 34 |
class SystemSettings(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 35 |
|
| 36 |
"""Helper class for System Settings application""" |
| 37 |
|
| 38 |
@classmethod |
| 39 |
def validate_dbus_object(cls, path, state): |
| 40 |
name = introspection.get_classname_from_path(path) |
| 41 |
return ((name == b'SystemSettings' and |
| 42 |
state['applicationName'][1] == 'SystemSettings') or |
| 43 |
(name == b'lomiri-system-settings' and |
| 44 |
state['applicationName'][1] == 'lomiri-system-settings')) |
| 45 |
|
| 46 |
@property |
| 47 |
def main_view(self): |
| 48 |
"""Return main view""" |
| 49 |
return self.select_single(objectName='systemSettingsMainView') |
| 50 |
|
| 51 |
|
| 52 |
class SystemSettingsMainWindow(lomiriuitoolkit.MainView): |
| 53 |
|
| 54 |
"""Autopilot helper for the Main Window.""" |
| 55 |
|
| 56 |
@classmethod |
| 57 |
def validate_dbus_object(cls, path, state): |
| 58 |
name = introspection.get_classname_from_path(path) |
| 59 |
return (name == b'MainWindow' and |
| 60 |
state['objectName'][1] == 'systemSettingsMainView') |
| 61 |
|
| 62 |
@autopilot.logging.log_action(logger.debug) |
| 63 |
def click_item(self, object_name): |
| 64 |
"""Click a system settings item. |
| 65 |
|
| 66 |
:param object_name: The objectName property of the item to click. |
| 67 |
|
| 68 |
""" |
| 69 |
item = self.select_single(objectName=object_name) |
| 70 |
item.swipe_into_view() |
| 71 |
self.pointing_device.click_object(item) |
| 72 |
|
| 73 |
@autopilot.logging.log_action(logger.debug) |
| 74 |
def go_to_reset_phone(self): |
| 75 |
return self._go_to_page('entryComponent-reset', 'resetPage') |
| 76 |
|
| 77 |
@autopilot.logging.log_action(logger.debug) |
| 78 |
def go_to_language_page(self): |
| 79 |
return self._go_to_page('entryComponent-language', 'languagePage') |
| 80 |
|
| 81 |
@autopilot.logging.log_action(logger.debug) |
| 82 |
def go_to_wifi_page(self): |
| 83 |
return self._go_to_page('entryComponent-wifi', 'wifiPage') |
| 84 |
|
| 85 |
@autopilot.logging.log_action(logger.debug) |
| 86 |
def go_to_cellular_page(self): |
| 87 |
return self._go_to_page('entryComponent-cellular', 'cellularPage') |
| 88 |
|
| 89 |
@autopilot.logging.log_action(logger.debug) |
| 90 |
def go_to_hotspot_page(self): |
| 91 |
return self._go_to_page('entryComponent-hotspot', 'hotspotPage') |
| 92 |
|
| 93 |
@autopilot.logging.log_action(logger.debug) |
| 94 |
def go_to_bluetooth_page(self): |
| 95 |
return self._go_to_page('entryComponent-bluetooth', 'bluetoothPage') |
| 96 |
|
| 97 |
@autopilot.logging.log_action(logger.debug) |
| 98 |
def go_to_phone_page(self): |
| 99 |
return self._go_to_page('entryComponent-phone', 'phonePage') |
| 100 |
|
| 101 |
@autopilot.logging.log_action(logger.debug) |
| 102 |
def go_to_about_page(self): |
| 103 |
return self._go_to_page('entryComponent-about', 'aboutPage') |
| 104 |
|
| 105 |
@autopilot.logging.log_action(logger.debug) |
| 106 |
def go_to_sound_page(self): |
| 107 |
return self._go_to_page('entryComponent-sound', 'soundPage') |
| 108 |
|
| 109 |
@autopilot.logging.log_action(logger.debug) |
| 110 |
def go_to_security_page(self): |
| 111 |
return self._go_to_page('entryComponent-security-privacy', |
| 112 |
'securityPrivacyPage') |
| 113 |
|
| 114 |
@autopilot.logging.log_action(logger.debug) |
| 115 |
def go_to_notification_page(self): |
| 116 |
return self._go_to_page('entryComponent-notifications', |
| 117 |
'systemNotificationsPage') |
| 118 |
|
| 119 |
@autopilot.logging.log_action(logger.debug) |
| 120 |
def go_to_datetime_page(self): |
| 121 |
return self._go_to_page('entryComponent-time-date', 'timeDatePage') |
| 122 |
|
| 123 |
@autopilot.logging.log_action(logger.debug) |
| 124 |
def go_to_vpn_page(self): |
| 125 |
return self._go_to_page('entryComponent-vpn', 'vpnPage') |
| 126 |
|
| 127 |
def _go_to_page(self, item_object_name, page_object_name): |
| 128 |
self.click_item(item_object_name) |
| 129 |
page = self.wait_select_single(objectName=page_object_name) |
| 130 |
page.active.wait_for(True) |
| 131 |
return page |
| 132 |
|
| 133 |
@autopilot.logging.log_action(logger.debug) |
| 134 |
def scroll_to(self, obj): |
| 135 |
|
| 136 |
def get_page_bottom(): |
| 137 |
return page.globalRect[1] + page.globalRect[3] |
| 138 |
|
| 139 |
page = self.system_settings_page |
| 140 |
page_right = page.globalRect[0] + page.globalRect[2] |
| 141 |
page_bottom = get_page_bottom() |
| 142 |
page_center_x = int(page_right / 2) |
| 143 |
page_center_y = int(page_bottom / 2) |
| 144 |
while obj.globalRect[1] + obj.height > get_page_bottom(): |
| 145 |
self.pointing_device.drag( |
| 146 |
page_center_x, |
| 147 |
page_center_y, |
| 148 |
page_center_x, |
| 149 |
page_center_y - obj.height * 2 |
| 150 |
) |
| 151 |
# avoid a flick, this is very important |
| 152 |
sleep(0.3) |
| 153 |
|
| 154 |
def scroll_to_and_click(self, obj): |
| 155 |
self.scroll_to(obj) |
| 156 |
self.pointing_device.click_object(obj) |
| 157 |
|
| 158 |
@property |
| 159 |
def system_settings_page(self): |
| 160 |
return self.select_single(objectName='systemSettingsPage') |
| 161 |
|
| 162 |
@property |
| 163 |
def choose_page(self): |
| 164 |
""" Return 'Choose carrier' page """ |
| 165 |
return self.select_single(objectName="chooseCarrierPage") |
| 166 |
|
| 167 |
@property |
| 168 |
def storage_page(self): |
| 169 |
""" Return 'Storage' page """ |
| 170 |
return self.select_single(objectName='storagePage') |
| 171 |
|
| 172 |
@property |
| 173 |
def updates_page(self): |
| 174 |
""" Return 'System Update' page """ |
| 175 |
return self.select_single(objectName='systemUpdatesPage') |
| 176 |
|
| 177 |
@property |
| 178 |
def background_page(self): |
| 179 |
""" Return 'Background' page """ |
| 180 |
return self.select_single(objectName='backgroundPage') |
| 181 |
|
| 182 |
@property |
| 183 |
def _orientation_lock_switch(self): |
| 184 |
return self.wait_select_single( |
| 185 |
lomiriuitoolkit.CheckBox, |
| 186 |
objectName='orientationLockSwitch') |
| 187 |
|
| 188 |
def enable_orientation_lock(self): |
| 189 |
self._orientation_lock_switch.check() |
| 190 |
|
| 191 |
def disable_orientation_lock(self): |
| 192 |
self._orientation_lock_switch.uncheck() |
| 193 |
|
| 194 |
|
| 195 |
class Dialog(lomiriuitoolkit.Dialog): |
| 196 |
# XXX A new Dialog custom proxy object was added to the toolkit. |
| 197 |
# Because of https://bugs.launchpad.net/autopilot-qt/+bug/1341671 |
| 198 |
# we need to make sure it does not match in any selection. |
| 199 |
|
| 200 |
@classmethod |
| 201 |
def validate_dbus_object(cls, path, state): |
| 202 |
return False |
| 203 |
|
| 204 |
|
| 205 |
class LabelTextField(lomiriuitoolkit.TextField): |
| 206 |
"""LabelTextField is a component local to the APN Editor in the cellular |
| 207 |
plugin.""" |
| 208 |
pass |
| 209 |
|
| 210 |
|
| 211 |
class CellularPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 212 |
|
| 213 |
"""Autopilot helper for the Cellular page.""" |
| 214 |
|
| 215 |
@classmethod |
| 216 |
def validate_dbus_object(cls, path, state): |
| 217 |
name = introspection.get_classname_from_path(path) |
| 218 |
if name == b'PageComponent': |
| 219 |
if state['objectName'][1] == 'cellularPage': |
| 220 |
return True |
| 221 |
return False |
| 222 |
|
| 223 |
@autopilot.logging.log_action(logger.debug) |
| 224 |
def enable_data(self): |
| 225 |
self._set_data(True) |
| 226 |
|
| 227 |
@autopilot.logging.log_action(logger.debug) |
| 228 |
def disable_data(self): |
| 229 |
self._set_data(False) |
| 230 |
|
| 231 |
@autopilot.logging.log_action(logger.debug) |
| 232 |
def _set_data(self, data): |
| 233 |
chk = self.select_single(objectName='data') |
| 234 |
if data: |
| 235 |
chk.check() |
| 236 |
else: |
| 237 |
chk.uncheck() |
| 238 |
|
| 239 |
@autopilot.logging.log_action(logger.debug) |
| 240 |
def get_data(self): |
| 241 |
return self.select_single(objectName='data').checked |
| 242 |
|
| 243 |
@autopilot.logging.log_action(logger.debug) |
| 244 |
def enable_roaming(self, timeout=10): |
| 245 |
self._set_roaming(True, timeout=timeout) |
| 246 |
|
| 247 |
@autopilot.logging.log_action(logger.debug) |
| 248 |
def disable_roaming(self, timeout=10): |
| 249 |
self._set_roaming(False, timeout=timeout) |
| 250 |
|
| 251 |
@autopilot.logging.log_action(logger.debug) |
| 252 |
def _set_roaming(self, roaming, timeout): |
| 253 |
chk = self.select_single(objectName='roaming') |
| 254 |
if roaming: |
| 255 |
chk.check(timeout=timeout) |
| 256 |
else: |
| 257 |
chk.uncheck(timeout=timeout) |
| 258 |
|
| 259 |
@autopilot.logging.log_action(logger.debug) |
| 260 |
def set_connection_type(self, radio_type, sim='/ril_0', |
| 261 |
scroll_to_and_click=None): |
| 262 |
self._set_connection_type(radio_type, sim, scroll_to_and_click) |
| 263 |
|
| 264 |
@autopilot.logging.log_action(logger.debug) |
| 265 |
def _set_connection_type(self, radio_type, sim, scroll_to_and_click): |
| 266 |
t = self.wait_select_single( |
| 267 |
'OptionSelectorDelegate', |
| 268 |
objectName='%s_radio_%s' % (sim, radio_type)) |
| 269 |
if scroll_to_and_click: |
| 270 |
scroll_to_and_click(t) |
| 271 |
else: |
| 272 |
t.swipe_into_view() |
| 273 |
|
| 274 |
self.pointing_device.click_object(t) |
| 275 |
|
| 276 |
@autopilot.logging.log_action(logger.debug) |
| 277 |
def change_carrier(self, carrier, sim=None): |
| 278 |
carrierApnPage = self._click_carrier_apn() |
| 279 |
chooseCarrierPage = carrierApnPage.open_carrier(sim) |
| 280 |
chooseCarrierPage.set_carrier(carrier) |
| 281 |
|
| 282 |
@autopilot.logging.log_action(logger.debug) |
| 283 |
def open_apn_editor(self, name, sim=None): |
| 284 |
carrierApnPage = self._click_carrier_apn() |
| 285 |
chooseApnPage = carrierApnPage.open_apn(sim) |
| 286 |
return chooseApnPage.open(name) |
| 287 |
|
| 288 |
@autopilot.logging.log_action(logger.debug) |
| 289 |
def open_apn_page(self, name, sim=None): |
| 290 |
carrierApnPage = self._click_carrier_apn() |
| 291 |
chooseApnPage = carrierApnPage.open_apn(sim) |
| 292 |
return chooseApnPage |
| 293 |
|
| 294 |
@autopilot.logging.log_action(logger.debug) |
| 295 |
def delete_apn(self, name, sim=None): |
| 296 |
carrierApnPage = self._click_carrier_apn() |
| 297 |
chooseApnPage = carrierApnPage.open_apn(sim) |
| 298 |
return chooseApnPage.delete(name) |
| 299 |
|
| 300 |
@autopilot.logging.log_action(logger.debug) |
| 301 |
def prefer_apn(self, name, sim=None): |
| 302 |
carrierApnPage = self._click_carrier_apn() |
| 303 |
chooseApnPage = carrierApnPage.open_apn(sim) |
| 304 |
return chooseApnPage.check(name) |
| 305 |
|
| 306 |
@autopilot.logging.log_action(logger.debug) |
| 307 |
def _click_carrier_apn(self): |
| 308 |
item = self.select_single(objectName='carrierApnEntry') |
| 309 |
self.pointing_device.click_object(item) |
| 310 |
return self.get_root_instance().wait_select_single( |
| 311 |
objectName='carrierApnPage') |
| 312 |
|
| 313 |
@autopilot.logging.log_action(logger.debug) |
| 314 |
def select_sim_for_data(self, sim): |
| 315 |
self._select_sim_for_data(sim) |
| 316 |
|
| 317 |
@autopilot.logging.log_action(logger.debug) |
| 318 |
def _select_sim_for_data(self, sim): |
| 319 |
item = self.select_single(objectName='use%s' % sim) |
| 320 |
self.pointing_device.click_object(item) |
| 321 |
|
| 322 |
@autopilot.logging.log_action(logger.debug) |
| 323 |
def select_sim_for_calls(self, sim): |
| 324 |
pass |
| 325 |
|
| 326 |
@autopilot.logging.log_action(logger.debug) |
| 327 |
def select_sim_for_messages(self): |
| 328 |
pass |
| 329 |
|
| 330 |
@autopilot.logging.log_action(logger.debug) |
| 331 |
def set_name(self, sim, name): |
| 332 |
self._set_name(sim, name) |
| 333 |
|
| 334 |
def get_name(self, sim): |
| 335 |
obj = self.select_single( |
| 336 |
objectName="label_%s" % sim) |
| 337 |
return obj.text |
| 338 |
|
| 339 |
def _set_name(self, sim, name): |
| 340 |
obj = self.select_single( |
| 341 |
objectName="edit_name_%s" % sim) |
| 342 |
self.pointing_device.click_object(obj) |
| 343 |
|
| 344 |
# wait for animation |
| 345 |
sleep(1) |
| 346 |
ok = self.select_single('Button', objectName="doRename") |
| 347 |
|
| 348 |
field = self.wait_select_single('TextField', objectName="nameField") |
| 349 |
field.write(name) |
| 350 |
self.pointing_device.click_object(ok) |
| 351 |
|
| 352 |
|
| 353 |
class HotspotPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 354 |
|
| 355 |
"""Autopilot helper for Hotspot page.""" |
| 356 |
|
| 357 |
@classmethod |
| 358 |
def validate_dbus_object(cls, path, state): |
| 359 |
name = introspection.get_classname_from_path(path) |
| 360 |
if name == b'ItemPage': |
| 361 |
if state['objectName'][1] == 'hotspotPage': |
| 362 |
return True |
| 363 |
return False |
| 364 |
|
| 365 |
@property |
| 366 |
def _switch(self): |
| 367 |
return self.wait_select_single( |
| 368 |
lomiriuitoolkit.CheckBox, |
| 369 |
objectName='hotspotSwitch') |
| 370 |
|
| 371 |
@autopilot.logging.log_action(logger.debug) |
| 372 |
def enable_hotspot(self): |
| 373 |
# We assume that the following AssertionError is due to the panel |
| 374 |
# instantly setting checked to False, prompting the user to turn on |
| 375 |
# Wi-Fi instead. |
| 376 |
try: |
| 377 |
self._switch.check(timeout=2) |
| 378 |
except AssertionError: |
| 379 |
pass |
| 380 |
|
| 381 |
try: |
| 382 |
prompt = self.get_root_instance().wait_select_single( |
| 383 |
objectName='enableWifiDialog') |
| 384 |
except StateNotFoundError: |
| 385 |
prompt = None |
| 386 |
|
| 387 |
if prompt: |
| 388 |
prompt.confirm_enable() |
| 389 |
prompt.wait_until_destroyed(timeout=5) |
| 390 |
|
| 391 |
@autopilot.logging.log_action(logger.debug) |
| 392 |
def disable_hotspot(self): |
| 393 |
self._switch.uncheck() |
| 394 |
|
| 395 |
@autopilot.logging.log_action(logger.debug) |
| 396 |
def setup_hotspot(self, config): |
| 397 |
obj = self.select_single(objectName='hotspotSetupButton') |
| 398 |
self.pointing_device.click_object(obj) |
| 399 |
setup = self.get_root_instance().wait_select_single( |
| 400 |
objectName='hotspotSetup') |
| 401 |
if config: |
| 402 |
if 'ssid' in config: |
| 403 |
setup.set_ssid(config['ssid']) |
| 404 |
if 'auth' in config: |
| 405 |
setup.set_auth(config['auth']) |
| 406 |
if 'password' in config: |
| 407 |
setup.set_password(config['password']) |
| 408 |
utils.dismiss_osk() |
| 409 |
setup.enable() |
| 410 |
if setup: |
| 411 |
setup.wait_until_destroyed() |
| 412 |
|
| 413 |
@autopilot.logging.log_action(logger.debug) |
| 414 |
def get_hotspot_status(self): |
| 415 |
return self._switch.checked |
| 416 |
|
| 417 |
@autopilot.logging.log_action(logger.debug) |
| 418 |
def get_hotspot_possible(self): |
| 419 |
return self._switch.enabled |
| 420 |
|
| 421 |
|
| 422 |
class HotspotEnableWifiDialog( |
| 423 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 424 |
"""Autopilot helper for the 'Turn on Wi-Fi' dialog in hotspot panel.""" |
| 425 |
|
| 426 |
@classmethod |
| 427 |
def validate_dbus_object(cls, path, state): |
| 428 |
name = introspection.get_classname_from_path(path) |
| 429 |
if name == b'Dialog': |
| 430 |
if state['objectName'][1] == 'enableWifiDialog': |
| 431 |
return True |
| 432 |
return False |
| 433 |
|
| 434 |
@autopilot.logging.log_action(logger.debug) |
| 435 |
def confirm_enable(self): |
| 436 |
button = self.select_single('Button', objectName='confirmEnable') |
| 437 |
self.pointing_device.click_object(button) |
| 438 |
|
| 439 |
|
| 440 |
class HotspotSetup(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 441 |
|
| 442 |
"""Autopilot helper for Hotspot setup.""" |
| 443 |
|
| 444 |
@classmethod |
| 445 |
def validate_dbus_object(cls, path, state): |
| 446 |
name = introspection.get_classname_from_path(path) |
| 447 |
if name == b'Dialog': |
| 448 |
if state['objectName'][1] == 'hotspotSetup': |
| 449 |
return True |
| 450 |
return False |
| 451 |
|
| 452 |
@property |
| 453 |
def _ssid_field(self): |
| 454 |
return self.wait_select_single( |
| 455 |
lomiriuitoolkit.TextField, |
| 456 |
objectName='ssidField') |
| 457 |
|
| 458 |
@property |
| 459 |
def _password_field(self): |
| 460 |
return self.wait_select_single( |
| 461 |
lomiriuitoolkit.TextField, |
| 462 |
objectName='passwordField') |
| 463 |
|
| 464 |
@property |
| 465 |
def _enable_button(self): |
| 466 |
return self.wait_select_single( |
| 467 |
'Button', objectName='confirmButton') |
| 468 |
|
| 469 |
@property |
| 470 |
def _password_required_check(self): |
| 471 |
return self.wait_select_single( |
| 472 |
'CheckBox', objectName='passwordRequiredToggle') |
| 473 |
|
| 474 |
@autopilot.logging.log_action(logger.debug) |
| 475 |
def set_ssid(self, ssid): |
| 476 |
self._ssid_field.write(ssid) |
| 477 |
|
| 478 |
@autopilot.logging.log_action(logger.debug) |
| 479 |
def set_password(self, password): |
| 480 |
self._password_field.write(password) |
| 481 |
|
| 482 |
@autopilot.logging.log_action(logger.debug) |
| 483 |
def set_auth(self, auth): |
| 484 |
if auth == 'wpa-psk': |
| 485 |
self._password_required_check.check() |
| 486 |
else: |
| 487 |
self._password_required_check.uncheck() |
| 488 |
|
| 489 |
@autopilot.logging.log_action(logger.debug) |
| 490 |
def enable(self): |
| 491 |
self.pointing_device.click_object(self._enable_button) |
| 492 |
|
| 493 |
|
| 494 |
class BluetoothPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 495 |
|
| 496 |
"""Autopilot helper for Bluetooth page.""" |
| 497 |
|
| 498 |
@classmethod |
| 499 |
def validate_dbus_object(cls, path, state): |
| 500 |
name = introspection.get_classname_from_path(path) |
| 501 |
if name == b'PageComponent': |
| 502 |
if state['objectName'][1] == 'bluetoothPage': |
| 503 |
return True |
| 504 |
return False |
| 505 |
|
| 506 |
def get_disconnected_devices(self): |
| 507 |
"""Return the list of known disconnected devices. |
| 508 |
|
| 509 |
:return: a list containing the text for each device |
| 510 |
|
| 511 |
""" |
| 512 |
disconnected_list = self.select_single( |
| 513 |
'QQuickColumn', |
| 514 |
objectName='disconnectedList' |
| 515 |
) |
| 516 |
# NOTE: the UI design uses ellipsis to be suggestive |
| 517 |
ellipsis = '\u2026' |
| 518 |
return [device.text.strip(ellipsis) for device in |
| 519 |
disconnected_list.select_many('LabelVisual')] |
| 520 |
|
| 521 |
|
| 522 |
class PageCarrierAndApn(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 523 |
|
| 524 |
"""Autopilot helper for carrier/apn entry page (singlesim).""" |
| 525 |
@autopilot.logging.log_action(logger.debug) |
| 526 |
def open_carrier(self, sim): |
| 527 |
return self._click_carrier(sim) |
| 528 |
|
| 529 |
@autopilot.logging.log_action(logger.debug) |
| 530 |
def _click_carrier(self, sim): |
| 531 |
obj = self.select_single( |
| 532 |
objectName='carrier') |
| 533 |
self.pointing_device.click_object(obj) |
| 534 |
return self.get_root_instance().wait_select_single( |
| 535 |
objectName='chooseCarrierPage') |
| 536 |
|
| 537 |
@autopilot.logging.log_action(logger.debug) |
| 538 |
def open_apn(self, sim): |
| 539 |
return self._click_apn(sim) |
| 540 |
|
| 541 |
@autopilot.logging.log_action(logger.debug) |
| 542 |
def _click_apn(self, sim): |
| 543 |
obj = self.select_single( |
| 544 |
objectName='apn') |
| 545 |
self.pointing_device.click_object(obj) |
| 546 |
return self.get_root_instance().wait_select_single( |
| 547 |
objectName='apnPage') |
| 548 |
|
| 549 |
|
| 550 |
class PageCarriersAndApns( |
| 551 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 552 |
"""Autopilot helper for carrier/apn entry page (multisim).""" |
| 553 |
@autopilot.logging.log_action(logger.debug) |
| 554 |
def open_carrier(self, sim): |
| 555 |
return self._click_carrier(sim) |
| 556 |
|
| 557 |
@autopilot.logging.log_action(logger.debug) |
| 558 |
def _click_carrier(self, sim): |
| 559 |
obj = self.select_single( |
| 560 |
objectName='%s_carriers' % sim) |
| 561 |
self.pointing_device.click_object(obj) |
| 562 |
return self.get_root_instance().wait_select_single( |
| 563 |
objectName='chooseCarrierPage') |
| 564 |
|
| 565 |
|
| 566 |
class PageChooseCarrier(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 567 |
|
| 568 |
"""Autopilot helper for carrier selection page""" |
| 569 |
|
| 570 |
@autopilot.logging.log_action(logger.debug) |
| 571 |
def set_automatic(self): |
| 572 |
item = self.select_single(text='Automatically') |
| 573 |
self.pointing_device.click_object(item) |
| 574 |
|
| 575 |
@autopilot.logging.log_action(logger.debug) |
| 576 |
def set_carrier(self, carrier): |
| 577 |
# wait for animation, since page.animationRunning.wait_for(False) |
| 578 |
# does not work? |
| 579 |
sleep(0.5) |
| 580 |
allOperators = self.select_single(objectName="allOperators") |
| 581 |
otherOperators = self.select_single(objectName="otherOperators") |
| 582 |
|
| 583 |
if allOperators.visible: |
| 584 |
opList = allOperators |
| 585 |
elif otherOperators.visible: |
| 586 |
opList = otherOperators |
| 587 |
else: |
| 588 |
raise Exception("No operator list visible.") |
| 589 |
|
| 590 |
item = opList.select_single(text=carrier, objectName="carrier") |
| 591 |
self.pointing_device.click_object(item) |
| 592 |
|
| 593 |
|
| 594 |
class PageChooseApn(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 595 |
|
| 596 |
"""Autopilot helper for apn editor page""" |
| 597 |
|
| 598 |
@autopilot.logging.log_action(logger.debug) |
| 599 |
def open(self, name): |
| 600 |
return self._open_editor(name) |
| 601 |
|
| 602 |
@autopilot.logging.log_action(logger.debug) |
| 603 |
def delete(self, name): |
| 604 |
self._delete(name) |
| 605 |
|
| 606 |
@autopilot.logging.log_action(logger.debug) |
| 607 |
def _delete(self, name): |
| 608 |
item = self.wait_select_single('Standard', objectName='edit_%s' % name) |
| 609 |
item.swipe_to_delete() |
| 610 |
item.confirm_removal() |
| 611 |
|
| 612 |
@autopilot.logging.log_action(logger.debug) |
| 613 |
def check(self, name): |
| 614 |
self._check(name) |
| 615 |
|
| 616 |
@autopilot.logging.log_action(logger.debug) |
| 617 |
def _check(self, name): |
| 618 |
item = self.wait_select_single( |
| 619 |
'CheckBox', objectName='%s_preferred' % name |
| 620 |
) |
| 621 |
item.check() |
| 622 |
|
| 623 |
@autopilot.logging.log_action(logger.debug) |
| 624 |
def _open_editor(self, name): |
| 625 |
if name: |
| 626 |
item = self.select_single(objectName='edit_%s' % name) |
| 627 |
self.pointing_device.click_object(item) |
| 628 |
else: |
| 629 |
main_view = self.get_root_instance().select_single( |
| 630 |
objectName='systemSettingsMainView') |
| 631 |
header = main_view.select_single('AppHeader') |
| 632 |
header.click_action_button('newApn') |
| 633 |
return self.get_root_instance().wait_select_single( |
| 634 |
objectName='apnEditor') |
| 635 |
|
| 636 |
|
| 637 |
class PageApnEditor(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 638 |
|
| 639 |
"""Autopilot helper for apn editor page""" |
| 640 |
|
| 641 |
flickable = None |
| 642 |
|
| 643 |
def __init__(self, *args): |
| 644 |
super().__init__(*args) |
| 645 |
self.flickable = self.select_single(objectName='scrollArea') |
| 646 |
|
| 647 |
@autopilot.logging.log_action(logger.debug) |
| 648 |
def set_type(self, t): |
| 649 |
selector = self.select_single( |
| 650 |
'ItemSelector', objectName='typeSelector') |
| 651 |
self.pointing_device.click_object(selector) |
| 652 |
selector.currentlyExpanded.wait_for(True) |
| 653 |
item = self.select_single(objectName='type_%s' % t) |
| 654 |
|
| 655 |
# A bit dirty |
| 656 |
while selector.currentlyExpanded: |
| 657 |
self.pointing_device.click_object(item) |
| 658 |
|
| 659 |
@autopilot.logging.log_action(logger.debug) |
| 660 |
def set_name(self, new_name): |
| 661 |
self._populate_field('name', new_name) |
| 662 |
|
| 663 |
@autopilot.logging.log_action(logger.debug) |
| 664 |
def set_access_point_name(self, new_name): |
| 665 |
self._populate_field('accessPointName', new_name) |
| 666 |
|
| 667 |
@autopilot.logging.log_action(logger.debug) |
| 668 |
def set_message_center(self, new_message_center): |
| 669 |
self._populate_field('messageCenter', new_message_center) |
| 670 |
|
| 671 |
@autopilot.logging.log_action(logger.debug) |
| 672 |
def set_message_proxy(self, new_message_proxy): |
| 673 |
self._populate_field('messageProxy', new_message_proxy) |
| 674 |
|
| 675 |
# Sleep for the duration of the timer that will copy any |
| 676 |
# port into the port field |
| 677 |
sleep(1.5) |
| 678 |
|
| 679 |
@autopilot.logging.log_action(logger.debug) |
| 680 |
def set_port(self, new_port): |
| 681 |
self._populate_field('port', new_port) |
| 682 |
|
| 683 |
@autopilot.logging.log_action(logger.debug) |
| 684 |
def set_username(self, new_username): |
| 685 |
self._populate_field('username', new_username) |
| 686 |
|
| 687 |
@autopilot.logging.log_action(logger.debug) |
| 688 |
def set_password(self, new_password): |
| 689 |
self._populate_field('password', new_password) |
| 690 |
|
| 691 |
def _populate_field(self, field, text): |
| 692 |
f = self.select_single(LabelTextField, objectName=field) |
| 693 |
self.flickable.swipe_child_into_view(f) |
| 694 |
f.write(text) |
| 695 |
|
| 696 |
@autopilot.logging.log_action(logger.debug) |
| 697 |
def save(self): |
| 698 |
main_view = self.get_root_instance().select_single( |
| 699 |
objectName='systemSettingsMainView') |
| 700 |
header = main_view.select_single('AppHeader') |
| 701 |
header.click_action_button('saveApn') |
| 702 |
|
| 703 |
|
| 704 |
class SecurityPage(lomiriuitoolkit.QQuickFlickable): |
| 705 |
|
| 706 |
"""Autopilot helper for the Security page.""" |
| 707 |
|
| 708 |
@classmethod |
| 709 |
def validate_dbus_object(cls, path, state): |
| 710 |
name = introspection.get_classname_from_path(path) |
| 711 |
if name == b'PageComponent': |
| 712 |
if state['objectName'][1] == 'securityPrivacyPage': |
| 713 |
return True |
| 714 |
return False |
| 715 |
|
| 716 |
@autopilot.logging.log_action(logger.debug) |
| 717 |
def go_to_sim_lock(self): |
| 718 |
selector = self.select_single(objectName='simControl') |
| 719 |
self.swipe_child_into_view(selector) |
| 720 |
self.pointing_device.click_object(selector) |
| 721 |
return self.get_root_instance().wait_select_single( |
| 722 |
objectName='simPinPage' |
| 723 |
) |
| 724 |
|
| 725 |
|
| 726 |
class SimPin(lomiriuitoolkit.QQuickFlickable): |
| 727 |
|
| 728 |
"""Autopilot helper for the SimPin Page.""" |
| 729 |
|
| 730 |
def get_sim_pin_switch(self, sim_number): |
| 731 |
"""Return the SIM PIN switch.""" |
| 732 |
switches = self.select_many(objectName='simPinSwitch') |
| 733 |
switches = sorted(switches, key=lambda switch: (switch.globalRect.y)) |
| 734 |
return switches[sim_number] |
| 735 |
|
| 736 |
@autopilot.logging.log_action(logger.debug) |
| 737 |
def click_sim_pin_switch(self, sim_number): |
| 738 |
"""Click on the SIM PIN switch, return the SIM PIN dialog.""" |
| 739 |
sim_pin_switch = self.get_sim_pin_switch(sim_number) |
| 740 |
self.pointing_device.click_object(sim_pin_switch) |
| 741 |
return self.get_root_instance().wait_select_single( |
| 742 |
objectName='lockDialogComponent' |
| 743 |
) |
| 744 |
|
| 745 |
@autopilot.logging.log_action(logger.debug) |
| 746 |
def enter_lock_pin(self, pin): |
| 747 |
"""Enter the given pin into our dialog.""" |
| 748 |
root_instance = self.get_root_instance() |
| 749 |
prev_input = root_instance.wait_select_single( |
| 750 |
objectName='prevInput' |
| 751 |
) |
| 752 |
prev_input.write(pin) |
| 753 |
lock_unlock_button = root_instance.select_single( |
| 754 |
objectName='lockButton' |
| 755 |
) |
| 756 |
self.pointing_device.click_object(lock_unlock_button) |
| 757 |
|
| 758 |
|
| 759 |
class TimeAndDatePage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 760 |
|
| 761 |
"""Autopilot helper for the TimeAndDate page.""" |
| 762 |
|
| 763 |
@classmethod |
| 764 |
def validate_dbus_object(cls, path, state): |
| 765 |
name = introspection.get_classname_from_path(path) |
| 766 |
if name == b'PageComponent': |
| 767 |
if state['objectName'][1] == 'timeDatePage': |
| 768 |
return True |
| 769 |
return False |
| 770 |
|
| 771 |
|
| 772 |
class SoundPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 773 |
|
| 774 |
"""Autopilot helper for the Sound page.""" |
| 775 |
|
| 776 |
@classmethod |
| 777 |
def validate_dbus_object(cls, path, state): |
| 778 |
name = introspection.get_classname_from_path(path) |
| 779 |
if name == b'ItemPage': |
| 780 |
if state['objectName'][1] == 'soundPage': |
| 781 |
return True |
| 782 |
return False |
| 783 |
|
| 784 |
|
| 785 |
class AboutPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 786 |
|
| 787 |
"""Autopilot helper for the About page.""" |
| 788 |
|
| 789 |
@classmethod |
| 790 |
def validate_dbus_object(cls, path, state): |
| 791 |
name = introspection.get_classname_from_path(path) |
| 792 |
if name == b'PageComponent': |
| 793 |
if state['objectName'][1] == 'aboutPage': |
| 794 |
return True |
| 795 |
return False |
| 796 |
|
| 797 |
def get_device_name(self): |
| 798 |
device_label = self.select_single(objectName='deviceLabel') |
| 799 |
return device_label.text |
| 800 |
|
| 801 |
def is_serial_visible(self): |
| 802 |
serial_item = self._get_serial_item() |
| 803 |
return serial_item.visible |
| 804 |
|
| 805 |
def _get_serial_item(self): |
| 806 |
return self.select_single(objectName='serialItem') |
| 807 |
|
| 808 |
def get_serial(self): |
| 809 |
serial_item = self._get_serial_item() |
| 810 |
return serial_item.value |
| 811 |
|
| 812 |
def is_imei_visible(self): |
| 813 |
imei_item = self._get_imei_item() |
| 814 |
return imei_item.visible |
| 815 |
|
| 816 |
def _get_imei_item(self): |
| 817 |
return self.wait_select_single(objectName='imeiItem') |
| 818 |
|
| 819 |
def get_imei(self): |
| 820 |
imei_item = self._get_imei_item() |
| 821 |
return imei_item.value |
| 822 |
|
| 823 |
def get_os_information(self): |
| 824 |
os_item = self.select_single(objectName='osItem') |
| 825 |
return os_item.value |
| 826 |
|
| 827 |
def get_last_updated_date(self): |
| 828 |
last_updated_item = self.select_single(objectName='lastUpdatedItem') |
| 829 |
return last_updated_item.value |
| 830 |
|
| 831 |
@autopilot.logging.log_action(logger.info) |
| 832 |
def go_to_check_for_updates(self): |
| 833 |
check_for_updates_button = self.select_single( |
| 834 |
objectName='updateButton') |
| 835 |
check_for_updates_button.swipe_into_view() |
| 836 |
self.pointing_device.click_object(check_for_updates_button) |
| 837 |
system_updates_page = self.get_root_instance().wait_select_single( |
| 838 |
objectName='systemUpdatesPage') |
| 839 |
system_updates_page.active.wait_for(True) |
| 840 |
return system_updates_page |
| 841 |
|
| 842 |
@autopilot.logging.log_action(logger.info) |
| 843 |
def go_to_software_licenses(self): |
| 844 |
license_item = self.select_single( |
| 845 |
'StandardProgression', objectName='licenseItem') |
| 846 |
license_item.swipe_into_view() |
| 847 |
self.pointing_device.click_object(license_item) |
| 848 |
licenses_page = self.get_root_instance().wait_select_single( |
| 849 |
objectName='licensesPage') |
| 850 |
licenses_page.active.wait_for(True) |
| 851 |
return licenses_page |
| 852 |
|
| 853 |
def get_number(self, obj): |
| 854 |
number = self.select_single(objectName=obj) |
| 855 |
return number.value |
| 856 |
|
| 857 |
|
| 858 |
class LicensesPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 859 |
|
| 860 |
"""Autopilot helper for the Licenses page.""" |
| 861 |
|
| 862 |
@classmethod |
| 863 |
def validate_dbus_object(cls, path, state): |
| 864 |
name = introspection.get_classname_from_path(path) |
| 865 |
if name == b'ItemPage': |
| 866 |
if state['objectName'][1] == 'licensesPage': |
| 867 |
return True |
| 868 |
return False |
| 869 |
|
| 870 |
|
| 871 |
class SystemUpdatesPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 872 |
|
| 873 |
"""Autopilot helper for the System Updates page.""" |
| 874 |
|
| 875 |
@classmethod |
| 876 |
def validate_dbus_object(cls, path, state): |
| 877 |
name = introspection.get_classname_from_path(path) |
| 878 |
if name == b'PageComponent': |
| 879 |
if state['objectName'][1] == 'systemUpdatesPage': |
| 880 |
return True |
| 881 |
return False |
| 882 |
|
| 883 |
def stop_check(self): |
| 884 |
btn = self.select_single(objectName='updatesGlobalStopButton') |
| 885 |
self.pointing_device.click_object(btn) |
| 886 |
|
| 887 |
|
| 888 |
class PhonePage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 889 |
|
| 890 |
"""Autopilot helper for the Phone page.""" |
| 891 |
|
| 892 |
@classmethod |
| 893 |
def validate_dbus_object(cls, path, state): |
| 894 |
name = introspection.get_classname_from_path(path) |
| 895 |
if name == b'PageComponent': |
| 896 |
if state['objectName'][1] == 'phonePage': |
| 897 |
return True |
| 898 |
return False |
| 899 |
|
| 900 |
def _go_to_page(self, item_object_name, page_object_name): |
| 901 |
self._click_item(item_object_name) |
| 902 |
page = self.get_root_instance().wait_select_single( |
| 903 |
objectName=page_object_name) |
| 904 |
page.active.wait_for(True) |
| 905 |
return page |
| 906 |
|
| 907 |
def _click_item(self, object_name): |
| 908 |
item = self.wait_select_single(objectName=object_name) |
| 909 |
item.swipe_into_view() |
| 910 |
self.pointing_device.click_object(item) |
| 911 |
|
| 912 |
@autopilot.logging.log_action(logger.info) |
| 913 |
def go_to_sim_services(self, sim=None): |
| 914 |
"""Open the SIM Services settings page. |
| 915 |
|
| 916 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 917 |
Required parameter in dual SIM setups |
| 918 |
:returns: The SIM Services settings page. |
| 919 |
|
| 920 |
""" |
| 921 |
find = "simServices" |
| 922 |
if sim is not None: |
| 923 |
find = "simServicesSim%d" % sim |
| 924 |
|
| 925 |
return self._go_to_page(find, 'servicesPage') |
| 926 |
|
| 927 |
def get_sim_services_enabled(self, sim=None): |
| 928 |
"""Return whether or not Sim Services is enabled. |
| 929 |
|
| 930 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 931 |
Required parameter in dual SIM setups |
| 932 |
:returns: Whether or not Sim Services is enabled. |
| 933 |
|
| 934 |
""" |
| 935 |
find = "simServices" |
| 936 |
if sim is not None: |
| 937 |
find = "simServicesSim%d" % sim |
| 938 |
return self.select_single(objectName=find).enabled |
| 939 |
|
| 940 |
@property |
| 941 |
def _dialpad_sounds(self): |
| 942 |
"""The dialpad sounds switch.""" |
| 943 |
return self.wait_select_single( |
| 944 |
lomiriuitoolkit.CheckBox, |
| 945 |
objectName='dialpadSounds') |
| 946 |
|
| 947 |
@autopilot.logging.log_action(logger.info) |
| 948 |
def enable_dialpad_sounds(self): |
| 949 |
"""Enable dialpad sounds.""" |
| 950 |
self._dialpad_sounds.check() |
| 951 |
|
| 952 |
@autopilot.logging.log_action(logger.info) |
| 953 |
def disable_dialpad_sounds(self): |
| 954 |
"""Disable dialpad sounds.""" |
| 955 |
self._dialpad_sounds.uncheck() |
| 956 |
|
| 957 |
@autopilot.logging.log_action(logger.info) |
| 958 |
def _enter_call_waiting(self, sim=None): |
| 959 |
"""Open the Call Waiting settings page. |
| 960 |
|
| 961 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 962 |
Required parameter in dual SIM setups |
| 963 |
:returns: The Call Waiting settings page. |
| 964 |
|
| 965 |
""" |
| 966 |
find = "callWait" |
| 967 |
if sim is not None: |
| 968 |
find = "callWaitSim%d" % sim |
| 969 |
return self._go_to_page(find, 'callWaitingPage') |
| 970 |
|
| 971 |
@autopilot.logging.log_action(logger.info) |
| 972 |
def enable_call_waiting(self, sim): |
| 973 |
self._enter_call_waiting(sim).enable_call_waiting() |
| 974 |
|
| 975 |
@autopilot.logging.log_action(logger.info) |
| 976 |
def disable_call_waiting(self, sim): |
| 977 |
self._enter_call_waiting(sim).disable_call_waiting() |
| 978 |
|
| 979 |
@autopilot.logging.log_action(logger.info) |
| 980 |
def _enter_call_forwarding(self, sim=None): |
| 981 |
"""Open the Call Forwarding settings page. |
| 982 |
|
| 983 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 984 |
Required parameter in dual SIM setups |
| 985 |
:returns: The Call Forwarding settings page. |
| 986 |
|
| 987 |
""" |
| 988 |
find = "callFwd" |
| 989 |
if sim is not None: |
| 990 |
find = "callFwdSim%d" % sim |
| 991 |
|
| 992 |
return self._go_to_page(find, 'callForwardingPage') |
| 993 |
|
| 994 |
@autopilot.logging.log_action(logger.info) |
| 995 |
def set_forward_unconditionally(self, number, sim=None): |
| 996 |
"""Sets forwarding unconditionally to number on a sim. |
| 997 |
|
| 998 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 999 |
Required parameter in dual SIM setups |
| 1000 |
:param number: Number to which we want to forward. |
| 1001 |
:returns: The Call Forwarding settings page. |
| 1002 |
""" |
| 1003 |
fwd_page = self._enter_call_forwarding(sim) |
| 1004 |
fwd_page.set_forward_unconditionally(number) |
| 1005 |
return fwd_page |
| 1006 |
|
| 1007 |
@autopilot.logging.log_action(logger.info) |
| 1008 |
def unset_forward_unconditionally(self, sim=None): |
| 1009 |
"""Disables forwarding unconditionally on a sim. |
| 1010 |
|
| 1011 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1012 |
Required parameter in dual SIM setups |
| 1013 |
:returns: The Call Forwarding settings page. |
| 1014 |
""" |
| 1015 |
fwd_page = self._enter_call_forwarding(sim) |
| 1016 |
fwd_page.unset_forward_unconditionally() |
| 1017 |
return fwd_page |
| 1018 |
|
| 1019 |
@autopilot.logging.log_action(logger.info) |
| 1020 |
def get_forward_unconditionally(self, sim=None): |
| 1021 |
"""Return forwarding unconditionally value on sim. |
| 1022 |
|
| 1023 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1024 |
Required parameter in dual SIM setups |
| 1025 |
:returns: The forward unconditionally value. |
| 1026 |
""" |
| 1027 |
fwd_page = self._enter_call_forwarding(sim) |
| 1028 |
return fwd_page.get_forward_unconditionally() |
| 1029 |
|
| 1030 |
@autopilot.logging.log_action(logger.info) |
| 1031 |
def set_forward_on_busy(self, number, sim=None): |
| 1032 |
"""Sets forwarding when busy to number on a sim. |
| 1033 |
|
| 1034 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1035 |
Required parameter in dual SIM setups |
| 1036 |
:param number: Number to which we want to forward. |
| 1037 |
:returns: The Call Forwarding settings page. |
| 1038 |
""" |
| 1039 |
fwd_page = self._enter_call_forwarding(sim) |
| 1040 |
fwd_page.set_forward_on_busy(number) |
| 1041 |
return fwd_page |
| 1042 |
|
| 1043 |
@autopilot.logging.log_action(logger.info) |
| 1044 |
def unset_forward_on_busy(self, sim=None): |
| 1045 |
"""Disables forwarding when busy on a sim. |
| 1046 |
|
| 1047 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1048 |
Required parameter in dual SIM setups |
| 1049 |
:returns: The Call Forwarding settings page. |
| 1050 |
""" |
| 1051 |
fwd_page = self._enter_call_forwarding(sim) |
| 1052 |
fwd_page.unset_forward_on_busy() |
| 1053 |
return fwd_page |
| 1054 |
|
| 1055 |
@autopilot.logging.log_action(logger.info) |
| 1056 |
def get_forward_on_busy(self, sim=None): |
| 1057 |
"""Return forwarding on busy value on sim. |
| 1058 |
|
| 1059 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1060 |
Required parameter in dual SIM setups |
| 1061 |
:returns: The forward on busy value. |
| 1062 |
""" |
| 1063 |
fwd_page = self._enter_call_forwarding(sim) |
| 1064 |
return fwd_page.get_forward_on_busy() |
| 1065 |
|
| 1066 |
@autopilot.logging.log_action(logger.info) |
| 1067 |
def set_forward_when_no_answer(self, number, sim=None): |
| 1068 |
"""Sets forwarding when no answer to number on a sim. |
| 1069 |
|
| 1070 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1071 |
Required parameter in dual SIM setups |
| 1072 |
:param number: Number to which we want to forward. |
| 1073 |
:returns: The Call Forwarding settings page. |
| 1074 |
""" |
| 1075 |
fwd_page = self._enter_call_forwarding(sim) |
| 1076 |
fwd_page.set_forward_when_no_answer(number) |
| 1077 |
return fwd_page |
| 1078 |
|
| 1079 |
@autopilot.logging.log_action(logger.info) |
| 1080 |
def unset_forward_when_no_answer(self, sim=None): |
| 1081 |
"""Disables forwarding when no answer on a sim. |
| 1082 |
|
| 1083 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1084 |
Required parameter in dual SIM setups |
| 1085 |
:returns: The Call Forwarding settings page. |
| 1086 |
""" |
| 1087 |
fwd_page = self._enter_call_forwarding(sim) |
| 1088 |
fwd_page.unset_forward_when_no_answer() |
| 1089 |
return fwd_page |
| 1090 |
|
| 1091 |
@autopilot.logging.log_action(logger.info) |
| 1092 |
def get_forward_when_no_answer(self, sim=None): |
| 1093 |
"""Return forwarding when no answer value on sim. |
| 1094 |
|
| 1095 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1096 |
Required parameter in dual SIM setups |
| 1097 |
:returns: The forward when no answer value. |
| 1098 |
""" |
| 1099 |
fwd_page = self._enter_call_forwarding(sim) |
| 1100 |
return fwd_page.get_forward_when_no_answer() |
| 1101 |
|
| 1102 |
@autopilot.logging.log_action(logger.info) |
| 1103 |
def set_forward_when_unreachable(self, number, sim=None): |
| 1104 |
"""Sets forwarding when unreachable to number on a sim. |
| 1105 |
|
| 1106 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1107 |
Required parameter in dual SIM setups |
| 1108 |
:param number: Number to which we want to forward. |
| 1109 |
:returns: The Call Forwarding settings page. |
| 1110 |
""" |
| 1111 |
fwd_page = self._enter_call_forwarding(sim) |
| 1112 |
fwd_page.set_forward_when_unreachable(number) |
| 1113 |
return fwd_page |
| 1114 |
|
| 1115 |
@autopilot.logging.log_action(logger.info) |
| 1116 |
def unset_forward_when_unreachable(self, sim=None): |
| 1117 |
"""Disables forwarding when unreachable on a sim. |
| 1118 |
|
| 1119 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1120 |
Required parameter in dual SIM setups |
| 1121 |
""" |
| 1122 |
fwd_page = self._enter_call_forwarding(sim) |
| 1123 |
fwd_page.unset_forward_when_unreachable() |
| 1124 |
return fwd_page |
| 1125 |
|
| 1126 |
@autopilot.logging.log_action(logger.info) |
| 1127 |
def get_forward_when_unreachable(self, sim=None): |
| 1128 |
"""Return forwarding when unreachable value on sim. |
| 1129 |
|
| 1130 |
:param sim: Number of what SIM to use, either 1 or 2. |
| 1131 |
Required parameter in dual SIM setups |
| 1132 |
:returns: The forward when unreachable value. |
| 1133 |
""" |
| 1134 |
fwd_page = self._enter_call_forwarding(sim) |
| 1135 |
return fwd_page.get_forward_when_unreachable() |
| 1136 |
|
| 1137 |
|
| 1138 |
class CallWaiting(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1139 |
|
| 1140 |
"""Autopilot helper for the Call waiting page.""" |
| 1141 |
|
| 1142 |
@property |
| 1143 |
def _switch(self): |
| 1144 |
return self.wait_select_single( |
| 1145 |
lomiriuitoolkit.CheckBox, |
| 1146 |
objectName='callWaitingSwitch') |
| 1147 |
|
| 1148 |
def enable_call_waiting(self): |
| 1149 |
self._switch.check() |
| 1150 |
|
| 1151 |
def disable_call_waiting(self): |
| 1152 |
self._switch.uncheck() |
| 1153 |
|
| 1154 |
|
| 1155 |
class CallForwarding(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1156 |
|
| 1157 |
"""Autopilot helper for the Call forwarding page.""" |
| 1158 |
|
| 1159 |
@autopilot.logging.log_action(logger.info) |
| 1160 |
def _set_rule(self): |
| 1161 |
"""Saves rule.""" |
| 1162 |
button = self.wait_select_single('Button', |
| 1163 |
objectName='setButton') |
| 1164 |
self.pointing_device.click_object(button) |
| 1165 |
|
| 1166 |
@autopilot.logging.log_action(logger.info) |
| 1167 |
def _check_rule(self, rule, value): |
| 1168 |
"""Checks a rule's associated CheckBox with value. |
| 1169 |
|
| 1170 |
:param rule: The string representation of the rule. |
| 1171 |
:param value: The new value of the CheckBox. |
| 1172 |
""" |
| 1173 |
check = self.wait_select_single(lomiriuitoolkit.CheckBox, |
| 1174 |
objectName='check_%s' % rule) |
| 1175 |
if value: |
| 1176 |
check.check() |
| 1177 |
else: |
| 1178 |
check.uncheck() |
| 1179 |
|
| 1180 |
@autopilot.logging.log_action(logger.info) |
| 1181 |
def enable_rule(self, rule): |
| 1182 |
"""Enables a rule. |
| 1183 |
|
| 1184 |
:param rule: The string representation of the rule. |
| 1185 |
""" |
| 1186 |
self._check_rule(rule, True) |
| 1187 |
|
| 1188 |
@autopilot.logging.log_action(logger.info) |
| 1189 |
def disable_rule(self, rule): |
| 1190 |
"""Disables a rule. |
| 1191 |
|
| 1192 |
:param rule: The string representation of the rule. |
| 1193 |
""" |
| 1194 |
self._check_rule(rule, False) |
| 1195 |
|
| 1196 |
@autopilot.logging.log_action(logger.info) |
| 1197 |
def _enter_rule(self, rule, number): |
| 1198 |
"""Enters a number into a rule's associated TextField. |
| 1199 |
|
| 1200 |
:param rule: The string representation of the rule. |
| 1201 |
:param number: Number to enter into field. |
| 1202 |
""" |
| 1203 |
field = self.wait_select_single('TextField', |
| 1204 |
objectName='field_%s' % rule) |
| 1205 |
field.write(number) |
| 1206 |
|
| 1207 |
@autopilot.logging.log_action(logger.info) |
| 1208 |
def _get_rule(self, rule): |
| 1209 |
"""Returns the value of the rule. |
| 1210 |
|
| 1211 |
:param rule: The string representation of the rule. |
| 1212 |
""" |
| 1213 |
return self.wait_select_single(objectName='current_%s' % rule).value |
| 1214 |
|
| 1215 |
@autopilot.logging.log_action(logger.info) |
| 1216 |
def set_forward_unconditionally(self, number): |
| 1217 |
"""Sets forward unconditionally. |
| 1218 |
|
| 1219 |
:param number: Number to forward to. |
| 1220 |
""" |
| 1221 |
self.enable_rule('voiceUnconditional') |
| 1222 |
self._enter_rule('voiceUnconditional', number) |
| 1223 |
self._set_rule() |
| 1224 |
|
| 1225 |
@autopilot.logging.log_action(logger.info) |
| 1226 |
def unset_forward_unconditionally(self): |
| 1227 |
"""Disables forward unconditionally.""" |
| 1228 |
self.disable_rule('voiceUnconditional') |
| 1229 |
|
| 1230 |
@autopilot.logging.log_action(logger.info) |
| 1231 |
def get_forward_unconditionally(self): |
| 1232 |
"""Returns value of forward unconditionally.""" |
| 1233 |
return self._get_rule('voiceUnconditional') |
| 1234 |
|
| 1235 |
@autopilot.logging.log_action(logger.info) |
| 1236 |
def set_forward_on_busy(self, number): |
| 1237 |
"""Sets forward on busy. |
| 1238 |
|
| 1239 |
:param number: Number to forward to. |
| 1240 |
""" |
| 1241 |
self.enable_rule('voiceBusy') |
| 1242 |
self._enter_rule('voiceBusy', number) |
| 1243 |
self._set_rule() |
| 1244 |
|
| 1245 |
@autopilot.logging.log_action(logger.info) |
| 1246 |
def unset_forward_on_busy(self): |
| 1247 |
"""Disables forward on busy.""" |
| 1248 |
self.disable_rule('voiceBusy') |
| 1249 |
|
| 1250 |
@autopilot.logging.log_action(logger.info) |
| 1251 |
def get_forward_on_busy(self): |
| 1252 |
"""Returns value of forward on busy.""" |
| 1253 |
return self._get_rule('voiceBusy') |
| 1254 |
|
| 1255 |
@autopilot.logging.log_action(logger.info) |
| 1256 |
def set_forward_when_no_answer(self, number): |
| 1257 |
"""Sets forward on no answer. |
| 1258 |
|
| 1259 |
:param number: Number to forward to. |
| 1260 |
""" |
| 1261 |
self.enable_rule('voiceNoReply') |
| 1262 |
self._enter_rule('voiceNoReply', number) |
| 1263 |
self._set_rule() |
| 1264 |
|
| 1265 |
@autopilot.logging.log_action(logger.info) |
| 1266 |
def unset_forward_when_no_answer(self): |
| 1267 |
"""Disables forward when no answer.""" |
| 1268 |
self.disable_rule('voiceNoReply') |
| 1269 |
|
| 1270 |
@autopilot.logging.log_action(logger.info) |
| 1271 |
def get_forward_when_no_answer(self): |
| 1272 |
"""Returns value of forward on no answer.""" |
| 1273 |
return self._get_rule('voiceNoReply') |
| 1274 |
|
| 1275 |
@autopilot.logging.log_action(logger.info) |
| 1276 |
def set_forward_when_unreachable(self, number): |
| 1277 |
"""Sets forward when unreachable. |
| 1278 |
|
| 1279 |
:param number: Number to forward to. |
| 1280 |
""" |
| 1281 |
self.enable_rule('voiceNotReachable') |
| 1282 |
self._enter_rule('voiceNotReachable', number) |
| 1283 |
self._set_rule() |
| 1284 |
|
| 1285 |
@autopilot.logging.log_action(logger.info) |
| 1286 |
def unset_forward_when_unreachable(self): |
| 1287 |
"""Disables forward when unreachable.""" |
| 1288 |
self.disable_rule('voiceNotReachable') |
| 1289 |
|
| 1290 |
@autopilot.logging.log_action(logger.info) |
| 1291 |
def get_forward_when_unreachable(self): |
| 1292 |
"""Returns value of forward when unreachable.""" |
| 1293 |
return self._get_rule('voiceNotReachable') |
| 1294 |
|
| 1295 |
|
| 1296 |
class Services(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1297 |
|
| 1298 |
"""Autopilot helper for the Sim Services page.""" |
| 1299 |
|
| 1300 |
# TODO: add pages for each relevant sim services page |
| 1301 |
def open_sim_service(self, service): |
| 1302 |
"""Return a sim service page""" |
| 1303 |
pass |
| 1304 |
|
| 1305 |
|
| 1306 |
class ResetPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1307 |
|
| 1308 |
"""Autopilot helper for the Reset page.""" |
| 1309 |
|
| 1310 |
@classmethod |
| 1311 |
def validate_dbus_object(cls, path, state): |
| 1312 |
name = introspection.get_classname_from_path(path) |
| 1313 |
if name == b'PageComponent': |
| 1314 |
if state['objectName'][1] == 'resetPage': |
| 1315 |
return True |
| 1316 |
return False |
| 1317 |
|
| 1318 |
@autopilot.logging.log_action(logger.info) |
| 1319 |
def reset_launcher(self): |
| 1320 |
"""Reset the launcher. |
| 1321 |
|
| 1322 |
:returns: The main system settings page object, that will be visible |
| 1323 |
after the reset is complete. |
| 1324 |
|
| 1325 |
""" |
| 1326 |
confirm_dialog = self._click_reset_launcher() |
| 1327 |
confirm_dialog.confirm_reset() |
| 1328 |
return self._wait_and_return_main_system_settins_page() |
| 1329 |
|
| 1330 |
@autopilot.logging.log_action(logger.debug) |
| 1331 |
def _click_reset_launcher(self): |
| 1332 |
button = self.select_single(objectName='resetLauncher') |
| 1333 |
self.pointing_device.click_object(button) |
| 1334 |
return self.get_root_instance().wait_select_single( |
| 1335 |
objectName='resetLauncherDialog') |
| 1336 |
|
| 1337 |
def _wait_and_return_main_system_settins_page(self): |
| 1338 |
main_view = self.get_root_instance().select_single( |
| 1339 |
objectName='systemSettingsMainView') |
| 1340 |
main_view.system_settings_page.active.wait_for(True) |
| 1341 |
return main_view.system_settings_page |
| 1342 |
|
| 1343 |
@autopilot.logging.log_action(logger.info) |
| 1344 |
def erase_and_reset_everything(self): |
| 1345 |
"""Reset to factory settings. |
| 1346 |
|
| 1347 |
:returns: The main system settings page object, that will be visible |
| 1348 |
after the reset is complete. |
| 1349 |
|
| 1350 |
""" |
| 1351 |
confirm_dialog = self._click_factory_reset() |
| 1352 |
confirm_dialog.confirm_reset() |
| 1353 |
return self._wait_and_return_main_system_settins_page() |
| 1354 |
|
| 1355 |
@autopilot.logging.log_action(logger.debug) |
| 1356 |
def _click_factory_reset(self): |
| 1357 |
button = self.select_single(objectName='factoryReset') |
| 1358 |
self.pointing_device.click_object(button) |
| 1359 |
return self.get_root_instance().select_single( |
| 1360 |
objectName='factoryResetDialog') |
| 1361 |
|
| 1362 |
|
| 1363 |
class ResetLauncherConfirmationDialog( |
| 1364 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1365 |
|
| 1366 |
"""Autopilot helper for the Reset Launcher Confirmation dialog.""" |
| 1367 |
|
| 1368 |
@classmethod |
| 1369 |
def validate_dbus_object(cls, path, state): |
| 1370 |
name = introspection.get_classname_from_path(path) |
| 1371 |
if name == b'Dialog': |
| 1372 |
if state['objectName'][1] == 'resetLauncherDialog': |
| 1373 |
return True |
| 1374 |
return False |
| 1375 |
|
| 1376 |
@autopilot.logging.log_action(logger.debug) |
| 1377 |
def confirm_reset(self): |
| 1378 |
button = self.select_single('Button', objectName='resetLauncherAction') |
| 1379 |
self.pointing_device.click_object(button) |
| 1380 |
|
| 1381 |
|
| 1382 |
class FactoryResetConfirmationDialog( |
| 1383 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1384 |
|
| 1385 |
"""Autopilot helper for the Reset Launcher Confirmation dialog.""" |
| 1386 |
|
| 1387 |
@classmethod |
| 1388 |
def validate_dbus_object(cls, path, state): |
| 1389 |
name = introspection.get_classname_from_path(path) |
| 1390 |
if name == b'Dialog': |
| 1391 |
if state['objectName'][1] == 'factoryResetDialog': |
| 1392 |
return True |
| 1393 |
return False |
| 1394 |
|
| 1395 |
@autopilot.logging.log_action(logger.debug) |
| 1396 |
def confirm_reset(self): |
| 1397 |
button = self.select_single('Button', objectName='factoryResetAction') |
| 1398 |
self.pointing_device.click_object(button) |
| 1399 |
|
| 1400 |
|
| 1401 |
class LanguagePage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1402 |
|
| 1403 |
"""Autopilot helper for the Language page.""" |
| 1404 |
|
| 1405 |
@classmethod |
| 1406 |
def validate_dbus_object(cls, path, state): |
| 1407 |
name = introspection.get_classname_from_path(path) |
| 1408 |
if name == b'PageComponent': |
| 1409 |
if state['objectName'][1] == 'languagePage': |
| 1410 |
return True |
| 1411 |
return False |
| 1412 |
|
| 1413 |
def get_current_language(self): |
| 1414 |
return self.wait_select_single( |
| 1415 |
objectName='currentLanguage').currentLanguage |
| 1416 |
|
| 1417 |
def _click_change_display_language(self): |
| 1418 |
item = self.select_single(objectName='displayLanguage') |
| 1419 |
self.pointing_device.click_object(item) |
| 1420 |
return self.get_root_instance().select_single( |
| 1421 |
objectName='displayLanguageDialog') |
| 1422 |
|
| 1423 |
@autopilot.logging.log_action(logger.info) |
| 1424 |
def change_display_language(self, langIndex, reboot=True): |
| 1425 |
"""Changes display language. |
| 1426 |
|
| 1427 |
:param langIndex: The language index to change to. |
| 1428 |
|
| 1429 |
:param reboot: Whether to reboot or not |
| 1430 |
|
| 1431 |
:returns: The language page |
| 1432 |
|
| 1433 |
""" |
| 1434 |
dialog = self._click_change_display_language() |
| 1435 |
dialog.set_language(langIndex, reboot) |
| 1436 |
return self.get_root_instance() |
| 1437 |
|
| 1438 |
|
| 1439 |
class DisplayLanguage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1440 |
|
| 1441 |
"""Autopilot helper for the Display Language dialog.""" |
| 1442 |
|
| 1443 |
@autopilot.logging.log_action(logger.debug) |
| 1444 |
def set_language(self, index, reboot): |
| 1445 |
self._click_language_item(index) |
| 1446 |
reboot_dialog = self._click_confirm() |
| 1447 |
|
| 1448 |
if reboot: |
| 1449 |
reboot_dialog.reboot() |
| 1450 |
else: |
| 1451 |
reboot_dialog.revert() |
| 1452 |
|
| 1453 |
@autopilot.logging.log_action(logger.debug) |
| 1454 |
def _click_language_item(self, index): |
| 1455 |
languages_list = self.select_single('QQuickListView', |
| 1456 |
objectName='languagesList') |
| 1457 |
languages_list.click_element('languageName%d' % index) |
| 1458 |
|
| 1459 |
@autopilot.logging.log_action(logger.debug) |
| 1460 |
def _click_confirm(self): |
| 1461 |
button = self.select_single('Button', |
| 1462 |
objectName='confirmChangeLanguage') |
| 1463 |
self.pointing_device.click_object(button) |
| 1464 |
return self.get_root_instance().select_single( |
| 1465 |
objectName='rebootNecessaryDialog') |
| 1466 |
|
| 1467 |
@autopilot.logging.log_action(logger.debug) |
| 1468 |
def _click_cancel(self): |
| 1469 |
button = self.select_single('Button', |
| 1470 |
objectName='cancelChangeLanguage') |
| 1471 |
self.pointing_device.click_object(button) |
| 1472 |
|
| 1473 |
|
| 1474 |
class RebootNecessary( |
| 1475 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1476 |
|
| 1477 |
"""Autopilot helper for the Reboot Necessary dialog.""" |
| 1478 |
|
| 1479 |
@autopilot.logging.log_action(logger.debug) |
| 1480 |
def reboot(self): |
| 1481 |
self._click_reboot() |
| 1482 |
|
| 1483 |
@autopilot.logging.log_action(logger.debug) |
| 1484 |
def revert(self): |
| 1485 |
self._click_revert() |
| 1486 |
|
| 1487 |
@autopilot.logging.log_action(logger.debug) |
| 1488 |
def _click_reboot(self): |
| 1489 |
button = self.select_single('Button', objectName='reboot') |
| 1490 |
self.pointing_device.click_object(button) |
| 1491 |
|
| 1492 |
@autopilot.logging.log_action(logger.debug) |
| 1493 |
def _click_revert(self): |
| 1494 |
button = self.select_single('Button', objectName='revert') |
| 1495 |
self.pointing_device.click_object(button) |
| 1496 |
|
| 1497 |
|
| 1498 |
class WifiPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1499 |
|
| 1500 |
"""Autopilot helper for the WiFi page.""" |
| 1501 |
|
| 1502 |
@classmethod |
| 1503 |
def validate_dbus_object(cls, path, state): |
| 1504 |
name = introspection.get_classname_from_path(path) |
| 1505 |
if name == b'PageComponent': |
| 1506 |
if state['objectName'][1] == 'wifiPage': |
| 1507 |
return True |
| 1508 |
return False |
| 1509 |
|
| 1510 |
@autopilot.logging.log_action(logger.debug) |
| 1511 |
def enable_wireless(self): |
| 1512 |
self._set_wireless(True) |
| 1513 |
|
| 1514 |
@autopilot.logging.log_action(logger.debug) |
| 1515 |
def disable_wireless(self): |
| 1516 |
self._set_wireless(False) |
| 1517 |
|
| 1518 |
""" |
| 1519 |
:returns: Whether or not WiFi can be used |
| 1520 |
""" |
| 1521 |
@autopilot.logging.log_action(logger.debug) |
| 1522 |
def have_wireless(self): |
| 1523 |
try: |
| 1524 |
self.wait_select_single('SwitchMenu', text=_('Wi-Fi')) |
| 1525 |
except StateNotFoundError: |
| 1526 |
return False |
| 1527 |
return True |
| 1528 |
|
| 1529 |
"""Returns the current WiFi state |
| 1530 |
|
| 1531 |
:returns: Whether or not WiFi is enabled |
| 1532 |
""" |
| 1533 |
@autopilot.logging.log_action(logger.debug) |
| 1534 |
def get_wireless(self): |
| 1535 |
return self.wait_select_single( |
| 1536 |
'SwitchMenu', text=_('Wi-Fi')).checked |
| 1537 |
|
| 1538 |
@autopilot.logging.log_action(logger.debug) |
| 1539 |
def _set_wireless(self, state): |
| 1540 |
obj = self.wait_select_single('SwitchMenu', text=_('Wi-Fi')) |
| 1541 |
if obj.checked != state: |
| 1542 |
self.pointing_device.click_object(obj) |
| 1543 |
|
| 1544 |
@autopilot.logging.log_action(logger.debug) |
| 1545 |
def go_to_previous_networks(self): |
| 1546 |
return self._click_previous_network() |
| 1547 |
|
| 1548 |
"""Removes previous network |
| 1549 |
|
| 1550 |
:param ssid: Network name string (SSID) |
| 1551 |
|
| 1552 |
:returns: PreviousNetwork page |
| 1553 |
|
| 1554 |
""" |
| 1555 |
@autopilot.logging.log_action(logger.debug) |
| 1556 |
def remove_previous_network(self, ssid): |
| 1557 |
page = self.go_to_previous_networks() |
| 1558 |
details = page.select_network(ssid) |
| 1559 |
details.forget_network() |
| 1560 |
return page |
| 1561 |
|
| 1562 |
@autopilot.logging.log_action(logger.debug) |
| 1563 |
def _click_previous_network(self): |
| 1564 |
|
| 1565 |
# we can't mock the qunitymenu items, so we |
| 1566 |
# have to wait for them to be built |
| 1567 |
sleep(0.5) |
| 1568 |
|
| 1569 |
button = self.select_single('*', |
| 1570 |
objectName='previousNetwork') |
| 1571 |
self._scroll_to_and_click(button) |
| 1572 |
return self.get_root_instance().wait_select_single( |
| 1573 |
objectName='previousNetworksPage') |
| 1574 |
|
| 1575 |
|
| 1576 |
class OtherNetwork( |
| 1577 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1578 |
|
| 1579 |
"""Autopilot helper for the Connect to Hidden Network dialog.""" |
| 1580 |
|
| 1581 |
@classmethod |
| 1582 |
def validate_dbus_object(cls, path, state): |
| 1583 |
name = introspection.get_classname_from_path(path) |
| 1584 |
if name == b'Dialog': |
| 1585 |
if state['objectName'][1] == 'otherNetworkDialog': |
| 1586 |
return True |
| 1587 |
return False |
| 1588 |
|
| 1589 |
@autopilot.logging.log_action(logger.debug) |
| 1590 |
def enter_password(self, password): |
| 1591 |
self._enter_password(password) |
| 1592 |
|
| 1593 |
@autopilot.logging.log_action(logger.debug) |
| 1594 |
def _enter_password(self, password): |
| 1595 |
pwdfield = self.wait_select_single('TextField', |
| 1596 |
objectName='password') |
| 1597 |
self._scroll_to_and_click(pwdfield) |
| 1598 |
pwdfield.write(password) |
| 1599 |
|
| 1600 |
@autopilot.logging.log_action(logger.debug) |
| 1601 |
def connect(self): |
| 1602 |
self._click_connect() |
| 1603 |
|
| 1604 |
@autopilot.logging.log_action(logger.debug) |
| 1605 |
def _click_connect(self): |
| 1606 |
button = self.select_single('Button', objectName='connect') |
| 1607 |
self._scroll_to_and_click(button) |
| 1608 |
|
| 1609 |
|
| 1610 |
class PreviousNetworks( |
| 1611 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1612 |
|
| 1613 |
"""Autopilot helper for the Previous Networks page.""" |
| 1614 |
|
| 1615 |
@classmethod |
| 1616 |
def validate_dbus_object(cls, path, state): |
| 1617 |
name = introspection.get_classname_from_path(path) |
| 1618 |
if name == b'ItemPage': |
| 1619 |
if state['objectName'][1] == 'previousNetworksPage': |
| 1620 |
return True |
| 1621 |
return False |
| 1622 |
|
| 1623 |
@autopilot.logging.log_action(logger.debug) |
| 1624 |
def select_network(self, name): |
| 1625 |
self._select_network(name) |
| 1626 |
return self.get_root_instance().wait_select_single( |
| 1627 |
objectName='networkDetailsPage') |
| 1628 |
|
| 1629 |
@autopilot.logging.log_action(logger.debug) |
| 1630 |
def _select_network(self, name): |
| 1631 |
net = self.select_single('StandardProgression', text=name) |
| 1632 |
self.pointing_device.click_object(net) |
| 1633 |
|
| 1634 |
|
| 1635 |
class NetworkDetails( |
| 1636 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1637 |
|
| 1638 |
"""Autopilot helper for the Networks Details page.""" |
| 1639 |
|
| 1640 |
@autopilot.logging.log_action(logger.debug) |
| 1641 |
def forget_network(self): |
| 1642 |
self._click_forget() |
| 1643 |
|
| 1644 |
@autopilot.logging.log_action(logger.debug) |
| 1645 |
def _click_forget(self): |
| 1646 |
button = self.select_single('Button', objectName='forgetNetwork') |
| 1647 |
self.pointing_device.click_object(button) |
| 1648 |
|
| 1649 |
|
| 1650 |
class VpnPage(lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase): |
| 1651 |
|
| 1652 |
"""Autopilot helper for the VPN page.""" |
| 1653 |
|
| 1654 |
@classmethod |
| 1655 |
def validate_dbus_object(cls, path, state): |
| 1656 |
name = introspection.get_classname_from_path(path) |
| 1657 |
if name == b'PageComponent': |
| 1658 |
if state['objectName'][1] == 'vpnPage': |
| 1659 |
return True |
| 1660 |
return False |
| 1661 |
|
| 1662 |
@autopilot.logging.log_action(logger.debug) |
| 1663 |
def add_vpn(self): |
| 1664 |
obj = self.select_single(objectName='addVpnButton') |
| 1665 |
self.get_root_instance().main_view.scroll_to_and_click(obj) |
| 1666 |
return self.get_root_instance().wait_select_single( |
| 1667 |
objectName='vpnEditor') |
| 1668 |
|
| 1669 |
@autopilot.logging.log_action(logger.debug) |
| 1670 |
def preview_vpn(self, at): |
| 1671 |
obj = self.wait_select_single(objectName='vpnListConnection%d' % at) |
| 1672 |
self.get_root_instance().main_view.scroll_to_and_click(obj) |
| 1673 |
return self.get_root_instance().wait_select_single( |
| 1674 |
objectName='vpnPreviewDialog') |
| 1675 |
|
| 1676 |
@autopilot.logging.log_action(logger.debug) |
| 1677 |
def change_vpn(self, at): |
| 1678 |
diag = self.preview_vpn(at) |
| 1679 |
change_button = diag.wait_select_single( |
| 1680 |
objectName='vpnPreviewChangeButton' |
| 1681 |
) |
| 1682 |
self.get_root_instance().main_view.scroll_to_and_click(change_button) |
| 1683 |
return self.get_root_instance().wait_select_single( |
| 1684 |
objectName='vpnEditor') |
| 1685 |
|
| 1686 |
|
| 1687 |
class VpnEditor( |
| 1688 |
lomiriuitoolkit.LomiriUIToolkitCustomProxyObjectBase |
| 1689 |
): |
| 1690 |
"""Autopilot helper for vpn change dialog.""" |
| 1691 |
|
| 1692 |
@property |
| 1693 |
def _openvpn_server_field(self): |
| 1694 |
return self.wait_select_single( |
| 1695 |
lomiriuitoolkit.TextField, |
| 1696 |
objectName='vpnOpenvpnServerField') |
| 1697 |
|
| 1698 |
@property |
| 1699 |
def _openvpn_port_field(self): |
| 1700 |
return self.wait_select_single( |
| 1701 |
lomiriuitoolkit.TextField, |
| 1702 |
objectName='vpnOpenvpnPortField') |
| 1703 |
|
| 1704 |
@property |
| 1705 |
def _openvpn_custom_port_toggle(self): |
| 1706 |
return self.wait_select_single( |
| 1707 |
lomiriuitoolkit.CheckBox, |
| 1708 |
objectName='vpnOpenvpnCustomPortToggle') |
| 1709 |
|
| 1710 |
@property |
| 1711 |
def _openvpn_tcp_toggle(self): |
| 1712 |
return self.wait_select_single( |
| 1713 |
lomiriuitoolkit.CheckBox, |
| 1714 |
objectName='vpnOpenvpnTcpToggle') |
| 1715 |
|
| 1716 |
@property |
| 1717 |
def _openvpn_udp_toggle(self): |
| 1718 |
return self.wait_select_single( |
| 1719 |
lomiriuitoolkit.CheckBox, |
| 1720 |
objectName='vpnOpenvpnUdpToggle') |
| 1721 |
|
| 1722 |
@property |
| 1723 |
def _openvpn_ca_field(self): |
| 1724 |
return self.wait_select_single(objectName='vpnOpenvpnCaField') |
| 1725 |
|
| 1726 |
@property |
| 1727 |
def _openvpn_ok_button(self): |
| 1728 |
return self.wait_select_single( |
| 1729 |
'Button', objectName='vpnEditorOkayButton') |
| 1730 |
|
| 1731 |
@autopilot.logging.log_action(logger.debug) |
| 1732 |
def set_openvpn_server(self, server): |
| 1733 |
self.get_root_instance().main_view.scroll_to( |
| 1734 |
self._openvpn_server_field |
| 1735 |
) |
| 1736 |
self._openvpn_server_field.write(server) |
| 1737 |
|
| 1738 |
@autopilot.logging.log_action(logger.debug) |
| 1739 |
def set_openvpn_custom_port(self, port): |
| 1740 |
self.get_root_instance().main_view.scroll_to( |
| 1741 |
self._openvpn_custom_port_toggle |
| 1742 |
) |
| 1743 |
self._openvpn_custom_port_toggle.check() |
| 1744 |
# XXX: workaround for lp:1546559, i.e. we need to wait |
| 1745 |
# some time between writing to the API. |
| 1746 |
sleep(1) |
| 1747 |
self._openvpn_port_field.write(port) |
| 1748 |
|
| 1749 |
@autopilot.logging.log_action(logger.debug) |
| 1750 |
def set_openvpn_ca(self, paths): |
| 1751 |
self.set_openvpn_file(self._openvpn_ca_field, paths) |
| 1752 |
|
| 1753 |
@autopilot.logging.log_action(logger.debug) |
| 1754 |
def set_openvpn_file(self, field, paths): |
| 1755 |
utils.dismiss_osk() |
| 1756 |
self.get_root_instance().main_view.scroll_to_and_click(field) |
| 1757 |
|
| 1758 |
# Wait for expanded animation. |
| 1759 |
sleep(0.5) |
| 1760 |
|
| 1761 |
# file = field.wait_select_single(objectName='vpnFileSelectorItem0') |
| 1762 |
choose = field.wait_select_single(objectName='vpnFileSelectorItem1') |
| 1763 |
self.pointing_device.click_object(choose) |
| 1764 |
self.get_root_instance().main_view.scroll_to_and_click(choose) |
| 1765 |
file_dialog = self.get_root_instance().wait_select_single( |
| 1766 |
objectName='vpnDialogFile' |
| 1767 |
) |
| 1768 |
|
| 1769 |
# Go to root / |
| 1770 |
root = file_dialog.wait_select_single(objectName='vpnFilePathItem_/') |
| 1771 |
self.pointing_device.click_object(root) |
| 1772 |
|
| 1773 |
for path in paths: |
| 1774 |
list_view = file_dialog.wait_select_single( |
| 1775 |
'QQuickListView', objectName='vpnFileList' |
| 1776 |
) |
| 1777 |
list_view.click_element('vpnFileItem_%s' % path) |
| 1778 |
accept = file_dialog.wait_select_single(objectName='vpnFileAccept') |
| 1779 |
self.pointing_device.click_object(accept) |
| 1780 |
|
| 1781 |
@autopilot.logging.log_action(logger.debug) |
| 1782 |
def openvpn_okay(self): |
| 1783 |
utils.dismiss_osk() |
| 1784 |
self.get_root_instance().main_view.scroll_to_and_click( |
| 1785 |
self._openvpn_ok_button |
| 1786 |
) |