on xenial help sign in
Allow setings wizard test to finish regardless of phone state
1277960Josh Arenson
tests/autopilot/unity8/settings_wizard/emulators/settings_wizard.py+16
@@ -363,6 +363,15 @@ class WifiConnectPage(UbuntuUIToolkitCustomProxyObjectBase):
363 return self.wait_select_single(
363 return self.wait_select_single(
364 'StackButton', text='Continue', visible='True')
364 'StackButton', text='Continue', visible='True')
365
365
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+
366 def is_network_checked(self, ssid):
375 def is_network_checked(self, ssid):
367 return self._get_network_checkbox(ssid).get_properties()['checked']
376 return self._get_network_checkbox(ssid).get_properties()['checked']
368
377
@@ -371,6 +380,13 @@ class WifiConnectPage(UbuntuUIToolkitCustomProxyObjectBase):
371 self.pointing_device.click_object(self._get_network_checkbox(ssid))
380 self.pointing_device.click_object(self._get_network_checkbox(ssid))
372 return PasswordNotification(self._get_notification(unity))
381 return PasswordNotification(self._get_notification(unity))
373
382
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+
374 @autopilot.logging.log_action(logger.info)
390 @autopilot.logging.log_action(logger.info)
375 def back(self):
391 def back(self):
376 self.pointing_device.click_object(self._get_back_button())
392 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−
4from unity8.settings_wizard import fixture_setup
1from unity8.settings_wizard import fixture_setup
5from unity8.settings_wizard.emulators.settings_wizard import Wizard
2from unity8.settings_wizard.emulators.settings_wizard import Wizard
6−from unity8.settings_wizard.phonesim_manager import PhonesimManager
7from unity8.shell import tests
3from unity8.shell import tests
8
4
9DEFAULT_LANGUAGE = 'English (United States)'
5DEFAULT_LANGUAGE = 'English (United States)'
10DEFAULT_PHONESIM_CONFIG_FILE = '/usr/share/phonesim/default.xml'
6DEFAULT_PHONESIM_CONFIG_FILE = '/usr/share/phonesim/default.xml'
11DEFAULT_SECURITY_METHOD = 'Passcode'
7DEFAULT_SECURITY_METHOD = 'Passcode'
12
8
13−import pdb
14−
15
9
16class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
10class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
17 """ Autopilot test for completing settings wizard """
11 """ Autopilot test for completing settings wizard """
18
12
19 def setUp(self):
13 def setUp(self):
20 super().setUp()
14 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)
30 self.wizard_helper = self.useFixture(
15 self.wizard_helper = self.useFixture(
31 fixture_setup.SettingsWizard(True))
16 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()
39 self.unity = self.launch_unity()
17 self.unity = self.launch_unity()
40 self.wizard = self._get_settings_wizard()
18 self.wizard = self._get_settings_wizard()
41
19
42− def tearDown(self):
43− self.phonesim_manager.shutdown()
44−
45 def _get_settings_wizard(self):
20 def _get_settings_wizard(self):
46 return self.unity.wait_select_single(Wizard)
21 return self.unity.wait_select_single(Wizard)
47
22
@@ -61,15 +36,19 @@ class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
61 password_page.select_security_option('Swipe')
36 password_page.select_security_option('Swipe')
62 return password_page.continue_()
37 return password_page.continue_()
63
38
39+ def _test_wifi_connect_page(self, wifi_connect_page):
40+ return wifi_connect_page.advance_page()
41+
64 def test_skipping_through_wizard(self):
42 def test_skipping_through_wizard(self):
65 """ Most basic test of the settings wizard. Skip all skipable pages """
43 """ 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
68 sim_inserted, next_page = self._test_language_page()
44 sim_inserted, next_page = self._test_language_page()
45+ if sim_inserted:
46+ password_page = next_page
47+ else:
69− password_page = next_page.skip()
48+ password_page = next_page.skip()
70 wifi_connect_page = self._test_password_page(password_page)
49 wifi_connect_page = self._test_password_page(password_page)
71 # FIXME This _will_ not work without a mock as the behavior is
50 # FIXME This _will_ not work without a mock as the behavior is
72 # dependent on weather or not there is a connection to a wifi network
51 # 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)
74 finish_page = reporting_page.continue_()
53 finish_page = reporting_page.continue_()
75 finish_page.finish()
54 finish_page.finish()