Merge lp:~unity-api-team/libqtdbusmock/template-parameters into lp:libqtdbusmock

Proposed by Pete Woods on 2015-10-08
Status: Merged
Approved by: Pete Woods on 2015-10-09
Approved revision: 42
Merged at revision: 42
Proposed branch: lp:~unity-api-team/libqtdbusmock/template-parameters
Merge into: lp:libqtdbusmock
Diff against target: 255 lines (+146/-11)
6 files modified
debian/changelog (+9/-0)
debian/control (+2/-2)
debian/libqtdbusmock1.symbols (+13/-1)
src/libqtdbusmock/DBusMock.cpp (+80/-8)
src/libqtdbusmock/DBusMock.h (+27/-0)
tests/libqtdbusmock/TestDBusMock.cpp (+15/-0)
To merge this branch: bzr merge lp:~unity-api-team/libqtdbusmock/template-parameters
Reviewer Review Type Date Requested Status
Unity Team 2015-10-08 Pending
Review via email: mp+273844@code.launchpad.net

Commit message

Enable the passing of parameters to templates. Add extra templates. Fix version number of registerTemplate symbol (marked 0changeme). Depend on python-dbusmock >= 0.16

Description of the change

Enable the passing of parameters to templates. Add extra templates. Fix version number of registerTemplate symbol (marked 0changeme). Depend on python-dbusmock >= 0.16

To post a comment you must log in.
42. By Pete Woods on 2015-10-09

