Merge lp:~unity-team/unity8/new-input-proxies into lp:unity8

Proposed by Michał Sawicz
Status: Merged
Approved by: Michał Sawicz
Approved revision: 2145
Merged at revision: 2243
Proposed branch: lp:~unity-team/unity8/new-input-proxies
Merge into: lp:unity8
Prerequisite: lp:~unity-team/unity8/as-refactor
Diff against target: 372 lines (+203/-5)
9 files modified
plugins/AccountsService/AccountsService.cpp (+54/-2)
plugins/AccountsService/AccountsService.h (+4/-1)
tests/plugins/AccountsService/CMakeLists.txt (+3/-0)
tests/plugins/AccountsService/PropertiesServer.cpp (+1/-2)
tests/plugins/AccountsService/UscServer.cpp (+28/-0)
tests/plugins/AccountsService/UscServer.h (+39/-0)
tests/plugins/AccountsService/client.cpp (+54/-0)
tests/plugins/AccountsService/interfaces.xml (+10/-0)
tests/plugins/AccountsService/server.cpp (+10/-0)
To merge this branch: bzr merge lp:~unity-team/unity8/new-input-proxies
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michał Sawicz Approve
Unity8 CI Bot continuous-integration Pending
Lukáš Tinkl Pending
Review via email: mp+287151@code.launchpad.net

This proposal supersedes a proposal from 2016-02-08.

Commit message

Proxy more mouse and touchpad properties to USC (LP: #1540398)

Description of the change

Mostly simple, but I added a converter capacity to our AccountsService proxy relay. And added some tests for proxy support in general (I realized it had been missed!) and specifically the converter support.

Note that MouseDoubleClickSpeed and TouchpadDoubleClickSpeed are not supported on the USC side yet. The properties exist in AccountsService, but USC/Mir haven't caught up. I added them anyway, so that there's one less thing to do to support them. It won't hurt us any to try and fail to proxy them until USC adds support.

= Checklist =

 * Are there any related MPs required for this MP to build/function as expected? Please list.
 Yes, just the pre-requisite.

 * Did you perform an exploratory manual test run of your code change and any related functionality?
 No, it's just adding properties.

 * Did you make sure that your branch does not contain spurious tags?
 Yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
 NA

 * If you changed the UI, has there been a design review?
 NA

To post a comment you must log in.
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal

FAILED: Continuous integration, rev:2142
https://unity8-jenkins.ubuntu.com/job/lp-unity8-1-ci/292/
Executed test runs:
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build/412/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-0-fetch/435
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/453
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/453
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/449
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=vivid+overlay/449/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=amd64,release=xenial/449/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/449
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=vivid+overlay/449/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=armhf,release=xenial/449/console
    SUCCESS: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/449
        deb: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=vivid+overlay/449/artifact/output/*zip*/output.zip
    FAILURE: https://unity8-jenkins.ubuntu.com/job/build-2-binpkg/arch=i386,release=xenial/449/console

Click here to trigger a rebuild:
https://unity8-jenkins.ubuntu.com/job/lp-unity8-1-ci/292/rebuild

review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Some minor stuff in inline comments, otherwise looks great

review: Needs Fixing (code-review)
Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

Commented, updated.

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Lukáš Tinkl (lukas-kde) wrote : Posted in a previous version of this proposal

Cool, I like it

* Did you perform an exploratory manual test run of the code change and any related functionality?

Yes

* Did CI run pass? If not, please explain why.

No, missing explicit dependency on https://code.launchpad.net/~unity-team/unity-api/surfaceItemSizeHints/+merge/284890 in the chain

* Did you make sure that the branch does not contain spurious tags?

Yes

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

I had to muck with the bzr history due to some pre-req shenanigans. But the diff is the same.

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

CMake Error at tests/plugins/AccountsService/CMakeLists.txt:28 (add_executable):
  Cannot find source file:

    UscServer.cpp

review: Needs Fixing
Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Terry (mterry) wrote : Posted in a previous version of this proposal

Whoops, forgot to bzr add UscServer.{cpp,h} when I was rebasing this branch. Those files were included in the original MP and review. I just dropped them when futzing with bzr history. :-/

Fixed now.

Revision history for this message
Unity8 CI Bot (unity8-ci-bot) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) : Posted in a previous version of this proposal
review: Abstain
Revision history for this message
Michał Sawicz (saviq) wrote :

