Merge lp:~mzanetti/ubuntu-system-settings/update-reset-launcher into lp:ubuntu-system-settings

Proposed by Michael Zanetti
Status: Merged
Approved by: Jonas G. Drange
Approved revision: 1098
Merged at revision: 1151
Proposed branch: lp:~mzanetti/ubuntu-system-settings/update-reset-launcher
Merge into: lp:ubuntu-system-settings
Diff against target: 193 lines (+23/-74)
5 files modified
plugins/reset/ResetLauncherHome.qml (+1/-1)
plugins/reset/reset.cpp (+2/-28)
plugins/reset/reset.h (+0/-10)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+0/-28)
tests/autopilot/ubuntu_system_settings/tests/test_reset.py (+20/-7)
To merge this branch: bzr merge lp:~mzanetti/ubuntu-system-settings/update-reset-launcher
Reviewer Review Type Date Requested Status
Jonas G. Drange (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+234309@code.launchpad.net

Commit message

update code to reset launcher after launcher backend implementation was reworked

To post a comment you must log in.
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)
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Is this binding necessary? A QML gsettings binding already exists, with he capability to reset a key IIRC.

review: Needs Information
Revision history for this message
Michael Zanetti (mzanetti) wrote :

I guess it could also be implemented in qml only... I just updated the existing code to make it work again. Not sure if the rest of the settings application prefers sticking to qml as much as possible. IMO its really a matter of taste/guidelines/consistency.

Revision history for this message
Iain Lane (laney) wrote :

On Fri, Sep 26, 2014 at 11:14:08AM -0000, Michael Zanetti wrote:
> I guess it could also be implemented in qml only... I just updated the existing code to make it work again. Not sure if the rest of the settings application prefers sticking to qml as much as possible. IMO its really a matter of taste/guidelines/consistency.