Enable the passing of parameters to templates
Add extra templates
Depend on python-dbusmock >= 0.16

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2015-10-06 11:47:54 +0000
3+++ debian/changelog 2015-10-09 10:55:59 +0000
4@@ -1,3 +1,12 @@
5+libqtdbusmock (0.5-0ubuntu1) UNRELEASED; urgency=medium
6+
7+ * Enable the passing of parameters to templates.
8+ * Add methods for all templates from dbusmock.
9+ * Fix version number of registerTemplate symbol (marked 0changeme).
10+ * Depend on python-dbusmock >= 0.16
11+
12+ -- Pete Woods <pete.woods@canonical.com> Fri, 09 Oct 2015 11:54:18 +0100
13+
14 libqtdbusmock (0.4+15.10.20151006.3-0ubuntu1) wily; urgency=medium
15
16 [ Pete Woods ]
17
18=== modified file 'debian/control'
19--- debian/control 2015-10-06 11:46:45 +0000
20+++ debian/control 2015-10-09 10:55:59 +0000
21@@ -9,7 +9,7 @@
22 libqtdbustest1-dev,
23 network-manager-dev,
24 pkg-config,
25- python3-dbusmock (>= 0.14),
26+ python3-dbusmock (>= 0.16),
27 qtbase5-dev,
28 Standards-Version: 3.9.4
29 Homepage: https://launchpad.net/libqtdbustest
30@@ -22,7 +22,7 @@
31 Architecture: any
32 Multi-Arch: same
33 Pre-Depends: ${misc:Pre-Depends},
34-Depends: python3-dbusmock,
35+Depends: python3-dbusmock (>= 0.16),
36 ${misc:Depends},
37 ${shlibs:Depends},
38 Description: Library for mocking DBus interactions using Qt
39
40=== modified file 'debian/libqtdbusmock1.symbols'
41--- debian/libqtdbusmock1.symbols 2015-10-06 11:47:54 +0000
42+++ debian/libqtdbusmock1.symbols 2015-10-09 10:55:59 +0000
43@@ -39,7 +39,19 @@
44 (c++)"QtDBusMock::DBusMock::registerNotificationDaemon()@Base" 0.3+15.04.20150331
45 (c++)"QtDBusMock::DBusMock::registerOfono()@Base" 0.3+15.04.20150331
46 (c++)"QtDBusMock::DBusMock::registerURfkill()@Base" 0.3+15.04.20150331
47- (c++)"QtDBusMock::DBusMock::registerTemplate(QString const&, QString const&, QDBusConnection::BusType)@Base" 0changeme
48+ (c++)"QtDBusMock::DBusMock::registerOfono(QMap<QString, QVariant> const&)@Base" 0replaceme
49+ (c++)"QtDBusMock::DBusMock::registerBluez4(QMap<QString, QVariant> const&)@Base" 0replaceme
50+ (c++)"QtDBusMock::DBusMock::registerBluez5(QMap<QString, QVariant> const&)@Base" 0replaceme
51+ (c++)"QtDBusMock::DBusMock::registerLogind(QMap<QString, QVariant> const&)@Base" 0replaceme
52+ (c++)"QtDBusMock::DBusMock::registerUpower(QMap<QString, QVariant> const&)@Base" 0replaceme
53+ (c++)"QtDBusMock::DBusMock::registerURfkill(QMap<QString, QVariant> const&)@Base" 0replaceme
54+ (c++)"QtDBusMock::DBusMock::registerTemplate(QString const&, QString const&, QMap<QString, QVariant> const&, QDBusConnection::BusType)@Base" 0replaceme
55+ (c++)"QtDBusMock::DBusMock::registerTimeDate(QMap<QString, QVariant> const&)@Base" 0replaceme
56+ (c++)"QtDBusMock::DBusMock::registerPolicyKit(QMap<QString, QVariant> const&)@Base" 0replaceme
57+ (c++)"QtDBusMock::DBusMock::registerNetworkManager(QMap<QString, QVariant> const&)@Base" 0replaceme
58+ (c++)"QtDBusMock::DBusMock::registerGnomeScreensaver(QMap<QString, QVariant> const&)@Base" 0replaceme
59+ (c++)"QtDBusMock::DBusMock::registerNotificationDaemon(QMap<QString, QVariant> const&)@Base" 0replaceme
60+ (c++)"QtDBusMock::DBusMock::registerTemplate(QString const&, QString const&, QDBusConnection::BusType)@Base" 0.2+14.10.20140730-0ubuntu1
61 (c++)"QtDBusMock::DBusMock::networkManagerInterface()@Base" 0.1
62 (c++)"QtDBusMock::DBusMock::notificationDaemonInterface()@Base" 0.3+15.04.20150331
63 (c++)"QtDBusMock::DBusMock::ofonoInterface()@Base" 0.3+15.04.20150331
64
65=== modified file 'src/libqtdbusmock/DBusMock.cpp'
66--- src/libqtdbusmock/DBusMock.cpp 2015-03-06 05:37:46 +0000
67+++ src/libqtdbusmock/DBusMock.cpp 2015-10-09 10:55:59 +0000
68@@ -20,6 +20,7 @@
69 #include <libqtdbustest/QProcessDBusService.h>
70
71 #include <NetworkManager.h>
72+#include <QJsonDocument>
73
74 using namespace QtDBusTest;
75
76@@ -70,28 +71,99 @@
77 void DBusMock::registerTemplate(const QString &service,
78 const QString &templateName,
79 QDBusConnection::BusType busType) {
80+ registerTemplate(service, templateName, QVariantMap(), busType);
81+}
82+
83+
84+void DBusMock::registerTemplate(const QString &service,
85+ const QString &templateName,
86+ const QVariantMap& parameters,
87+ QDBusConnection::BusType busType) {
88+ QStringList arguments;
89+ arguments << "-m" << "dbusmock";
90+ arguments << "--template" << templateName;
91+
92+ if (!parameters.isEmpty())
93+ {
94+ auto doc = QJsonDocument::fromVariant(parameters);
95+ arguments << "--parameters" << QString::fromUtf8(doc.toJson(QJsonDocument::Compact));
96+ }
97+
98 d->m_testRunner.registerService(
99 DBusServicePtr(
100- new QProcessDBusService(service,
101- busType, "python3",
102- QStringList() << "-m" << "dbusmock" << "--template"
103- << templateName)));
104+ new QProcessDBusService(service, busType, "python3",
105+ arguments)));
106+}
107+
108+void DBusMock::registerBluez5(const QVariantMap& parameters) {
109+ registerTemplate("org.bluez", "bluez5", parameters,
110+ QDBusConnection::SystemBus);
111+}
112+
113+void DBusMock::registerBluez4(const QVariantMap& parameters) {
114+ registerTemplate("org.bluez", "bluez4", parameters,
115+ QDBusConnection::SystemBus);
116+}
117+
118+void DBusMock::registerGnomeScreensaver(const QVariantMap& parameters) {
119+ registerTemplate("org.gnome.ScreenSaver", "gnome_screensaver", parameters,
120+ QDBusConnection::SessionBus);
121+}
122+
123+void DBusMock::registerLogind(const QVariantMap& parameters) {
124+ registerTemplate("org.freedesktop.login1", "logind", parameters,
125+ QDBusConnection::SystemBus);
126 }
127
128 void DBusMock::registerNetworkManager() {
129- registerTemplate(NM_DBUS_SERVICE, "networkmanager", QDBusConnection::SystemBus);
130+ registerNetworkManager(QVariantMap());
131+}
132+
133+void DBusMock::registerNetworkManager(const QVariantMap& parameters) {
134+ registerTemplate(NM_DBUS_SERVICE, "networkmanager", parameters,
135+ QDBusConnection::SystemBus);
136 }
137
138 void DBusMock::registerNotificationDaemon() {
139- registerTemplate("org.freedesktop.Notifications", "notification_daemon", QDBusConnection::SessionBus);
140+ registerNotificationDaemon(QVariantMap());
141+}
142+
143+void DBusMock::registerNotificationDaemon(const QVariantMap& parameters) {
144+ registerTemplate("org.freedesktop.Notifications", "notification_daemon",
145+ parameters, QDBusConnection::SessionBus);
146 }
147
148 void DBusMock::registerOfono() {
149- registerTemplate("org.ofono", "ofono", QDBusConnection::SystemBus);
150+ registerOfono(QVariantMap());
151+}
152+
153+void DBusMock::registerOfono(const QVariantMap& parameters) {
154+ registerTemplate("org.ofono", "ofono", parameters,
155+ QDBusConnection::SystemBus);
156+}
157+
158+void DBusMock::registerPolicyKit(const QVariantMap& parameters) {
159+ registerTemplate("org.freedesktop.PolicyKit1", "polkitd", parameters,
160+ QDBusConnection::SystemBus);
161+}
162+
163+void DBusMock::registerTimeDate(const QVariantMap& parameters) {
164+ registerTemplate("org.freedesktop.timedate1", "timedated", parameters,
165+ QDBusConnection::SystemBus);
166 }
167
168 void DBusMock::registerURfkill() {
169- registerTemplate("org.freedesktop.URfkill", "urfkill", QDBusConnection::SystemBus);
170+ registerURfkill(QVariantMap());
171+}
172+
173+void DBusMock::registerUpower(const QVariantMap& parameters) {
174+ registerTemplate("org.freedesktop.UPower", "upower", parameters,
175+ QDBusConnection::SystemBus);
176+}
177+
178+void DBusMock::registerURfkill(const QVariantMap& parameters) {
179+ registerTemplate("org.freedesktop.URfkill", "urfkill", parameters,
180+ QDBusConnection::SystemBus);
181 }
182
183 void DBusMock::registerCustomMock(const QString &name, const QString &path,
184
185=== modified file 'src/libqtdbusmock/DBusMock.h'
186--- src/libqtdbusmock/DBusMock.h 2015-03-06 05:37:46 +0000
187+++ src/libqtdbusmock/DBusMock.h 2015-10-09 10:55:59 +0000
188@@ -49,14 +49,41 @@
189 const QString &templateName,
190 QDBusConnection::BusType busType);
191
192+ virtual void registerTemplate(const QString &service,
193+ const QString &templateName,
194+ const QVariantMap& parameters,
195+ QDBusConnection::BusType busType);
196+
197+ virtual void registerBluez4(const QVariantMap& parameters = QVariantMap());
198+
199+ virtual void registerBluez5(const QVariantMap& parameters = QVariantMap());
200+
201+ virtual void registerGnomeScreensaver(const QVariantMap& parameters = QVariantMap());
202+
203+ virtual void registerLogind(const QVariantMap& parameters = QVariantMap());
204+
205 virtual void registerNetworkManager();
206
207+ virtual void registerNetworkManager(const QVariantMap& parameters);
208+
209 virtual void registerNotificationDaemon();
210
211+ virtual void registerNotificationDaemon(const QVariantMap& parameters);
212+
213 virtual void registerOfono();
214
215+ virtual void registerOfono(const QVariantMap& parameters);
216+
217+ virtual void registerPolicyKit(const QVariantMap& parameters = QVariantMap());
218+
219+ virtual void registerTimeDate(const QVariantMap& parameters = QVariantMap());
220+
221 virtual void registerURfkill();
222
223+ virtual void registerURfkill(const QVariantMap& parameters);
224+
225+ virtual void registerUpower(const QVariantMap& parameters = QVariantMap());
226+
227 virtual void registerCustomMock(const QString &name, const QString &path,
228 const QString &interface, QDBusConnection::BusType);
229
230
231=== modified file 'tests/libqtdbusmock/TestDBusMock.cpp'
232--- tests/libqtdbusmock/TestDBusMock.cpp 2014-07-25 16:28:08 +0000
233+++ tests/libqtdbusmock/TestDBusMock.cpp 2015-10-09 10:55:59 +0000
234@@ -101,6 +101,21 @@
235 ASSERT_EQ(1, devices.value().size());
236 }
237
238+TEST_F(TestDBusMock, StartsDBusMockTemplateParameters) {
239+ dbusMock.registerUpower({{"DaemonVersion", "0.99.0"}, {"OnBattery", true}});
240+ dbusTestRunner.startServices();
241+
242+ EXPECT_TRUE(
243+ processListContains(
244+ "python3 -m dbusmock --template upower --parameters {\"DaemonVersion\":\"0.99.0\",\"OnBattery\":true}"));
245+
246+ QDBusInterface iface("org.freedesktop.UPower", "/org/freedesktop/UPower",
247+ "org.freedesktop.UPower", dbusTestRunner.systemConnection());
248+
249+ EXPECT_EQ("0.99.0", iface.property("DaemonVersion").toString());
250+ EXPECT_TRUE(iface.property("OnBattery").toBool());
251+}
252+
253 TEST_F(TestDBusMock, StartsDBusMockWithTemplate) {
254 dbusMock.registerTemplate(NM_DBUS_SERVICE,
255 "networkmanager",

Subscribers

People subscribed via source and target branches

to all changes: