~ken-vandine/ubuntu-system-settings/rtm-14.09_lp1351383

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_system_settings/tests/test_security.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:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
# Copyright 2014 Canonical
 
3
#
 
4
# This program is free software: you can redistribute it and/or modify it
 
5
# under the terms of the GNU General Public License version 3, as published
 
6
# by the Free Software Foundation.
 
7
 
 
8
from gi.repository import Gio
 
9
from time import sleep
 
10
import unittest
 
11
from testtools.matchers import Equals, NotEquals
 
12
from autopilot.matchers import Eventually
 
13
 
 
14
from ubuntu_system_settings.tests import (
 
15
    SecurityBaseTestCase,
 
16
    SIM_IFACE)
 
17
 
 
18
from ubuntu_system_settings.utils.i18n import ugettext as _
 
19
from ubuntuuitoolkit import emulators as toolkit_emulators
 
20
 
 
21
 
 
22
class SecurityTestCase(SecurityBaseTestCase):
 
23
    """ Tests for Security Page """
 
24
 
 
25
    def setUp(self):
 
26
        super(SecurityTestCase, self).setUp()
 
27
        self.assertEqual(['pin'], self.modem_0.Get(SIM_IFACE, 'LockedPins'))
 
28
        prps = self.system_settings.main_view.security_page.get_properties()
 
29
        self.use_powerd = prps['usePowerd']
 
30
        if self.use_powerd:
 
31
            gsettings = Gio.Settings.new('com.ubuntu.touch.system')
 
32
            prev = gsettings.get_uint('activity-timeout')
 
33
            self.addCleanup(
 
34
                self.set_prev_activity_timeout, gsettings, prev)
 
35
        else:
 
36
            gsettings = Gio.Settings.new('org.gnome.desktop.session')
 
37
            prev = gsettings.get_uint('idle-delay')
 
38
            self.addCleanup(
 
39
                self.set_prev_idle_delay, gsettings, prev)
 
40
 
 
41
    def set_prev_idle_delay(self, gsettings, prev):
 
42
        gsettings.set_uint('idle-delay', prev)
 
43
        self.assertThat(
 
44
            lambda: int(gsettings.get_uint('idle-delay')),
 
45
            Eventually(Equals(prev))
 
46
        )
 
47
 
 
48
    def set_prev_activity_timeout(self, gsettings, prev):
 
49
        gsettings.set_uint('activity-timeout', prev)
 
50
        self.assertThat(
 
51
            lambda: int(gsettings.get_uint('activity-timeout')),
 
52
            Eventually(Equals(prev))
 
53
        )
 
54
 
 
55
    def _get_activity_timeout(self):
 
56
        if self.use_powerd:
 
57
            gsettings = Gio.Settings.new('com.ubuntu.touch.system')
 
58
            prev = gsettings.get_uint('activity-timeout')
 
59
            return prev
 
60
        else:
 
61
            gsettings = Gio.Settings.new('org.gnome.desktop.session')
 
62
            prev = gsettings.get_uint('idle-delay')
 
63
            return prev
 
64
 
 
65
    def _go_to_phone_lock(self):
 
66
        selector = self.security_page.select_single(
 
67
            objectName="lockingControl"
 
68
        )
 
69
        self.system_settings.main_view.scroll_to_and_click(selector)
 
70
 
 
71
    def _go_to_sim_lock(self):
 
72
        selector = self.security_page.select_single(
 
73
            objectName="simControl"
 
74
        )
 
75
        self.system_settings.main_view.scroll_to_and_click(selector)
 
76
 
 
77
    def _go_to_sleep_values(self):
 
78
        self._go_to_phone_lock()
 
79
        selector = self.system_settings.main_view.select_single(
 
80
            objectName="lockTimeout"
 
81
        )
 
82
        self.system_settings.main_view.scroll_to_and_click(selector)
 
83
 
 
84
    def _get_sleep_selector(self):
 
85
        self._go_to_sleep_values()
 
86
        sleep_values_page = self.system_settings.main_view.select_single(
 
87
            objectName='sleepValues')
 
88
        self.assertThat(
 
89
            sleep_values_page,
 
90
            NotEquals(None)
 
91
        )
 
