on xenial help sign in
Allow setings wizard test to finish regardless of phone state
commit1277960cbe5444cbeb5c413713806ab31aeaba6a authorJosh Arenson <joshua.arenson@canonical.com> dateTue 19 May 2015, 13:37 (11 years ago) parent5bfbcf6
2 files changed+24−29
tests/autopilot/unity8/settings_wizard/emulators/settings_wizard.py+16 tests/autopilot/unity8/settings_wizard/tests/test_settings_wizard.py+8−29
tests/autopilot/unity8/settings_wizard/emulators/settings_wizard.py+16
@@ -363,6 +363,15 @@ class WifiConnectPage(UbuntuUIToolkitCustomProxyObjectBase):
363363 return self.wait_select_single(
364364 'StackButton', text='Continue', visible='True')
365365
366+ def _get_next_button(self):
367+ # Since the phone state is unknown, this returns skip||continue
368+ # depending on which one is visible
369+ buttons = self.select_many('StackButton')
370+ for button in buttons:
371+ if button.text == "Continue" or button.text == "Skip":
372+ return button
373+ raise introspection.dbus.StateNotFoundError
374+
366375 def is_network_checked(self, ssid):
367376 return self._get_network_checkbox(ssid).get_properties()['checked']
368377
@@ -371,6 +380,13 @@ class WifiConnectPage(UbuntuUIToolkitCustomProxyObjectBase):
371380 self.pointing_device.click_object(self._get_network_checkbox(ssid))
372381 return PasswordNotification(self._get_notification(unity))
373382
383+ @autopilot.logging.log_action(logger.info)
384+ def advance_page(self):
385+ """ Advance the wizard regardless of weather or not
386+ continue||skip button is present """
387+ self.pointing_device.click_object(self._get_next_button())
388+ return get_wizard(self).get_reporting_page()
389+
374390 @autopilot.logging.log_action(logger.info)
375391 def back(self):
376392 self.pointing_device.click_object(self._get_back_button())
tests/autopilot/unity8/settings_wizard/tests/test_settings_wizard.py+8−29
@@ -1,47 +1,22 @@
1−import os
2−import sysconfig
3−
41from unity8.settings_wizard import fixture_setup
52from unity8.settings_wizard.emulators.settings_wizard import Wizard
6−from unity8.settings_wizard.phonesim_manager import PhonesimManager
73from unity8.shell import tests
84
95DEFAULT_LANGUAGE = 'English (United States)'
106DEFAULT_PHONESIM_CONFIG_FILE = '/usr/share/phonesim/default.xml'
117DEFAULT_SECURITY_METHOD = 'Passcode'
128
13−import pdb
14−
159
1610class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
1711 """ Autopilot test for completing settings wizard """
1812
1913 def setUp(self):
2014 super().setUp()
21− phonesim_datadir = os.getenv('INDICATOR_NETWORK_PHONESIM_DATA')
22− if phonesim_datadir is None:
23− phonesim_datadir = sysconfig.get_config_var('datarootdir') + \
24− '/indicator-network/phonesim'
25−
26− sims = [('sim1',
27− 23456,
28− phonesim_datadir + '/pin-unlock.xml')]
29− self.phonesim_manager = PhonesimManager(sims)
3015 self.wizard_helper = self.useFixture(
3116 fixture_setup.SettingsWizard(True))
32− pdb.set_trace()
33− self.phonesim_manager.start_phonesim_processes()
34− self.phonesim_manager.remove_all_ofono()
35− self.phonesim_manager.add_ofono('sim1')
36− self.phonesim_manager.power_on('sim1')
37− self.phonesim_manager.power_off('sim1')
38− pdb.set_trace()
3917 self.unity = self.launch_unity()
4018 self.wizard = self._get_settings_wizard()
4119
42− def tearDown(self):
43− self.phonesim_manager.shutdown()
44−
4520 def _get_settings_wizard(self):
4621 return self.unity.wait_select_single(Wizard)
4722
@@ -61,15 +36,19 @@ class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
6136 password_page.select_security_option('Swipe')
6237 return password_page.continue_()
6338
39+ def _test_wifi_connect_page(self, wifi_connect_page):
40+ return wifi_connect_page.advance_page()
41+
6442 def test_skipping_through_wizard(self):
6543 """ Most basic test of the settings wizard. Skip all skipable pages """
66− # FIXME for now, assume there is no SIM card in the phone
67− # A mock should allow testing both situations later
6844 sim_inserted, next_page = self._test_language_page()
69− password_page = next_page.skip()
45+ if sim_inserted:
46+ password_page = next_page
47+ else:
48+ password_page = next_page.skip()
7049 wifi_connect_page = self._test_password_page(password_page)
7150 # FIXME This _will_ not work without a mock as the behavior is
7251 # dependent on weather or not there is a connection to a wifi network
73− reporting_page = wifi_connect_page.skip()
52+ reporting_page = self._test_wifi_connect_page(wifi_connect_page)
7453 finish_page = reporting_page.continue_()
7554 finish_page.finish()