Merge lp:~jonas-drange/ubuntu-system-settings/fix-1240875 into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Ken VanDine
Approved revision: 989
Merged at revision: 992
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/fix-1240875
Merge into: lp:ubuntu-system-settings
Diff against target: 565 lines (+365/-7)
12 files modified
plugins/language/CMakeLists.txt (+2/-1)
plugins/language/DisplayLanguage.qml (+12/-5)
plugins/language/PageComponent.qml (+25/-1)
plugins/language/RebootNecessary.qml (+53/-0)
plugins/language/language-plugin.cpp (+5/-0)
plugins/language/language-plugin.h (+4/-0)
src/CMakeLists.txt (+4/-0)
src/sessionservice.cpp (+42/-0)
src/sessionservice.h (+40/-0)
tests/autopilot/ubuntu_system_settings/__init__.py (+101/-0)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+37/-0)
tests/autopilot/ubuntu_system_settings/tests/test_language.py (+40/-0)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/fix-1240875
Reviewer Review Type Date Requested Status
Ken VanDine Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+233054@code.launchpad.net

Commit message

[language] explain to the user that a reboot is necessary for the change to take effect

Description of the change

Hi,

This branch changes the UI for changing the display language. After you've confirmed a language change, a dialog will appear, prompting you to reboot the device or revert the change you made.

To be able to reboot the device, I have written a new library for USS. It's called sessionservice and currently offers functionality to reboot the device. It is modelled after accountservice and can be included by any USS plugin.

Thanks

 * Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes
 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
No
 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
No
 * Has your component "TestPlan” been executed successfully on emulator, N4?
No – waiting for debs
 * Has a 5 minute exploratory testing run been executed on N4?
No
 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
N/A
 * If you changed the UI, did you subscribe the design-reviewers to this MP?
I'll notify @mpt
 * What components might get impacted by your changes?
The language panel
 * Have you requested review by the teams of these owning components?
Yes

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, that looks fine but it's not very useful to tell the user they need to reboot if we don't expose a reboot command in the UI anywhere...

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks fine, the lack of an obvious way to reboot is an unrelated issue.

review: Approve
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Perhaps this dialog should include a "Reboot now" button?

Revision history for this message
Ken VanDine (ken-vandine) wrote :

I talked to @mpt, lets make the dialog reboot on confirmation or revert.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
989. By Jonas G. Drange

making cleanup more robust, using helper to find element lazily loaded in listview

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

Looks good, tested on mako image 220

review: Approve
Revision history for this message
Adolfo Jayme Barrientos (fitojb) wrote :

Hi, just chiming in to remind you guys that the POT file needs to be updated when introducing new strings, preferably in the same MP, so that translators can do their work with a bigger time window. Thanks!

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

@fitojb Hi, I don't know what that means.

Revision history for this message
Sebastien Bacher (seb128) wrote :

@Jonas, it means somebody needs to run "make pot" and commit an updated po/ubuntu-system-settings.pot so new strings are translatable

