Unity 8
test_settings_wizard.py
1 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2 #
3 # Unity Autopilot Test Suite
4 # Copyright (C) 2015 Canonical
5 #
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #
19 
20 from unity8.settings_wizard import fixture_setup, Wizard
21 from unity8.shell import tests
22 
23 DEFAULT_LANGUAGE = 'English (United States)'
24 DEFAULT_PHONESIM_CONFIG_FILE = '/usr/share/phonesim/default.xml'
25 DEFAULT_SECURITY_METHOD = 'Passcode'
26 
27 
28 class SkipThroughSettingsWizardTestCase(tests.UnityTestCase):
29  """ Autopilot test for completing settings wizard """
30 
31  def setUp(self):
32  super().setUp()
33  self.wizard_helper = self.useFixture(
34  fixture_setup.SettingsWizard(True))
35  self.unity = self.launch_unity()
36  self.wizard = self._get_settings_wizard()
37 
38  def _get_settings_wizard(self):
39  return self.unity.wait_select_single(Wizard)
40 
41  def _test_language_page(self):
42  """ Get the language page, check the default language and continue """
43  language_page = self.wizard.get_language_page()
44  default_selection = language_page.get_selected_language()
45  self.assertEqual(default_selection, DEFAULT_LANGUAGE)
46  return language_page.continue_()
47 
48  def _test_location_page(self, location_page):
49  return location_page.continue_()
50 
51  def _test_password_page(self, password_page):
52  """ Check default selection for password type and change
53  password type to swipe to keep this test as uncomplicated
54  as possible """
55  default_selection = password_page.get_selected_security_option()
56  self.assertEqual(default_selection, DEFAULT_SECURITY_METHOD)
57  password_page.select_security_option('Swipe')
58  return password_page.continue_()
59 
60  def _test_reporting_page(self, reporting_page):
61  return reporting_page.continue_()
62 
63  def _test_sim_page(self, sim_page):
64  return sim_page.skip()
65 
66  def _test_wifi_connect_page(self, wifi_connect_page):
67  if wifi_connect_page.is_any_network_checked() or not \
68  wifi_connect_page.is_any_network_found():
69  return wifi_connect_page.continue_()
70  else:
71  return wifi_connect_page.skip()
72 
74  """ Most basic test of the settings wizard. Skip all skipable pages """
75  sim_inserted, next_page = self._test_language_page()
76  if not sim_inserted:
77  sim_page = next_page
78  password_page = self._test_sim_page(sim_page)
79  else:
80  password_page = next_page
81  wifi_connect_page = self._test_password_page(password_page)
82 
83  reporting_page = None
84  locationPageEnabled, reportingPageEnabled, next_page = self._test_wifi_connect_page(wifi_connect_page)
85  if locationPageEnabled:
86  location_page = next_page
87  if reportingPageEnabled:
88  reporting_page = self._test_location_page(location_page)
89  else:
90  finish_page = next_page
91 
92  if reporting_page is not None:
93  finish_page = self._test_reporting_page(reporting_page)
94  else:
95  finish_page = next_page
96 
97  finish_page.finish()
98  self.assertFalse(
99  self.wizard_helper.is_settings_wizard_enabled())