~ken-vandine/ubuntu-system-settings/rtm_click_framework_check

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_system_settings/tests/__init__.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:
13
13
import dbusmock
14
14
import os
15
15
import subprocess
16
 
from time import sleep
17
 
 
18
16
import ubuntuuitoolkit
 
17
 
19
18
from autopilot.matchers import Eventually
 
19
from dbusmock.templates.networkmanager import DEVICE_IFACE
 
20
from datetime import datetime
20
21
from fixtures import EnvironmentVariable
21
22
from testtools.matchers import Equals, NotEquals, GreaterThan
22
 
 
23
 
from datetime import datetime
24
 
 
 
23
from time import sleep
25
24
from ubuntu_system_settings import SystemSettings
26
25
 
27
26
ACCOUNTS_IFACE = 'org.freedesktop.Accounts'
34
33
RDO_IFACE = 'org.ofono.RadioSettings'
35
34
SIM_IFACE = 'org.ofono.SimManager'
36
35
NETREG_IFACE = 'org.ofono.NetworkRegistration'
 
36
CALL_FWD_IFACE = 'org.ofono.CallForwarding'
 
37
CALL_SETTINGS_IFACE = 'org.ofono.CallSettings'
37
38
SYSTEM_IFACE = 'com.canonical.SystemImage'
38
39
SYSTEM_SERVICE_OBJ = '/Service'
 
40
LM_SERVICE = 'org.freedesktop.login1'
 
41
LM_PATH = '/org/freedesktop/login1'
 
42
LM_IFACE = 'org.freedesktop.login1.Manager'
 
43
NM_SERVICE = 'org.freedesktop.NetworkManager'
 
44
NM_PATH = '/org/freedesktop/NetworkManager'
 
45
NM_IFACE = 'org.freedesktop.NetworkManager'
39
46
 
40
47
 
41
48
class UbuntuSystemSettingsTestCase(
51
58
            Eventually(Equals(True)))
52
59
 
53
60
    def set_orientation(self, gsettings, value):
54
 
        gsettings.set_value('orientation-lock', value)
55
 
        # wait for gsettings
56
 
        sleep(1)
 
61
        gsettings.set_value('rotation-lock', value)
 
62
        self.assertThat(
 
63
            lambda: gsettings.get_value('rotation-lock').get_boolean(),
 
64
            Eventually(Equals(value.get_boolean())))
57
65
 
58
66
 
59
67
class UbuntuSystemSettingsUpowerTestCase(UbuntuSystemSettingsTestCase,
102
110
                                        dbusmock.DBusTestCase):
103
111
    """Class for cellular tests which sets up an Ofono mock """
104
112
 
105
 
    technology_preference = 'gsm'
106
113
    use_sims = 1
107
114
 
108
115
    @property
125
132
               'for m in objects if "%s/operator/" in m]' % name
126
133
 
127
134
    def mock_connection_manager(self, modem):
128
 
        modem.AddProperty(CONNMAN_IFACE, 'Powered', True)
 
135
        modem.AddProperty(CONNMAN_IFACE, 'Powered', dbus.Boolean(1))
129
136
        modem.AddProperty(CONNMAN_IFACE, 'RoamingAllowed', False)
130
137
        modem.AddMethods(
131
138
            CONNMAN_IFACE,
175
182
            ]
176
183
        )
177
184
 
178
 
    def mock_radio_settings(self, modem):
179
 
        modem.AddProperty(
180
 
            RDO_IFACE, 'TechnologyPreference', self.technology_preference)
 
185
    def mock_radio_settings(self, modem, preference='gsm',
 
186
                            technologies=['gsm', 'umts', 'lte']):
 
187
        modem.AddProperty(
 
188
            RDO_IFACE, 'TechnologyPreference', preference)
 
189
        modem.AddProperty(
 
190
            RDO_IFACE, 'ModemTechnologies', technologies)