@Adolfo, we do that regularly, we just can't do it at every commit

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'plugins/language/CMakeLists.txt'
--- plugins/language/CMakeLists.txt 2014-01-27 16:05:26 +0000
+++ plugins/language/CMakeLists.txt 2014-09-03 22:02:11 +0000
@@ -6,6 +6,7 @@
6 KeyboardLayoutItem.qml6 KeyboardLayoutItem.qml
7 KeyboardLayouts.qml7 KeyboardLayouts.qml
8 PageComponent.qml8 PageComponent.qml
9 RebootNecessary.qml
9 SpellChecking.qml10 SpellChecking.qml
10 SubsetView.qml11 SubsetView.qml
11)12)
@@ -15,7 +16,7 @@
15 keyboard-layout.h language-plugin.h plugin.h subset-model.h16 keyboard-layout.h language-plugin.h plugin.h subset-model.h
16 ${QML_SOURCES})17 ${QML_SOURCES})
17qt5_use_modules(UbuntuLanguagePlugin Qml Quick DBus)18qt5_use_modules(UbuntuLanguagePlugin Qml Quick DBus)
18target_link_libraries(UbuntuLanguagePlugin ${GLIB_LDFLAGS} ${GIO_LDFLAGS} ${ACCOUNTSSERVICE_LDFLAGS} ${ICU_LDFLAGS})19target_link_libraries(UbuntuLanguagePlugin uss-sessionservice ${GLIB_LDFLAGS} ${GIO_LDFLAGS} ${ACCOUNTSSERVICE_LDFLAGS} ${ICU_LDFLAGS})
1920
20set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/LanguagePlugin)21set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/LanguagePlugin)
21install(TARGETS UbuntuLanguagePlugin DESTINATION ${PLUG_DIR})22install(TARGETS UbuntuLanguagePlugin DESTINATION ${PLUG_DIR})
2223
=== modified file 'plugins/language/DisplayLanguage.qml'
--- plugins/language/DisplayLanguage.qml 2014-02-27 21:17:09 +0000
+++ plugins/language/DisplayLanguage.qml 2014-09-03 22:02:11 +0000
@@ -26,9 +26,12 @@
2626
27SheetBase {27SheetBase {
28 id: root28 id: root
29 objectName: "displayLanguageDialog"
2930
30 property string initialLanguage31 property string initialLanguage
3132
33 signal languageChanged (int newLanguage, int oldLanguage)
34
32 modal: true35 modal: true
33 title: i18n.tr("Display language")36 title: i18n.tr("Display language")
3437
@@ -41,7 +44,7 @@
4144
42 ListView {45 ListView {
43 id: languageList46 id: languageList
4447 objectName: "languagesList"
45 clip: true48 clip: true
4649
47 anchors.top: parent.top50 anchors.top: parent.top
@@ -59,6 +62,7 @@
5962
60 model: plugin.languageNames63 model: plugin.languageNames
61 delegate: ListItem.Standard {64 delegate: ListItem.Standard {
65 objectName: "languageName" + index
62 text: modelData66 text: modelData
63 selected: index == languageList.currentIndex67 selected: index == languageList.currentIndex
6468
@@ -90,7 +94,7 @@
9094
91 Button {95 Button {
92 id: cancelButton96 id: cancelButton
9397 objectName: "cancelChangeLanguage"
94 text: i18n.tr("Cancel")98 text: i18n.tr("Cancel")
9599
96 anchors.left: parent.left100 anchors.left: parent.left
@@ -110,7 +114,7 @@
110114
111 Button {115 Button {
112 id: confirmButton116 id: confirmButton
113117 objectName: "confirmChangeLanguage"
114 text: i18n.tr("Confirm")118 text: i18n.tr("Confirm")
115 enabled: languageList.currentIndex != plugin.currentLanguage119 enabled: languageList.currentIndex != plugin.currentLanguage
116120
@@ -123,8 +127,11 @@
123 anchors.bottomMargin: units.gu(1)127 anchors.bottomMargin: units.gu(1)
124128
125 onClicked: {129 onClicked: {
126 plugin.currentLanguage = languageList.currentIndex130 var oldLang = plugin.currentLanguage;
127 PopupUtils.close(root)131 var newLang = languageList.currentIndex;
132 languageChanged(newLang, oldLang);
133 plugin.currentLanguage = newLang;
134 PopupUtils.close(root);
128 }135 }
129 }136 }
130 }137 }
131138
=== modified file 'plugins/language/PageComponent.qml'
--- plugins/language/PageComponent.qml 2014-08-11 16:11:20 +0000
+++ plugins/language/PageComponent.qml 2014-09-03 22:02:11 +0000
@@ -29,6 +29,7 @@
2929
30ItemPage {30ItemPage {
31 id: root31 id: root
32 objectName: "languagePage"
3233
33 title: i18n.tr("Language & Text")34 title: i18n.tr("Language & Text")
3435
@@ -39,7 +40,13 @@
39 Component {40 Component {
40 id: displayLanguage41 id: displayLanguage
4142
42 DisplayLanguage {}43 DisplayLanguage {
44 onLanguageChanged: {
45 PopupUtils.open(rebootNecessaryNotification, root, {
46 revertTo: oldLanguage
47 })
48 }
49 }
43 }50 }
4451
45 Component {52 Component {
@@ -54,6 +61,20 @@
54 SpellChecking {}61 SpellChecking {}
55 }62 }
5663
64 Component {
65 id: rebootNecessaryNotification
66
67 RebootNecessary {
68
69 onReboot: {
70 plugin.reboot();
71 }
72 onRevert: {
73 plugin.currentLanguage = to;
74 }
75 }
76 }
77
57 GSettings {78 GSettings {
58 id: settings79 id: settings
5980
@@ -77,7 +98,10 @@
77 Menus.StandardMenu {98 Menus.StandardMenu {
78 iconSource: "image://theme/language-chooser"99 iconSource: "image://theme/language-chooser"
79 text: i18n.tr("Display language…")100 text: i18n.tr("Display language…")
101 objectName: "displayLanguage"
80 component: Label {102 component: Label {
103 property int currentLanguage: plugin.currentLanguage
104 objectName: "currentLanguage"
81 text: plugin.languageNames[plugin.currentLanguage]105 text: plugin.languageNames[plugin.currentLanguage]
82 elide: Text.ElideRight106 elide: Text.ElideRight
83 opacity: enabled ? 1.0 : 0.5107 opacity: enabled ? 1.0 : 0.5
84108
=== added file 'plugins/language/RebootNecessary.qml'
--- plugins/language/RebootNecessary.qml 1970-01-01 00:00:00 +0000
+++ plugins/language/RebootNecessary.qml 2014-09-03 22:02:11 +0000
@@ -0,0 +1,53 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2014 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21import QtQuick 2.0
22import Ubuntu.Components 0.1
23import Ubuntu.Components.Popups 0.1
24
25Dialog {
26 id: dialog
27 objectName: "rebootNecessaryDialog"
28
29 property int revertTo
30
31 signal reboot()
32 signal revert(int to)
33
34 text: i18n.tr("The phone needs to restart for changes to take effect.")
35 Button {
36 id: reboot
37 objectName: "reboot"
38 text: i18n.tr("Restart Now")
39 onClicked: {
40 dialog.reboot();
41 PopupUtils.close(dialog)
42 }
43 }
44 Button {
45 id: revert
46 objectName: "revert"
47 text: i18n.tr("Cancel")
48 onClicked: {
49 dialog.revert(revertTo);
50 PopupUtils.close(dialog)
51 }
52 }
53}
054
=== modified file 'plugins/language/language-plugin.cpp'
--- plugins/language/language-plugin.cpp 2014-08-28 07:22:28 +0000
+++ plugins/language/language-plugin.cpp 2014-09-03 22:02:11 +0000
@@ -594,3 +594,8 @@
594 LanguagePlugin *plugin(static_cast<LanguagePlugin *>(user_data));594 LanguagePlugin *plugin(static_cast<LanguagePlugin *>(user_data));
595 plugin->enabledLayoutsChanged();595 plugin->enabledLayoutsChanged();
596}596}
597
598void LanguagePlugin::reboot()
599{
600 m_sessionService.reboot();
601}
597602
=== modified file 'plugins/language/language-plugin.h'
--- plugins/language/language-plugin.h 2014-08-28 07:22:28 +0000
+++ plugins/language/language-plugin.h 2014-09-03 22:02:11 +0000
@@ -23,6 +23,7 @@
2323
24#include <QtCore>24#include <QtCore>
25#include "subset-model.h"25#include "subset-model.h"
26#include "sessionservice.h"
2627
27typedef struct _ActUser ActUser;28typedef struct _ActUser ActUser;
28typedef struct _ActUserManager ActUserManager;29typedef struct _ActUserManager ActUserManager;
@@ -63,6 +64,8 @@
63 READ spellCheckingModel64 READ spellCheckingModel
64 CONSTANT)65 CONSTANT)
6566
67 Q_INVOKABLE void reboot();
68
66 explicit LanguagePlugin(QObject *parent = nullptr);69 explicit LanguagePlugin(QObject *parent = nullptr);
6770
68 virtual ~LanguagePlugin();71 virtual ~LanguagePlugin();
@@ -122,6 +125,7 @@
122 QList<KeyboardLayout *> m_keyboardLayouts;125 QList<KeyboardLayout *> m_keyboardLayouts;
123 SubsetModel m_keyboardLayoutsModel;126 SubsetModel m_keyboardLayoutsModel;
124 SubsetModel m_spellCheckingModel;127 SubsetModel m_spellCheckingModel;
128 SessionService m_sessionService;
125};129};
126130
127#endif // LANGUAGE_PLUGIN_H131#endif // LANGUAGE_PLUGIN_H
128132
=== modified file 'src/CMakeLists.txt'
--- src/CMakeLists.txt 2014-02-13 15:27:47 +0000
+++ src/CMakeLists.txt 2014-09-03 22:02:11 +0000
@@ -33,6 +33,10 @@
33install(TARGETS system-settings RUNTIME DESTINATION bin)33install(TARGETS system-settings RUNTIME DESTINATION bin)
3434
35add_library(uss-accountsservice SHARED accountsservice.h accountsservice.cpp)35add_library(uss-accountsservice SHARED accountsservice.h accountsservice.cpp)
36add_library(uss-sessionservice SHARED sessionservice.h sessionservice.cpp)
36qt5_use_modules(uss-accountsservice Core Qml DBus)37qt5_use_modules(uss-accountsservice Core Qml DBus)
38qt5_use_modules(uss-sessionservice Core Qml DBus)
37set_target_properties(uss-accountsservice PROPERTIES VERSION 0.0 SOVERSION 0.0)39set_target_properties(uss-accountsservice PROPERTIES VERSION 0.0 SOVERSION 0.0)
40set_target_properties(uss-sessionservice PROPERTIES VERSION 0.0 SOVERSION 0.0)
38install(TARGETS uss-accountsservice LIBRARY DESTINATION ${PLUGIN_MODULE_DIR} NAMELINK_SKIP)41install(TARGETS uss-accountsservice LIBRARY DESTINATION ${PLUGIN_MODULE_DIR} NAMELINK_SKIP)
42install(TARGETS uss-sessionservice LIBRARY DESTINATION ${PLUGIN_MODULE_DIR} NAMELINK_SKIP)
3943
=== added file 'src/sessionservice.cpp'
--- src/sessionservice.cpp 1970-01-01 00:00:00 +0000
+++ src/sessionservice.cpp 2014-09-03 22:02:11 +0000
@@ -0,0 +1,42 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2014 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include "sessionservice.h"
22
23#include <QDebug>
24
25#define LM_SERVICE "org.freedesktop.login1"
26#define LM_PATH "/org/freedesktop/login1"
27#define LM_IFACE "org.freedesktop.login1.Manager"
28
29SessionService::SessionService(QObject *parent)
30 : QObject(parent),
31 m_systemBusConnection(QDBusConnection::systemBus()),
32 m_loginManager(LM_SERVICE,
33 LM_PATH,
34 LM_IFACE,
35 m_systemBusConnection)
36{
37}
38
39void SessionService::reboot()
40{
41 m_loginManager.call("Reboot", false);
42}
043
=== added file 'src/sessionservice.h'
--- src/sessionservice.h 1970-01-01 00:00:00 +0000
+++ src/sessionservice.h 2014-09-03 22:02:11 +0000
@@ -0,0 +1,40 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2014 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef SESSIONSERVICE_H
22#define SESSIONSERVICE_H
23
24#include <QtDBus/QDBusInterface>
25
26class SessionService : public QObject
27{
28 Q_OBJECT
29
30public:
31 explicit SessionService (QObject *parent = 0);
32 void reboot();
33
34private:
35 QDBusConnection m_systemBusConnection;
36 QDBusInterface m_loginManager;
37
38};
39
40#endif // SESSIONSERVICE_H
041
=== modified file 'tests/autopilot/ubuntu_system_settings/__init__.py'
--- tests/autopilot/ubuntu_system_settings/__init__.py 2014-08-26 01:12:17 +0000
+++ tests/autopilot/ubuntu_system_settings/__init__.py 2014-09-03 22:02:11 +0000
@@ -110,6 +110,10 @@
110 def go_to_reset_phone(self):110 def go_to_reset_phone(self):
111 return self._go_to_page('entryComponent-reset', 'resetPage')111 return self._go_to_page('entryComponent-reset', 'resetPage')
112112
113 @autopilot.logging.log_action(logger.debug)
114 def go_to_language_page(self):
115 return self._go_to_page('entryComponent-language', 'languagePage')
116
113 def _go_to_page(self, item_object_name, page_object_name):117 def _go_to_page(self, item_object_name, page_object_name):
114 self.click_item(item_object_name)118 self.click_item(item_object_name)
115 page = self.wait_select_single(objectName=page_object_name)119 page = self.wait_select_single(objectName=page_object_name)
@@ -553,3 +557,100 @@
553 def confirm_reset(self):557 def confirm_reset(self):
554 button = self.select_single('Button', objectName='factoryResetAction')558 button = self.select_single('Button', objectName='factoryResetAction')
555 self.pointing_device.click_object(button)559 self.pointing_device.click_object(button)
560
561
562class LanguagePage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
563
564 """Autopilot helper for the Language page."""
565
566 @classmethod
567 def validate_dbus_object(cls, path, state):
568 name = introspection.get_classname_from_path(path)
569 if name == b'ItemPage':
570 if state['objectName'][1] == 'languagePage':
571 return True
572 return False
573
574 def get_current_language(self):
575 return self.select_single(
576 'Label', objectName='currentLanguage').currentLanguage
577
578 def _click_change_display_language(self):
579 item = self.select_single(objectName='displayLanguage')
580 self.pointing_device.click_object(item)
581 return self.get_root_instance().select_single(
582 objectName='displayLanguageDialog')
583
584 @autopilot.logging.log_action(logger.info)
585 def change_display_language(self, langIndex, reboot=True):
586 """Changes display language.
587
588 :param langIndex: The language index to change to.
589
590 :param reboot: Whether to reboot or not
591
592 :returns: The language page
593
594 """
595 dialog = self._click_change_display_language()
596 dialog.set_language(langIndex, reboot)
597 return self.get_root_instance()
598
599
600class DisplayLanguage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
601
602 """Autopilot helper for the Display Language dialog."""
603
604 @autopilot.logging.log_action(logger.debug)
605 def set_language(self, index, reboot):
606 self._click_language_item(index)
607 reboot_dialog = self._click_confirm()
608
609 if reboot:
610 reboot_dialog.reboot()
611 else:
612 reboot_dialog.revert()
613
614 @autopilot.logging.log_action(logger.debug)
615 def _click_language_item(self, index):
616 languages_list = self.select_single('QQuickListView',
617 objectName='languagesList')
618 languages_list.click_element('languageName%d' % index)
619
620 @autopilot.logging.log_action(logger.debug)
621 def _click_confirm(self):
622 button = self.select_single('Button',
623 objectName='confirmChangeLanguage')
624 self.pointing_device.click_object(button)
625 return self.get_root_instance().select_single(
626 objectName='rebootNecessaryDialog')
627
628 @autopilot.logging.log_action(logger.debug)
629 def _click_cancel(self):
630 button = self.select_single('Button',
631 objectName='cancelChangeLanguage')
632 self.pointing_device.click_object(button)
633
634
635class RebootNecessary(
636 ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
637
638 """Autopilot helper for the Reboot Necessary dialog."""
639
640 @autopilot.logging.log_action(logger.debug)
641 def reboot(self):
642 self._click_reboot()
643
644 @autopilot.logging.log_action(logger.debug)
645 def revert(self):
646 self._click_revert()
647
648 @autopilot.logging.log_action(logger.debug)
649 def _click_reboot(self):
650 button = self.select_single('Button', objectName='reboot')
651 self.pointing_device.click_object(button)
652
653 @autopilot.logging.log_action(logger.debug)
654 def _click_revert(self):
655 button = self.select_single('Button', objectName='revert')
656 self.pointing_device.click_object(button)
556657
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-08-28 17:33:40 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-09-03 22:02:11 +0000
@@ -38,6 +38,9 @@
38CALL_SETTINGS_IFACE = 'org.ofono.CallSettings'38CALL_SETTINGS_IFACE = 'org.ofono.CallSettings'
39SYSTEM_IFACE = 'com.canonical.SystemImage'39SYSTEM_IFACE = 'com.canonical.SystemImage'
40SYSTEM_SERVICE_OBJ = '/Service'40SYSTEM_SERVICE_OBJ = '/Service'
41LM_SERVICE = 'org.freedesktop.login1'
42LM_PATH = '/org/freedesktop/login1'
43LM_IFACE = 'org.freedesktop.login1.Manager'
4144
4245
43class UbuntuSystemSettingsTestCase(46class UbuntuSystemSettingsTestCase(
@@ -696,3 +699,37 @@
696699
697 def tearDown(self):700 def tearDown(self):
698 super(PhoneSoundBaseTestCase, self).tearDown()701 super(PhoneSoundBaseTestCase, self).tearDown()
702
703
704class LanguageBaseTestCase(UbuntuSystemSettingsTestCase,
705 dbusmock.DBusTestCase):
706 """ Base class for language settings tests"""
707
708 def mock_loginmanager(self):
709 self.mock_server = self.spawn_server(LM_SERVICE, LM_PATH,
710 LM_IFACE, system_bus=True,
711 stdout=subprocess.PIPE)
712 # spawn_server does not wait properly
713 # Reported as bug here: http://pad.lv/1350833
714 sleep(2)
715 self.session_mock = dbus.Interface(self.dbus_con.get_object(
716 LM_SERVICE, LM_PATH), dbusmock.MOCK_IFACE)
717
718 self.session_mock.AddMethod(LM_IFACE, 'Reboot', 'b', '', '')
719
720 @classmethod
721 def setUpClass(klass):
722 klass.start_system_bus()
723 klass.dbus_con = klass.get_dbus(True)
724
725 def setUp(self):
726 self.mock_loginmanager()
727
728 super(LanguageBaseTestCase, self).setUp()
729 self.language_page = self.system_settings.\
730 main_view.go_to_language_page()
731
732 def tearDown(self):
733 self.mock_server.terminate()
734 self.mock_server.wait()
735 super(LanguageBaseTestCase, self).tearDown()
699736
=== added file 'tests/autopilot/ubuntu_system_settings/tests/test_language.py'
--- tests/autopilot/ubuntu_system_settings/tests/test_language.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/test_language.py 2014-09-03 22:02:11 +0000
@@ -0,0 +1,40 @@
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
8from __future__ import absolute_import
9
10from autopilot.matchers import Eventually
11from testtools.matchers import Contains, Equals
12from ubuntu_system_settings.tests import LanguageBaseTestCase
13from ubuntu_system_settings.utils.i18n import ugettext as _
14
15
16class LanguageTestCase(LanguageBaseTestCase):
17 """Tests for Language Page"""
18
19 def test_language_page_title_is_correct(self):
20 """Checks whether Language page is available"""
21 self.assertThat(
22 self.language_page.title,
23 Equals(_('Language & Text')))
24
25 def test_change_language(self):
26 current_language = self.language_page.get_current_language()
27 target_language = current_language + 1
28 self.language_page.change_display_language(target_language)
29
30 self.assertThat(
31 lambda:
32 self.language_page.get_current_language(),
33 Eventually(Equals(target_language)))
34
35 self.addCleanup(
36 self.language_page.change_display_language, current_language)
37
38 self.assertThat(
39 lambda: str(self.session_mock.GetCalls()),
40 Eventually(Contains('Reboot')))

Subscribers

People subscribed via source and target branches