~ken-vandine/ubuntu-system-settings/rtm_click_framework_check

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_system_settings/__init__.py

[ CI bot ]
* Resync trunk
[ Michael Zanetti ]
* update code to reset launcher after launcher backend implementation
  was reworked (LP: #1376707)
[ Sebastien Bacher ]
* [storage] translator comment for the string "%1 free" (LP: #1377929)
* [system-update] ellipsize labels if needed (LP: #1376286)
* [sound] Use the correct low icon (LP: #1376286)
[ Lars Uebernickel ]
* notification-manager: fix issues with GVariant API usage
[ jonas-drange ]
* [security/privacy] allow user to change HERE and location detection
  settings. (LP: #1375322)
[ Ken VanDine ]
* Updated the pot file.
[ jonas-drange ]
* [cellular] indirectly recreate ConnectionManager interface's dbus
  proxy so it reports the true value of 'Powered' after flight mode
  (LP: #1376957)
[ Iain Lane ]
* [sound] Make listSounds take a list of directories and list all of
  the files in them, instead of assuming "/custom" all the time.
[ Ubuntu daily release ]
* New rebuild forced
[ Sebastien Bacher ]
* [sound] list custom ringtones as well (LP: #1381528)
[ Ken VanDine ]
* Add an APN editor. (LP: #1225174)
[ Michael Terry ]
* Complete the unlock security screens and update a host of other
  small design issues. (LP: #1365034, LP: #1348362) (LP: #1365034,
  #1348362)
[ Diego Sarmentero ]
* Improves in network backend. Detect network connection and show
  "Connect to the internet..." message or retry on netword detected. .
* Detect account added on online accounts (LP: #1362149)
[ jonas-drange ]
* [wifi/phone] dynamically chooses what SIM to use when there's only
  one present. (LP: #1375832)
[ Iain Lane ]
* [storage/about] Use a QSharedPointer to manage freeing of the
  counter which we use to display all of the collected sizes at once.
  If the measuring process was cancelled, we were freeing it multiple
  times - once for each outstanding size measurement. This led to a
  crash. (LP: #1375988)
* [security-privacy] Link with gobject, uses symbols from this
  library. Prevents "[…]libUbuntuSecurityPrivacyPanel.so contains an
  unresolvable reference to symbol
  g_signal_handlers_disconnect_matched: it's probably a plugin"
  warnings.
[ jonas-drange ]
* [cellular] react to application.state changes and update potential
  out-of-date default SIM settings (LP: #1364103)
* [wifi] let removed networks update the previous network model so
  that we can reuse the model (and not pop the pagestack twice,
  causing this ux issue) (LP: #1370389)
[ Sebastien Bacher ]
* [location] use a flickable so the list can be scrolled (LP:
  #1374017)
* [security] get localized application names from the trust-store (LP:
  #1374018)
[ Ken VanDine ]
* Fixed handling of the Downloading/Installing label based on actual
  state. . Forward updateProgress signals for system updates. Layout
  fixes (LP: #1312587)
* Use new splash screen (LP: #1376242)
* Improved tracking download states
* Use new target_build_number from system-image-dbus to determine
  visibility of the update notification (LP: #1355803)
[ CI bot ]
* Resync trunk
[ Sebastien Bacher ]
* [storage] use libclick rather than calling the command line (LP:
  #1368967)
* [storage] tweaks to the disk informations, limit the free space to
  the user available one (excluding the system partitions), don't list
  the external mounts, that's described in the design and is going to
  require work on the categories computation to give correct values
  (LP: #1284247)
* [about] display the free space value next to the storage label (LP:
  #1335144)
[ Albert Astals ]
* Add i18n.tr
[ jonas-drange ]
* [wifi] connect to hidden network is now a dialog (LP: #1366005)
[ Ken VanDine ]
* Provide more keywords to make search useful (LP: #1370219) (LP:
  #1370219)
* [background] set sourceSize in the image preview to work around an
  issue loading large images (LP: #1373462)
[ CI bot ]
* Resync trunk
[ Mathieu Trudel-Lapierre ]
* [bluetooth] Properly handle device types for connection and
  disconnection. (LP: #1369964)
[ Michael Terry ]
* Add a translator comment for what HERE means. (LP: #1368838) (LP:
  #1368838)
* Prevent a crash in unity8 when the wizard also crashes or stops
  early. (LP: #1355892) (LP: #1355892)
[ Michael Terry ]
* Prevent the buttons of the wizard's password page from overlapping
  its content when the OSK appears. (LP: #1368346) (LP: #1368346)
[ Ken VanDine ]
* Set the version information in the SystemUpdate constructor (LP:
  #1371810) (LP: #1371810)
* [reset] Don't bail out on an isValid() check on the SystemImage
  QDBusInterface, the docs say isValid() may not be reliable for
  remote interfaces (LP: #1370815) (LP: #1370815)
* Fixed reference error for count on the various device models (LP:
  #1362517) (LP: #1362517)
* [background] Use the ContentPeerPicker to select sources for
  backgrounds (LP: #1356542) (LP: #1356542)
[ Iain Lane ]
* Don't check if the timedated interface is valid before calling
  SetTime on it, it might have timed out and we should reactivate it
  in that case.
* [about] Fix developerMode property to be QMLish - read & write
  instead of separate "read" and "toggle" properties.
* [about] Don't display a frame for icons that can't be found,
  improving the visual appearance. Also return the correct path for
  click packages which use the icon theme.
[ Sebastien Bacher ]
* [storage] handle the scope click .ini and get the correct icons (LP:
  #1368920)
[ Albert Astals ]
* make pot
[ Oliver Grawert ]
* fix LP: #1365903, add a watch to Developer Mode page so the page
  gets refreshed when going back through the page stack, also fix the
  page id and bounds (LP: #1365903)
* Some packaging fixes
  - > is not a valid relationship. It should be >>
  - Don't recommend suru-icon-theme since we also depend on it
  - Bump S-V to 3.9.6 which for example allows the images we ship in
    /usr/lib/
  - Override binary-no-manpage lintian warnings. We're not going to get man
    pages for u-s-s any time soon
[ Ken VanDine ]
* Make UpdateManager a singleton and refresh the availableUpdates
  count when the model updates (LP: #1325629) (LP: #1325629)
[ Ken VanDine ]
* Include an icon instead of using the themed icon (LP: #1365408) (LP:
  #1365408)
[ Mathieu Trudel-Lapierre ]
* [bluetooth] don't try to enable Discoverable if the device isn't
  powered yet. (LP: #1355904)
[ Ken VanDine ]
* When activated by a url request for a specific panel, clear the
  pageStack to maintain the natural navigation instead of pushing a
  new page on top of a page from a the previous panel (LP: #1362025)
  (LP: #1362025, #1359953)
[ Lars Uebernickel ]
* Use Icon instead of StatusIcon
[ CI bot ]
* Resync trunk
[ John R. Lenton ]
* Take the system settings push helper closer to implementing the spec
  at https://wiki.ubuntu.com/SoftwareUpdates#Prompting (LP: #1363972)
[ Ken VanDine ]
* Don't try to tweak the bottomMargin for the OSK, it was trying to
  calculate it based on an undefined component so failing. It
  shouldn't be needed anyway.
[ jonas-drange ]
* [wifi] "Other Network" -> "Connect to hidden network" (LP: #1365984)
* [wifi] fix bad looking buttons in "Other Networks" panel (LP:
  #1362127)
[ Jussi Pakkanen ]
* Hide entry to connect to hidden network when wifi is off. (LP:
  #1365960)
[ Ken VanDine ]
* Fixed tests for the dialpad settings failing on mako
* Don't call downloadUpdate when we see a system update ready, the
  service does that for us (LP: #1368294) (LP: #1368294)
* Translate desktop file (LP: #1318008) (LP: #1318008)
[ Martin Pitt ]
* update POT
[ Sebastien Bacher ]
* [system-update] open the ubuntuone subpanel rather than the list
  (LP: #1348580)
* [security-privacy] use ngettext strings when needed (LP: #1368159)
* Increase vertical spacing in the settings grid (LP: #1348579)
[ jonas-drange ]
* [background] always keep custom images, and remove press-and-hold
  action. (LP: #1365167)
* [wifi] do not use predictive text for network name input (LP:
  #1365992)
* [language] workaround for transition bug in keyboard layout menu
  (LP: #1350809)
* [wifi] factory was setting the icon property, which was causing the
  icon to not render (LP: #1364366)
[ Alejandro J. Cura ]
* Fixing the refreshing of the apps scope (LP: #1360369)
[ Sebastien Bacher ]
* [sound] use the correct backend to control the keyboard sound toggle
  (LP: #1366208)
[ Ken VanDine ]
* Don't call downloadUpdate for system updates that are already
  downloading (LP: #1365646) (LP: #1311219, #1365646)
[ Ken VanDine ]
* Notify the user if the phone needs to be plug to power for update.
[ Sebastien Bacher ]
* [system-update] don't draw a frame around ubuntu updates (LP:
  #1367136)
[ Mathieu Trudel-Lapierre ]
* Also allow Speakers and Carkits as valid audio devices to pair.
[ Michael Terry ]
* Allow switch from PIN code to passphrase and back using the same
  password. (LP: #1357043) (LP: #1357043)
* Fix false-negatives from AccountsService when switching from swipe
  to password (LP: #1363405) (LP: #1363405)
[ Ricardo Salveti de Araujo ]
* sound: setting default audio role for ringtone and messages
[ Michael Terry ]
* Don't crash when destructing the Wizard.Utils.System plugin. This
  fixes the crash on wizard exit and the crash when pressing back on
  the HERE license.
[ CI bot ]
* Resync trunk
[ Sebastien Bacher ]
* [developer-mode] working scrolling and correct spacing
* Use standard items for the categories and don't display dividers
  (LP: #1365563)
* [orientation-lock] don't display a frame around the icon (LP:
  #1365450)
[ jonas-drange ]
* [about/versions] create reusable component of singlevalue items that
  have long values (LP: #1363927)
[ David Barth ]
* Enable location panel, display contols for authorized applications.
[ Ken VanDine ]
* Tweak the depends for accountsservice-ubuntu-schemas to handle a "~"
  version
[ CI bot ]
* Resync trunk
[ Guillermo Gonzalez ]
* Basic unittest for the push-helper script
[ Mathieu Trudel-Lapierre ]
* Downgrade qFatal failure to register bluetooth agent to a qCritical.
[ Andrea Cimitan ]
* Various fixes for wifi wizard page (LP: #1362296)
[ Sebastien Bacher ]
* [security] don't mark "%1" string as translatable
* [security] give a translation context to the 'None' string (LP:
  #1362143)
* [licenses] display an error when the copyright can't be read (LP:
  #1206150)
[ Michael Terry ]
* Avoid another race condition when switching password types by
  completing all DBus operations synchronously as we exit the
  policykit agent. LP: 1361137 (LP: #1361137)
* Fix the OSK not working on first boot. When the wizard closes, shut
  down maliit-server and the indicators so that unity8 can start them
  itself. LP: 1362679 (LP: #1362679)
[ jonas-drange ]
* [about] print out phone numbers for dual sims as well
* [about/wifi] adding mac addresses for bt and wifi, and ip for wifi
  (LP: #1356239)
* [language] explain to the user that a reboot is necessary for the
  change to take effect (LP: #1240875)
[ Michael Terry ]
* Make the HERE license optional, clearly mark it as a HERE license
  instead of an Ubuntu license, and connect it to the HERE backend.
[ CI bot ]
* Resync trunk
[ Martin Pitt ]
* POT update
[ Ken VanDine ]
* Added setting for dialpad sounds to both the sound and phone panels.
[ CI bot ]
* Resync trunk
[ Diego Sarmentero ]
* Fix out of sync image download. Refresh scope after installation
  (LP: #1324923)
[ Sebastien Bacher ]
* [battery] refresh the graph on a minute basis
* [notifications] use normal text style and ubuntushaped icons
[ Michael Terry ]
* When changing to swipe mode, it was possible that our policykit
  agent would not unregister itself, making the next attempt to change
  modes appear to work, but in truth fail. Also, no longer ask for a
  password to switch to swipe mode if policykit has a cached
  authentication for us. (LP: #1350381)
[ Sebastien Bacher ]
* [security] tweak some pin locking details to match the design better
[ Michael Terry ]
* Implement the "When locked, allow:" portion of the Security &
  Privacy panel, so now the user can control whether the launcher
  and/or indicators are available while locked. (LP: #1358340) (LP:
  #1358340)
[ Michael Terry ]
* Update look and feel of wizard to more closely match the visual
  design.
[ Jussi Pakkanen ]
* Minor cleanups.
[ Roberto Alsina ]
* Don't crash the push helper in locales that have no .mo file (LP:
  #1357506)
[ Ken VanDine ]
* SIM PIN lock implementation
[ jonas-drange ]
* [main panel] add visual feedback on press
* [cellular] uses modemtechnologies property from ofono to populate
  technology preference options (LP: #1346790)
[ Sebastien Bacher ]
* [language] workaround inconsistent languages casing (LP: #1362123)
* [background] Display the default background selected (LP: #1349329)
* [storage] display translated names (LP: #1360207)
* [updates] don't display animations when clicking on update rows (LP:
  #1360364)
* [background] don't use an icon in the headerbar (LP: #1362122)
[ Mathieu Trudel-Lapierre ]
* Fix PIN code or passcode requests by properly matching the tag for
  the original request. (LP: #1355152)
[ Martin Pitt ]
* Update PO template
[ Sebastien Bacher ]
* Include extra files for translations (LP: #1359267)
[ jonas-drange ]
* [main panel] show rotation lock, point to correct setting
[ Ken VanDine ]
* Hide sleep locks immediately setting, which isn't implemented yet
  (LP: #1361297) (LP: #1361297)
[ Sebastien Bacher ]
* [system-update] rework the ui to use a column rather than anchors,
  the layout is quite dynamic and it should be easier to position and
  stack widgets this way (LP: #1343172)
[ Michael Terry ]
* After selecting the language, update the session environment
  immediately and restart indicators so that their notifications (like
  wifi prompt) are translated. (LP: #1354325)
[ Ken VanDine ]
* Added autopilot tests for security-privacy
[ jonas-drange ]
* [phone] adding dual sim functionality to phone panel
[ Charles Kerr ]
* In the welcome wizard, refresh the text in the 'no sim card' and
  'all done' pages to match the latest from design.
[ Michael Terry ]
* Add a location page and a terms and conditions page for the HERE
  service.
[ Ken VanDine ]
* Settings for idle/lock timeout (LP: #1230345)
* Added flickable to fix scrolling (LP: #1354161)
[ Jussi Pakkanen ]
* Fix a bunch of compiler warnings.
[ jonas-drange ]
* [cellular] displays cellular UIs based on how many SIMs are present.
  (LP: #1357393)

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
from time import sleep
25
25
 
 
26
from autopilot.input import Keyboard
26
27
import autopilot.logging
27
28
import ubuntuuitoolkit
28
29
from autopilot import introspection, platform
29
 
 
 
30
from ubuntu_system_settings.utils.i18n import ugettext as _
30
31
 
31
32
logger = logging.getLogger(__name__)
32
33
 
105
106
    def go_to_reset_phone(self):
106
107
        return self._go_to_page('entryComponent-reset', 'resetPage')
107
108
 
 
109
    @autopilot.logging.log_action(logger.debug)
 
110
    def go_to_language_page(self):
 
111
        return self._go_to_page('entryComponent-language', 'languagePage')
 
112
 
 
113
    @autopilot.logging.log_action(logger.debug)
 
114
    def go_to_wifi_page(self):
 
115
        return self._go_to_page('entryComponent-wifi', 'wifiPage')
 
116
 
108
117
    def _go_to_page(self, item_object_name, page_object_name):
109
118
        self.click_item(item_object_name)
110
119
        page = self.wait_select_single(objectName=page_object_name)
166
175
        return self.select_single(objectName='soundPage')
167
176
 
168
177
    @property
 
178
    def security_page(self):
 
179
        """ Return 'Security' page """
 
180
        return self.select_single(objectName='securityPrivacyPage')
 
181
 
 
182
    @property
 
183
    def about_page(self):
 
184
        """ Return 'About' page """
 
185
        return self.select_single(objectName='aboutPage')
 
186
 
 
187
    @property
 
188
    def wifi_page(self):
 
189
        """ Return 'Wifi' page """
 
190
        return self.select_single(objectName='wifiPage')
 
191
 
 
192
    @property
169
193
    def _orientation_lock_switch(self):
170
194
        return self.wait_select_single(
171
195
            ubuntuuitoolkit.CheckBox,
311
335
        return False
312
336
 
313
337
 
 
338
class PhonePage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
339
 
 
340
    """Autopilot helper for the Phone page."""
 
341
 
 
342
    @classmethod
 
343
    def validate_dbus_object(cls, path, state):
 
344
        name = introspection.get_classname_from_path(path)
 
345
        if name == b'PageComponent':
 
346
            if state['objectName'][1] == 'phonePage':
 
347
                return True
 
348
        return False
 
349
 
 
350
    @autopilot.logging.log_action(logger.info)
 
351
    def go_to_call_forwarding(self, sim=None):
 
352
        """Open the Call Forwarding settings page.
 
353
 
 
354
        :param sim: Number of what SIM to use, either 1 or 2.
 
355
            Required parameter in dual SIM setups
 
356
        :returns: The Call Forwarding settings page.
 
357
 
 
358
        """
 
359
        find = "callFwd"
 
360
        if sim:
 
361
            find = "callFwdSim%d" % sim
 
362
 
 
363
        return self._go_to_page(find, 'callForwardingPage')
 
364
 
 
365
    def _go_to_page(self, item_object_name, page_object_name):
 
366
        self._click_item(item_object_name)
 
367
        page = self.get_root_instance().wait_select_single(
 
368
            objectName=page_object_name)
 
369
        page.active.wait_for(True)
 
370
        return page
 
371
 
 
372
    def _click_item(self, object_name):
 
373
        item = self.select_single(objectName=object_name)
 
374
        item.swipe_into_view()
 
375
        self.pointing_device.click_object(item)
 
376
 
 
377
    @autopilot.logging.log_action(logger.info)
 
378
    def go_to_call_waiting(self, sim=None):
 
379
        """Open the Call Waiting settings page.
 
380
 
 
381
        :param sim: Number of what SIM to use, either 1 or 2.
 
382
            Required parameter in dual SIM setups
 
383
        :returns: The Call Waiting settings page.
 
384
 
 
385
        """
 
386
        find = "callWait"
 
387
        if sim:
 
388
            find = "callWaitSim%d" % sim
 
389
        return self._go_to_page(find, 'callWaitingPage')
 
390
 
 
391
    @autopilot.logging.log_action(logger.info)
 
392
    def go_to_sim_services(self, sim=None):
 
393
        """Open the SIM Services settings page.
 
394
 
 
395
        :param sim: Number of what SIM to use, either 1 or 2.
 
396
            Required parameter in dual SIM setups
 
397
        :returns: The SIM Services settings page.
 
398
 
 
399
        """
 
400
        find = "simServices"
 
401
        if sim:
 
402
            find = "simServicesSim%d" % sim
 
403
 
 
404
        return self._go_to_page(find, 'servicesPage')
 
405
 
 
406
 
 
407
class CallWaiting(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
408
 
 
409
    """Autopilot helper for the Call waiting page."""
 
410
 
 
411
    @property
 
412
    def _switch(self):
 
413
        return self.wait_select_single(
 
414
            ubuntuuitoolkit.CheckBox,
 
415
            objectName='callWaitingSwitch')
 
416
 
 
417
    def enable_call_waiting(self):
 
418
        self._switch.check()
 
419
 
 
420
    def disable_call_waiting(self):
 
421
        self._switch.uncheck()
 
422
 
 
423
 
 
424
class CallForwarding(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
425
 
 
426
    """Autopilot helper for the Call forwarding page."""
 
427
 
 
428
    @property
 
429
    def _switch(self):
 
430
        return self.wait_select_single(
 
431
            ubuntuuitoolkit.CheckBox,
 
432
            objectName='callForwardingSwitch')
 
433
 
 
434
    @property
 
435
    def _number_field(self):
 
436
        return self.wait_select_single(
 
437
            objectName='destNumberField')
 
438
 
 
439
    def _click_set(self):
 
440
        button = self.wait_select_single(
 
441
            objectName='set')
 
442
        self.pointing_device.click_object(button)
 
443
 
 
444
    def _click_cancel(self):
 
445
        button = self.wait_select_single(
 
446
            objectName='cancel')
 
447
        self.pointing_device.click_object(button)
 
448
 
 
449
    @property
 
450
    def current_forwarding(self):
 
451
        return self.wait_select_single(
 
452
            objectName='destNumberField').text
 
453
 
 
454
    def enable_call_forwarding(self):
 
455
        self._switch.check()
 
456
 
 
457
    def disable_call_forwarding(self):
 
458
        self._switch.uncheck()
 
459
 
 
460
    def set_forward(self, number):
 
461
        input_method = Keyboard.create()
 
462
        self.enable_call_forwarding()
 
463
        self.pointing_device.click_object(self._number_field)
 
464
        input_method.type(number)
 
465
        self._click_set()
 
466
 
 
467
 
 
468
class Services(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
469
 
 
470
    """Autopilot helper for the Call waiting page."""
 
471
 
 
472
    # TODO: add pages for each relevant sim services page
 
473
    def open_sim_service(self, service):
 
474
        """Return a sim service page"""
 
475
        pass
 
476
 
 
477
 
314
478
class ResetPage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
315
479
 
316
480
    """Autopilot helper for the Reset page."""
403
567
    def confirm_reset(self):
404
568
        button = self.select_single('Button', objectName='factoryResetAction')
405
569
        self.pointing_device.click_object(button)
 
570
 
 
571
 
 
572
class LanguagePage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
573
 
 
574
    """Autopilot helper for the Language page."""
 
575
 
 
576
    @classmethod
 
577
    def validate_dbus_object(cls, path, state):
 
578
        name = introspection.get_classname_from_path(path)
 
579
        if name == b'ItemPage':
 
580
            if state['objectName'][1] == 'languagePage':
 
581
                return True
 
582
        return False
 
583
 
 
584
    def get_current_language(self):
 
585
        return self.select_single(
 
586
            'Label', objectName='currentLanguage').currentLanguage
 
587
 
 
588
    def _click_change_display_language(self):
 
589
        item = self.select_single(objectName='displayLanguage')
 
590
        self.pointing_device.click_object(item)
 
591
        return self.get_root_instance().select_single(
 
592
            objectName='displayLanguageDialog')
 
593
 
 
594
    @autopilot.logging.log_action(logger.info)
 
595
    def change_display_language(self, langIndex, reboot=True):
 
596
        """Changes display language.
 
597
 
 
598
        :param langIndex: The language index to change to.
 
599
 
 
600
        :param reboot: Whether to reboot or not
 
601
 
 
602
        :returns: The language page
 
603
 
 
604
        """
 
605
        dialog = self._click_change_display_language()
 
606
        dialog.set_language(langIndex, reboot)
 
607
        return self.get_root_instance()
 
608
 
 
609
 
 
610
class DisplayLanguage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
611
 
 
612
    """Autopilot helper for the Display Language dialog."""
 
613
 
 
614
    @autopilot.logging.log_action(logger.debug)
 
615
    def set_language(self, index, reboot):
 
616
        self._click_language_item(index)
 
617
        reboot_dialog = self._click_confirm()
 
618
 
 
619
        if reboot:
 
620
            reboot_dialog.reboot()
 
621
        else:
 
622
            reboot_dialog.revert()
 
623
 
 
624
    @autopilot.logging.log_action(logger.debug)
 
625
    def _click_language_item(self, index):
 
626
        languages_list = self.select_single('QQuickListView',
 
627
                                            objectName='languagesList')
 
628
        languages_list.click_element('languageName%d' % index)
 
629
 
 
630
    @autopilot.logging.log_action(logger.debug)
 
631
    def _click_confirm(self):
 
632
        button = self.select_single('Button',
 
633
                                    objectName='confirmChangeLanguage')
 
634
        self.pointing_device.click_object(button)
 
635
        return self.get_root_instance().select_single(
 
636
            objectName='rebootNecessaryDialog')
 
637
 
 
638
    @autopilot.logging.log_action(logger.debug)
 
639
    def _click_cancel(self):
 
640
        button = self.select_single('Button',
 
641
                                    objectName='cancelChangeLanguage')
 
642
        self.pointing_device.click_object(button)
 
643
 
 
644
 
 
645
class RebootNecessary(
 
646
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
647
 
 
648
    """Autopilot helper for the Reboot Necessary dialog."""
 
649
 
 
650
    @autopilot.logging.log_action(logger.debug)
 
651
    def reboot(self):
 
652
        self._click_reboot()
 
653
 
 
654
    @autopilot.logging.log_action(logger.debug)
 
655
    def revert(self):
 
656
        self._click_revert()
 
657
 
 
658
    @autopilot.logging.log_action(logger.debug)
 
659
    def _click_reboot(self):
 
660
        button = self.select_single('Button', objectName='reboot')
 
661
        self.pointing_device.click_object(button)
 
662
 
 
663
    @autopilot.logging.log_action(logger.debug)
 
664
    def _click_revert(self):
 
665
        button = self.select_single('Button', objectName='revert')
 
666
        self.pointing_device.click_object(button)
 
667
 
 
668
 
 
669
class WifiPage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
670
 
 
671
    """Autopilot helper for the Sound page."""
 
672
 
 
673
    @classmethod
 
674
    def validate_dbus_object(cls, path, state):
 
675
        name = introspection.get_classname_from_path(path)
 
676
        if name == b'ItemPage':
 
677
            if state['objectName'][1] == 'wifiPage':
 
678
                return True
 
679
        return False
 
680
 
 
681
    """Connects to hidden network
 
682
 
 
683
    :param name: Network name string (SSID)
 
684
    :kwarg security: A string that is either "none", "wpa" or "wep
 
685
    :kwarg password: A string/hex secret
 
686
    :kwarg cancel: A boolean deciding whether we press cancel or not
 
687
 
 
688
    :returns: If we are connecting, it returns the dialog,
 
689
        if we cancel, it returns itself
 
690
 
 
691
    """
 
692
    @autopilot.logging.log_action(logger.debug)
 
693
    def connect_to_hidden_network(self, name, security="none", password=None,
 
694
                                  cancel=False, scroll_to_and_click=None):
 
695
        dialog = self._click_connect_to_hidden_network(scroll_to_and_click)
 
696
        dialog.enter_name(name)
 
697
        if security:
 
698
            dialog.set_security(security)
 
699
        if password:
 
700
            dialog.enter_password(password)
 
701
 
 
702
        if cancel:
 
703
            dialog.cancel()
 
704
            return self
 
705
        else:
 
706
            dialog.connect()
 
707
            return dialog
 
708
 
 
709
    @autopilot.logging.log_action(logger.debug)
 
710
    def _click_connect_to_hidden_network(self, scroll_to_and_click):
 
711
 
 
712
        # we can't mock the qunitymenu items, so we
 
713
        # have to wait for them to be built
 
714
        sleep(0.5)
 
715
 
 
716
        button = self.select_single('*',
 
717
                                    objectName='connectToHiddenNetwork')
 
718
        if (scroll_to_and_click):
 
719
            scroll_to_and_click(button)
 
720
        else:
 
721
            self.pointing_device.click_object(button)
 
722
        return self.get_root_instance().wait_select_single(
 
723
            objectName='otherNetworkDialog')
 
724
 
 
725
    @autopilot.logging.log_action(logger.debug)
 
726
    def go_to_previous_networks(self, scroll_to_and_click=None):
 
727
        return self._click_previous_network(scroll_to_and_click)
 
728
 
 
729
    """Removes previous network
 
730
 
 
731
    :param ssid: Network name string (SSID)
 
732
 
 
733
    :returns: PreviousNetwork page
 
734
 
 
735
    """
 
736
    @autopilot.logging.log_action(logger.debug)
 
737
    def remove_previous_network(self, ssid, scroll_to_and_click=None):
 
738
        page = self.go_to_previous_networks(scroll_to_and_click)
 
739
        details = page.select_network(ssid)
 
740
        details.forget_network()
 
741
        return page
 
742
 
 
743
    @autopilot.logging.log_action(logger.debug)
 
744
    def _click_previous_network(self, scroll_to_and_click):
 
745
 
 
746
        # we can't mock the qunitymenu items, so we
 
747
        # have to wait for them to be built
 
748
        sleep(0.5)
 
749
 
 
750
        button = self.select_single('*',
 
751
                                    objectName='previousNetwork')
 
752
        if (scroll_to_and_click):
 
753
            scroll_to_and_click(button)
 
754
        else:
 
755
            self.pointing_device.click_object(button)
 
756
        return self.get_root_instance().wait_select_single(
 
757
            objectName='previousNetworksPage')
 
758
 
 
759
 
 
760
class OtherNetwork(
 
761
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
762
 
 
763
    """Autopilot helper for the Connect to Hidden Network dialog."""
 
764
 
 
765
    @classmethod
 
766
    def validate_dbus_object(cls, path, state):
 
767
        name = introspection.get_classname_from_path(path)
 
768
        if name == b'Dialog':
 
769
            if state['objectName'][1] == 'otherNetworkDialog':
 
770
                return True
 
771
        return False
 
772
 
 
773
    @autopilot.logging.log_action(logger.debug)
 
774
    def enter_name(self, name):
 
775
        self._enter_name(name)
 
776
 
 
777
    @autopilot.logging.log_action(logger.debug)
 
778
    def _enter_name(self, name):
 
779
        namefield = self.select_single('TextField',
 
780
                                       objectName='networkname')
 
781
        namefield.write(name)
 
782
 
 
783
    @autopilot.logging.log_action(logger.debug)
 
784
    def set_security(self, security):
 
785
        """Sets the hidden network's security
 
786
 
 
787
        :param security: Either "none", "wpa" or "wep
 
788
 
 
789
        :returns: None
 
790
 
 
791
        """
 
792
        self._set_security(security)
 
793
 
 
794
    @autopilot.logging.log_action(logger.debug)
 
795
    def _expand_security_list(self):
 
796
        sec_list = self.select_single(
 
797
            '*', objectName='securityList')
 
798
        active_child = sec_list.select_single(
 
799
            '*', objectName='listContainer')
 
800
        self.pointing_device.click_object(active_child)
 
801
        # wait for it to expand
 
802
        sleep(0.5)
 
803
        return sec_list
 
804
 
 
805
    @autopilot.logging.log_action(logger.debug)
 
806
    def _set_security(self, security):
 
807
        if security == 'none':
 
808
            sec_list = self._expand_security_list()
 
809
            item = sec_list.wait_select_single('*',
 
810
                                               text=_('None'))
 
811
            self.pointing_device.click_object(item)
 
812
        elif security == 'wpa':
 
813
            sec_list = self._expand_security_list()
 
814
            item = sec_list.wait_select_single('*',
 
815
                                               text=_('WPA & WPA2 Personal'))
 
816
            self.pointing_device.click_object(item)
 
817
        elif security == 'wep':
 
818
            sec_list = self._expand_security_list()
 
819
            item = sec_list.wait_select_single('*',
 
820
                                               text=_('WEP'))
 
821
            self.pointing_device.click_object(item)
 
822
        elif security is not None:
 
823
            raise ValueError('security type %s is not valid' % security)
 
824
        # wait for ui to change
 
825
        sleep(0.5)
 
826
 
 
827
    @autopilot.logging.log_action(logger.debug)
 
828
    def enter_password(self, password):
 
829
        self._enter_password(password)
 
830
 
 
831
    @autopilot.logging.log_action(logger.debug)
 
832
    def _enter_password(self, password):
 
833
        pwdfield = self.select_single('TextField',
 
834
                                      objectName='password')
 
835
        pwdfield.write(password)
 
836
 
 
837
    @autopilot.logging.log_action(logger.debug)
 
838
    def cancel(self):
 
839
        self._click_cancel()
 
840
 
 
841
    @autopilot.logging.log_action(logger.debug)
 
842
    def _click_cancel(self):
 
843
        button = self.select_single('Button', objectName='cancel')
 
844
        self.pointing_device.click_object(button)
 
845
 
 
846
    @autopilot.logging.log_action(logger.debug)
 
847
    def connect(self):
 
848
        self._click_connect()
 
849
 
 
850
    @autopilot.logging.log_action(logger.debug)
 
851
    def _click_connect(self):
 
852
        button = self.select_single('Button', objectName='connect')
 
853
        self.pointing_device.click_object(button)
 
854
 
 
855
 
 
856
class PreviousNetworks(
 
857
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
858
 
 
859
    """Autopilot helper for the Previous Networks page."""
 
860
 
 
861
    @classmethod
 
862
    def validate_dbus_object(cls, path, state):
 
863
        name = introspection.get_classname_from_path(path)
 
864
        if name == b'ItemPage':
 
865
            if state['objectName'][1] == 'previousNetworksPage':
 
866
                return True
 
867
        return False
 
868
 
 
869
    @autopilot.logging.log_action(logger.debug)
 
870
    def select_network(self, name):
 
871
        self._select_network(name)
 
872
        return self.get_root_instance().wait_select_single(
 
873
            objectName='networkDetailsPage')
 
874
 
 
875
    @autopilot.logging.log_action(logger.debug)
 
876
    def _select_network(self, name):
 
877
        net = self.select_single('Standard', text=name)
 
878
        self.pointing_device.click_object(net)
 
879
 
 
880
 
 
881
class NetworkDetails(
 
882
        ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
883
 
 
884
    """Autopilot helper for the Networks Details page."""
 
885
 
 
886
    @autopilot.logging.log_action(logger.debug)
 
887
    def forget_network(self):
 
888
        self._click_forget()
 
889
 
 
890
    @autopilot.logging.log_action(logger.debug)
 
891
    def _click_forget(self):
 
892
        button = self.select_single('Button', objectName='forgetNetwork')
 
893
        self.pointing_device.click_object(button)