181
191
        modem.AddMethods(
182
192
            RDO_IFACE,
183
193
            [('GetProperties', '', 'a{sv}',
188
198
                 "PropertyChanged", "sv", [args[0], args[1]])'
189
199
                    .replace('IFACE', RDO_IFACE)), ])
190
200
 
191
 
    def mock_sim_manager(self, modem, properties=None):
192
 
        if not properties:
193
 
            properties = {
194
 
                'SubscriberNumbers': ['123456', '234567']
195
 
            }
196
 
        modem.AddProperties(SIM_IFACE, properties)
197
 
        modem.AddMethods(
198
 
            SIM_IFACE,
199
 
            [('GetProperties', '', 'a{sv}',
200
 
                'ret = self.GetAll("%s")' % SIM_IFACE),
201
 
                ('SetProperty', 'sv', '',
202
 
                 'self.Set("IFACE", args[0], args[1]); '
203
 
                 'self.EmitSignal("IFACE",\
204
 
                 "PropertyChanged", "sv", [args[0], args[1]])'
205
 
                    .replace('IFACE', SIM_IFACE)), ])
 
201
    def mock_call_forwarding(self, modem):
 
202
        modem.AddProperty(
 
203
            CALL_FWD_IFACE, 'VoiceUnconditional', '')
 
204
        modem.AddMethods(
 
205
            CALL_FWD_IFACE,
 
206
            [('GetProperties', '', 'a{sv}',
 
207
              'ret = self.GetAll("%s")' % CALL_FWD_IFACE),
 
208
                ('SetProperty', 'sv', '',
 
209
                 'self.Set("IFACE", args[0], args[1]); '
 
210
                 'self.EmitSignal("IFACE",\
 
211
                 "PropertyChanged", "sv", [args[0], args[1]])'
 
212
                    .replace('IFACE', CALL_FWD_IFACE)), ])
 
213
 
 
214
    def mock_call_settings(self, modem):
 
215
        modem.AddProperty(
 
216
            CALL_SETTINGS_IFACE, 'VoiceCallWaiting', 'disabled')
 
217
        modem.AddMethods(
 
218
            CALL_SETTINGS_IFACE,
 
219
            [('GetProperties', '', 'a{sv}',
 
220
              'ret = self.GetAll("%s")' % CALL_SETTINGS_IFACE),
 
221
                ('SetProperty', 'sv', '',
 
222
                 'self.Set("IFACE", args[0], args[1]); '
 
223
                 'self.EmitSignal("IFACE",\
 
224
                 "PropertyChanged", "sv", [args[0], args[1]])'
 
225
                    .replace('IFACE', CALL_SETTINGS_IFACE)), ])
206
226
 
207
227
    def add_sim1(self):
208
228
        # create modem_0 proxy
209
229
        self.modem_0 = self.dbus_con.get_object('org.ofono', '/ril_0')
210
230
 
211
 
        # Add an available carrier
212
231
        self.mock_carriers('ril_0')
213
 
 
214
232
        self.mock_radio_settings(self.modem_0)
215
 
 
216
233
        self.mock_connection_manager(self.modem_0)
217
 
 
218
 
        self.mock_sim_manager(self.modem_0)
 
234
        self.mock_call_forwarding(self.modem_0)
 
235
        self.mock_call_settings(self.modem_0)
219
236
 