92
        self._go_to_sleep_values()
 
93
        sleep_values_page = self.system_settings.main_view.select_single(
 
94
            objectName='sleepValues')
 
95
        return sleep_values_page.select_single(
 
96
            toolkit_emulators.ItemSelector,
 
97
            objectName="sleepSelector"
 
98
        )
 
99
 
 
100
    def test_security_page(self):
 
101
        """ Checks whether Security page is available """
 
102
        self.assertThat(
 
103
            self.system_settings.main_view.security_page,
 
104
            NotEquals(None)
 
105
        )
 
106
        self.assertThat(
 
107
            self.system_settings.main_view.security_page.title,
 
108
            Equals(_('Security & Privacy'))
 
109
        )
 
110
 
 
111
    def test_locking_control_value(self):
 
112
        actTimeout = self._get_activity_timeout()
 
113
        activityTimeout = self.security_page.select_single(
 
114
            objectName='lockingControl').value
 
115
        if actTimeout is 0:
 
116
            self.assertEquals(activityTimeout, ('Manually'))
 
117
        elif actTimeout is 60:
 
118
            self.assertEquals(
 
119
                activityTimeout,
 
120
                ('After {:d} minute').format(int(actTimeout/60)))
 
121
        else:
 
122
            self.assertEquals(
 
123
                activityTimeout,
 
124
                ('After {:d} minutes').format(int(actTimeout/60)))
 
125
 
 
126
    def test_phone_lock_page(self):
 
127
        self._go_to_phone_lock()
 
128
        phone_lock_page = self.system_settings.main_view.select_single(
 
129
            objectName='phoneLockingPage')
 
130
        self.assertThat(
 
131
            phone_lock_page,
 
132
            NotEquals(None)
 
133
        )
 
134
        self.assertThat(
 
135
            phone_lock_page.title,
 
136
            Equals(_('Phone locking'))
 
137
        )
 
138
 
 
139
    def test_phone_lock_value(self):
 
140
        self._go_to_phone_lock()
 
141
        phone_lock_page = self.system_settings.main_view.select_single(
 
142
            objectName='phoneLockingPage')
 
143
        actTimeout = self._get_activity_timeout()
 
144
        activityTimeout = phone_lock_page.select_single(
 
145
            objectName='lockTimeout').value
 
146
        if actTimeout is 0:
 
147
            self.assertEquals(activityTimeout, ('Never'))
 
148
        elif actTimeout is 60:
 
149
            self.assertEquals(
 
150
                activityTimeout,
 
151
                ('{:d} minute').format(int(actTimeout/60))
 
152
            )
 
153
        else:
 
154
            self.assertEquals(
 
155
                activityTimeout,
 
156
                ('{:d} minutes').format(int(actTimeout/60))
 
157
            )
 
158
 
 
159
    def test_idle_never_timeout(self):
 
160
        selector = self._get_sleep_selector()
 
161
        to_select = selector.select_single(
 
162
            'OptionSelectorDelegate', text='Never')
 
163
        self.system_settings.main_view.pointing_device.click_object(to_select)
 
164
        to_select.selected.wait_for(True)
 
165
        sleep(1)
 
166
        actTimeout = self._get_activity_timeout()
 
167
        self.assertEquals(actTimeout, 0)
 
168
        selected_delegate = selector.select_single(
 
169
            'OptionSelectorDelegate', selected=True)
 
170
        self.assertEquals(selected_delegate.text, 'Never')
 
171
 
 
172
    def test_idle_change_timeout(self):
 
173
        selector = self._get_sleep_selector()
 
174
        to_select = selector.select_single(
 
175
            'OptionSelectorDelegate', text='After 4 minutes')
 
176
        self.system_settings.main_view.pointing_device.click_object(to_select)
 
177
        to_select.selected.wait_for(True)
 
178
        sleep(1)
 
179
        actTimeout = self._get_activity_timeout()
 
180
        self.assertEquals(actTimeout, 240)
 
181
        selected_delegate = selector.select_single(
 
182
            'OptionSelectorDelegate', selected=True)
 
183
        self.assertEquals(selected_delegate.text, 'After 4 minutes')
 
184
 
 
185
    def test_sim_pin_control_value(self):
 