We tend to use QML APIs where they exist, so I think that (assuming
Jonas is right, I didn't double-check gsettings-qt, but I think he is)
this should be in QML.

--
Iain Lane [ <email address hidden> ]
Debian Developer [ <email address hidden> ]
Ubuntu Developer [ <email address hidden> ]

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> We tend to use QML APIs where they exist, so I think that (assuming
> Jonas is right, I didn't double-check gsettings-qt, but I think he is)
> this should be in QML.

ok. updated

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)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

Please take this over... The code should be fine, but I'm not able to update autopilot to something meaningful...

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: Approve (continuous-integration)
Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/reset/ResetLauncherHome.qml'
2--- plugins/reset/ResetLauncherHome.qml 2014-08-07 10:21:37 +0000
3+++ plugins/reset/ResetLauncherHome.qml 2014-10-01 15:08:44 +0000
4@@ -46,7 +46,7 @@
5 onClicked: {
6 dialog.state = "clicked";
7 unitySettings.schema.reset("favorites");
8- resetBackend.resetLauncher();
9+ unitySettings.schema.reset("items");
10 root.done();
11 }
12 }
13
14=== modified file 'plugins/reset/reset.cpp'
15--- plugins/reset/reset.cpp 2014-09-23 18:57:58 +0000
16+++ plugins/reset/reset.cpp 2014-10-01 15:08:44 +0000
17@@ -19,40 +19,14 @@
18 */
19
20 #include "reset.h"
21-#include <QEvent>
22+
23+#include <QDBusInterface>
24 #include <QDBusReply>
25 #include <QDebug>
26-#include <unistd.h>
27-#include <QDBusMetaType>
28-
29-typedef QList<QVariantMap> resetLauncherItemsArg;
30-Q_DECLARE_METATYPE(resetLauncherItemsArg)
31
32 Reset::Reset(QObject *parent)
33 : QObject(parent)
34 {
35- static bool isRegistered = false;
36- if(!isRegistered) {
37- qDBusRegisterMetaType<resetLauncherItemsArg>();
38- isRegistered = true;
39- }
40-}
41-
42-bool Reset::resetLauncher()
43-{
44- QList<QVariantMap> items;
45- QVariantMap defaults;
46- defaults.insert("defaults", true);
47- items << defaults;
48- QVariant answer = m_accountsService.setUserProperty(
49- "com.canonical.unity.AccountsService",
50- "launcher-items",
51- QVariant::fromValue(items));
52-
53- if (answer.isValid())
54- return true;
55-
56- return false;
57 }
58
59 bool Reset::factoryReset()
60
61=== modified file 'plugins/reset/reset.h'
62--- plugins/reset/reset.h 2014-09-23 18:47:03 +0000
63+++ plugins/reset/reset.h 2014-10-01 15:08:44 +0000
64@@ -21,13 +21,7 @@
65 #ifndef RESET_H
66 #define RESET_H
67
68-#include "accountsservice.h"
69-
70-#include <QDBusInterface>
71-#include <QDBusServiceWatcher>
72 #include <QObject>
73-#include <QProcess>
74-#include <QUrl>
75
76 class Reset : public QObject
77 {
78@@ -36,11 +30,7 @@
79 public:
80 explicit Reset(QObject *parent = 0);
81 ~Reset();
82- Q_INVOKABLE bool resetLauncher(void);
83 Q_INVOKABLE bool factoryReset(void);
84-
85-private:
86- AccountsService m_accountsService;
87 };
88
89 #endif // RESET_H
90
91=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
92--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-09-18 14:33:27 +0000
93+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2014-10-01 15:08:44 +0000
94@@ -623,32 +623,6 @@
95 dbusmock.DBusTestCase):
96 """ Base class for reset settings tests"""
97
98- def mock_for_launcher_reset(self):
99- user_obj = '/user/foo'
100- # start dbus system bus
101- self.mock_server = self.spawn_server(ACCOUNTS_IFACE, ACCOUNTS_OBJ,
102- ACCOUNTS_IFACE, system_bus=True,
103- stdout=subprocess.PIPE)
104-
105- # spawn_server does not wait properly
106- # Reported as bug here: http://pad.lv/1350833
107- sleep(2)
108- self.acc_proxy = dbus.Interface(self.dbus_con.get_object(
109- ACCOUNTS_IFACE, ACCOUNTS_OBJ), dbusmock.MOCK_IFACE)
110-
111- self.acc_proxy.AddMethod(ACCOUNTS_IFACE, 'FindUserById', 'x', 'o',
112- 'ret = "%s"' % user_obj)
113-
114- self.acc_proxy.AddObject(
115- user_obj, ACCOUNTS_USER_IFACE, {}, [])
116-
117- self.user_mock = dbus.Interface(self.dbus_con.get_object(
118- ACCOUNTS_IFACE, user_obj),
119- dbusmock.MOCK_IFACE)
120-
121- self.user_mock.AddMethod(
122- 'org.freedesktop.DBus.Properties', 'Set', 'ssaa{sv}', '', '')
123-
124 def mock_for_factory_reset(self):
125 self.mock_server = self.spawn_server(SYSTEM_IFACE, SYSTEM_SERVICE_OBJ,
126 SYSTEM_IFACE, system_bus=True,
127@@ -667,9 +641,7 @@
128 klass.dbus_con = klass.get_dbus(True)
129
130 def setUp(self):
131- self.mock_for_launcher_reset()
132 self.mock_for_factory_reset()
133-
134 super(ResetBaseTestCase, self).setUp()
135 self.reset_page = self.system_settings.main_view.go_to_reset_phone()
136
137
138=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_reset.py'
139--- tests/autopilot/ubuntu_system_settings/tests/test_reset.py 2014-07-31 23:12:24 +0000
140+++ tests/autopilot/ubuntu_system_settings/tests/test_reset.py 2014-10-01 15:08:44 +0000
141@@ -10,7 +10,7 @@
142 from time import sleep
143
144 from autopilot.matchers import Eventually
145-from gi.repository import Gio
146+from gi.repository import Gio, GLib
147 from testtools.matchers import Contains, Equals
148
149 from ubuntu_system_settings.tests import ResetBaseTestCase
150@@ -20,8 +20,8 @@
151 class ResetTestCase(ResetBaseTestCase):
152 """Tests for Reset Page"""
153
154- def set_unity_launcher_favorites(self, gsettings, favorites):
155- gsettings.set_value('favorites', favorites)
156+ def set_unity_launcher(self, gsettings, key, value):
157+ gsettings.set_value(key, value)
158 # wait for gsettings
159 sleep(1)
160
161@@ -33,15 +33,28 @@
162
163 def test_reset_launcher(self):
164 gsettings = Gio.Settings.new('com.canonical.Unity.Launcher')
165+
166 favorites = gsettings.get_value('favorites')
167- self.addCleanup(
168- self.set_unity_launcher_favorites, gsettings, favorites)
169+ gsettings.set_value(
170+ 'favorites',
171+ GLib.Variant('as', ['application://nautilus.desktop']))
172+ self.addCleanup(
173+ self.set_unity_launcher, gsettings, 'favorites', favorites)
174+
175+ items = gsettings.get_value('items')
176+ gsettings.set_value(
177+ 'items', GLib.Variant('as', ['application:///dialer-app.desktop']))
178+ self.addCleanup(
179+ self.set_unity_launcher, gsettings, 'items', items)
180
181 self.reset_page.reset_launcher()
182+ self.assertThat(
183+ lambda: gsettings.get_value('favorites'),
184+ Eventually(Equals(gsettings.get_default_value('favorites'))))
185
186 self.assertThat(
187- lambda: str(self.user_mock.GetCalls()),
188- Eventually(Contains('com.canonical.unity.AccountsService')))
189+ lambda: gsettings.get_value('items'),
190+ Eventually(Equals(gsettings.get_default_value('items'))))
191
192 def test_factory_reset(self):
193 self.reset_page.erase_and_reset_everything()

Subscribers

People subscribed via source and target branches