220
237
        self.modem_0.AddMethods('org.ofono.NetworkRegistration', [
221
238
            ('GetProperties', '', 'a{sv}',
232
249
        self.dbusmock.AddModem(second_modem, {'Powered': True})
233
250
        self.modem_1 = self.dbus_con.get_object(
234
251
            'org.ofono', '/%s' % second_modem)
 
252
 
235
253
        self.modem_1.AddMethods(NETREG_IFACE, [
236
254
            ('GetProperties', '', 'a{sv}',
237
255
                'ret = self.GetAll("org.ofono.NetworkRegistration")'),
242
260
                self.get_all_operators(second_modem)),
243
261
        ])
244
262
        self.mock_carriers(second_modem)
245
 
        self.mock_radio_settings(self.modem_1)
 
263
        self.mock_radio_settings(self.modem_1, technologies=['gsm'])
246
264
        self.mock_connection_manager(self.modem_1)
 
265
        self.mock_call_forwarding(self.modem_1)
 
266
        self.mock_call_settings(self.modem_1)
247
267
 
248
 
        self.mock_sim_manager(self.modem_1, {
249
 
            'SubscriberNumbers': ['08123', '938762783']
250
 
        })
 
268
        self.modem_1.Set(
 
269
            SIM_IFACE,
 
270
            'SubscriberNumbers', ['08123', '938762783']
 
271
        )
251
272
 
252
273
    @classmethod
253
274
    def setUpClass(cls):
254
275
        cls.start_system_bus()
255
276
        cls.dbus_con = cls.get_dbus(True)
 
277
        template = os.path.join(os.path.dirname(__file__), 'ofono.py')
256
278
        # Add a mock Ofono environment so we get consistent results
257
279
        (cls.p_mock, cls.obj_ofono) = cls.spawn_server_template(
258
 
            'ofono', stdout=subprocess.PIPE)
 
280
            template, stdout=subprocess.PIPE)
259
281
        cls.dbusmock = dbus.Interface(cls.obj_ofono, dbusmock.MOCK_IFACE)
260
282
 
261
283
    def setUp(self, panel=None):
294
316
        super(CellularBaseTestCase, self).setUp('cellular')
295
317
 
296
318
 
 
319
class PhoneOfonoBaseTestCase(UbuntuSystemSettingsOfonoTestCase):
 
320
    def setUp(self):
 
321
        """ Go to Phone page """
 
322
        super(PhoneOfonoBaseTestCase, self).setUp('phone')
 
323
        self.phone_page = self.system_settings.main_view.select_single(
 
324
            objectName='phonePage'
 
325
        )
 
326
 
 
327
 
297
328
class AboutBaseTestCase(UbuntuSystemSettingsTestCase):
298
329
    def setUp(self):
299
330
        """Go to About page."""
491
522
        klass.start_system_bus()
492
523
        klass.dbus_con = klass.get_dbus(True)
493
524
 
494
 
    def setUp(self):
 
525
    def setUp(self, panel='sound'):
495
526
 
496
527
        user_obj = '/user/foo'
497
528
 
503
534
            'IncomingMessageVibrate': dbus.Boolean(False,
504
535
                                                   variant_level=1),
505
536
            'IncomingMessageVibrateSilentMode': dbus.Boolean(False,
506
 
                                                             variant_level=1)}
 
537
                                                             variant_level=1),
 
538
            'DialpadSoundsEnabled': dbus.Boolean(True,
 
539
                                                 variant_level=1)}
507
540
 
508
541
        # start dbus system bus
509
542
        self.mock_server = self.spawn_server(ACCOUNTS_IFACE, ACCOUNTS_OBJ,
562
595
                    'GetIncomingMessageVibrateSilentMode', '', 'v',
563
596
                    'ret = self.Get("%s", \
564
597
                                    "IncomingMessageVibrateSilentMode")' %
 
598
                    ACCOUNTS_SOUND_IFACE),
 
599
                (
 
600
                    'GetDialpadSoundsEnabled', '', 'v',
 
601
                    'ret = self.Get("%s", \
 
602
                                    "DialpadSoundsEnabled")' %
565
603
                    ACCOUNTS_SOUND_IFACE)
566
604
            ])
567
605
 
568
606
        self.obj_test = self.dbus_con.get_object(ACCOUNTS_IFACE, user_obj,
569
607
                                                 ACCOUNTS_IFACE)
570
608
 
571
 
        super(SoundBaseTestCase, self).setUp('sound')
 
609
        super(SoundBaseTestCase, self).setUp(panel)