186
        self.assertEqual('none', self.modem_0.Get(SIM_IFACE, 'PinRequired'))
 
187
        self.assertEqual(['pin'], self.modem_0.Get(SIM_IFACE, 'LockedPins'))
 
188
 
 
189
        sim_pin_value = self.security_page.select_single(
 
190
            objectName='simControl').value
 
191
 
 
192
        self.assertThat(
 
193
            sim_pin_value,
 
194
            Equals(_('On'))
 
195
        )
 
196
 
 
197
    def test_sim_pin_lock_control(self):
 
198
        self._go_to_sim_lock()
 
199
        sim_lock_control = self.system_settings.main_view.select_single(
 
200
            objectName='simPinSwitch')
 
201
        locked = len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
 
202
        self.assertEquals(locked, sim_lock_control.checked)
 
203
 
 
204
    def test_sim_pin_lock_control_unlock(self):
 
205
        self._go_to_sim_lock()
 
206
        sim_lock_control = self.system_settings.main_view.select_single(
 
207
            objectName='simPinSwitch')
 
208
 
 
209
        self.assertTrue(sim_lock_control.checked)
 
210
 
 
211
        self.system_settings.main_view.scroll_to_and_click(sim_lock_control)
 
212
 
 
213
        lock_dialog = self.system_settings.main_view.select_single(
 
214
            objectName='lockDialogComponent')
 
215
        self.assertEqual(
 
216
            lock_dialog.title,
 
217
            _("Enter SIM PIN")
 
218
        )
 
219
 
 
220
        prev_input = self.system_settings.main_view.select_single(
 
221
            objectName='prevInput')
 
222
        submit_button = self.system_settings.main_view.select_single(
 
223
            objectName='lockButton')
 
224
 
 
225
        self.assertEqual(
 
226
            submit_button.text,
 
227
            _("Unlock")
 
228
        )
 
229
 
 
230
        self.assertFalse(
 
231
            submit_button.get_properties()['enabled']
 
232
        )
 
233
        self.system_settings.main_view.scroll_to_and_click(prev_input)
 
234
        self.keyboard.type("246")
 
235
        self.assertFalse(
 
236
            submit_button.get_properties()['enabled']
 
237
        )
 
238
        self.keyboard.type("8")
 
239
 
 
240
        self.assertTrue(
 
241
            submit_button.get_properties()['enabled']
 
242
        )
 
243
 
 
244
        self.system_settings.main_view.scroll_to_and_click(submit_button)
 
245
 
 
246
        self.assertFalse(sim_lock_control.checked)
 
247
 
 
248
        locked = len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
 
249
        self.assertEquals(locked, sim_lock_control.checked)
 
250
 
 
251
    @unittest.skip('skipped because the simPinSwitch state fails to update')
 
252
    def test_sim_pin_lock_control_lock(self):
 
253
        self.modem_0.Set(SIM_IFACE, 'LockedPins', "")
 
254
        self._go_to_sim_lock()
 
255
        sim_lock_control = self.system_settings.main_view.select_single(
 
256
            objectName='simPinSwitch')
 
257
 
 
258
        self.assertFalse(sim_lock_control.checked)
 
259
 
 
260
        self.system_settings.main_view.scroll_to_and_click(sim_lock_control)
 
261
 
 
262
        lock_dialog = self.system_settings.main_view.select_single(
 
263
            objectName='lockDialogComponent')
 
264
        self.assertEqual(
 
265
            lock_dialog.title,
 
266
            _("Enter SIM PIN")
 
267
        )
 
268
 
 
269
        prev_input = self.system_settings.main_view.select_single(
 
270
            objectName='prevInput')
 
271
        submit_button = self.system_settings.main_view.select_single(
 
272
            objectName='lockButton')
 
273
 
 
274
        self.assertEqual(
 
275
            submit_button.text,
 
276
            _("Lock")
 
277
        )
 
278
 
 
279
        self.assertFalse(
 
280
            submit_button.get_properties()['enabled']
 
281
        )
 
282
        self.system_settings.main_view.scroll_to_and_click(prev_input)
 
283
        self.keyboard.type("246")
 
