Merge lp:~pete-woods/indicator-network/wakelock-on-hotspot-active into lp:indicator-network/15.10
- wakelock-on-hotspot-active
- Merge into trunk.15.10
Status: | Merged |
---|---|
Approved by: | Pete Woods |
Approved revision: | 517 |
Merged at revision: | 504 |
Proposed branch: | lp:~pete-woods/indicator-network/wakelock-on-hotspot-active |
Merge into: | lp:indicator-network/15.10 |
Prerequisite: | lp:~pete-woods/indicator-network/hotspot-management |
Diff against target: |
621 lines (+466/-0) (has conflicts) 12 files modified
data/com.canonical.powerd.xml (+77/-0) src/CMakeLists.txt (+1/-0) src/indicator/CMakeLists.txt (+1/-0) src/indicator/nmofono/hotspot-manager.cpp (+16/-0) src/qdbus-stubs/CMakeLists.txt (+7/-0) src/qdbus-stubs/dbus-types.h (+6/-0) src/qpowerd/CMakeLists.txt (+16/-0) src/qpowerd/qpowerd.cpp (+79/-0) src/qpowerd/qpowerd.h (+58/-0) tests/integration/CMakeLists.txt (+1/-0) tests/integration/indicator-network-test-base.cpp (+27/-0) tests/integration/test-connectivity-api.cpp (+177/-0) Text conflict in debian/changelog |
To merge this branch: | bzr merge lp:~pete-woods/indicator-network/wakelock-on-hotspot-active |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot (community) | continuous-integration | Approve | |
Indicator Applet Developers | Pending | ||
Review via email: mp+264527@code.launchpad.net |
Commit message
Hold a wakelock when the hotspot is active.
Description of the change
Hold a wakelock when the hotspot is active
PS Jenkins bot (ps-jenkins) wrote : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:504
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:506
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:509
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:510
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:511
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:512
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:513
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:514
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:516
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:518
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 500. By Charles Kerr
-
drop build-dependency on g++-4.9 Edit Fixes: #1452327
Approved by: Pete Woods, PS Jenkins bot, Rodney Dawes - 501. By CI Train Bot Account
-
Releasing 0.5.1+15.
10.20150727- 0ubuntu1 - 506. By Pete Woods
-
Only update the initialized property when both interfaces have been initalized
- 507. By Pete Woods
-
Add HotspotManager
- 508. By Pete Woods
-
Remove dead method
- 509. By Pete Woods
-
Initialize Priv data member in HotspotManager
- 510. By Pete Woods
-
Grab property values from the correct interface
- 511. By Pete Woods
-
Make HotspotManager more OO, e.g. use member variables instead of passing around state
- 512. By Pete Woods
-
Wire up reportError signal to public interface
- 513. By Pete Woods
-
Add qpowerd bindings for powerd
- 514. By Pete Woods
-
Use powerd to establish wakelocks
- 515. By Pete Woods
-
Start of very basic tests for hotspot
- 516. By Pete Woods
-
Expand the hotspot test
- 517. By Pete Woods
-
Check for hotspot disable, too
- 518. By Pete Woods
-
Move definitions to avoid merge conflict
Preview Diff
1 | === added file 'data/com.canonical.powerd.xml' |
2 | --- data/com.canonical.powerd.xml 1970-01-01 00:00:00 +0000 |
3 | +++ data/com.canonical.powerd.xml 2015-08-10 16:49:18 +0000 |
4 | @@ -0,0 +1,77 @@ |
5 | +<?xml version="1.0" encoding="UTF-8"?> |
6 | +<node name="/"> |
7 | + <interface name="com.canonical.powerd"> |
8 | + <!-- Properties --> |
9 | + |
10 | + <property name="brightness" type="i" access="read"> |
11 | + </property> |
12 | + |
13 | + |
14 | + <!-- Functions --> |
15 | + <method name="requestSysState"> |
16 | + <arg type="s" name="name" direction="in" /> |
17 | + <arg type="i" name="state" direction="in" /> |
18 | + <arg type="s" name="cookie" direction="out" /> |
19 | + </method> |
20 | + |
21 | + <method name="clearSysState"> |
22 | + <arg type="s" name="cookie" direction="in" /> |
23 | + </method> |
24 | + |
25 | + <method name="requestWakeup"> |
26 | + <arg type="s" name="name" direction="in" /> |
27 | + <arg type="t" name="time" direction="in" /> |
28 | + <arg type="s" name="cookie" direction="out" /> |
29 | + </method> |
30 | + |
31 | + <method name="enableProximityHandling"> |
32 | + <arg type="s" name="name" direction="in" /> |
33 | + </method> |
34 | + |
35 | + <method name="disableProximityHandling"> |
36 | + <arg type="s" name="name" direction="in" /> |
37 | + </method> |
38 | + |
39 | + <method name="clearWakeup"> |
40 | + <arg type="s" name="cookie" direction="in" /> |
41 | + </method> |
42 | + |
43 | + <method name="registerClient"> |
44 | + <arg type="s" name="name" direction="in" /> |
45 | + </method> |
46 | + |
47 | + <method name="unregisterClient"> |
48 | + <arg type="s" name="name" direction="in" /> |
49 | + </method> |
50 | + |
51 | + <method name="ackStateChange"> |
52 | + <arg type="i" name="state" direction="in" /> |
53 | + </method> |
54 | + |
55 | + <!-- User settings --> |
56 | + <method name="userAutobrightnessEnable"> |
57 | + <arg type="b" name="enable" direction="in" /> |
58 | + </method> |
59 | + |
60 | + <!-- |
61 | + <method name="getBrightnessParams"> |
62 | + <!-- Returns min, max, and default brighness and whether or not |
63 | + autobrightness is supported, in that order --> |
64 | + <arg type="(iiiib)" name="params" direction="out" /> |
65 | + </method> |
66 | + --> |
67 | + |
68 | + <method name="setUserBrightness"> |
69 | + <arg type="i" name="brightness" direction="in" /> |
70 | + </method> |
71 | + |
72 | + <!-- Signals --> |
73 | + <signal name="SysPowerStateChange"> |
74 | + <arg type="i" name="sysState" direction="out" /> |
75 | + </signal> |
76 | + |
77 | + <signal name="Wakeup"> |
78 | + </signal> |
79 | + |
80 | + </interface> |
81 | +</node> |
82 | |
83 | === modified file 'src/CMakeLists.txt' |
84 | --- src/CMakeLists.txt 2015-05-07 10:03:46 +0000 |
85 | +++ src/CMakeLists.txt 2015-08-10 16:49:18 +0000 |
86 | @@ -4,6 +4,7 @@ |
87 | add_subdirectory(indicator) |
88 | add_subdirectory(menumodel-cpp) |
89 | add_subdirectory(qdbus-stubs) |
90 | +add_subdirectory(qpowerd) |
91 | add_subdirectory(notify-cpp) |
92 | add_subdirectory(sniffer) |
93 | add_subdirectory(url-dispatcher-cpp) |
94 | |
95 | === modified file 'src/indicator/CMakeLists.txt' |
96 | --- src/indicator/CMakeLists.txt 2015-08-10 16:49:17 +0000 |
97 | +++ src/indicator/CMakeLists.txt 2015-08-10 16:49:18 +0000 |
98 | @@ -98,6 +98,7 @@ |
99 | notify_cpp |
100 | url_dispatcher_cpp |
101 | qdbus-stubs |
102 | + qpowerd |
103 | ${DBUSCPP_LIBRARIES} |
104 | ${GLIB_LIBRARIES} |
105 | ${NOTIFY_LIBRARIES} |
106 | |
107 | === modified file 'src/indicator/nmofono/hotspot-manager.cpp' |
108 | --- src/indicator/nmofono/hotspot-manager.cpp 2015-08-10 16:49:17 +0000 |
109 | +++ src/indicator/nmofono/hotspot-manager.cpp 2015-08-10 16:49:18 +0000 |
110 | @@ -19,6 +19,7 @@ |
111 | */ |
112 | |
113 | #include <nmofono/hotspot-manager.h> |
114 | +#include <qpowerd/qpowerd.h> |
115 | #include <NetworkManagerActiveConnectionInterface.h> |
116 | #include <NetworkManagerDeviceInterface.h> |
117 | #include <NetworkManagerInterface.h> |
118 | @@ -142,6 +143,16 @@ |
119 | if (m_enabled != value) |
120 | { |
121 | m_enabled = value; |
122 | + // Request or clear the wakelock, depending on the hotspot state |
123 | + if (value) |
124 | + { |
125 | + m_wakelock = m_powerd->requestSysState( |
126 | + "connectivity-service", QPowerd::SysPowerState::active); |
127 | + } |
128 | + else |
129 | + { |
130 | + m_wakelock.reset(); |
131 | + } |
132 | Q_EMIT p.enabledChanged(value); |
133 | } |
134 | } |
135 | @@ -644,6 +655,9 @@ |
136 | |
137 | QDBusObjectPath m_device_path; |
138 | |
139 | + QPowerd::UPtr m_powerd; |
140 | + QPowerd::RequestSPtr m_wakelock; |
141 | + |
142 | /** |
143 | * NetworkManager dbus interface proxy we will use to query |
144 | * against NetworkManager. See |
145 | @@ -671,6 +685,8 @@ |
146 | d->m_settings = make_unique<OrgFreedesktopNetworkManagerSettingsInterface>( |
147 | NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, connection); |
148 | |
149 | + d->m_powerd = make_unique<QPowerd>(connection); |
150 | + |
151 | d->generatePassword(); |
152 | d->getWirelessDevice(); |
153 | |
154 | |
155 | === modified file 'src/qdbus-stubs/CMakeLists.txt' |
156 | --- src/qdbus-stubs/CMakeLists.txt 2015-08-10 16:49:17 +0000 |
157 | +++ src/qdbus-stubs/CMakeLists.txt 2015-08-10 16:49:18 +0000 |
158 | @@ -24,6 +24,7 @@ |
159 | "${DATA_DIR}/org.freedesktop.URfkill.xml" |
160 | "${DATA_DIR}/org.freedesktop.URfkill.Device.xml" |
161 | "${DATA_DIR}/org.freedesktop.URfkill.Killswitch.xml" |
162 | + "${DATA_DIR}/com.canonical.powerd.xml" |
163 | PROPERTIES |
164 | NO_NAMESPACE YES |
165 | ) |
166 | @@ -116,6 +117,12 @@ |
167 | NotificationsInterface |
168 | ) |
169 | |
170 | +qt5_add_dbus_interface( |
171 | + CONNECTIVITY_BACKEND_SRC |
172 | + "${DATA_DIR}/com.canonical.powerd.xml" |
173 | + PowerdInterface |
174 | +) |
175 | + |
176 | add_library( |
177 | qdbus-stubs |
178 | STATIC |
179 | |
180 | === modified file 'src/qdbus-stubs/dbus-types.h' |
181 | --- src/qdbus-stubs/dbus-types.h 2015-04-23 13:22:55 +0000 |
182 | +++ src/qdbus-stubs/dbus-types.h 2015-08-10 16:49:18 +0000 |
183 | @@ -35,6 +35,12 @@ |
184 | qDBusRegisterMetaType<QVariantDictMap>(); |
185 | } |
186 | |
187 | + static constexpr char const* POWERD_DBUS_NAME = "com.canonical.powerd"; |
188 | + |
189 | + static constexpr char const* POWERD_DBUS_INTERFACE = "com.canonical.powerd"; |
190 | + |
191 | + static constexpr char const* POWERD_DBUS_PATH = "/com/canonical/powerd"; |
192 | + |
193 | static constexpr char const* DBUS_NAME = "com.ubuntu.connectivity1"; |
194 | |
195 | static constexpr char const* SERVICE_INTERFACE = "com.ubuntu.connectivity1.NetworkingStatus"; |
196 | |
197 | === added directory 'src/qpowerd' |
198 | === added file 'src/qpowerd/CMakeLists.txt' |
199 | --- src/qpowerd/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
200 | +++ src/qpowerd/CMakeLists.txt 2015-08-10 16:49:18 +0000 |
201 | @@ -0,0 +1,16 @@ |
202 | +include_directories("${CMAKE_SOURCE_DIR}/src/") |
203 | +include_directories("${CMAKE_SOURCE_DIR}/src/qdbus-stubs") |
204 | +include_directories("${CMAKE_BINARY_DIR}/src/qdbus-stubs") |
205 | + |
206 | +set(QPOWERD_SOURCES |
207 | + qpowerd.cpp |
208 | +) |
209 | + |
210 | +add_library(qpowerd STATIC ${QPOWERD_SOURCES}) |
211 | + |
212 | +target_link_libraries( |
213 | + qpowerd |
214 | + Qt5::Core |
215 | + Qt5::DBus |
216 | + qdbus-stubs |
217 | +) |
218 | |
219 | === added file 'src/qpowerd/qpowerd.cpp' |
220 | --- src/qpowerd/qpowerd.cpp 1970-01-01 00:00:00 +0000 |
221 | +++ src/qpowerd/qpowerd.cpp 2015-08-10 16:49:18 +0000 |
222 | @@ -0,0 +1,79 @@ |
223 | +/* |
224 | + * Copyright © 2015 Canonical Ltd. |
225 | + * |
226 | + * This program is free software: you can redistribute it and/or modify it |
227 | + * under the terms of the GNU Lesser General Public License version 3, |
228 | + * as published by the Free Software Foundation. |
229 | + * |
230 | + * This program is distributed in the hope that it will be useful, |
231 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
232 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
233 | + * GNU Lesser General Public License for more details. |
234 | + * |
235 | + * You should have received a copy of the GNU Lesser General Public License |
236 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
237 | + * |
238 | + * Authors: |
239 | + * Pete Woods <pete.woods@canonical.com> |
240 | + */ |
241 | + |
242 | +#include <qpowerd/qpowerd.h> |
243 | +#include <dbus-types.h> |
244 | +#include <PowerdInterface.h> |
245 | + |
246 | +using namespace std; |
247 | + |
248 | +class QPowerd::Priv |
249 | +{ |
250 | +public: |
251 | + shared_ptr<ComCanonicalPowerdInterface> m_powerd; |
252 | +}; |
253 | + |
254 | +class QPowerd::QSysStateRequest |
255 | +{ |
256 | +public: |
257 | + QSysStateRequest(QPowerd& parent, const QString& cookie) |
258 | + : m_parent(parent), m_cookie(cookie) |
259 | + { |
260 | + |
261 | + } |
262 | + |
263 | + ~QSysStateRequest() |
264 | + { |
265 | + m_parent.d->m_powerd->clearSysState(m_cookie); |
266 | + } |
267 | + |
268 | +protected: |
269 | + QPowerd m_parent; |
270 | + |
271 | + QString m_cookie; |
272 | +}; |
273 | + |
274 | +QPowerd::QPowerd(const QDBusConnection& connection) : |
275 | + d(new Priv) |
276 | +{ |
277 | + d->m_powerd = make_shared<ComCanonicalPowerdInterface>( |
278 | + DBusTypes::POWERD_DBUS_NAME, DBusTypes::POWERD_DBUS_PATH, |
279 | + connection); |
280 | +} |
281 | + |
282 | +QPowerd::~QPowerd() |
283 | +{ |
284 | +} |
285 | + |
286 | +QPowerd::RequestSPtr QPowerd::requestSysState(const QString& name, SysPowerState state) |
287 | +{ |
288 | + auto reply = d->m_powerd->requestSysState(name, static_cast<int>(state)); |
289 | + QString cookie; |
290 | + reply.waitForFinished(); |
291 | + if (reply.isError()) |
292 | + { |
293 | + qWarning() << __PRETTY_FUNCTION__ << reply.error().message(); |
294 | + } |
295 | + else |
296 | + { |
297 | + cookie = reply; |
298 | + } |
299 | + return make_shared<QSysStateRequest>(*this, cookie); |
300 | +} |
301 | + |
302 | |
303 | === added file 'src/qpowerd/qpowerd.h' |
304 | --- src/qpowerd/qpowerd.h 1970-01-01 00:00:00 +0000 |
305 | +++ src/qpowerd/qpowerd.h 2015-08-10 16:49:18 +0000 |
306 | @@ -0,0 +1,58 @@ |
307 | +/* |
308 | + * Copyright © 2015 Canonical Ltd. |
309 | + * |
310 | + * This program is free software: you can redistribute it and/or modify it |
311 | + * under the terms of the GNU Lesser General Public License version 3, |
312 | + * as published by the Free Software Foundation. |
313 | + * |
314 | + * This program is distributed in the hope that it will be useful, |
315 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
316 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
317 | + * GNU Lesser General Public License for more details. |
318 | + * |
319 | + * You should have received a copy of the GNU Lesser General Public License |
320 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
321 | + * |
322 | + * Authors: |
323 | + * Pete Woods <pete.woods@canonical.com> |
324 | + */ |
325 | + |
326 | +#pragma once |
327 | + |
328 | +#include <QDBusConnection> |
329 | +#include <QObject> |
330 | +#include <memory> |
331 | + |
332 | +class QPowerd |
333 | +{ |
334 | +public: |
335 | + class QSysStateRequest; |
336 | + |
337 | + typedef std::shared_ptr<QPowerd> UPtr; |
338 | + typedef std::shared_ptr<QPowerd> SPtr; |
339 | + typedef std::shared_ptr<QSysStateRequest> RequestSPtr; |
340 | + |
341 | + enum class SysPowerState |
342 | + { |
343 | + suspend = 0, |
344 | + //The Active state will prevent system suspend |
345 | + active, |
346 | + //Substate of Active with disabled proximity based blanking |
347 | + active_blank_on_proximity, |
348 | + num_power_states |
349 | + }; |
350 | + |
351 | + QPowerd(const QDBusConnection& connection); |
352 | + |
353 | + ~QPowerd(); |
354 | + |
355 | + RequestSPtr requestSysState(const QString &name, SysPowerState state); |
356 | + |
357 | +protected: |
358 | + class Priv; |
359 | + |
360 | + friend Priv; |
361 | + friend QSysStateRequest; |
362 | + |
363 | + std::shared_ptr<Priv> d; |
364 | +}; |
365 | |
366 | === modified file 'tests/integration/CMakeLists.txt' |
367 | --- tests/integration/CMakeLists.txt 2015-05-19 13:49:21 +0000 |
368 | +++ tests/integration/CMakeLists.txt 2015-08-10 16:49:18 +0000 |
369 | @@ -4,6 +4,7 @@ |
370 | include_directories( |
371 | "${CMAKE_SOURCE_DIR}/src/connectivity-api/connectivity-qt" |
372 | "${CMAKE_SOURCE_DIR}/src/qdbus-stubs" |
373 | + "${CMAKE_BINARY_DIR}/src/qdbus-stubs" |
374 | ) |
375 | |
376 | set( |
377 | |
378 | === modified file 'tests/integration/indicator-network-test-base.cpp' |
379 | --- tests/integration/indicator-network-test-base.cpp 2015-08-10 16:49:17 +0000 |
380 | +++ tests/integration/indicator-network-test-base.cpp 2015-08-10 16:49:18 +0000 |
381 | @@ -65,6 +65,12 @@ |
382 | dbusMock.registerURfkill(); |
383 | |
384 | dbusMock.registerCustomMock( |
385 | + DBusTypes::POWERD_DBUS_NAME, |
386 | + DBusTypes::POWERD_DBUS_PATH, |
387 | + DBusTypes::POWERD_DBUS_INTERFACE, |
388 | + QDBusConnection::SystemBus); |
389 | + |
390 | + dbusMock.registerCustomMock( |
391 | "com.canonical.URLDispatcher", |
392 | "/com/canonical/URLDispatcher", |
393 | "com.canonical.URLDispatcher", |
394 | @@ -89,6 +95,27 @@ |
395 | "ret = args[0]" |
396 | ).waitForFinished(); |
397 | |
398 | + // Set up a basic powerd mock - only supports power states |
399 | + auto& powerd = dbusMock.mockInterface( |
400 | + DBusTypes::POWERD_DBUS_NAME, |
401 | + DBusTypes::POWERD_DBUS_PATH, |
402 | + DBusTypes::POWERD_DBUS_INTERFACE, |
403 | + QDBusConnection::SystemBus); |
404 | + powerd.AddMethod( |
405 | + DBusTypes::POWERD_DBUS_INTERFACE, |
406 | + "requestSysState", |
407 | + "si", |
408 | + "s", |
409 | + "ret = 'dummy_cookie'" |
410 | + ).waitForFinished(); |
411 | + powerd.AddMethod( |
412 | + DBusTypes::POWERD_DBUS_INTERFACE, |
413 | + "clearSysState", |
414 | + "s", |
415 | + "", |
416 | + "" |
417 | + ).waitForFinished(); |
418 | + |
419 | // mock service creates ril_0 automatically |
420 | // Initial ConnectionManager properties are insane, fix them here |
421 | setConnectionManagerProperty(firstModem(), "Bearer", "none"); |
422 | |
423 | === modified file 'tests/integration/test-connectivity-api.cpp' |
424 | --- tests/integration/test-connectivity-api.cpp 2015-05-06 08:24:47 +0000 |
425 | +++ tests/integration/test-connectivity-api.cpp 2015-08-10 16:49:18 +0000 |
426 | @@ -19,6 +19,7 @@ |
427 | #include <indicator-network-test-base.h> |
428 | #include <connectivityqt/connectivity.h> |
429 | #include <dbus-types.h> |
430 | +#include <NetworkManagerSettingsInterface.h> |
431 | |
432 | #include <QDebug> |
433 | #include <QTestEventLoop> |
434 | @@ -47,6 +48,18 @@ |
435 | |
436 | return connectivity; |
437 | } |
438 | + |
439 | + QVariantList getMethodCall(const QSignalSpy& spy, const QString& method) |
440 | + { |
441 | + for(const auto& call: spy) |
442 | + { |
443 | + if (call.first().toString() == method) |
444 | + { |
445 | + return call.at(1).toList(); |
446 | + } |
447 | + } |
448 | + throw domain_error(qPrintable("No method call [" + method + "] could be found")); |
449 | + } |
450 | }; |
451 | |
452 | TEST_F(TestConnectivityApi, FollowsFlightMode) |
453 | @@ -338,4 +351,168 @@ |
454 | EXPECT_FALSE(connectivity->limitedBandwith()); |
455 | } |
456 | |
457 | +TEST_F(TestConnectivityApi, HotspotConfig) |
458 | +{ |
459 | + setGlobalConnectedState(NM_STATE_DISCONNECTED); |
460 | + auto device = createWiFiDevice(NM_DEVICE_STATE_DISCONNECTED); |
461 | + |
462 | + // Start the indicator |
463 | + ASSERT_NO_THROW(startIndicator()); |
464 | + |
465 | + auto& powerdMock = dbusMock.mockInterface(DBusTypes::POWERD_DBUS_NAME, |
466 | + DBusTypes::POWERD_DBUS_PATH, |
467 | + DBusTypes::POWERD_DBUS_INTERFACE, |
468 | + QDBusConnection::SystemBus); |
469 | + QSignalSpy powerdMockCallSpy( |
470 | + &powerdMock, |
471 | + SIGNAL(MethodCalled(const QString &, const QVariantList &))); |
472 | + |
473 | + auto& nmSettingsMock = dbusMock.mockInterface(NM_DBUS_SERVICE, |
474 | + NM_DBUS_PATH_SETTINGS, |
475 | + NM_DBUS_IFACE_SETTINGS, |
476 | + QDBusConnection::SystemBus); |
477 | + QSignalSpy nmSettingsMockCallSpy( |
478 | + &nmSettingsMock, |
479 | + SIGNAL(MethodCalled(const QString &, const QVariantList &))); |
480 | + |
481 | + OrgFreedesktopNetworkManagerSettingsInterface settings( |
482 | + NM_DBUS_SERVICE, NM_DBUS_PATH_SETTINGS, dbusTestRunner.systemConnection()); |
483 | + QSignalSpy settingsNewConnectionSpy( |
484 | + &settings, |
485 | + SIGNAL(NewConnection(const QDBusObjectPath &))); |
486 | + |
487 | + // Connect the the service |
488 | + auto connectivity(newConnectivity()); |
489 | + |
490 | + QSignalSpy storedSpy(connectivity.get(), SIGNAL(hotspotStoredUpdated(bool))); |
491 | + QSignalSpy enabledSpy(connectivity.get(), SIGNAL(hotspotEnabledUpdated(bool))); |
492 | + QSignalSpy passwordSpy(connectivity.get(), SIGNAL(hotspotPasswordUpdated(const QString&))); |
493 | + |
494 | + EXPECT_EQ("Ubuntu", connectivity->hotspotSsid().toStdString()); |
495 | + EXPECT_FALSE(connectivity->hotspotStored()); |
496 | + EXPECT_FALSE(connectivity->hotspotEnabled()); |
497 | + |
498 | + connectivity->setHotspotPassword("the password"); |
499 | + |
500 | + if (passwordSpy.empty()) |
501 | + { |
502 | + ASSERT_TRUE(passwordSpy.wait()); |
503 | + } |
504 | + EXPECT_FALSE(passwordSpy.empty()); |
505 | + EXPECT_EQ("the password", connectivity->hotspotPassword().toStdString()); |
506 | + |
507 | + connectivity->setHotspotEnabled(true); |
508 | + |
509 | + if (enabledSpy.empty()) |
510 | + { |
511 | + ASSERT_TRUE(enabledSpy.wait()); |
512 | + } |
513 | + EXPECT_FALSE(enabledSpy.empty()); |
514 | + |
515 | + if (storedSpy.empty()) |
516 | + { |
517 | + ASSERT_TRUE(storedSpy.wait()); |
518 | + } |
519 | + EXPECT_FALSE(storedSpy.empty()); |
520 | + |
521 | + if (powerdMockCallSpy.empty()) |
522 | + { |
523 | + ASSERT_TRUE(powerdMockCallSpy.wait()); |
524 | + } |
525 | + EXPECT_FALSE(powerdMockCallSpy.empty()); |
526 | + |
527 | + if (nmSettingsMockCallSpy.empty()) |
528 | + { |
529 | + ASSERT_TRUE(nmSettingsMockCallSpy.wait()); |
530 | + } |
531 | + EXPECT_FALSE(nmSettingsMockCallSpy.empty()); |
532 | + |
533 | + if (settingsNewConnectionSpy.empty()) |
534 | + { |
535 | + ASSERT_TRUE(settingsNewConnectionSpy.wait()); |
536 | + } |
537 | + EXPECT_FALSE(settingsNewConnectionSpy.empty()); |
538 | + |
539 | + EXPECT_TRUE(connectivity->hotspotEnabled()); |
540 | + EXPECT_TRUE(connectivity->hotspotStored()); |
541 | + |
542 | + // Connect to method calls on the newly added connection |
543 | + auto connectionPath = qvariant_cast<QDBusObjectPath>(settingsNewConnectionSpy.first().first()); |
544 | + auto& connectionSettingsMock = dbusMock.mockInterface(NM_DBUS_SERVICE, connectionPath.path(), |
545 | + NM_DBUS_IFACE_SETTINGS_CONNECTION, |
546 | + QDBusConnection::SystemBus); |
547 | + QSignalSpy connectionSettingsMockCallSpy( |
548 | + &connectionSettingsMock, |
549 | + SIGNAL(MethodCalled(const QString &, const QVariantList &))); |
550 | + |
551 | + // Expect a wakelock request |
552 | + EXPECT_EQ( |
553 | + QVariantList({"connectivity-service", int(1)}), |
554 | + getMethodCall(powerdMockCallSpy, "requestSysState")); |
555 | + |
556 | + { |
557 | + auto call = getMethodCall(nmSettingsMockCallSpy, "AddConnection"); |
558 | + // Decode the QDBusArgument |
559 | + QVariantDictMap connection; |
560 | + qvariant_cast<QDBusArgument>(call.first()) >> connection; |
561 | + EXPECT_EQ(QVariantMap({ |
562 | + {"mode", "ap"}, |
563 | + {"security", "802-11-wireless-security"}, |
564 | + {"ssid", "Ubuntu"} |
565 | + }), connection["802-11-wireless"]); |
566 | + EXPECT_EQ(QVariantMap({ |
567 | + {"group", "ccmp"}, |
568 | + {"key-mgmt", "wpa-psk"}, |
569 | + {"pairwise" , QStringList{"ccmp"}}, |
570 | + {"proto" , QStringList{"rsn"}}, |
571 | + {"psk", "the password"} |
572 | + }), connection["802-11-wireless-security"]); |
573 | + EXPECT_TRUE(connection["connection"]["autoconnect"].toBool()); |
574 | + } |
575 | + |
576 | + // Next we'll disable the hotspot |
577 | + storedSpy.clear(); |
578 | + enabledSpy.clear(); |
579 | + passwordSpy.clear(); |
580 | + powerdMockCallSpy.clear(); |
581 | + nmSettingsMockCallSpy.clear(); |
582 | + |
583 | + connectivity->setHotspotEnabled(false); |
584 | + |
585 | + if (powerdMockCallSpy.empty()) |
586 | + { |
587 | + ASSERT_TRUE(powerdMockCallSpy.wait()); |
588 | + } |
589 | + EXPECT_FALSE(powerdMockCallSpy.empty()); |
590 | + |
591 | + if (connectionSettingsMockCallSpy.empty()) |
592 | + { |
593 | + ASSERT_TRUE(connectionSettingsMockCallSpy.wait()); |
594 | + } |
595 | + EXPECT_FALSE(connectionSettingsMockCallSpy.empty()); |
596 | + |
597 | + if (enabledSpy.empty()) |
598 | + { |
599 | + ASSERT_TRUE(enabledSpy.wait()); |
600 | + } |
601 | + EXPECT_FALSE(enabledSpy.empty()); |
602 | + |
603 | + EXPECT_FALSE(connectivity->hotspotEnabled()); |
604 | + EXPECT_TRUE(connectivity->hotspotStored()); |
605 | + |
606 | + // Expect a wakelock cancel |
607 | + EXPECT_EQ( |
608 | + QVariantList{"dummy_cookie"}, |
609 | + getMethodCall(powerdMockCallSpy, "clearSysState")); |
610 | + |
611 | + // The connection should no-longer auto-connect |
612 | + { |
613 | + auto call = getMethodCall(connectionSettingsMockCallSpy, "Update"); |
614 | + // Decode the QDBusArgument |
615 | + QVariantDictMap connection; |
616 | + qvariant_cast<QDBusArgument>(call.first()) >> connection; |
617 | + EXPECT_FALSE(connection["connection"]["autoconnect"].toBool()); |
618 | + } |
619 | +} |
620 | + |
621 | } |
PASSED: Continuous integration, rev:503 jenkins. qa.ubuntu. com/job/ indicator- network- ci/358/ jenkins. qa.ubuntu. com/job/ indicator- network- wily-amd64- ci/10 jenkins. qa.ubuntu. com/job/ indicator- network- wily-armhf- ci/10 jenkins. qa.ubuntu. com/job/ indicator- network- wily-armhf- ci/10/artifact/ work/output/ *zip*/output. zip
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/indicator- network- ci/358/ rebuild
http://