572
610
 
573
611
        """ Go to Sound page """
574
 
        self.assertThat(self.system_settings.main_view.sound_page.active,
575
 
                        Eventually(Equals(True)))
 
612
        if panel == 'sound':
 
613
            self.assertThat(self.system_settings.main_view.sound_page.active,
 
614
                            Eventually(Equals(True)))
576
615
 
577
616
    def tearDown(self):
578
617
        self.mock_server.terminate()
584
623
                        dbusmock.DBusTestCase):
585
624
    """ Base class for reset settings tests"""
586
625
 
587
 
    def mock_for_launcher_reset(self):
588
 
        user_obj = '/user/foo'
589
 
        # start dbus system bus
590
 
        self.mock_server = self.spawn_server(ACCOUNTS_IFACE, ACCOUNTS_OBJ,
591
 
                                             ACCOUNTS_IFACE, system_bus=True,
592
 
                                             stdout=subprocess.PIPE)
593
 
 
594
 
        # spawn_server does not wait properly
595
 
        # Reported as bug here: http://pad.lv/1350833
596
 
        sleep(2)
597
 
        self.acc_proxy = dbus.Interface(self.dbus_con.get_object(
598
 
            ACCOUNTS_IFACE, ACCOUNTS_OBJ), dbusmock.MOCK_IFACE)
599
 
 
600
 
        self.acc_proxy.AddMethod(ACCOUNTS_IFACE, 'FindUserById', 'x', 'o',
601
 
                                 'ret = "%s"' % user_obj)
602
 
 
603
 
        self.acc_proxy.AddObject(
604
 
            user_obj, ACCOUNTS_USER_IFACE, {}, [])
605
 
 
606
 
        self.user_mock = dbus.Interface(self.dbus_con.get_object(
607
 
            ACCOUNTS_IFACE, user_obj),
608
 
            dbusmock.MOCK_IFACE)
609
 
 
610
 
        self.user_mock.AddMethod(
611
 
            'org.freedesktop.DBus.Properties', 'Set', 'ssaa{sv}', '', '')
612
 
 
613
626
    def mock_for_factory_reset(self):