284
        self.assertFalse(
 
285
            submit_button.get_properties()['enabled']
 
286
        )
 
287
        self.keyboard.type("8")
 
288
 
 
289
        self.assertTrue(
 
290
            submit_button.get_properties()['enabled']
 
291
        )
 
292
 
 
293
        self.system_settings.main_view.scroll_to_and_click(submit_button)
 
294
 
 
295
        self.assertTrue(sim_lock_control.checked)
 
296
 
 
297
        self.assertEqual(['pin'], self.modem_0.Get(SIM_IFACE, 'LockedPins'))
 
298
        locked = len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
 
299
        self.assertEquals(locked, sim_lock_control.checked)
 
300
 
 
301
    def test_sim_pin_lock_control_unlock_fail(self):
 
302
        self._go_to_sim_lock()
 
303
        sim_lock_control = self.system_settings.main_view.select_single(
 
304
            objectName='simPinSwitch')
 
305
 
 
306
        self.assertTrue(
 
307
            len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
 
308
        )
 
309
        self.assertTrue(sim_lock_control.checked)
 
310
 
 
311
        self.system_settings.main_view.scroll_to_and_click(sim_lock_control)
 
312
 
 
313
        lock_dialog = self.system_settings.main_view.select_single(
 
314
            objectName='lockDialogComponent')
 
315
        self.assertEqual(
 
316
            lock_dialog.title,
 
317
            _("Enter SIM PIN")
 
318
        )
 
319
 
 
320
        prev_input = self.system_settings.main_view.select_single(
 
321
            objectName='prevInput')
 
322
        submit_button = self.system_settings.main_view.select_single(
 
323
            objectName='lockButton')
 
324
 
 
325
        self.assertEqual(
 
326
            submit_button.text,
 
327
            _("Unlock")
 
328
        )
 
329
 
 
330
        self.assertFalse(
 
331
            submit_button.get_properties()['enabled']
 
332
        )
 
333
        self.system_settings.main_view.scroll_to_and_click(prev_input)
 
334
        self.keyboard.type("1234")
 
335
 
 
336
        self.assertTrue(
 
337
            submit_button.get_properties()['enabled']
 
338
        )
 
339
 
 
340
        self.system_settings.main_view.scroll_to_and_click(submit_button)
 
341
 
 
342
        self.assertTrue(
 
343
            len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
 
344
        )
 
345
 
 
346
    @unittest.skip('skipped because the simPinSwitch state fails to update')
 
347
    def test_sim_pin_lock_control_lock_fail(self):
 
348
        self.modem_0.Set(SIM_IFACE, 'LockedPins', "")
 
349
        self._go_to_sim_lock()
 
350
        sim_lock_control = self.system_settings.main_view.select_single(
 
351
            objectName='simPinSwitch')
 
352
 
 
353
        self.assertFalse(
 
354
            len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
 
355
        )
 
356
 
 
357
        self.system_settings.main_view.scroll_to_and_click(sim_lock_control)
 
358
 
 
359
        lock_dialog = self.system_settings.main_view.select_single(
 
360
            objectName='lockDialogComponent')
 
361
        self.assertEqual(
 
362
            lock_dialog.title,
 
363
            _("Enter SIM PIN")
 
364
        )
 
365
 
 
366
        prev_input = self.system_settings.main_view.select_single(
 
367
            objectName='prevInput')
 
368
        submit_button = self.system_settings.main_view.select_single(
 
369
            objectName='lockButton')
 
370
 
 
371
        self.assertEqual(
 
372
            submit_button.text,
 
373
            _("Lock")
 
374
        )
 
375
 
 
376
        self.assertFalse(
 
377
            submit_button.get_properties()['enabled']
 
378
        )
 
379
        self.system_settings.main_view.scroll_to_and_click(prev_input)
 
380
        self.keyboard.type("1234")
 
381
 
 
382
        self.assertTrue(
 
383
            submit_button.get_properties()['enabled']
 
384
        )
 
385
 
 
386
        self.system_settings.main_view.scroll_to_and_click(submit_button)
 
387
 
 
388
        self.assertFalse(
 
389
            len(self.modem_0.Get(SIM_IFACE, 'LockedPins')) > 0
 
390
        )