Approving as per superseded MP.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :

FAILED: Continuous integration, rev:2145
http://jenkins.qa.ubuntu.com/job/unity8-ci/7413/
Executed test runs:
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-vivid-touch/6630
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-xenial-touch/828/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity-phablet-qmluitests-vivid/2118
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-qmluitest-xenial-amd64/821
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-amd64-ci/2013
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-vivid-i386-ci/2013
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-amd64-ci/820
    SUCCESS: http://jenkins.qa.ubuntu.com/job/unity8-xenial-i386-ci/819
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-vivid-touch/5033
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/6641
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-vivid-armhf/6641/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27884
    FAILURE: http://jenkins.qa.ubuntu.com/job/generic-deb-autopilot-runner-xenial-touch/427/console
    SUCCESS: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/826
        deb: http://jenkins.qa.ubuntu.com/job/generic-mediumtests-builder-xenial-armhf/826/artifact/work/output/*zip*/output.zip
    SUCCESS: http://s-jenkins.ubuntu-ci:8080/job/touch-flash-device/27883

Click here to trigger a rebuild:
http://s-jenkins.ubuntu-ci:8080/job/unity8-ci/7413/rebuild

review: Needs Fixing (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/AccountsService/AccountsService.cpp'
2--- plugins/AccountsService/AccountsService.cpp 2016-02-25 10:58:15 +0000
3+++ plugins/AccountsService/AccountsService.cpp 2016-02-25 10:58:16 +0000
4@@ -40,9 +40,32 @@
5 #define PROP_LICENSE_ACCEPTED QStringLiteral("LicenseAccepted")
6 #define PROP_LICENSE_BASE_PATH QStringLiteral("LicenseBasePath")
7 #define PROP_MOUSE_CURSOR_SPEED QStringLiteral("MouseCursorSpeed")
8+#define PROP_MOUSE_DOUBLE_CLICK_SPEED QStringLiteral("MouseDoubleClickSpeed")
9+#define PROP_MOUSE_PRIMARY_BUTTON QStringLiteral("MousePrimaryButton")
10+#define PROP_MOUSE_SCROLL_SPEED QStringLiteral("MouseScrollSpeed")
11 #define PROP_PASSWORD_DISPLAY_HINT QStringLiteral("PasswordDisplayHint")
12 #define PROP_STATS_WELCOME_SCREEN QStringLiteral("StatsWelcomeScreen")
13 #define PROP_TOUCHPAD_CURSOR_SPEED QStringLiteral("TouchpadCursorSpeed")
14+#define PROP_TOUCHPAD_DISABLE_WHILE_TYPING QStringLiteral("TouchpadDisableWhileTyping")
15+#define PROP_TOUCHPAD_DISABLE_WITH_MOUSE QStringLiteral("TouchpadDisableWithMouse")
16+#define PROP_TOUCHPAD_DOUBLE_CLICK_SPEED QStringLiteral("TouchpadDoubleClickSpeed")
17+#define PROP_TOUCHPAD_PRIMARY_BUTTON QStringLiteral("TouchpadPrimaryButton")
18+#define PROP_TOUCHPAD_SCROLL_SPEED QStringLiteral("TouchpadScrollSpeed")
19+#define PROP_TOUCHPAD_TAP_TO_CLICK QStringLiteral("TouchpadTapToClick")
20+#define PROP_TOUCHPAD_TWO_FINGER_SCROLL QStringLiteral("TouchpadTwoFingerScroll")
21+
22+
23+QVariant primaryButtonConverter(const QVariant &value)
24+{
25+ QString stringValue = value.toString();
26+ if (stringValue == "left") {
27+ return QVariant::fromValue(0);
28+ } else if (stringValue == "right") {
29+ return QVariant::fromValue(1); // Mir is less clear on this -- any non-zero value is the same
30+ } else {
31+ return QVariant::fromValue(0); // default to left
32+ }
33+}
34
35 AccountsService::AccountsService(QObject* parent, const QString &user)
36 : QObject(parent)
37@@ -68,8 +91,30 @@
38
39 registerProxy(IFACE_UBUNTU_INPUT, PROP_MOUSE_CURSOR_SPEED,
40 m_unityInput, QStringLiteral("setMouseCursorSpeed"));
41+ registerProxy(IFACE_UBUNTU_INPUT, PROP_MOUSE_DOUBLE_CLICK_SPEED,
42+ m_unityInput, QStringLiteral("setMouseDoubleClickSpeed"));
43+ registerProxy(IFACE_UBUNTU_INPUT, PROP_MOUSE_PRIMARY_BUTTON,
44+ m_unityInput, QStringLiteral("setMousePrimaryButton"),
45+ primaryButtonConverter);
46+ registerProxy(IFACE_UBUNTU_INPUT, PROP_MOUSE_SCROLL_SPEED,
47+ m_unityInput, QStringLiteral("setMouseScrollSpeed"));
48 registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_CURSOR_SPEED,
49 m_unityInput, QStringLiteral("setTouchpadCursorSpeed"));
50+ registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_SCROLL_SPEED,
51+ m_unityInput, QStringLiteral("setTouchpadScrollSpeed"));
52+ registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_DISABLE_WHILE_TYPING,
53+ m_unityInput, QStringLiteral("setTouchpadDisableWhileTyping"));
54+ registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_DISABLE_WITH_MOUSE,
55+ m_unityInput, QStringLiteral("setTouchpadDisableWithMouse"));
56+ registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_DOUBLE_CLICK_SPEED,
57+ m_unityInput, QStringLiteral("setTouchpadDoubleClickSpeed"));
58+ registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_PRIMARY_BUTTON,
59+ m_unityInput, QStringLiteral("setTouchpadPrimaryButton"),
60+ primaryButtonConverter);
61+ registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_TAP_TO_CLICK,
62+ m_unityInput, QStringLiteral("setTouchpadTapToClick"));
63+ registerProxy(IFACE_UBUNTU_INPUT, PROP_TOUCHPAD_TWO_FINGER_SCROLL,
64+ m_unityInput, QStringLiteral("setTouchpadTwoFingerScroll"));
65
66 setUser(!user.isEmpty() ? user : QString::fromUtf8(qgetenv("USER")));
67 }
68@@ -200,7 +245,13 @@
69 PropertyInfo &info = m_properties[interface][property];
70
71 if (info.proxyInterface) {
72- info.proxyInterface->asyncCall(info.proxyMethod, value);
73+ QVariant finalValue;
74+ if (info.proxyConverter) {
75+ finalValue = info.proxyConverter(value);
76+ } else {
77+ finalValue = value;
78+ }
79+ info.proxyInterface->asyncCall(info.proxyMethod, finalValue);
80 return; // don't bother saving a copy
81 }
82
83@@ -259,12 +310,13 @@
84 }
85 }
86
87-void AccountsService::registerProxy(const QString &interface, const QString &property, QDBusInterface *iface, const QString &method)
88+void AccountsService::registerProxy(const QString &interface, const QString &property, QDBusInterface *iface, const QString &method, ProxyConverter converter)
89 {
90 registerProperty(interface, property, nullptr);
91
92 m_properties[interface][property].proxyInterface = iface;
93 m_properties[interface][property].proxyMethod = method;
94+ m_properties[interface][property].proxyConverter = converter;
95 }
96
97 void AccountsService::registerProperty(const QString &interface, const QString &property, const QString &signal)
98
99=== modified file 'plugins/AccountsService/AccountsService.h'
100--- plugins/AccountsService/AccountsService.h 2016-02-25 10:58:15 +0000
101+++ plugins/AccountsService/AccountsService.h 2016-02-25 10:58:16 +0000
102@@ -111,9 +111,11 @@
103 void onMaybeChanged(const QString &user);
104
105 private:
106+ typedef QVariant (*ProxyConverter)(const QVariant &);
107+
108 void refresh(bool async);
109 void registerProperty(const QString &interface, const QString &property, const QString &signal);
110- void registerProxy(const QString &interface, const QString &property, QDBusInterface *iface, const QString &method);
111+ void registerProxy(const QString &interface, const QString &property, QDBusInterface *iface, const QString &method, ProxyConverter converter = nullptr);
112
113 void updateAllProperties(const QString &interface, bool async);
114 void updateProperty(const QString &interface, const QString &property);
115@@ -129,6 +131,7 @@
116 QString signal{};
117 QDBusInterface *proxyInterface{};
118 QString proxyMethod{};
119+ ProxyConverter proxyConverter{};
120 };
121 typedef QHash< QString, QHash<QString, PropertyInfo> > PropertyHash;
122 PropertyHash m_properties;
123
124=== modified file 'tests/plugins/AccountsService/CMakeLists.txt'
125--- tests/plugins/AccountsService/CMakeLists.txt 2016-02-25 10:58:15 +0000
126+++ tests/plugins/AccountsService/CMakeLists.txt 2016-02-25 10:58:16 +0000
127@@ -16,6 +16,7 @@
128 make_dbus_class(Location com.ubuntu.location.providers.here.AccountsService)
129 make_dbus_class(AccountsUser org.freedesktop.Accounts.User)
130 make_dbus_class(AccountsPrivate com.canonical.unity.AccountsService.Private)
131+make_dbus_class(UscInput com.canonical.Unity.Input)
132
133 include_directories(
134 ${CMAKE_CURRENT_BINARY_DIR}
135@@ -32,9 +33,11 @@
136 ${CMAKE_CURRENT_BINARY_DIR}/PropertiesAdaptor.cpp
137 ${CMAKE_CURRENT_BINARY_DIR}/LocationAdaptor.cpp
138 ${CMAKE_CURRENT_BINARY_DIR}/SecurityPrivacyAdaptor.cpp
139+ ${CMAKE_CURRENT_BINARY_DIR}/UscInputAdaptor.cpp
140 server.cpp
141 AccountsServer.cpp
142 PropertiesServer.cpp
143+ UscServer.cpp
144 )
145 qt5_use_modules(mock-server Core DBus)
146
147
148=== modified file 'tests/plugins/AccountsService/PropertiesServer.cpp'
149--- tests/plugins/AccountsService/PropertiesServer.cpp 2016-02-25 10:58:15 +0000
150+++ tests/plugins/AccountsService/PropertiesServer.cpp 2016-02-25 10:58:16 +0000
151@@ -92,8 +92,7 @@
152 m_properties["com.canonical.unity.AccountsService"]["LauncherItems"] = QVariant::fromValue(QList<QVariantMap>());
153 m_properties["com.canonical.unity.AccountsService.Private"]["FailedLogins"] = 0;
154 m_properties["com.ubuntu.touch.AccountsService.SecurityPrivacy"]["StatsWelcomeScreen"] = true;
155- m_properties["com.ubuntu.AccountsService.Input"]["MouseCursorSpeed"] = 0.5;
156- m_properties["com.ubuntu.AccountsService.Input"]["TouchpadCursorSpeed"] = 0.5;
157+ m_properties["com.ubuntu.AccountsService.Input"]["MousePrimaryButton"] = "right";
158 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableLauncherWhileLocked"] = true;
159 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["EnableIndicatorsWhileLocked"] = true;
160 m_properties["com.ubuntu.AccountsService.SecurityPrivacy"]["PasswordDisplayHint"] = AccountsService::Keyboard;
161
162=== added file 'tests/plugins/AccountsService/UscServer.cpp'
163--- tests/plugins/AccountsService/UscServer.cpp 1970-01-01 00:00:00 +0000
164+++ tests/plugins/AccountsService/UscServer.cpp 2016-02-25 10:58:16 +0000
165@@ -0,0 +1,28 @@
166+/*
167+ * Copyright 2016 Canonical Ltd.
168+ *
169+ * This program is free software: you can redistribute it and/or modify it
170+ * under the terms of the GNU General Public License version 3, as published
171+ * by the Free Software Foundation.
172+ *
173+ * This program is distributed in the hope that it will be useful, but
174+ * WITHOUT ANY WARRANTY; without even the implied warranties of
175+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
176+ * PURPOSE. See the GNU General Public License for more details.
177+ *
178+ * You should have received a copy of the GNU General Public License
179+ * version 3 along with this program. If not, see
180+ * <http://www.gnu.org/licenses/>
181+ */
182+
183+#include "UscServer.h"
184+
185+UscServer::UscServer(QObject *parent)
186+ : QObject(parent)
187+{
188+}
189+
190+void UscServer::setMousePrimaryButton(int button)
191+{
192+ Q_EMIT setMousePrimaryButtonCalled(button);
193+}
194
195=== added file 'tests/plugins/AccountsService/UscServer.h'
196--- tests/plugins/AccountsService/UscServer.h 1970-01-01 00:00:00 +0000
197+++ tests/plugins/AccountsService/UscServer.h 2016-02-25 10:58:16 +0000
198@@ -0,0 +1,39 @@
199+/*
200+ * Copyright 2016 Canonical Ltd.
201+ *
202+ * This program is free software: you can redistribute it and/or modify it
203+ * under the terms of the GNU General Public License version 3, as published
204+ * by the Free Software Foundation.
205+ *
206+ * This program is distributed in the hope that it will be useful, but
207+ * WITHOUT ANY WARRANTY; without even the implied warranties of
208+ * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
209+ * PURPOSE. See the GNU General Public License for more details.
210+ *
211+ * You should have received a copy of the GNU General Public License
212+ * version 3 along with this program. If not, see
213+ * <http://www.gnu.org/licenses/>
214+ */
215+
216+#ifndef UNITY_USCSERVER_H
217+#define UNITY_USCSERVER_H
218+
219+#include <QDBusContext>
220+#include <QObject>
221+
222+class UscServer: public QObject, protected QDBusContext
223+{
224+ Q_OBJECT
225+
226+public:
227+ explicit UscServer(QObject *parent = nullptr);
228+
229+public Q_SLOTS:
230+ void setMousePrimaryButton(int button);
231+
232+Q_SIGNALS:
233+ // mock only.
234+ void setMousePrimaryButtonCalled(int button);
235+};
236+
237+#endif
238
239=== modified file 'tests/plugins/AccountsService/client.cpp'
240--- tests/plugins/AccountsService/client.cpp 2016-02-25 10:58:15 +0000
241+++ tests/plugins/AccountsService/client.cpp 2016-02-25 10:58:16 +0000
242@@ -42,7 +42,16 @@
243 : QObject(parent)
244 , m_userInterface(nullptr)
245 , m_spy(this, &AccountsServiceTest::propertiesChanged)
246+ , m_mousePrimaryButtonSpy(this, &AccountsServiceTest::setMousePrimaryButtonCalled)
247 {
248+ m_uscInputInterface = new QDBusInterface("com.canonical.Unity.Input",
249+ "/com/canonical/Unity/Input",
250+ "com.canonical.Unity.Input",
251+ QDBusConnection::sessionBus(),
252+ this);
253+
254+ QObject::connect(m_uscInputInterface, SIGNAL(setMousePrimaryButtonCalled(int)),
255+ this, SIGNAL(setMousePrimaryButtonCalled(int)));
256 }
257
258 private Q_SLOTS:
259@@ -71,6 +80,7 @@
260
261 delete m_userInterface;
262 m_spy.clear();
263+ m_mousePrimaryButtonSpy.clear();
264 }
265
266 void testInvalids()
267@@ -215,12 +225,56 @@
268 QTRY_COMPARE(session.backgroundFile(), QString("/test/BackgroundFile"));
269 }
270
271+ void testProxyOnStartup()
272+ {
273+ AccountsService session(this, QTest::currentTestFunction());
274+
275+ QTRY_COMPARE(m_mousePrimaryButtonSpy.count(), 1);
276+ QList<QVariant> arguments = m_mousePrimaryButtonSpy.takeFirst();
277+ QCOMPARE(arguments.at(0).toInt(), 1);
278+ }
279+
280+ void testProxyOnChange()
281+ {
282+ AccountsService session(this, QTest::currentTestFunction());
283+ QTRY_COMPARE(m_mousePrimaryButtonSpy.count(), 1);
284+ m_mousePrimaryButtonSpy.clear();
285+
286+ ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
287+ "com.ubuntu.AccountsService.Input",
288+ "MousePrimaryButton",
289+ dbusVariant("left")));
290+
291+ QTRY_COMPARE(m_mousePrimaryButtonSpy.count(), 1);
292+ QList<QVariant> arguments = m_mousePrimaryButtonSpy.takeFirst();
293+ QCOMPARE(arguments.at(0).toInt(), 0);
294+ }
295+
296+ void testInvalidPrimaryButton()
297+ {
298+ AccountsService session(this, QTest::currentTestFunction());
299+ QTRY_COMPARE(m_mousePrimaryButtonSpy.count(), 1);
300+ m_mousePrimaryButtonSpy.clear();
301+
302+ ASSERT_DBUS_CALL(m_userInterface->asyncCall("Set",
303+ "com.ubuntu.AccountsService.Input",
304+ "MousePrimaryButton",
305+ dbusVariant("NOPE")));
306+
307+ QTRY_COMPARE(m_mousePrimaryButtonSpy.count(), 1);
308+ QList<QVariant> arguments = m_mousePrimaryButtonSpy.takeFirst();
309+ QCOMPARE(arguments.at(0).toInt(), 0);
310+ }
311+
312 Q_SIGNALS:
313 void propertiesChanged(const QString &interface, const QVariantMap &changed, const QStringList &invalid);
314+ void setMousePrimaryButtonCalled(int button);
315
316 private:
317+ QDBusInterface* m_uscInputInterface;
318 QDBusInterface* m_userInterface;
319 QSignalSpy m_spy;
320+ QSignalSpy m_mousePrimaryButtonSpy;
321 };
322
323 QTEST_MAIN(AccountsServiceTest)
324
325=== modified file 'tests/plugins/AccountsService/interfaces.xml'
326--- tests/plugins/AccountsService/interfaces.xml 2016-02-25 10:58:15 +0000
327+++ tests/plugins/AccountsService/interfaces.xml 2016-02-25 10:58:16 +0000
328@@ -44,4 +44,14 @@
329 <signal name="Changed" />
330 </interface>
331 <interface name="com.canonical.unity.AccountsService.Private" />
332+
333+ <interface name="com.canonical.Unity.Input">
334+ <method name="setMousePrimaryButton">
335+ <arg name="button" type="i" direction="in" />
336+ </method>
337+ <!-- Just for testing -->
338+ <signal name="setMousePrimaryButtonCalled">
339+ <arg name="button" type="i" direction="out" />
340+ </signal>
341+ </interface>
342 </node>
343
344=== modified file 'tests/plugins/AccountsService/server.cpp'
345--- tests/plugins/AccountsService/server.cpp 2016-02-25 10:58:15 +0000
346+++ tests/plugins/AccountsService/server.cpp 2016-02-25 10:58:16 +0000
347@@ -24,6 +24,8 @@
348 #include "SecurityPrivacyAdaptor.h"
349 #include "LocationAdaptor.h"
350 #include "AccountsPrivateAdaptor.h"
351+#include "UscInputAdaptor.h"
352+#include "UscServer.h"
353 #include <QCoreApplication>
354
355 int main(int argc, char *argv[])
356@@ -36,8 +38,16 @@
357 new SecurityPrivacyAdaptor(accounts);
358 new LocationAdaptor(accounts);
359 new AccountsPrivateAdaptor(accounts);
360+
361+ auto usc = new UscServer(&a);
362+ new UscInputAdaptor(usc);
363+
364 // We use the session bus for testing. The real plugin uses the system bus
365 auto connection = QDBusConnection::sessionBus();
366+ if (!connection.registerObject("/com/canonical/Unity/Input", usc))
367+ return 1;
368+ if (!connection.registerService("com.canonical.Unity.Input"))
369+ return 1;
370 if (!connection.registerObject("/org/freedesktop/Accounts", accounts))
371 return 1;
372 if (!connection.registerService("org.freedesktop.Accounts"))

Subscribers

People subscribed via source and target branches