614
627
        self.mock_server = self.spawn_server(SYSTEM_IFACE, SYSTEM_SERVICE_OBJ,
615
628
                                             SYSTEM_IFACE, system_bus=True,
628
641
        klass.dbus_con = klass.get_dbus(True)
629
642
 
630
643
    def setUp(self):
631
 
        self.mock_for_launcher_reset()
632
644
        self.mock_for_factory_reset()
633
 
 
634
645
        super(ResetBaseTestCase, self).setUp()
635
646
        self.reset_page = self.system_settings.main_view.go_to_reset_phone()
636
647
 
638
649
        self.mock_server.terminate()
639
650
        self.mock_server.wait()
640
651
        super(ResetBaseTestCase, self).tearDown()
 
652
 
 
653
 
 
654
class SecurityBaseTestCase(UbuntuSystemSettingsOfonoTestCase):
 
655
    """ Base class for security and privacy settings tests"""
 
656
 
 
657
    def setUp(self):
 
658
        super(SecurityBaseTestCase, self).setUp('security-privacy')
 
659
        """ Go to Security & Privacy page """
 
660
        self.security_page = self.system_settings.main_view.select_single(
 
661
            objectName='securityPrivacyPage'
 
662
        )
 
663
        self.assertThat(self.security_page.active,
 
664
                        Eventually(Equals(True)))
 
665
 
 
666
    def tearDown(self):
 
667
        super(SecurityBaseTestCase, self).tearDown()
 
668
 
 
669
 
 
670
class PhoneSoundBaseTestCase(SoundBaseTestCase):
 
671
    def setUp(self):
 
672
        """ Go to Phone page """
 
673
        super(PhoneSoundBaseTestCase, self).setUp('phone')
 
674
        self.phone_page = self.system_settings.main_view.select_single(
 
675
            objectName='phonePage'
 
676
        )
 
677
 
 
678
    def tearDown(self):
 
679
        super(PhoneSoundBaseTestCase, self).tearDown()
 
680
 
 
681
 
 
682
class LanguageBaseTestCase(UbuntuSystemSettingsTestCase,
 
683
                           dbusmock.DBusTestCase):
 
684
    """ Base class for language settings tests"""
 
685
 
 
686
    def mock_loginmanager(self):
 
687
        self.mock_server = self.spawn_server(LM_SERVICE, LM_PATH,
 
688
                                             LM_IFACE, system_bus=True,
 
689
                                             stdout=subprocess.PIPE)
 
690
        # spawn_server does not wait properly
 
691
        # Reported as bug here: http://pad.lv/1350833
 
692
        sleep(2)
 
693
        self.session_mock = dbus.Interface(self.dbus_con.get_object(
 
694
            LM_SERVICE, LM_PATH), dbusmock.MOCK_IFACE)
 
695
 
 
696
        self.session_mock.AddMethod(LM_IFACE, 'Reboot', 'b', '', '')
 
697
 
 
698
    @classmethod
 
699
    def setUpClass(klass):
 
700
        klass.start_system_bus()
 
701
        klass.dbus_con = klass.get_dbus(True)
 
702
 
 
703
    def setUp(self):
 
704
        self.mock_loginmanager()
 
705
 
 
706
        super(LanguageBaseTestCase, self).setUp()
 
707
        self.language_page = self.system_settings.\
 
708
            main_view.go_to_language_page()
 
709
 
 
710
    def tearDown(self):
 
711
        self.mock_server.terminate()
 
712
        self.mock_server.wait()
 
713
        super(LanguageBaseTestCase, self).tearDown()
 
714
 
 
715
 
 
716
class WifiBaseTestCase(UbuntuSystemSettingsTestCase,
 
717
                       dbusmock.DBusTestCase):
 
718
    """ Base class for wifi settings tests"""
 
719
 
 
720
    @classmethod
 
721
    def setUpClass(cls):
 
722
        cls.start_system_bus()
 
723
        cls.dbus_con = cls.get_dbus(True)
 
724
        # Add a mock NetworkManager environment so we get consistent results
 
725
        (cls.p_mock, cls.obj_nm) = cls.spawn_server_template(
 
726
            'networkmanager', stdout=subprocess.PIPE)
 
727
        cls.dbusmock = dbus.Interface(cls.obj_nm, dbusmock.MOCK_IFACE)
 
728
 
 
729
    def setUp(self, panel=None):
 
730
        self.obj_nm.Reset()
 
731
        device_path = self.obj_nm.AddWiFiDevice('test0', 'Barbaz', 1)
 
732
        self.device_mock = dbus.Interface(self.dbus_con.get_object(
 
733
            'org.freedesktop.NetworkManager', device_path),
 
734
            dbusmock.MOCK_IFACE)
 
735
 
 
736
        """A device should not just implement Device.Wireless/Device.Wired
 
737
        interfaces, but also the Device interface. Since we want to test
 
738
        the Disconnect method, we add it."""
 
739
 
 
740
        try:
 
741
            self.device_mock.AddMethod(DEVICE_IFACE, 'Disconnect', '', '', '')
 
742
        except:
 
743
            # it was already added
 
744
            pass
 
745
 
 
746
        super(WifiBaseTestCase, self).setUp()
 
747
        self.wifi_page = self.system_settings.\
 
748
            main_view.go_to_wifi_page()
 
749
 
 
750
    def add_previous_networks(self, networks):
 
751
        dev_path = str(self.obj_nm.GetDevices()[0])
 
752
        for network in networks:
 
753
            self.obj_nm.AddWiFiConnection(
 
754
                dev_path, network['connection_name'],
 
755
                network['ssid'], network.get('keymng', ''))