on xenial help sign in
Make settings wizard test smarter when clicking through the wifi page
da14b64Josh Arenson
tests/autopilot/unity8/settings_wizard/emulators/settings_wizard.py+20
@@ -337,6 +337,14 @@ class WifiConnectPage(UbuntuUIToolkitCustomProxyObjectBase):
337 return True
337 return True
338 return False
338 return False
339
339
340+ def _get_all_networks(self):
341+ try:
342+ networks = self.select_many('Standard', objectName='accessPoint',
343+ visible='True')
344+ except:
345+ networks = []
346+ return networks
347+
340 def _get_network(self, ssid):
348 def _get_network(self, ssid):
341 return self.wait_select_single(
349 return self.wait_select_single(
342 'Standard', objectName='accessPoint', text=ssid, visible='True')
350 'Standard', objectName='accessPoint', text=ssid, visible='True')
@@ -372,6 +380,18 @@ class WifiConnectPage(UbuntuUIToolkitCustomProxyObjectBase):
372 return button
380 return button
373 raise introspection.dbus.StateNotFoundError
381 raise introspection.dbus.StateNotFoundError
374
382
383+ def is_any_network_checked(self):
384+ networks = self._get_all_networks()
385+ for network in networks:
386+ checkbox = network.select_single('CheckBox', visible='True')
387+ if checkbox.get_properties()['checked']:
388+ return True
389+ return False
390+
391+ def is_any_network_found(self):
392+ num_neworks = len(self._get_all_networks())
393+ return True if num_neworks > 0 else False
394+
375 def is_network_checked(self, ssid):
395 def is_network_checked(self, ssid):
376 return self._get_network_checkbox(ssid).get_properties()['checked']
396 return self._get_network_checkbox(ssid).get_properties()['checked']
377
397
tests/autopilot/unity8/settings_wizard/tests/test_settings_wizard.py+5−1
@@ -59,7 +59,11 @@ class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
59 return reporting_page.continue_()
59 return reporting_page.continue_()
60
60
61 def _test_wifi_connect_page(self, wifi_connect_page):
61 def _test_wifi_connect_page(self, wifi_connect_page):
62+ if wifi_connect_page.is_any_network_checked() or not \
63+ wifi_connect_page.is_any_network_found():
62− return wifi_connect_page.advance_page()
64+ return wifi_connect_page.continue_()
65+ else:
66+ return wifi_connect_page.skip()
63
67
64 def test_skipping_through_wizard(self):
68 def test_skipping_through_wizard(self):
65 """ Most basic test of the settings wizard. Skip all skipable pages """
69 """ Most basic test of the settings wizard. Skip all skipable pages """