Merge lp:~unity-api-team/indicator-network/connectity-api-beginnings into lp:indicator-network/15.10
- connectity-api-beginnings
- Merge into trunk.15.10
Status: | Merged |
---|---|
Approved by: | Marcus Tomlinson |
Approved revision: | 499 |
Merged at revision: | 487 |
Proposed branch: | lp:~unity-api-team/indicator-network/connectity-api-beginnings |
Merge into: | lp:indicator-network/15.10 |
Prerequisite: | lp:~unity-api-team/indicator-network/restore-connectivity-headers |
Diff against target: |
5655 lines (+1760/-2788) 52 files modified
data/com.ubuntu.connectivity1.NetworkingStatus.xml (+5/-0) data/com.ubuntu.connectivity1.Private.xml (+8/-0) data/org.freedesktop.DBus.Properties.xml (+27/-0) src/CMakeLists.txt (+2/-0) src/connectivity-api/CMakeLists.txt (+4/-0) src/connectivity-api/connectivity-qt/CMakeLists.txt (+52/-0) src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp (+130/-0) src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h (+84/-0) src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.cpp (+156/-0) src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.h (+57/-0) src/indicator/agent/SecretAgent.cpp (+66/-48) src/indicator/agent/SecretAgent.h (+28/-41) src/indicator/agent/SecretAgentInclude.h (+1/-1) src/indicator/agent/SecretRequest.cpp (+2/-0) src/indicator/agent/SecretRequest.h (+1/-1) src/indicator/connectivity-service/connectivity-service.cpp (+50/-1) src/indicator/connectivity-service/connectivity-service.h (+13/-0) src/indicator/main.cpp (+3/-2) src/indicator/nmofono/kill-switch.cpp (+5/-8) src/indicator/nmofono/manager-impl.cpp (+80/-76) src/indicator/nmofono/manager-impl.h (+4/-4) src/indicator/nmofono/manager.h (+10/-10) src/indicator/sections/quick-access-section.cpp (+18/-27) src/indicator/sections/wifi-section.cpp (+1/-13) src/menumodel-cpp/gio-helpers/variant.h (+8/-0) src/qdbus-stubs/CMakeLists.txt (+1/-15) src/qdbus-stubs/dbus-types.h (+11/-9) tests/integration/CMakeLists.txt (+0/-2) tests/integration/connectivity-cpp/CMakeLists.txt (+0/-130) tests/integration/connectivity-cpp/mocks/urfkill.h (+0/-162) tests/integration/connectivity-cpp/sig_term_catcher.h (+0/-74) tests/integration/connectivity-cpp/test_data.h.in (+0/-38) tests/integration/connectivity-cpp/test_flight_mode.cpp (+0/-138) tests/integration/connectivity-cpp/test_networking_status.cpp (+0/-178) tests/integration/connectivity-cpp/test_service.h (+0/-124) tests/integration/connectivity-cpp/test_wifi_connect.cpp (+0/-278) tests/integration/connectivity-cpp/test_wifi_link.cpp (+0/-362) tests/integration/connectivity-cpp/test_wifi_link_dedup.cpp (+0/-240) tests/integration/connectivity-cpp/test_wifi_link_enable_disable.cpp (+0/-186) tests/integration/indicator-network-test-base.cpp (+338/-0) tests/integration/indicator-network-test-base.h (+156/-0) tests/integration/test-connectivity-api.cpp (+289/-0) tests/integration/test-indicator.cpp (+45/-418) tests/unit/CMakeLists.txt (+87/-3) tests/unit/indicator/CMakeLists.txt (+0/-6) tests/unit/indicator/menuitems/CMakeLists.txt (+0/-39) tests/unit/menumodel-cpp/CMakeLists.txt (+0/-35) tests/unit/menumodel-cpp/test-menu-exporter.cpp (+9/-9) tests/unit/secret-agent/CMakeLists.txt (+0/-71) tests/unit/secret-agent/secret-agent-main.cpp (+1/-1) tests/unit/secret-agent/test-secret-agent.cpp (+8/-24) tests/unit/test_variant.h (+0/-14) |
To merge this branch: | bzr merge lp:~unity-api-team/indicator-network/connectity-api-beginnings |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Marcus Tomlinson (community) | Approve | ||
PS Jenkins bot (community) | continuous-integration | Approve | |
Review via email: mp+257045@code.launchpad.net |
Commit message
Add flight mode and wifi toggles to connectivity service interface
Description of the change
Add flight mode and wifi toggles to connectivity service interface
PS Jenkins bot (ps-jenkins) wrote : | # |
Ted Gould (ted) wrote : | # |
On Wed, 2015-04-22 at 10:09 +0000, Pete Woods wrote:
> Add flight mode and wifi toggles to connectivity service interface
It seems odd to me that we're adding to dbus whether the value is
changing.
+ <property name="FlightMode" type="b" access="read"/>
+ <property name="FlightMod
+
+ <property name="WifiEnabled" type="b" access="read"/>
+ <property name="WifiEnabl
Why would an application care if the value is changing?
- 496. By Pete Woods
-
Robustify the tests
Pete Woods (pete-woods) wrote : | # |
The purpose of those properties (have now merged into one property) is to allow simple data binding in a client application for when to enable / disable the wifi and flight mode toggle buttons.
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:496
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
- 497. By Pete Woods
-
Make the unit tests resistant against the dbus connection closing (as you should expect in a test case)
- 498. By Pete Woods
-
Use built in notification daemon template, instead of custom mock
- 499. By Pete Woods
-
Test that all the signals are emitted
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:498
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:499
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
deb: http://
Click here to trigger a rebuild:
http://
Marcus Tomlinson (marcustomlinson) wrote : | # |
Diff is sane, still seems functionality sound, plus test coverage is looking good too. +1
Just a note on test coverage:
692 + if (!d->m_
693 throw logic_error(
Its tricky to recreate some of these failure conditions, but we should consider coming back some time to test things like this. I.e. check that the indicator doesn't completely fall apart when these exceptions are thrown.
Ted Gould (ted) wrote : | # |
Applications don't need to toggle the buttons, they only need to know the
state of things. The only person chaning it should be the network
indicator.
On Thursday, April 23, 2015 11:04:06 AM BST, Pete Woods wrote:
> The purpose of those properties (have now merged into one
> property) is to allow simple data binding in a client
> application for when to enable / disable the wifi and flight
> mode toggle buttons.
Preview Diff
1 | === modified file 'data/com.ubuntu.connectivity1.NetworkingStatus.xml' |
2 | --- data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-03-20 15:24:02 +0000 |
3 | +++ data/com.ubuntu.connectivity1.NetworkingStatus.xml 2015-04-23 13:23:11 +0000 |
4 | @@ -6,6 +6,11 @@ |
5 | <property name="Limitations" type="as" access="read"/> |
6 | <property name="Status" type="s" access="read"/> |
7 | |
8 | + <property name="FlightMode" type="b" access="read"/> |
9 | + <property name="WifiEnabled" type="b" access="read"/> |
10 | + |
11 | + <property name="UnstoppableOperationHappening" type="b" access="read"/> |
12 | + |
13 | </interface> |
14 | </node> |
15 | |
16 | |
17 | === modified file 'data/com.ubuntu.connectivity1.Private.xml' |
18 | --- data/com.ubuntu.connectivity1.Private.xml 2015-03-23 14:46:24 +0000 |
19 | +++ data/com.ubuntu.connectivity1.Private.xml 2015-04-23 13:23:11 +0000 |
20 | @@ -9,6 +9,14 @@ |
21 | <method name="UnlockModem"> |
22 | <arg type="s" direction="in" name="modem"/> |
23 | </method> |
24 | + |
25 | + <method name="SetFlightMode"> |
26 | + <arg type="b" direction="in" name="enabled"/> |
27 | + </method> |
28 | + |
29 | + <method name="SetWifiEnabled"> |
30 | + <arg type="b" direction="in" name="enabled"/> |
31 | + </method> |
32 | |
33 | </interface> |
34 | </node> |
35 | |
36 | === added file 'data/org.freedesktop.DBus.Properties.xml' |
37 | --- data/org.freedesktop.DBus.Properties.xml 1970-01-01 00:00:00 +0000 |
38 | +++ data/org.freedesktop.DBus.Properties.xml 2015-04-23 13:23:11 +0000 |
39 | @@ -0,0 +1,27 @@ |
40 | +<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" |
41 | + "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd"> |
42 | +<node> |
43 | + <interface name="org.freedesktop.DBus.Properties"> |
44 | + <method name="Get"> |
45 | + <arg type="s" name="interface_name" direction="in"/> |
46 | + <arg type="s" name="property_name" direction="in"/> |
47 | + <arg type="v" name="value" direction="out"/> |
48 | + </method> |
49 | + <method name="GetAll"> |
50 | + <arg type="s" name="interface_name" direction="in"/> |
51 | + <arg type="a{sv}" name="properties" direction="out"/> |
52 | + <annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="QVariantMap"/> |
53 | + </method> |
54 | + <method name="Set"> |
55 | + <arg type="s" name="interface_name" direction="in"/> |
56 | + <arg type="s" name="property_name" direction="in"/> |
57 | + <arg type="v" name="value" direction="in"/> |
58 | + </method> |
59 | + <signal name="PropertiesChanged"> |
60 | + <arg type="s" name="interface_name"/> |
61 | + <arg type="a{sv}" name="changed_properties"/> |
62 | + <annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="QVariantMap"/> |
63 | + <arg type="as" name="invalidated_properties"/> |
64 | + </signal> |
65 | + </interface> |
66 | +</node> |
67 | |
68 | === modified file 'src/CMakeLists.txt' |
69 | --- src/CMakeLists.txt 2015-04-23 13:23:11 +0000 |
70 | +++ src/CMakeLists.txt 2015-04-23 13:23:11 +0000 |
71 | @@ -3,6 +3,8 @@ |
72 | set(COMMON_FLAGS "${COMMON_FLAGS} -Werror") |
73 | endif() |
74 | |
75 | +add_subdirectory(connectivity-api) |
76 | + |
77 | add_subdirectory(indicator) |
78 | add_subdirectory(menumodel-cpp) |
79 | add_subdirectory(qdbus-stubs) |
80 | |
81 | === added directory 'src/connectivity-api' |
82 | === added file 'src/connectivity-api/CMakeLists.txt' |
83 | --- src/connectivity-api/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
84 | +++ src/connectivity-api/CMakeLists.txt 2015-04-23 13:23:11 +0000 |
85 | @@ -0,0 +1,4 @@ |
86 | + |
87 | +#add_subdirectory(connectivity-cpp) |
88 | +add_subdirectory(connectivity-qt) |
89 | +add_subdirectory(connectivity-qml) |
90 | \ No newline at end of file |
91 | |
92 | === renamed directory 'src/connectivity-cpp' => 'src/connectivity-api/connectivity-cpp' |
93 | === added directory 'src/connectivity-api/connectivity-qml' |
94 | === added file 'src/connectivity-api/connectivity-qml/CMakeLists.txt' |
95 | === added directory 'src/connectivity-api/connectivity-qt' |
96 | === added file 'src/connectivity-api/connectivity-qt/CMakeLists.txt' |
97 | --- src/connectivity-api/connectivity-qt/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
98 | +++ src/connectivity-api/connectivity-qt/CMakeLists.txt 2015-04-23 13:23:11 +0000 |
99 | @@ -0,0 +1,52 @@ |
100 | + |
101 | +include_directories("${CMAKE_SOURCE_DIR}/src/qdbus-stubs") |
102 | + |
103 | +set( |
104 | + CONNECTIVITY_QT_SRC |
105 | + connectivityqt/internal/dbus-property-cache.cpp |
106 | + connectivityqt/connectivity.cpp |
107 | +) |
108 | + |
109 | +set_source_files_properties( |
110 | + "${DATA_DIR}/org.freedesktop.DBus.Properties.xml" |
111 | + "${DATA_DIR}/com.ubuntu.connectivity1.NetworkingStatus.xml" |
112 | + "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml" |
113 | + PROPERTIES |
114 | + NO_NAMESPACE YES |
115 | +) |
116 | + |
117 | + |
118 | +qt5_add_dbus_interface( |
119 | + CONNECTIVITY_QT_SRC |
120 | + "${DATA_DIR}/com.ubuntu.connectivity1.NetworkingStatus.xml" |
121 | + NetworkingStatusInterface |
122 | +) |
123 | + |
124 | +qt5_add_dbus_interface( |
125 | + CONNECTIVITY_QT_SRC |
126 | + "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml" |
127 | + NetworkingStatusPrivateInterface |
128 | +) |
129 | + |
130 | +qt5_add_dbus_interface( |
131 | + CONNECTIVITY_QT_SRC |
132 | + "${DATA_DIR}/org.freedesktop.DBus.Properties.xml" |
133 | + PropertiesInterface |
134 | +) |
135 | + |
136 | +add_library( |
137 | + connectivity-qt |
138 | + SHARED |
139 | + ${CONNECTIVITY_QT_SRC} |
140 | +) |
141 | + |
142 | +qt5_use_modules( |
143 | + connectivity-qt |
144 | + Core |
145 | + DBus |
146 | +) |
147 | + |
148 | +target_link_libraries( |
149 | + connectivity-qt |
150 | + qdbus-stubs |
151 | +) |
152 | |
153 | === added directory 'src/connectivity-api/connectivity-qt/connectivityqt' |
154 | === added file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp' |
155 | --- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 1970-01-01 00:00:00 +0000 |
156 | +++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.cpp 2015-04-23 13:23:11 +0000 |
157 | @@ -0,0 +1,130 @@ |
158 | +/* |
159 | + * Copyright (C) 2015 Canonical, Ltd. |
160 | + * |
161 | + * This program is free software: you can redistribute it and/or modify it |
162 | + * under the terms of the GNU General Public License version 3, as published |
163 | + * by the Free Software Foundation. |
164 | + * |
165 | + * This program is distributed in the hope that it will be useful, but |
166 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
167 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
168 | + * PURPOSE. See the GNU General Public License for more details. |
169 | + * |
170 | + * You should have received a copy of the GNU General Public License along |
171 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
172 | + * |
173 | + * Authors: |
174 | + * Pete Woods <pete.woods@canonical.com> |
175 | + */ |
176 | + |
177 | +#include <connectivityqt/connectivity.h> |
178 | +#include <connectivityqt/internal/dbus-property-cache.h> |
179 | +#include <dbus-types.h> |
180 | +#include <NetworkingStatusInterface.h> |
181 | +#include <NetworkingStatusPrivateInterface.h> |
182 | + |
183 | +#include <QDebug> |
184 | + |
185 | +using namespace std; |
186 | + |
187 | +namespace connectivityqt |
188 | +{ |
189 | + |
190 | +class Connectivity::Priv: public QObject |
191 | +{ |
192 | + Q_OBJECT |
193 | +public: |
194 | + Priv(Connectivity& parent, const QDBusConnection& sessionConnection) : |
195 | + p(parent), m_sessionConnection(sessionConnection) |
196 | + { |
197 | + } |
198 | + |
199 | + Connectivity& p; |
200 | + |
201 | + QDBusConnection m_sessionConnection; |
202 | + |
203 | + shared_ptr<internal::DBusPropertyCache> m_propertyCache; |
204 | + |
205 | + shared_ptr<ComUbuntuConnectivity1NetworkingStatusInterface> m_readInterface; |
206 | + |
207 | + shared_ptr<ComUbuntuConnectivity1PrivateInterface> m_writeInterface; |
208 | + |
209 | +public Q_SLOTS: |
210 | + |
211 | + void propertyChanged(const QString& name, const QVariant& value) |
212 | + { |
213 | + if (name == "FlightMode") |
214 | + { |
215 | + Q_EMIT p.flightModeUpdated(value.toBool()); |
216 | + } |
217 | + else if (name == "WifiEnabled") |
218 | + { |
219 | + Q_EMIT p.wifiEnabledUpdated(value.toBool()); |
220 | + } |
221 | + else if (name == "UnstoppableOperationHappening") |
222 | + { |
223 | + Q_EMIT p.unstoppableOperationHappeningUpdated(value.toBool()); |
224 | + } |
225 | + } |
226 | +}; |
227 | + |
228 | +Connectivity::Connectivity(const QDBusConnection& sessionConnection) : |
229 | + d(new Priv(*this, sessionConnection)) |
230 | +{ |
231 | + d->m_readInterface = make_shared< |
232 | + ComUbuntuConnectivity1NetworkingStatusInterface>( |
233 | + DBusTypes::DBUS_NAME, DBusTypes::SERVICE_PATH, |
234 | + d->m_sessionConnection); |
235 | + |
236 | + d->m_writeInterface = make_shared<ComUbuntuConnectivity1PrivateInterface>( |
237 | + DBusTypes::DBUS_NAME, DBusTypes::PRIVATE_PATH, |
238 | + d->m_sessionConnection); |
239 | + |
240 | + d->m_propertyCache = make_shared<internal::DBusPropertyCache>( |
241 | + DBusTypes::DBUS_NAME, DBusTypes::SERVICE_INTERFACE, |
242 | + DBusTypes::SERVICE_PATH, sessionConnection); |
243 | + connect(d->m_propertyCache.get(), |
244 | + &internal::DBusPropertyCache::propertyChanged, d.get(), |
245 | + &Priv::propertyChanged); |
246 | + connect(d->m_propertyCache.get(), |
247 | + &internal::DBusPropertyCache::initialized, this, |
248 | + &Connectivity::initialized); |
249 | +} |
250 | + |
251 | +Connectivity::~Connectivity() |
252 | +{ |
253 | +} |
254 | + |
255 | +bool Connectivity::flightMode() const |
256 | +{ |
257 | + return d->m_propertyCache->get("FlightMode").toBool(); |
258 | +} |
259 | + |
260 | +bool Connectivity::wifiEnabled() const |
261 | +{ |
262 | + return d->m_propertyCache->get("WifiEnabled").toBool(); |
263 | +} |
264 | + |
265 | +bool Connectivity::unstoppableOperationHappening() const |
266 | +{ |
267 | + return d->m_propertyCache->get("UnstoppableOperationHappening").toBool(); |
268 | +} |
269 | + |
270 | +void Connectivity::setFlightMode(bool enabled) |
271 | +{ |
272 | + d->m_writeInterface->SetFlightMode(enabled); |
273 | +} |
274 | + |
275 | +void Connectivity::setwifiEnabled(bool enabled) |
276 | +{ |
277 | + d->m_writeInterface->SetWifiEnabled(enabled); |
278 | +} |
279 | + |
280 | +bool Connectivity::isInitialized() const |
281 | +{ |
282 | + return d->m_propertyCache->isInitialized(); |
283 | +} |
284 | + |
285 | +} |
286 | + |
287 | +#include "connectivity.moc" |
288 | |
289 | === added file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h' |
290 | --- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 1970-01-01 00:00:00 +0000 |
291 | +++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-04-23 13:23:11 +0000 |
292 | @@ -0,0 +1,84 @@ |
293 | +/* |
294 | + * Copyright (C) 2015 Canonical, Ltd. |
295 | + * |
296 | + * This program is free software: you can redistribute it and/or modify it |
297 | + * under the terms of the GNU General Public License version 3, as published |
298 | + * by the Free Software Foundation. |
299 | + * |
300 | + * This program is distributed in the hope that it will be useful, but |
301 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
302 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
303 | + * PURPOSE. See the GNU General Public License for more details. |
304 | + * |
305 | + * You should have received a copy of the GNU General Public License along |
306 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
307 | + * |
308 | + * Authors: |
309 | + * Pete Woods <pete.woods@canonical.com> |
310 | + */ |
311 | + |
312 | +#pragma once |
313 | + |
314 | +#include <QDBusConnection> |
315 | +#include <QObject> |
316 | +#include <QStringList> |
317 | +#include <memory> |
318 | + |
319 | +#include <unity/util/DefinesPtrs.h> |
320 | + |
321 | +namespace connectivityqt |
322 | +{ |
323 | + |
324 | +class Q_DECL_EXPORT Connectivity: public QObject |
325 | +{ |
326 | + Q_OBJECT |
327 | + |
328 | +public: |
329 | + UNITY_DEFINES_PTRS(Connectivity); |
330 | + |
331 | + Connectivity(const QDBusConnection& sessionConnection = QDBusConnection::sessionBus()); |
332 | + |
333 | + ~Connectivity(); |
334 | + |
335 | + Q_PROPERTY(bool FlightMode READ flightMode WRITE setFlightMode NOTIFY flightModeUpdated) |
336 | + bool flightMode() const; |
337 | + |
338 | +// Q_PROPERTY(QStringList Limitations READ limitations NOTIFY limitationsUpdated) |
339 | +// QStringList limitations() const; |
340 | + |
341 | +// Q_PROPERTY(QString Status READ status NOTIFY statusUpdated) |
342 | +// QString status() const; |
343 | + |
344 | + Q_PROPERTY(bool WifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated) |
345 | + bool wifiEnabled() const; |
346 | + |
347 | + Q_PROPERTY(bool UnstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated) |
348 | + bool unstoppableOperationHappening() const; |
349 | + |
350 | + Q_PROPERTY(bool Initialized READ isInitialized NOTIFY initialized) |
351 | + bool isInitialized() const; |
352 | + |
353 | +public Q_SLOTS: |
354 | + void setFlightMode(bool enabled); |
355 | + |
356 | + void setwifiEnabled(bool enabled); |
357 | + |
358 | +Q_SIGNALS: |
359 | + void flightModeUpdated(bool); |
360 | + |
361 | +// void limitationsUpdated(const QStringList&); |
362 | + |
363 | +// void statusUpdated(const QString&); |
364 | + |
365 | + void wifiEnabledUpdated(bool); |
366 | + |
367 | + void unstoppableOperationHappeningUpdated(bool); |
368 | + |
369 | + void initialized(); |
370 | + |
371 | +protected: |
372 | + class Priv; |
373 | + std::shared_ptr<Priv> d; |
374 | +}; |
375 | + |
376 | +} |
377 | |
378 | === added directory 'src/connectivity-api/connectivity-qt/connectivityqt/internal' |
379 | === added file 'src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.cpp' |
380 | --- src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.cpp 1970-01-01 00:00:00 +0000 |
381 | +++ src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.cpp 2015-04-23 13:23:11 +0000 |
382 | @@ -0,0 +1,156 @@ |
383 | +/* |
384 | + * Copyright (C) 2015 Canonical, Ltd. |
385 | + * |
386 | + * This program is free software: you can redistribute it and/or modify it |
387 | + * under the terms of the GNU General Public License version 3, as published |
388 | + * by the Free Software Foundation. |
389 | + * |
390 | + * This program is distributed in the hope that it will be useful, but |
391 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
392 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
393 | + * PURPOSE. See the GNU General Public License for more details. |
394 | + * |
395 | + * You should have received a copy of the GNU General Public License along |
396 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
397 | + * |
398 | + * Authors: |
399 | + * Pete Woods <pete.woods@canonical.com> |
400 | + */ |
401 | + |
402 | +#include <connectivityqt/internal/dbus-property-cache.h> |
403 | + |
404 | +#include <PropertiesInterface.h> |
405 | + |
406 | +using namespace std; |
407 | + |
408 | +namespace connectivityqt |
409 | +{ |
410 | +namespace internal |
411 | +{ |
412 | + |
413 | +class DBusPropertyCache::Priv: public QObject |
414 | +{ |
415 | + Q_OBJECT |
416 | + |
417 | +public: |
418 | + Priv(DBusPropertyCache& parent, const QDBusConnection& connection) : |
419 | + p(parent), m_connection(connection) |
420 | + { |
421 | + } |
422 | + |
423 | + DBusPropertyCache& p; |
424 | + |
425 | + QDBusConnection m_connection; |
426 | + |
427 | + QString m_service; |
428 | + |
429 | + QString m_interface; |
430 | + |
431 | + QString m_path; |
432 | + |
433 | + shared_ptr<QDBusServiceWatcher> m_serviceWatcher; |
434 | + |
435 | + shared_ptr<OrgFreedesktopDBusPropertiesInterface> m_propertiesInterface; |
436 | + |
437 | + QVariantMap m_propertyCache; |
438 | + |
439 | + void refreshProperties(const QStringList& names) |
440 | + { |
441 | + for(const QString& name: names) |
442 | + { |
443 | + QDBusVariant value = m_propertiesInterface->Get(m_interface, name); |
444 | + m_propertyCache[name] = value.variant(); |
445 | + Q_EMIT p.propertyChanged(name, value.variant()); |
446 | + } |
447 | + } |
448 | + |
449 | +public Q_SLOTS: |
450 | + void serviceOwnerChanged(const QString &, const QString &, |
451 | + const QString & newOwner) |
452 | + { |
453 | + m_propertiesInterface.reset(); |
454 | + m_propertyCache.clear(); |
455 | + |
456 | + if (newOwner.isEmpty()) |
457 | + { |
458 | + return; |
459 | + } |
460 | + |
461 | + m_propertiesInterface = make_shared< |
462 | + OrgFreedesktopDBusPropertiesInterface>(m_service, m_path, |
463 | + m_connection); |
464 | + |
465 | + connect(m_propertiesInterface.get(), |
466 | + &OrgFreedesktopDBusPropertiesInterface::PropertiesChanged, this, |
467 | + &Priv::propertiesChanged); |
468 | + |
469 | + m_propertyCache = m_propertiesInterface->GetAll(m_interface); |
470 | + QMapIterator<QString, QVariant> it(m_propertyCache); |
471 | + while (it.hasNext()) |
472 | + { |
473 | + it.next(); |
474 | + Q_EMIT p.propertyChanged(it.key(), it.value()); |
475 | + } |
476 | + |
477 | + Q_EMIT p.initialized(); |
478 | + } |
479 | + |
480 | + void propertiesChanged(const QString &, |
481 | + const QVariantMap &changedProperties, |
482 | + const QStringList &invalidatedProperties) |
483 | + { |
484 | + QMapIterator<QString, QVariant> it(changedProperties); |
485 | + while (it.hasNext()) |
486 | + { |
487 | + it.next(); |
488 | + m_propertyCache[it.key()] = it.value(); |
489 | + Q_EMIT p.propertyChanged(it.key(), it.value()); |
490 | + } |
491 | + |
492 | + refreshProperties(invalidatedProperties); |
493 | + } |
494 | +}; |
495 | + |
496 | +DBusPropertyCache::DBusPropertyCache(const QString &service, |
497 | + const QString &interface, |
498 | + const QString &path, |
499 | + const QDBusConnection &connection) : |
500 | + d(new Priv(*this, connection)) |
501 | +{ |
502 | + d->m_service = service; |
503 | + d->m_interface = interface; |
504 | + d->m_path = path; |
505 | + |
506 | + d->m_serviceWatcher = make_shared<QDBusServiceWatcher>(service, |
507 | + connection); |
508 | + |
509 | + connect(d->m_serviceWatcher.get(), &QDBusServiceWatcher::serviceOwnerChanged, |
510 | + d.get(), &Priv::serviceOwnerChanged); |
511 | + |
512 | + // If the service is already registered |
513 | + QString serviceOwner = connection.interface()->serviceOwner(service); |
514 | + if (!serviceOwner.isEmpty()) |
515 | + { |
516 | + d->serviceOwnerChanged(service, "", serviceOwner); |
517 | + } |
518 | +} |
519 | + |
520 | +DBusPropertyCache::~DBusPropertyCache() |
521 | +{ |
522 | +} |
523 | + |
524 | +QVariant DBusPropertyCache::get(const QString& name) |
525 | +{ |
526 | + return d->m_propertyCache[name]; |
527 | +} |
528 | + |
529 | +bool DBusPropertyCache::isInitialized() const |
530 | +{ |
531 | + return !d->m_propertyCache.empty(); |
532 | +} |
533 | + |
534 | +} |
535 | +} |
536 | + |
537 | +#include "dbus-property-cache.moc" |
538 | + |
539 | |
540 | === added file 'src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.h' |
541 | --- src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.h 1970-01-01 00:00:00 +0000 |
542 | +++ src/connectivity-api/connectivity-qt/connectivityqt/internal/dbus-property-cache.h 2015-04-23 13:23:11 +0000 |
543 | @@ -0,0 +1,57 @@ |
544 | +/* |
545 | + * Copyright (C) 2015 Canonical, Ltd. |
546 | + * |
547 | + * This program is free software: you can redistribute it and/or modify it |
548 | + * under the terms of the GNU General Public License version 3, as published |
549 | + * by the Free Software Foundation. |
550 | + * |
551 | + * This program is distributed in the hope that it will be useful, but |
552 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
553 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
554 | + * PURPOSE. See the GNU General Public License for more details. |
555 | + * |
556 | + * You should have received a copy of the GNU General Public License along |
557 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
558 | + * |
559 | + * Authors: |
560 | + * Pete Woods <pete.woods@canonical.com> |
561 | + */ |
562 | + |
563 | +#pragma once |
564 | + |
565 | +#include <QDBusConnection> |
566 | +#include <QObject> |
567 | +#include <QString> |
568 | +#include <memory> |
569 | + |
570 | +namespace connectivityqt |
571 | +{ |
572 | +namespace internal |
573 | +{ |
574 | + |
575 | +class DBusPropertyCache: public QObject |
576 | +{ |
577 | + Q_OBJECT |
578 | + |
579 | +public: |
580 | + DBusPropertyCache(const QString &service, const QString& interface, |
581 | + const QString &path, const QDBusConnection &connection); |
582 | + |
583 | + ~DBusPropertyCache(); |
584 | + |
585 | + QVariant get(const QString& name); |
586 | + |
587 | + bool isInitialized() const; |
588 | + |
589 | +Q_SIGNALS: |
590 | + void propertyChanged(const QString& name, const QVariant& value); |
591 | + |
592 | + void initialized(); |
593 | + |
594 | +protected: |
595 | + class Priv; |
596 | + std::shared_ptr<Priv> d; |
597 | +}; |
598 | + |
599 | +} |
600 | +} |
601 | |
602 | === modified file 'src/indicator/agent/SecretAgent.cpp' |
603 | --- src/indicator/agent/SecretAgent.cpp 2015-04-23 13:23:11 +0000 |
604 | +++ src/indicator/agent/SecretAgent.cpp 2015-04-23 13:23:11 +0000 |
605 | @@ -16,12 +16,13 @@ |
606 | * Author: Pete Woods <pete.woods@canonical.com> |
607 | */ |
608 | |
609 | -#include <menumodel-cpp/gio-helpers/util.h> |
610 | #include <agent/SecretAgent.h> |
611 | +#include <agent/SecretRequest.h> |
612 | +#include <AgentManagerInterface.h> |
613 | +#include <NotificationsInterface.h> |
614 | #include <SecretAgentAdaptor.h> |
615 | |
616 | #include <NetworkManager.h> |
617 | - |
618 | #include <stdexcept> |
619 | |
620 | using namespace std; |
621 | @@ -29,53 +30,67 @@ |
622 | namespace agent |
623 | { |
624 | |
625 | -const QString SecretAgent::CONNECTION_SETTING_NAME("connection"); |
626 | -const QString SecretAgent::WIRELESS_SECURITY_SETTING_NAME( |
627 | - "802-11-wireless-security"); |
628 | - |
629 | -const QString SecretAgent::CONNECTION_ID("id"); |
630 | - |
631 | -const QString SecretAgent::WIRELESS_SECURITY_PSK("psk"); |
632 | -const QString SecretAgent::WIRELESS_SECURITY_WEP_KEY0("wep-key0"); |
633 | - |
634 | -const QString SecretAgent::WIRELESS_SECURITY_KEY_MGMT("key-mgmt"); |
635 | - |
636 | -const QString SecretAgent::KEY_MGMT_WPA_NONE("wpa-none"); |
637 | -const QString SecretAgent::KEY_MGMT_WPA_PSK("wpa-psk"); |
638 | -const QString SecretAgent::KEY_MGMT_NONE("none"); |
639 | +class SecretAgent::Priv : public QObject { |
640 | + Q_OBJECT |
641 | + |
642 | +public: |
643 | + Priv(const QDBusConnection &systemConnection, |
644 | + const QDBusConnection &sessionConnection) : |
645 | + m_systemConnection(systemConnection), |
646 | + m_sessionConnection(sessionConnection), |
647 | + m_managerWatcher(NM_DBUS_SERVICE, m_systemConnection), |
648 | + m_agentManager(NM_DBUS_SERVICE, NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), |
649 | + m_notifications("org.freedesktop.Notifications", "/org/freedesktop/Notifications", m_sessionConnection), |
650 | + m_request(nullptr) { |
651 | + } |
652 | + |
653 | +public Q_SLOTS: |
654 | + void serviceOwnerChanged(const QString &name, const QString &oldOwner, |
655 | + const QString &newOwner) |
656 | + { |
657 | + Q_UNUSED(name) |
658 | + Q_UNUSED(oldOwner) |
659 | + if (!newOwner.isEmpty()) { |
660 | + m_agentManager.Register("com.canonical.indicator.SecretAgent").waitForFinished(); |
661 | + } |
662 | + } |
663 | + |
664 | +public: |
665 | + QDBusConnection m_systemConnection; |
666 | + |
667 | + QDBusConnection m_sessionConnection; |
668 | + |
669 | + QDBusServiceWatcher m_managerWatcher; |
670 | + |
671 | + OrgFreedesktopNetworkManagerAgentManagerInterface m_agentManager; |
672 | + |
673 | + OrgFreedesktopNotificationsInterface m_notifications; |
674 | + |
675 | + std::shared_ptr<SecretRequest> m_request; |
676 | +}; |
677 | |
678 | SecretAgent::SecretAgent(const QDBusConnection &systemConnection, |
679 | const QDBusConnection &sessionConnection, QObject *parent) : |
680 | - QObject(parent), m_adaptor(new SecretAgentAdaptor(this)), m_systemConnection( |
681 | - systemConnection), m_sessionConnection(sessionConnection), m_managerWatcher( |
682 | - NM_DBUS_SERVICE, m_systemConnection), m_agentManager(NM_DBUS_SERVICE, |
683 | - NM_DBUS_PATH_AGENT_MANAGER, m_systemConnection), m_notifications( |
684 | - "org.freedesktop.Notifications", "/org/freedesktop/Notifications", |
685 | - m_sessionConnection), m_request(nullptr) { |
686 | - if (!m_systemConnection.registerObject(NM_DBUS_PATH_SECRET_AGENT, this)) { |
687 | + QObject(parent), d(new Priv(systemConnection, sessionConnection)) |
688 | + { |
689 | + // Memory managed by Qt |
690 | + new SecretAgentAdaptor(this); |
691 | + |
692 | + if (!d->m_systemConnection.registerObject(NM_DBUS_PATH_SECRET_AGENT, this)) { |
693 | throw logic_error( |
694 | - "Unable to register user secret agent object on DBus"); |
695 | + "Unable to register user secret agent object on DBus"); |
696 | } |
697 | |
698 | // Watch for NM restarting (or starting after we do) |
699 | - connect(&m_managerWatcher, SIGNAL(serviceOwnerChanged(QString, QString, QString)), |
700 | - this, SLOT(serviceOwnerChanged(QString, QString, QString))); |
701 | + connect(&d->m_managerWatcher, &QDBusServiceWatcher::serviceOwnerChanged, |
702 | + d.get(), &Priv::serviceOwnerChanged); |
703 | |
704 | - m_agentManager.Register("com.canonical.indicator.SecretAgent").waitForFinished(); |
705 | + d->m_agentManager.Register("com.canonical.indicator.SecretAgent").waitForFinished(); |
706 | } |
707 | |
708 | SecretAgent::~SecretAgent() { |
709 | - m_agentManager.Unregister().waitForFinished(); |
710 | - m_systemConnection.unregisterObject(NM_DBUS_PATH_SECRET_AGENT); |
711 | -} |
712 | - |
713 | -void SecretAgent::serviceOwnerChanged(const QString &name, |
714 | - const QString &oldOwner, const QString &newOwner) { |
715 | - Q_UNUSED(name) |
716 | - Q_UNUSED(oldOwner) |
717 | - if (!newOwner.isEmpty()) { |
718 | - m_agentManager.Register("com.canonical.indicator.SecretAgent").waitForFinished(); |
719 | - } |
720 | + d->m_agentManager.Unregister().waitForFinished(); |
721 | + d->m_systemConnection.unregisterObject(NM_DBUS_PATH_SECRET_AGENT); |
722 | } |
723 | |
724 | /** |
725 | @@ -123,11 +138,11 @@ |
726 | setDelayedReply(true); |
727 | |
728 | if (flags == 0) { |
729 | - m_systemConnection.send( |
730 | + d->m_systemConnection.send( |
731 | message().createErrorReply(QDBusError::InternalError, |
732 | "No password found for this connection.")); |
733 | } else { |
734 | - m_request.reset(new SecretRequest(*this, connection, |
735 | + d->m_request.reset(new SecretRequest(*this, connection, |
736 | connectionPath, settingName, hints, flags, message())); |
737 | } |
738 | |
739 | @@ -136,23 +151,23 @@ |
740 | |
741 | void SecretAgent::FinishGetSecrets(SecretRequest &request, bool error) { |
742 | if (error) { |
743 | - m_systemConnection.send( |
744 | + d->m_systemConnection.send( |
745 | request.message().createErrorReply(QDBusError::InternalError, |
746 | "No password found for this connection.")); |
747 | } else { |
748 | - m_systemConnection.send( |
749 | + d->m_systemConnection.send( |
750 | request.message().createReply( |
751 | QVariant::fromValue(request.connection()))); |
752 | } |
753 | |
754 | - m_request.reset(); |
755 | + d->m_request.reset(); |
756 | } |
757 | |
758 | void SecretAgent::CancelGetSecrets(const QDBusObjectPath &connectionPath, |
759 | const QString &settingName) { |
760 | Q_UNUSED(connectionPath); |
761 | Q_UNUSED(settingName); |
762 | - m_request.reset(); |
763 | + d->m_request.reset(); |
764 | } |
765 | |
766 | void SecretAgent::DeleteSecrets(const QVariantDictMap &connection, |
767 | @@ -168,7 +183,10 @@ |
768 | } |
769 | |
770 | OrgFreedesktopNotificationsInterface & SecretAgent::notifications() { |
771 | - return m_notifications; |
772 | -} |
773 | - |
774 | -} |
775 | + return d->m_notifications; |
776 | +} |
777 | + |
778 | +} |
779 | + |
780 | +#include "SecretAgent.moc" |
781 | + |
782 | |
783 | === modified file 'src/indicator/agent/SecretAgent.h' |
784 | --- src/indicator/agent/SecretAgent.h 2015-04-23 13:23:11 +0000 |
785 | +++ src/indicator/agent/SecretAgent.h 2015-04-23 13:23:11 +0000 |
786 | @@ -18,50 +18,52 @@ |
787 | |
788 | #pragma once |
789 | |
790 | +#include <dbus-types.h> |
791 | + |
792 | #include <memory> |
793 | |
794 | -#include <QScopedPointer> |
795 | #include <QDBusConnection> |
796 | #include <QDBusContext> |
797 | #include <QMap> |
798 | |
799 | -#include <DBusTypes.h> |
800 | -#include <agent/SecretRequest.h> |
801 | -#include <AgentManagerInterface.h> |
802 | -#include <NotificationsInterface.h> |
803 | - |
804 | +class OrgFreedesktopNotificationsInterface; |
805 | class SecretAgentAdaptor; |
806 | |
807 | namespace agent |
808 | { |
809 | |
810 | +class SecretRequest; |
811 | + |
812 | class SecretAgent: public QObject, protected QDBusContext { |
813 | -Q_OBJECT |
814 | + Q_OBJECT |
815 | + |
816 | + friend SecretAgentAdaptor; |
817 | + friend SecretRequest; |
818 | |
819 | public: |
820 | - typedef std::shared_ptr<SecretAgent> Ptr; |
821 | - typedef std::unique_ptr<SecretAgent> UPtr; |
822 | - |
823 | - static const QString CONNECTION_SETTING_NAME; |
824 | - static const QString WIRELESS_SECURITY_SETTING_NAME; |
825 | - |
826 | - static const QString CONNECTION_ID; |
827 | - |
828 | - static const QString WIRELESS_SECURITY_PSK; |
829 | - static const QString WIRELESS_SECURITY_WEP_KEY0; |
830 | - |
831 | - static const QString WIRELESS_SECURITY_KEY_MGMT; |
832 | - |
833 | - static const QString KEY_MGMT_WPA_NONE; |
834 | - static const QString KEY_MGMT_WPA_PSK; |
835 | - static const QString KEY_MGMT_NONE; |
836 | + typedef std::shared_ptr<SecretAgent> Ptr; |
837 | + typedef std::unique_ptr<SecretAgent> UPtr; |
838 | + |
839 | + static constexpr char const* CONNECTION_SETTING_NAME = "connection"; |
840 | + static constexpr char const* WIRELESS_SECURITY_SETTING_NAME = "802-11-wireless-security"; |
841 | + |
842 | + static constexpr char const* CONNECTION_ID = "id"; |
843 | + |
844 | + static constexpr char const* WIRELESS_SECURITY_PSK = "psk"; |
845 | + static constexpr char const* WIRELESS_SECURITY_WEP_KEY0 = "wep-key0"; |
846 | + |
847 | + static constexpr char const* WIRELESS_SECURITY_KEY_MGMT = "key-mgmt"; |
848 | + |
849 | + static constexpr char const* KEY_MGMT_WPA_NONE = "wpa-none"; |
850 | + static constexpr char const* KEY_MGMT_WPA_PSK = "wpa-psk"; |
851 | + static constexpr char const* KEY_MGMT_NONE = "none"; |
852 | |
853 | explicit SecretAgent(const QDBusConnection &systemConnection, |
854 | const QDBusConnection &sessionConnection, QObject *parent = 0); |
855 | |
856 | virtual ~SecretAgent(); |
857 | |
858 | -public Q_SLOTS: |
859 | +protected Q_SLOTS: |
860 | QVariantDictMap GetSecrets(const QVariantDictMap &connection, |
861 | const QDBusObjectPath &connectionPath, const QString &settingName, |
862 | const QStringList &hints, uint flags); |
863 | @@ -79,24 +81,9 @@ |
864 | |
865 | OrgFreedesktopNotificationsInterface & notifications(); |
866 | |
867 | -protected Q_SLOTS: |
868 | - void serviceOwnerChanged(const QString &name, const QString &oldOwner, |
869 | - const QString &newOwner); |
870 | - |
871 | protected: |
872 | - QScopedPointer<SecretAgentAdaptor> m_adaptor; |
873 | - |
874 | - QDBusConnection m_systemConnection; |
875 | - |
876 | - QDBusConnection m_sessionConnection; |
877 | - |
878 | - QDBusServiceWatcher m_managerWatcher; |
879 | - |
880 | - OrgFreedesktopNetworkManagerAgentManagerInterface m_agentManager; |
881 | - |
882 | - OrgFreedesktopNotificationsInterface m_notifications; |
883 | - |
884 | - std::shared_ptr<SecretRequest> m_request; |
885 | + class Priv; |
886 | + std::shared_ptr<Priv> d; |
887 | }; |
888 | |
889 | } |
890 | |
891 | === modified file 'src/indicator/agent/SecretAgentInclude.h' |
892 | --- src/indicator/agent/SecretAgentInclude.h 2015-04-23 13:23:11 +0000 |
893 | +++ src/indicator/agent/SecretAgentInclude.h 2015-04-23 13:23:11 +0000 |
894 | @@ -18,6 +18,6 @@ |
895 | |
896 | #pragma once |
897 | |
898 | -#include <DBusTypes.h> |
899 | +#include <dbus-types.h> |
900 | #include <agent/SecretAgent.h> |
901 | |
902 | |
903 | === modified file 'src/indicator/agent/SecretRequest.cpp' |
904 | --- src/indicator/agent/SecretRequest.cpp 2015-04-23 13:23:11 +0000 |
905 | +++ src/indicator/agent/SecretRequest.cpp 2015-04-23 13:23:11 +0000 |
906 | @@ -20,6 +20,8 @@ |
907 | #include <agent/SecretAgent.h> |
908 | #include <util/localisation.h> |
909 | |
910 | +#include <NotificationsInterface.h> |
911 | + |
912 | namespace agent |
913 | { |
914 | |
915 | |
916 | === modified file 'src/indicator/agent/SecretRequest.h' |
917 | --- src/indicator/agent/SecretRequest.h 2015-04-23 13:23:11 +0000 |
918 | +++ src/indicator/agent/SecretRequest.h 2015-04-23 13:23:11 +0000 |
919 | @@ -18,7 +18,7 @@ |
920 | |
921 | #pragma once |
922 | |
923 | -#include <DBusTypes.h> |
924 | +#include <dbus-types.h> |
925 | #include <agent/PasswordMenu.h> |
926 | |
927 | #include <QDBusMessage> |
928 | |
929 | === modified file 'src/indicator/connectivity-service/connectivity-service.cpp' |
930 | --- src/indicator/connectivity-service/connectivity-service.cpp 2015-04-23 13:23:11 +0000 |
931 | +++ src/indicator/connectivity-service/connectivity-service.cpp 2015-04-23 13:23:11 +0000 |
932 | @@ -20,7 +20,7 @@ |
933 | #include <connectivity-service/connectivity-service.h> |
934 | #include <NetworkingStatusAdaptor.h> |
935 | #include <NetworkingStatusPrivateAdaptor.h> |
936 | -#include <DBusTypes.h> |
937 | +#include <dbus-types.h> |
938 | |
939 | using namespace nmofono; |
940 | using namespace std; |
941 | @@ -69,6 +69,27 @@ |
942 | } |
943 | |
944 | public Q_SLOTS: |
945 | + void flightModeUpdated() |
946 | + { |
947 | + notifyPropertyChanged(DBusTypes::SERVICE_PATH, |
948 | + DBusTypes::SERVICE_INTERFACE, |
949 | + { "FlightMode" }); |
950 | + } |
951 | + |
952 | + void wifiEnabledUpdated() |
953 | + { |
954 | + notifyPropertyChanged(DBusTypes::SERVICE_PATH, |
955 | + DBusTypes::SERVICE_INTERFACE, |
956 | + { "WifiEnabled" }); |
957 | + } |
958 | + |
959 | + void unstoppableOperationHappeningUpdated() |
960 | + { |
961 | + notifyPropertyChanged(DBusTypes::SERVICE_PATH, |
962 | + DBusTypes::SERVICE_INTERFACE, |
963 | + { "UnstoppableOperationHappening" }); |
964 | + } |
965 | + |
966 | void updateNetworkingStatus() |
967 | { |
968 | QStringList changed; |
969 | @@ -125,6 +146,9 @@ |
970 | |
971 | connect(d->m_manager.get(), &Manager::characteristicsUpdated, d.get(), &Private::updateNetworkingStatus); |
972 | connect(d->m_manager.get(), &Manager::statusUpdated, d.get(), &Private::updateNetworkingStatus); |
973 | + connect(d->m_manager.get(), &Manager::flightModeUpdated, d.get(), &Private::flightModeUpdated); |
974 | + connect(d->m_manager.get(), &Manager::wifiEnabledUpdated, d.get(), &Private::wifiEnabledUpdated); |
975 | + connect(d->m_manager.get(), &Manager::unstoppableOperationHappeningUpdated, d.get(), &Private::unstoppableOperationHappeningUpdated); |
976 | |
977 | d->updateNetworkingStatus(); |
978 | |
979 | @@ -160,6 +184,21 @@ |
980 | return d->m_status; |
981 | } |
982 | |
983 | +bool ConnectivityService::wifiEnabled() const |
984 | +{ |
985 | + return d->m_manager->wifiEnabled(); |
986 | +} |
987 | + |
988 | +bool ConnectivityService::flightMode() const |
989 | +{ |
990 | + return (d->m_manager->flightMode() == Manager::FlightModeStatus::on); |
991 | +} |
992 | + |
993 | +bool ConnectivityService::unstoppableOperationHappening() const |
994 | +{ |
995 | + return d->m_manager->unstoppableOperationHappening(); |
996 | +} |
997 | + |
998 | PrivateService::PrivateService(ConnectivityService& parent) : |
999 | p(parent) |
1000 | { |
1001 | @@ -177,6 +216,16 @@ |
1002 | Q_EMIT p.unlockModem(modem); |
1003 | } |
1004 | |
1005 | +void PrivateService::SetFlightMode(bool enabled) |
1006 | +{ |
1007 | + p.d->m_manager->setFlightMode(enabled); |
1008 | +} |
1009 | + |
1010 | +void PrivateService::SetWifiEnabled(bool enabled) |
1011 | +{ |
1012 | + p.d->m_manager->setWifiEnabled(enabled); |
1013 | +} |
1014 | + |
1015 | } |
1016 | |
1017 | #include "connectivity-service.moc" |
1018 | |
1019 | === modified file 'src/indicator/connectivity-service/connectivity-service.h' |
1020 | --- src/indicator/connectivity-service/connectivity-service.h 2015-04-23 13:23:11 +0000 |
1021 | +++ src/indicator/connectivity-service/connectivity-service.h 2015-04-23 13:23:11 +0000 |
1022 | @@ -50,6 +50,15 @@ |
1023 | Q_PROPERTY(QString Status READ status) |
1024 | QString status() const; |
1025 | |
1026 | + Q_PROPERTY(bool WifiEnabled READ wifiEnabled) |
1027 | + bool wifiEnabled() const; |
1028 | + |
1029 | + Q_PROPERTY(bool FlightMode READ flightMode) |
1030 | + bool flightMode() const; |
1031 | + |
1032 | + Q_PROPERTY(bool UnstoppableOperationHappening READ unstoppableOperationHappening) |
1033 | + bool unstoppableOperationHappening() const; |
1034 | + |
1035 | Q_SIGNALS: |
1036 | void unlockAllModems(); |
1037 | |
1038 | @@ -76,6 +85,10 @@ |
1039 | |
1040 | void UnlockModem(const QString &modem); |
1041 | |
1042 | + void SetFlightMode(bool enabled); |
1043 | + |
1044 | + void SetWifiEnabled(bool enabled); |
1045 | + |
1046 | protected: |
1047 | ConnectivityService& p; |
1048 | }; |
1049 | |
1050 | === modified file 'src/indicator/main.cpp' |
1051 | --- src/indicator/main.cpp 2015-04-23 13:23:11 +0000 |
1052 | +++ src/indicator/main.cpp 2015-04-23 13:23:11 +0000 |
1053 | @@ -19,7 +19,7 @@ |
1054 | |
1055 | #include <factory.h> |
1056 | #include <util/unix-signal-handler.h> |
1057 | -#include <DBusTypes.h> |
1058 | +#include <dbus-types.h> |
1059 | |
1060 | #include <QCoreApplication> |
1061 | |
1062 | @@ -38,6 +38,7 @@ |
1063 | { |
1064 | QCoreApplication app(argc, argv); |
1065 | DBusTypes::registerMetaTypes(); |
1066 | + Variant::registerMetaTypes(); |
1067 | |
1068 | util::UnixSignalHandler handler([]{ |
1069 | QCoreApplication::exit(0); |
1070 | @@ -60,8 +61,8 @@ |
1071 | { |
1072 | Factory factory; |
1073 | auto menu = factory.newMenuBuilder(); |
1074 | + auto secretAgent = factory.newSecretAgent(); |
1075 | auto connectivityService = factory.newConnectivityService(); |
1076 | - auto secretAgent = factory.newSecretAgent(); |
1077 | |
1078 | QObject::connect(connectivityService.get(), &ConnectivityService::unlockAllModems, menu.get(), &MenuBuilder::unlockAllModems); |
1079 | QObject::connect(connectivityService.get(), &ConnectivityService::unlockModem, menu.get(), &MenuBuilder::unlockModem); |
1080 | |
1081 | === modified file 'src/indicator/nmofono/kill-switch.cpp' |
1082 | --- src/indicator/nmofono/kill-switch.cpp 2015-04-23 13:23:11 +0000 |
1083 | +++ src/indicator/nmofono/kill-switch.cpp 2015-04-23 13:23:11 +0000 |
1084 | @@ -20,14 +20,11 @@ |
1085 | |
1086 | #include <nmofono/kill-switch.h> |
1087 | #include <backend-utils.h> |
1088 | +#include <dbus-types.h> |
1089 | |
1090 | #include <URfkillInterface.h> |
1091 | #include <URfkillKillswitchInterface.h> |
1092 | |
1093 | -static QString const cBusName = "org.freedesktop.URfkill"; |
1094 | -static QString const cURfkillPath = "/org/freedesktop/URfkill"; |
1095 | -static QString const cURfkillKillswitchPath = "/org/freedesktop/URfkill/WLAN"; |
1096 | - |
1097 | namespace nmofono |
1098 | { |
1099 | |
1100 | @@ -60,12 +57,12 @@ |
1101 | |
1102 | KillSwitch::KillSwitch(const QDBusConnection& systemBus) |
1103 | { |
1104 | - auto urfkill = std::make_shared<OrgFreedesktopURfkillInterface>(cBusName, |
1105 | - cURfkillPath, |
1106 | + auto urfkill = std::make_shared<OrgFreedesktopURfkillInterface>(DBusTypes::URFKILL_BUS_NAME, |
1107 | + DBusTypes::URFKILL_OBJ_PATH, |
1108 | systemBus); |
1109 | |
1110 | - auto killSwitch = std::make_shared<OrgFreedesktopURfkillKillswitchInterface>(cBusName, |
1111 | - cURfkillKillswitchPath, |
1112 | + auto killSwitch = std::make_shared<OrgFreedesktopURfkillKillswitchInterface>(DBusTypes::URFKILL_BUS_NAME, |
1113 | + DBusTypes::URFKILL_WIFI_OBJ_PATH, |
1114 | systemBus); |
1115 | |
1116 | connect(urfkill.get(), SIGNAL(FlightModeChanged(bool)), this, SLOT(setFlightMode(bool))); |
1117 | |
1118 | === modified file 'src/indicator/nmofono/manager-impl.cpp' |
1119 | --- src/indicator/nmofono/manager-impl.cpp 2015-04-23 13:23:11 +0000 |
1120 | +++ src/indicator/nmofono/manager-impl.cpp 2015-04-23 13:23:11 +0000 |
1121 | @@ -53,12 +53,13 @@ |
1122 | shared_ptr<QOfonoManager> m_ofono; |
1123 | |
1124 | Manager::FlightModeStatus m_flightMode = FlightModeStatus::on; |
1125 | + bool m_unstoppableOperationHappening = false; |
1126 | Manager::NetworkingStatus m_status = NetworkingStatus::offline; |
1127 | uint32_t m_characteristics = 0; |
1128 | |
1129 | bool m_hasWifi = false; |
1130 | bool m_wifiEnabled = false; |
1131 | - KillSwitch::Ptr m_wifiKillSwitch; |
1132 | + KillSwitch::Ptr m_killSwitch; |
1133 | |
1134 | QSet<Link::Ptr> m_nmLinks; |
1135 | QMap<QString, wwan::Modem::Ptr> m_ofonoLinks; |
1136 | @@ -71,13 +72,24 @@ |
1137 | { |
1138 | } |
1139 | |
1140 | + void setUnstoppableOperationHappening(bool happening) |
1141 | + { |
1142 | + if (m_unstoppableOperationHappening == happening) |
1143 | + { |
1144 | + return; |
1145 | + } |
1146 | + |
1147 | + m_unstoppableOperationHappening = happening; |
1148 | + Q_EMIT p.unstoppableOperationHappeningUpdated(m_unstoppableOperationHappening); |
1149 | + } |
1150 | + |
1151 | public Q_SLOTS: |
1152 | void updateHasWifi() |
1153 | { |
1154 | - if (m_wifiKillSwitch->state() != KillSwitch::State::not_available) |
1155 | + if (m_killSwitch->state() != KillSwitch::State::not_available) |
1156 | { |
1157 | m_hasWifi = true; |
1158 | - if (m_wifiKillSwitch->state() == KillSwitch::State::unblocked) |
1159 | + if (m_killSwitch->state() == KillSwitch::State::unblocked) |
1160 | { |
1161 | m_wifiEnabled = true; |
1162 | } |
1163 | @@ -107,15 +119,15 @@ |
1164 | |
1165 | void setFlightMode(bool flightMode) |
1166 | { |
1167 | - if (flightMode) |
1168 | - { |
1169 | - m_flightMode = Manager::FlightModeStatus::on; |
1170 | - } |
1171 | - else |
1172 | - { |
1173 | - m_flightMode = Manager::FlightModeStatus::off; |
1174 | - } |
1175 | - |
1176 | + FlightModeStatus newStatus = |
1177 | + flightMode ? FlightModeStatus::on : FlightModeStatus::off; |
1178 | + |
1179 | + if (m_flightMode == newStatus) |
1180 | + { |
1181 | + return; |
1182 | + } |
1183 | + |
1184 | + m_flightMode = newStatus; |
1185 | Q_EMIT p.flightModeUpdated(m_flightMode); |
1186 | } |
1187 | |
1188 | @@ -212,8 +224,8 @@ |
1189 | /// @todo offload the initialization to a thread or something |
1190 | /// @todo those Id() thingies |
1191 | |
1192 | - d->m_wifiKillSwitch = make_shared<KillSwitch>(systemConnection); |
1193 | - connect(d->m_wifiKillSwitch.get(), &KillSwitch::stateChanged, d.get(), &Private::updateHasWifi); |
1194 | + d->m_killSwitch = make_shared<KillSwitch>(systemConnection); |
1195 | + connect(d->m_killSwitch.get(), &KillSwitch::stateChanged, d.get(), &Private::updateHasWifi); |
1196 | |
1197 | connect(d->nm.get(), &OrgFreedesktopNetworkManagerInterface::DeviceAdded, this, &ManagerImpl::device_added); |
1198 | QList<QDBusObjectPath> devices(d->nm->GetDevices()); |
1199 | @@ -225,10 +237,10 @@ |
1200 | updateNetworkingStatus(d->nm->state()); |
1201 | connect(d->nm.get(), &OrgFreedesktopNetworkManagerInterface::PropertiesChanged, this, &ManagerImpl::nm_properties_changed); |
1202 | |
1203 | - connect(d->m_wifiKillSwitch.get(), &KillSwitch::flightModeChanged, d.get(), &Private::setFlightMode); |
1204 | + connect(d->m_killSwitch.get(), &KillSwitch::flightModeChanged, d.get(), &Private::setFlightMode); |
1205 | try |
1206 | { |
1207 | - d->setFlightMode(d->m_wifiKillSwitch->isFlightMode()); |
1208 | + d->setFlightMode(d->m_killSwitch->isFlightMode()); |
1209 | } |
1210 | catch (exception const& e) |
1211 | { |
1212 | @@ -299,7 +311,7 @@ |
1213 | if (dev->deviceType() == NM_DEVICE_TYPE_WIFI) { |
1214 | link = make_shared<wifi::WifiLinkImpl>(dev, |
1215 | d->nm, |
1216 | - d->m_wifiKillSwitch); |
1217 | + d->m_killSwitch); |
1218 | } |
1219 | } catch (const exception &e) { |
1220 | qDebug() << __PRETTY_FUNCTION__ << ": failed to create Device proxy for "<< path.path() << ": "; |
1221 | @@ -318,27 +330,23 @@ |
1222 | |
1223 | |
1224 | void |
1225 | -ManagerImpl::enableFlightMode() |
1226 | -{ |
1227 | -#ifdef INDICATOR_NETWORK_TRACE_MESSAGES |
1228 | - cout << __PRETTY_FUNCTION__ << endl; |
1229 | -#endif |
1230 | - if (!d->m_wifiKillSwitch->flightMode(true)) |
1231 | - { |
1232 | - qWarning() << "Failed to enable flightmode."; |
1233 | - } |
1234 | -} |
1235 | - |
1236 | -void |
1237 | -ManagerImpl::disableFlightMode() |
1238 | -{ |
1239 | -#ifdef INDICATOR_NETWORK_TRACE_MESSAGES |
1240 | - cout << __PRETTY_FUNCTION__ << endl; |
1241 | -#endif |
1242 | - if (!d->m_wifiKillSwitch->flightMode(false)) |
1243 | - { |
1244 | - qWarning() << "Failed to disable flightmode"; |
1245 | - } |
1246 | +ManagerImpl::setFlightMode(bool enabled) |
1247 | +{ |
1248 | +#ifdef INDICATOR_NETWORK_TRACE_MESSAGES |
1249 | + qDebug() << __PRETTY_FUNCTION__ << enabled; |
1250 | +#endif |
1251 | + if (enabled == d->m_killSwitch->isFlightMode()) |
1252 | + { |
1253 | + return; |
1254 | + } |
1255 | + |
1256 | + d->setUnstoppableOperationHappening(true); |
1257 | + |
1258 | + if (!d->m_killSwitch->flightMode(enabled)) |
1259 | + { |
1260 | + qWarning() << "Failed to change flightmode."; |
1261 | + } |
1262 | + d->setUnstoppableOperationHappening(false); |
1263 | } |
1264 | |
1265 | Manager::FlightModeStatus |
1266 | @@ -350,6 +358,12 @@ |
1267 | return d->m_flightMode; |
1268 | } |
1269 | |
1270 | +bool |
1271 | +ManagerImpl::unstoppableOperationHappening() const |
1272 | +{ |
1273 | + return d->m_unstoppableOperationHappening; |
1274 | +} |
1275 | + |
1276 | QSet<Link::Ptr> |
1277 | ManagerImpl::links() const |
1278 | { |
1279 | @@ -387,57 +401,47 @@ |
1280 | |
1281 | |
1282 | bool |
1283 | -ManagerImpl::enableWifi() |
1284 | +ManagerImpl::setWifiEnabled(bool enabled) |
1285 | { |
1286 | if (!d->m_hasWifi) |
1287 | { |
1288 | return false; |
1289 | } |
1290 | |
1291 | - if (d->m_wifiEnabled) |
1292 | + if (d->m_wifiEnabled == enabled) |
1293 | { |
1294 | return false; |
1295 | } |
1296 | |
1297 | + bool success = true; |
1298 | + d->setUnstoppableOperationHappening(true); |
1299 | + |
1300 | try |
1301 | { |
1302 | - if (d->m_wifiKillSwitch->state() == KillSwitch::State::soft_blocked) |
1303 | - { |
1304 | - // try to unblock. throws if fails. |
1305 | - d->m_wifiKillSwitch->unblock(); |
1306 | - } |
1307 | - d->nm->setWirelessEnabled(true); |
1308 | - } catch(runtime_error &e) { |
1309 | + if (enabled) |
1310 | + { |
1311 | + if (d->m_killSwitch->state() == KillSwitch::State::soft_blocked) |
1312 | + { |
1313 | + // try to unblock. throws if fails. |
1314 | + d->m_killSwitch->unblock(); |
1315 | + } |
1316 | + } |
1317 | + else |
1318 | + { |
1319 | + if (d->m_killSwitch->state() == KillSwitch::State::unblocked) { |
1320 | + // block the device. that will disable it also |
1321 | + d->m_killSwitch->block(); |
1322 | + } |
1323 | + } |
1324 | + d->nm->setWirelessEnabled(enabled); |
1325 | + } |
1326 | + catch (runtime_error &e) |
1327 | + { |
1328 | qWarning() << __PRETTY_FUNCTION__ << ": " << e.what(); |
1329 | - return false; |
1330 | - } |
1331 | - return true; |
1332 | -} |
1333 | - |
1334 | -bool |
1335 | -ManagerImpl::disableWifi() |
1336 | -{ |
1337 | - if (!d->m_hasWifi) |
1338 | - { |
1339 | - return false; |
1340 | - } |
1341 | - |
1342 | - if (!d->m_wifiEnabled) |
1343 | - { |
1344 | - return false; |
1345 | - } |
1346 | - |
1347 | - try { |
1348 | - if (d->m_wifiKillSwitch->state() == KillSwitch::State::unblocked) { |
1349 | - // block the device. that will disable it also |
1350 | - d->m_wifiKillSwitch->block(); |
1351 | - } |
1352 | - d->nm->setWirelessEnabled(false); |
1353 | - } catch(runtime_error &e) { |
1354 | - cerr << __PRETTY_FUNCTION__ << ": " << e.what() << endl; |
1355 | - return false; |
1356 | - } |
1357 | - return true; |
1358 | + success = false; |
1359 | + } |
1360 | + d->setUnstoppableOperationHappening(false); |
1361 | + return success; |
1362 | } |
1363 | |
1364 | bool |
1365 | |
1366 | === modified file 'src/indicator/nmofono/manager-impl.h' |
1367 | --- src/indicator/nmofono/manager-impl.h 2015-04-23 13:23:11 +0000 |
1368 | +++ src/indicator/nmofono/manager-impl.h 2015-04-23 13:23:11 +0000 |
1369 | @@ -42,15 +42,15 @@ |
1370 | ManagerImpl(const QDBusConnection& systemBus); |
1371 | |
1372 | // Public API |
1373 | - void enableFlightMode() override; |
1374 | - void disableFlightMode() override; |
1375 | + void setFlightMode(bool) override; |
1376 | Manager::FlightModeStatus flightMode() const override; |
1377 | |
1378 | + bool unstoppableOperationHappening() const override; |
1379 | + |
1380 | bool hasWifi() const override; |
1381 | bool wifiEnabled() const override; |
1382 | |
1383 | - bool enableWifi() override; |
1384 | - bool disableWifi() override; |
1385 | + bool setWifiEnabled(bool) override; |
1386 | |
1387 | bool roaming() const override; |
1388 | |
1389 | |
1390 | === modified file 'src/indicator/nmofono/manager.h' |
1391 | --- src/indicator/nmofono/manager.h 2015-04-23 13:23:11 +0000 |
1392 | +++ src/indicator/nmofono/manager.h 2015-04-23 13:23:11 +0000 |
1393 | @@ -81,15 +81,12 @@ |
1394 | }; |
1395 | |
1396 | /// @private |
1397 | - virtual void enableFlightMode() = 0; |
1398 | - |
1399 | - /// @private |
1400 | - virtual void disableFlightMode() = 0; |
1401 | - |
1402 | - /// @private |
1403 | Q_PROPERTY(Manager::FlightModeStatus flightMode READ flightMode NOTIFY flightModeUpdated) |
1404 | virtual FlightModeStatus flightMode() const = 0; |
1405 | |
1406 | + Q_PROPERTY(bool unstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated) |
1407 | + virtual bool unstoppableOperationHappening() const = 0; |
1408 | + |
1409 | /// @private |
1410 | Q_PROPERTY(QSet<Link::Ptr> links READ links NOTIFY linksUpdated) |
1411 | virtual QSet<Link::Ptr> links() const = 0; |
1412 | @@ -123,10 +120,6 @@ |
1413 | Q_PROPERTY(bool wifiEnabled READ wifiEnabled NOTIFY wifiEnabledUpdated) |
1414 | virtual bool wifiEnabled() const = 0; |
1415 | |
1416 | - virtual bool enableWifi() = 0; |
1417 | - |
1418 | - virtual bool disableWifi() = 0; |
1419 | - |
1420 | virtual bool roaming() const = 0; |
1421 | |
1422 | virtual void unlockModem(wwan::Modem::Ptr modem) = 0; |
1423 | @@ -148,6 +141,13 @@ |
1424 | |
1425 | void wifiEnabledUpdated(bool); |
1426 | |
1427 | + void unstoppableOperationHappeningUpdated(bool); |
1428 | + |
1429 | +public Q_SLOTS: |
1430 | + virtual bool setWifiEnabled(bool) = 0; |
1431 | + |
1432 | + virtual void setFlightMode(bool) = 0; |
1433 | + |
1434 | protected: |
1435 | /** |
1436 | * @brief The default constructor is protected. |
1437 | |
1438 | === modified file 'src/indicator/sections/quick-access-section.cpp' |
1439 | --- src/indicator/sections/quick-access-section.cpp 2015-04-23 13:23:11 +0000 |
1440 | +++ src/indicator/sections/quick-access-section.cpp 2015-04-23 13:23:11 +0000 |
1441 | @@ -48,6 +48,18 @@ |
1442 | Private(Manager::Ptr manager, SwitchItem::Ptr wifiSwitch); |
1443 | |
1444 | public Q_SLOTS: |
1445 | + void unstoppableOperationHappeningUpdated(bool happening) |
1446 | + { |
1447 | + m_flightModeSwitch->setEnabled(!happening); |
1448 | + m_wifiSwitch->setEnabled(!happening); |
1449 | + |
1450 | + if (happening) |
1451 | + { |
1452 | + // Give the GActionGroup a chance to emit its Changed signal |
1453 | + runGMainloop(); |
1454 | + } |
1455 | + } |
1456 | + |
1457 | void flightModeUpdated(Manager::FlightModeStatus value) |
1458 | { |
1459 | switch (value) { |
1460 | @@ -59,32 +71,6 @@ |
1461 | break; |
1462 | } |
1463 | } |
1464 | - |
1465 | - void flightModeSwitchActivated(bool state) |
1466 | - { |
1467 | - m_flightModeSwitch->setEnabled(false); |
1468 | - m_wifiSwitch->setEnabled(false); |
1469 | - |
1470 | - // Give the GActionGroup a change to emit its Changed signal |
1471 | - runGMainloop(); |
1472 | - |
1473 | - if (state) { |
1474 | - try { |
1475 | - m_manager->enableFlightMode(); |
1476 | - } catch (const std::exception &e) { |
1477 | - std::cerr << e.what() << std::endl; |
1478 | - } |
1479 | - } else { |
1480 | - try { |
1481 | - m_manager->disableFlightMode(); |
1482 | - } catch (const std::exception &e) { |
1483 | - std::cerr << e.what() << std::endl; |
1484 | - } |
1485 | - } |
1486 | - |
1487 | - m_flightModeSwitch->setEnabled(true); |
1488 | - m_wifiSwitch->setEnabled(true); |
1489 | - } |
1490 | }; |
1491 | |
1492 | QuickAccessSection::Private::Private(Manager::Ptr manager, |
1493 | @@ -97,10 +83,15 @@ |
1494 | m_flightModeSwitch = std::make_shared<SwitchItem>(_("Flight Mode"), "airplane", "enabled"); |
1495 | flightModeUpdated(m_manager->flightMode()); |
1496 | connect(m_manager.get(), &Manager::flightModeUpdated, this, &Private::flightModeUpdated); |
1497 | - connect(m_flightModeSwitch.get(), &SwitchItem::stateUpdated, this, &Private::flightModeSwitchActivated); |
1498 | + connect(m_flightModeSwitch.get(), &SwitchItem::stateUpdated, m_manager.get(), &Manager::setFlightMode); |
1499 | |
1500 | m_actionGroupMerger->add(m_flightModeSwitch->actionGroup()); |
1501 | m_menu->append(m_flightModeSwitch->menuItem()); |
1502 | + |
1503 | + // Connect the unstoppable operation property to the toggle enabled properties |
1504 | + // Make sure we don't also connect this signal in the wifi-section.cpp |
1505 | + connect(m_manager.get(), &Manager::unstoppableOperationHappeningUpdated, |
1506 | + this, &Private::unstoppableOperationHappeningUpdated); |
1507 | } |
1508 | |
1509 | QuickAccessSection::QuickAccessSection(Manager::Ptr manager, SwitchItem::Ptr wifiSwitch) |
1510 | |
1511 | === modified file 'src/indicator/sections/wifi-section.cpp' |
1512 | --- src/indicator/sections/wifi-section.cpp 2015-04-23 13:23:11 +0000 |
1513 | +++ src/indicator/sections/wifi-section.cpp 2015-04-23 13:23:11 +0000 |
1514 | @@ -67,7 +67,7 @@ |
1515 | |
1516 | m_switch->setState(m_manager->wifiEnabled()); |
1517 | connect(m_manager.get(), &Manager::wifiEnabledUpdated, m_switch.get(), &SwitchItem::setState); |
1518 | - connect(m_switch.get(), &SwitchItem::stateUpdated, this, &Private::switchActivated); |
1519 | + connect(m_switch.get(), &SwitchItem::stateUpdated, m_manager.get(), &Manager::setWifiEnabled); |
1520 | |
1521 | m_openWifiSettings = std::make_shared<TextItem>(_("Wi-Fi settingsā¦"), "wifi", "settings"); |
1522 | connect(m_openWifiSettings.get(), &TextItem::activated, this, &Private::openWiFiSettings); |
1523 | @@ -115,18 +115,6 @@ |
1524 | break; |
1525 | } |
1526 | } |
1527 | - |
1528 | - void switchActivated(bool state) |
1529 | - { |
1530 | - m_switch->setEnabled(false); |
1531 | - runGMainloop(); |
1532 | - if (state) { |
1533 | - m_manager->enableWifi(); |
1534 | - } else { |
1535 | - m_manager->disableWifi(); |
1536 | - } |
1537 | - m_switch->setEnabled(true); |
1538 | - } |
1539 | }; |
1540 | |
1541 | WifiSection::WifiSection(Manager::Ptr manager) |
1542 | |
1543 | === modified file 'src/menumodel-cpp/gio-helpers/variant.h' |
1544 | --- src/menumodel-cpp/gio-helpers/variant.h 2015-04-01 08:39:34 +0000 |
1545 | +++ src/menumodel-cpp/gio-helpers/variant.h 2015-04-23 13:23:11 +0000 |
1546 | @@ -24,6 +24,7 @@ |
1547 | #include <vector> |
1548 | #include <memory> |
1549 | #include <gio/gio.h> |
1550 | +#include <QObject> |
1551 | |
1552 | #include <cassert> |
1553 | |
1554 | @@ -31,6 +32,8 @@ |
1555 | |
1556 | class Variant; |
1557 | |
1558 | +Q_DECLARE_METATYPE(Variant) |
1559 | + |
1560 | template<typename T> |
1561 | struct Codec |
1562 | { |
1563 | @@ -41,6 +44,11 @@ |
1564 | class Variant |
1565 | { |
1566 | public: |
1567 | + static void registerMetaTypes() |
1568 | + { |
1569 | + qRegisterMetaType<Variant>("Variant"); |
1570 | + } |
1571 | + |
1572 | static Variant fromGVariant(GVariant *variant) { |
1573 | return Variant(variant); |
1574 | } |
1575 | |
1576 | === modified file 'src/qdbus-stubs/CMakeLists.txt' |
1577 | --- src/qdbus-stubs/CMakeLists.txt 2015-04-23 13:23:11 +0000 |
1578 | +++ src/qdbus-stubs/CMakeLists.txt 2015-04-23 13:23:11 +0000 |
1579 | @@ -21,8 +21,6 @@ |
1580 | "${DATA_DIR}/nm-access-point.xml" |
1581 | "${DATA_DIR}/nm-active-connection.xml" |
1582 | "${DATA_DIR}/nm-agent-manager.xml" |
1583 | - "${DATA_DIR}/com.ubuntu.connectivity1.NetworkingStatus.xml" |
1584 | - "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml" |
1585 | "${DATA_DIR}/org.freedesktop.URfkill.xml" |
1586 | "${DATA_DIR}/org.freedesktop.URfkill.Device.xml" |
1587 | "${DATA_DIR}/org.freedesktop.URfkill.Killswitch.xml" |
1588 | @@ -36,7 +34,7 @@ |
1589 | "${DATA_DIR}/org.freedesktop.Notifications.xml" |
1590 | PROPERTIES |
1591 | NO_NAMESPACE YES |
1592 | - INCLUDE "DBusTypes.h" |
1593 | + INCLUDE "dbus-types.h" |
1594 | ) |
1595 | |
1596 | qt5_add_dbus_interface( |
1597 | @@ -105,18 +103,6 @@ |
1598 | NotificationsInterface |
1599 | ) |
1600 | |
1601 | -qt5_add_dbus_interface( |
1602 | - CONNECTIVITY_BACKEND_SRC |
1603 | - "${DATA_DIR}/com.ubuntu.connectivity1.NetworkingStatus.xml" |
1604 | - NetworkingStatusInterface |
1605 | -) |
1606 | - |
1607 | -qt5_add_dbus_interface( |
1608 | - CONNECTIVITY_BACKEND_SRC |
1609 | - "${DATA_DIR}/com.ubuntu.connectivity1.Private.xml" |
1610 | - NetworkingStatusPrivateInterface |
1611 | -) |
1612 | - |
1613 | add_library( |
1614 | qdbus-stubs |
1615 | STATIC |
1616 | |
1617 | === renamed file 'src/qdbus-stubs/DBusTypes.h' => 'src/qdbus-stubs/dbus-types.h' |
1618 | --- src/qdbus-stubs/DBusTypes.h 2015-03-23 14:46:24 +0000 |
1619 | +++ src/qdbus-stubs/dbus-types.h 2015-04-23 13:23:11 +0000 |
1620 | @@ -16,8 +16,7 @@ |
1621 | * Author: Pete Woods <pete.woods@canonical.com> |
1622 | */ |
1623 | |
1624 | -#ifndef DBUSTYPES_H_ |
1625 | -#define DBUSTYPES_H_ |
1626 | +#pragma once |
1627 | |
1628 | #include <QDBusMetaType> |
1629 | #include <QtCore> |
1630 | @@ -27,10 +26,9 @@ |
1631 | typedef QMap<QString, QVariantMap> QVariantDictMap; |
1632 | Q_DECLARE_METATYPE(QVariantDictMap) |
1633 | |
1634 | -class DBusTypes { |
1635 | -public: |
1636 | - static void |
1637 | - registerMetaTypes() |
1638 | +namespace DBusTypes |
1639 | +{ |
1640 | + inline void registerMetaTypes() |
1641 | { |
1642 | qRegisterMetaType<QVariantDictMap>("QVariantDictMap"); |
1643 | |
1644 | @@ -46,6 +44,10 @@ |
1645 | static constexpr char const* SERVICE_PATH = "/com/ubuntu/connectivity1/NetworkingStatus"; |
1646 | |
1647 | static constexpr char const* PRIVATE_PATH = "/com/ubuntu/connectivity1/Private"; |
1648 | -}; |
1649 | - |
1650 | -#endif /* DBUSTYPES_H_ */ |
1651 | + |
1652 | + static constexpr char const* URFKILL_BUS_NAME = "org.freedesktop.URfkill"; |
1653 | + |
1654 | + static constexpr char const* URFKILL_OBJ_PATH = "/org/freedesktop/URfkill"; |
1655 | + |
1656 | + static constexpr char const* URFKILL_WIFI_OBJ_PATH = "/org/freedesktop/URfkill/WLAN"; |
1657 | +} |
1658 | |
1659 | === renamed file 'tests/integration/indicator/CMakeLists.txt' => 'tests/integration/CMakeLists.txt' |
1660 | --- tests/integration/indicator/CMakeLists.txt 2015-02-19 11:14:56 +0000 |
1661 | +++ tests/integration/CMakeLists.txt 2015-04-23 13:23:11 +0000 |
1662 | @@ -1,9 +1,16 @@ |
1663 | |
1664 | add_definitions(-DNETWORK_SERVICE_BIN="${CMAKE_BINARY_DIR}/src/indicator/indicator-network-service") |
1665 | |
1666 | +include_directories( |
1667 | + "${CMAKE_SOURCE_DIR}/src/connectivity-api/connectivity-qt" |
1668 | + "${CMAKE_SOURCE_DIR}/src/qdbus-stubs" |
1669 | +) |
1670 | + |
1671 | set( |
1672 | INTEGRATION_TESTS_SRC |
1673 | - TestIndicatorNetworkService.cpp |
1674 | + indicator-network-test-base.cpp |
1675 | + test-indicator.cpp |
1676 | + test-connectivity-api.cpp |
1677 | ) |
1678 | |
1679 | add_executable( |
1680 | @@ -22,6 +29,7 @@ |
1681 | integration-tests |
1682 | test-utils |
1683 | menuharness |
1684 | + connectivity-qt |
1685 | ${QTDBUSMOCK_LDFLAGS} |
1686 | ${QTDBUSTEST_LDFLAGS} |
1687 | ${GTEST_LIBRARIES} |
1688 | |
1689 | === removed file 'tests/integration/CMakeLists.txt' |
1690 | --- tests/integration/CMakeLists.txt 2015-03-31 10:39:35 +0000 |
1691 | +++ tests/integration/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1692 | @@ -1,2 +0,0 @@ |
1693 | -#add_subdirectory(connectivity-cpp) |
1694 | -add_subdirectory(indicator) |
1695 | |
1696 | === removed directory 'tests/integration/connectivity-cpp' |
1697 | === removed file 'tests/integration/connectivity-cpp/CMakeLists.txt' |
1698 | --- tests/integration/connectivity-cpp/CMakeLists.txt 2015-02-16 18:33:09 +0000 |
1699 | +++ tests/integration/connectivity-cpp/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1700 | @@ -1,130 +0,0 @@ |
1701 | -# Copyright Ā© 2013 Canonical Ltd. |
1702 | -# |
1703 | -# This program is free software: you can redistribute it and/or modify it |
1704 | -# under the terms of the GNU Lesser General Public License version 3, |
1705 | -# as published by the Free Software Foundation. |
1706 | -# |
1707 | -# This program is distributed in the hope that it will be useful, |
1708 | -# but WITHOUT ANY WARRANTY; without even the implied warranty of |
1709 | -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1710 | -# GNU Lesser General Public License for more details. |
1711 | -# |
1712 | -# You should have received a copy of the GNU Lesser General Public License |
1713 | -# along with this program. If not, see <http://www.gnu.org/licenses/>. |
1714 | -# |
1715 | -# Authors: |
1716 | -# Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
1717 | - |
1718 | - |
1719 | -include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) |
1720 | - |
1721 | -if (NOT DEFINED GTEST_ROOT) |
1722 | - set(GTEST_ROOT /usr/src/gtest) |
1723 | -endif() |
1724 | - |
1725 | -set(GTEST_SRC_DIR "${GTEST_ROOT}/src") |
1726 | -set(GTEST_INCLUDE_DIR ${GTEST_ROOT}) |
1727 | - |
1728 | -add_library(connectivity-gtest STATIC |
1729 | -${GTEST_SRC_DIR}/gtest-all.cc |
1730 | -${GTEST_SRC_DIR}/gtest_main.cc |
1731 | - |
1732 | -) |
1733 | - |
1734 | -set_target_properties(connectivity-gtest PROPERTIES INCLUDE_DIRECTORIES ${GTEST_INCLUDE_DIR}) |
1735 | -target_link_libraries(connectivity-gtest ${CMAKE_THREAD_LIBS_INIT}) |
1736 | - |
1737 | -include_directories(${GTEST_INCLUDE_DIRS}) |
1738 | - |
1739 | -add_definitions(-DCORE_DBUS_ENABLE_GOOGLE_TEST_FIXTURE) |
1740 | - |
1741 | -pkg_check_modules(PROCESS_CPP process-cpp) |
1742 | - |
1743 | -configure_file( |
1744 | - ${CMAKE_CURRENT_SOURCE_DIR}/test_data.h.in |
1745 | - ${CMAKE_CURRENT_BINARY_DIR}/test_data.h @ONLY |
1746 | -) |
1747 | -include_directories( |
1748 | - ${CMAKE_CURRENT_BINARY_DIR} |
1749 | - ${CMAKE_SOURCE_DIR}/src/connectivity-cpp/include |
1750 | - ${CMAKE_SOURCE_DIR}/src/connectivity-cpp/dbus-cpp |
1751 | -) |
1752 | - |
1753 | -add_executable ( |
1754 | - test_networking_status |
1755 | - test_networking_status.cpp |
1756 | -) |
1757 | - |
1758 | -add_executable ( |
1759 | - test_flight_mode |
1760 | - test_flight_mode.cpp |
1761 | -) |
1762 | - |
1763 | -add_executable ( |
1764 | - test_wifi_link |
1765 | - test_wifi_link.cpp |
1766 | -) |
1767 | - |
1768 | -add_executable ( |
1769 | - test_wifi_link_dedup |
1770 | - test_wifi_link_dedup.cpp |
1771 | -) |
1772 | - |
1773 | -add_executable ( |
1774 | - test_wifi_connect |
1775 | - test_wifi_connect.cpp |
1776 | -) |
1777 | - |
1778 | -add_executable ( |
1779 | - test_wifi_link_enable_disable |
1780 | - test_wifi_link_enable_disable.cpp |
1781 | -) |
1782 | - |
1783 | -target_link_libraries( |
1784 | - test_networking_status |
1785 | - connectivity-cpp |
1786 | - connectivity-gtest |
1787 | - ${PROCESS_CPP_LIBRARIES} |
1788 | -) |
1789 | - |
1790 | -target_link_libraries( |
1791 | - test_flight_mode |
1792 | - connectivity-cpp |
1793 | - connectivity-gtest |
1794 | - ${PROCESS_CPP_LIBRARIES} |
1795 | -) |
1796 | - |
1797 | -target_link_libraries( |
1798 | - test_wifi_link |
1799 | - connectivity-cpp |
1800 | - connectivity-gtest |
1801 | - ${PROCESS_CPP_LIBRARIES} |
1802 | -) |
1803 | - |
1804 | -target_link_libraries( |
1805 | - test_wifi_link_dedup |
1806 | - connectivity-cpp |
1807 | - connectivity-gtest |
1808 | - ${PROCESS_CPP_LIBRARIES} |
1809 | -) |
1810 | - |
1811 | -target_link_libraries( |
1812 | - test_wifi_connect |
1813 | - connectivity-cpp |
1814 | - connectivity-gtest |
1815 | - ${PROCESS_CPP_LIBRARIES} |
1816 | -) |
1817 | - |
1818 | -target_link_libraries( |
1819 | - test_wifi_link_enable_disable |
1820 | - connectivity-cpp |
1821 | - connectivity-gtest |
1822 | - ${PROCESS_CPP_LIBRARIES} |
1823 | -) |
1824 | - |
1825 | -add_test(test_networking_status ${CMAKE_CURRENT_BINARY_DIR}/test_networking_status) |
1826 | -add_test(test_flight_mode ${CMAKE_CURRENT_BINARY_DIR}/test_flight_mode) |
1827 | -add_test(test_wifi_link ${CMAKE_CURRENT_BINARY_DIR}/test_wifi_link) |
1828 | -add_test(test_wifi_link_dedup ${CMAKE_CURRENT_BINARY_DIR}/test_wifi_link_dedup) |
1829 | -add_test(test_wifi_connect ${CMAKE_CURRENT_BINARY_DIR}/test_wifi_connect) |
1830 | -add_test(test_wifi_link_enable_disable ${CMAKE_CURRENT_BINARY_DIR}/test_wifi_link_enable_disable) |
1831 | |
1832 | === removed directory 'tests/integration/connectivity-cpp/mocks' |
1833 | === removed file 'tests/integration/connectivity-cpp/mocks/urfkill.h' |
1834 | --- tests/integration/connectivity-cpp/mocks/urfkill.h 2014-08-19 19:55:15 +0000 |
1835 | +++ tests/integration/connectivity-cpp/mocks/urfkill.h 1970-01-01 00:00:00 +0000 |
1836 | @@ -1,162 +0,0 @@ |
1837 | -/* |
1838 | - * Copyright Ā© 2014 Canonical Ltd. |
1839 | - * |
1840 | - * This program is free software: you can redistribute it and/or modify it |
1841 | - * under the terms of the GNU Lesser General Public License version 3, |
1842 | - * as published by the Free Software Foundation. |
1843 | - * |
1844 | - * This program is distributed in the hope that it will be useful, |
1845 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
1846 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
1847 | - * GNU Lesser General Public License for more details. |
1848 | - * |
1849 | - * You should have received a copy of the GNU Lesser General Public License |
1850 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
1851 | - * |
1852 | - * Authored by: Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
1853 | - */ |
1854 | - |
1855 | -#ifndef MOCKS_URFKILL_H |
1856 | -#define MOCKS_URFKILL_H |
1857 | - |
1858 | -#include <services/urfkill.h> |
1859 | - |
1860 | -class DefaultURfkillMock : public org::freedesktop::URfkill::Service::Mock |
1861 | -{ |
1862 | - typedef org::freedesktop::URfkill::Interface::Killswitch Killswitch; |
1863 | - |
1864 | - bool inFlightMode; |
1865 | - |
1866 | -public: |
1867 | - |
1868 | - DefaultURfkillMock() = delete; |
1869 | - DefaultURfkillMock(const core::dbus::Bus::Ptr& bus) |
1870 | - : org::freedesktop::URfkill::Service::Mock(bus), |
1871 | - inFlightMode{false}, |
1872 | - bt{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::bluetooth)), |
1873 | - Killswitch::Type::bluetooth)}, |
1874 | - fm{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::fm)), |
1875 | - Killswitch::Type::fm)}, |
1876 | - gps{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::gps)), |
1877 | - Killswitch::Type::gps)}, |
1878 | - nfc{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::nfc)), |
1879 | - Killswitch::Type::nfc)}, |
1880 | - uwb{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::uwb)), |
1881 | - Killswitch::Type::uwb)}, |
1882 | - wimax{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::wimax)), |
1883 | - Killswitch::Type::wimax)}, |
1884 | - wlan{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::wlan)), |
1885 | - Killswitch::Type::wlan)}, |
1886 | - wwan{Killswitch(urfkill->service->add_object_for_path(Killswitch::path(Killswitch::Type::wwan)), |
1887 | - Killswitch::Type::wwan)} |
1888 | - { |
1889 | - urfkill->object->install_method_handler |
1890 | - <org::freedesktop::URfkill::Interface::URfkill::Method::Block> |
1891 | - ([this, bus](const core::dbus::Message::Ptr& msg) |
1892 | - { |
1893 | - auto reader = msg->reader(); |
1894 | - |
1895 | - std::uint32_t type = reader.pop_uint32(); |
1896 | - bool value = reader.pop_boolean(); |
1897 | - |
1898 | - auto reply = core::dbus::Message::make_method_return(msg); |
1899 | - reply->writer() << block(type, value); |
1900 | - bus->send(reply); |
1901 | - }); |
1902 | - |
1903 | - urfkill->object->install_method_handler |
1904 | - <org::freedesktop::URfkill::Interface::URfkill::Method::FlightMode> |
1905 | - ([this, bus](const core::dbus::Message::Ptr& msg) |
1906 | - { |
1907 | - auto reply = core::dbus::Message::make_method_return(msg); |
1908 | - |
1909 | - auto reader = msg->reader(); |
1910 | - bool value = reader.pop_boolean(); |
1911 | - |
1912 | - reply->writer() << true; |
1913 | - bus->send(reply); |
1914 | - |
1915 | - if (inFlightMode != value) { |
1916 | - inFlightMode = value; |
1917 | - auto signal_flightmode_changed |
1918 | - = urfkill->object->get_signal<org::freedesktop::URfkill::Interface::URfkill::Signal::FlightModeChanged>(); |
1919 | - signal_flightmode_changed->emit(inFlightMode); |
1920 | - |
1921 | - block(1, inFlightMode); |
1922 | - } |
1923 | - }); |
1924 | - |
1925 | - urfkill->object->install_method_handler |
1926 | - <org::freedesktop::URfkill::Interface::URfkill::Method::IsFlightMode> |
1927 | - ([this, bus](const core::dbus::Message::Ptr& msg) |
1928 | - { |
1929 | - auto reply = core::dbus::Message::make_method_return(msg); |
1930 | - reply->writer() << inFlightMode; |
1931 | - bus->send(reply); |
1932 | - }); |
1933 | - |
1934 | - bt._state->set(0); |
1935 | - fm._state->set(0); |
1936 | - gps._state->set(0); |
1937 | - nfc._state->set(0); |
1938 | - uwb._state->set(0); |
1939 | - wimax._state->set(0); |
1940 | - wlan._state->set(0); |
1941 | - wwan._state->set(0); |
1942 | - } |
1943 | - |
1944 | - bool block(std::uint32_t type, bool block) |
1945 | - { |
1946 | - switch (type) { |
1947 | - case 1: |
1948 | - { |
1949 | - if (block) |
1950 | - wlan._state->set(1); // soft blocked |
1951 | - else |
1952 | - wlan._state->set(0); // unblocked |
1953 | - |
1954 | - auto signal_properties_changed |
1955 | - = wlan.object->get_signal<core::dbus::interfaces::Properties::Signals::PropertiesChanged>(); |
1956 | - std::map<std::string, core::dbus::types::Variant> changed; |
1957 | - changed["state"] = core::dbus::types::TypedVariant<std::int32_t>(wlan._state->get()); |
1958 | - core::dbus::interfaces::Properties::Signals::PropertiesChanged::ArgumentType args |
1959 | - (org::freedesktop::URfkill::Interface::Killswitch::name(), |
1960 | - changed, |
1961 | - {} |
1962 | - ); |
1963 | - signal_properties_changed->emit(args); |
1964 | - break; |
1965 | - } |
1966 | - case 2: |
1967 | - //Killswitch::Type::bluetooth |
1968 | - case 3: |
1969 | - //Killswitch::Type::uwb |
1970 | - case 4: |
1971 | - //Killswitch::Type::wimax |
1972 | - case 5: |
1973 | - //Killswitch::Type::wwan |
1974 | - case 6: |
1975 | - //Killswitch::Type::gps |
1976 | - case 7: |
1977 | - //Killswitch::Type::fm |
1978 | - case 8: |
1979 | - //Killswitch::Type::nfc |
1980 | - break; |
1981 | - default: |
1982 | - std::logic_error("Unknown killswitch id: " + std::to_string(type)); |
1983 | - } |
1984 | - |
1985 | - return true; |
1986 | - } |
1987 | - |
1988 | - org::freedesktop::URfkill::Interface::Killswitch bt; |
1989 | - org::freedesktop::URfkill::Interface::Killswitch fm; |
1990 | - org::freedesktop::URfkill::Interface::Killswitch gps; |
1991 | - org::freedesktop::URfkill::Interface::Killswitch nfc; |
1992 | - org::freedesktop::URfkill::Interface::Killswitch uwb; |
1993 | - org::freedesktop::URfkill::Interface::Killswitch wimax; |
1994 | - org::freedesktop::URfkill::Interface::Killswitch wlan; |
1995 | - org::freedesktop::URfkill::Interface::Killswitch wwan; |
1996 | -}; |
1997 | - |
1998 | -#endif |
1999 | |
2000 | === removed file 'tests/integration/connectivity-cpp/sig_term_catcher.h' |
2001 | --- tests/integration/connectivity-cpp/sig_term_catcher.h 2014-08-19 19:55:15 +0000 |
2002 | +++ tests/integration/connectivity-cpp/sig_term_catcher.h 1970-01-01 00:00:00 +0000 |
2003 | @@ -1,74 +0,0 @@ |
2004 | -/* |
2005 | - * Copyright Ā© 2013 Canonical Ltd. |
2006 | - * |
2007 | - * This program is free software: you can redistribute it and/or modify it |
2008 | - * under the terms of the GNU Lesser General Public License version 3, |
2009 | - * as published by the Free Software Foundation. |
2010 | - * |
2011 | - * This program is distributed in the hope that it will be useful, |
2012 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2013 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2014 | - * GNU Lesser General Public License for more details. |
2015 | - * |
2016 | - * You should have received a copy of the GNU Lesser General Public License |
2017 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2018 | - * |
2019 | - * Authored by: Thomas VoĆ <thomas.voss@canonical.com> |
2020 | - */ |
2021 | - |
2022 | -#ifndef CORE_TESTING_SIG_TERM_CATCHER_H_ |
2023 | -#define CORE_TESTING_SIG_TERM_CATCHER_H_ |
2024 | - |
2025 | -#include <system_error> |
2026 | - |
2027 | -#include <signal.h> |
2028 | -#include <unistd.h> |
2029 | -#include <poll.h> |
2030 | -#include <sys/signalfd.h> |
2031 | - |
2032 | -namespace core |
2033 | -{ |
2034 | -namespace testing |
2035 | -{ |
2036 | -struct SigTermCatcher |
2037 | -{ |
2038 | - inline SigTermCatcher() |
2039 | - { |
2040 | - sigemptyset(&signal_mask); |
2041 | - |
2042 | - if (-1 == sigaddset(&signal_mask, SIGTERM)) |
2043 | - throw std::system_error(errno, std::system_category()); |
2044 | - |
2045 | - if (-1 == sigprocmask(SIG_BLOCK, &signal_mask, NULL)) |
2046 | - throw std::system_error(errno, std::system_category()); |
2047 | - |
2048 | - if (-1 == (signal_fd = signalfd(-1, &signal_mask, 0))) |
2049 | - throw std::system_error(errno, std::system_category()); |
2050 | - } |
2051 | - |
2052 | - inline ~SigTermCatcher() |
2053 | - { |
2054 | - ::close(signal_fd); |
2055 | - } |
2056 | - |
2057 | - inline void wait_for_signal_for(const std::chrono::milliseconds& ms) |
2058 | - { |
2059 | - pollfd fd; fd.fd = signal_fd; fd.events = POLLIN; |
2060 | - if (poll(&fd, 1, ms.count()) > 0) |
2061 | - { |
2062 | - signalfd_siginfo siginfo; |
2063 | - if (-1 == ::read(signal_fd, &siginfo, sizeof(siginfo))) |
2064 | - throw std::system_error(errno, std::system_category()); |
2065 | - } else |
2066 | - { |
2067 | - throw std::system_error(errno, std::system_category()); |
2068 | - } |
2069 | - } |
2070 | - |
2071 | - sigset_t signal_mask; |
2072 | - int signal_fd = -1; |
2073 | -}; |
2074 | -} |
2075 | -} |
2076 | - |
2077 | -#endif // CORE_TESTING_SIG_TERM_CATCHER_H_ |
2078 | |
2079 | === removed file 'tests/integration/connectivity-cpp/test_data.h.in' |
2080 | --- tests/integration/connectivity-cpp/test_data.h.in 2014-08-19 20:17:22 +0000 |
2081 | +++ tests/integration/connectivity-cpp/test_data.h.in 1970-01-01 00:00:00 +0000 |
2082 | @@ -1,38 +0,0 @@ |
2083 | -/* |
2084 | - * Copyright Ā© 2013 Canonical Ltd. |
2085 | - * |
2086 | - * This program is free software: you can redistribute it and/or modify it |
2087 | - * under the terms of the GNU Lesser General Public License version 3, |
2088 | - * as published by the Free Software Foundation. |
2089 | - * |
2090 | - * This program is distributed in the hope that it will be useful, |
2091 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2092 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2093 | - * GNU Lesser General Public License for more details. |
2094 | - * |
2095 | - * You should have received a copy of the GNU Lesser General Public License |
2096 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2097 | - * |
2098 | - * Authored by: Thomas VoĆ <thomas.voss@canonical.com> |
2099 | - */ |
2100 | - |
2101 | -#ifndef TEST_DATA_H_ |
2102 | -#define TEST_DATA_H_ |
2103 | - |
2104 | -namespace core |
2105 | -{ |
2106 | -namespace testing |
2107 | -{ |
2108 | - |
2109 | -constexpr const char* session_bus_configuration_file() |
2110 | -{ |
2111 | - return "@CMAKE_SOURCE_DIR@/src/connectivity-cpp/data/session.conf"; |
2112 | -} |
2113 | - |
2114 | -constexpr const char* system_bus_configuration_file() |
2115 | -{ |
2116 | - return "@CMAKE_SOURCE_DIR@/src/connectivity-cpp/data/system.conf"; |
2117 | -} |
2118 | -} |
2119 | -} |
2120 | -#endif // TEST_DATA_H_ |
2121 | |
2122 | === removed file 'tests/integration/connectivity-cpp/test_flight_mode.cpp' |
2123 | --- tests/integration/connectivity-cpp/test_flight_mode.cpp 2014-08-19 19:55:15 +0000 |
2124 | +++ tests/integration/connectivity-cpp/test_flight_mode.cpp 1970-01-01 00:00:00 +0000 |
2125 | @@ -1,138 +0,0 @@ |
2126 | -/* |
2127 | - * Copyright Ā© 2013 Canonical Ltd. |
2128 | - * |
2129 | - * This program is free software: you can redistribute it and/or modify it |
2130 | - * under the terms of the GNU Lesser General Public License version 3, |
2131 | - * as published by the Free Software Foundation. |
2132 | - * |
2133 | - * This program is distributed in the hope that it will be useful, |
2134 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2135 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2136 | - * GNU Lesser General Public License for more details. |
2137 | - * |
2138 | - * You should have received a copy of the GNU Lesser General Public License |
2139 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2140 | - * |
2141 | - * Authored by: Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
2142 | - */ |
2143 | - |
2144 | -#include <core/dbus/dbus.h> |
2145 | -#include <core/dbus/fixture.h> |
2146 | -#include <core/dbus/object.h> |
2147 | -#include <core/dbus/property.h> |
2148 | -#include <core/dbus/service.h> |
2149 | -#include <core/dbus/interfaces/properties.h> |
2150 | -#include <core/dbus/types/stl/tuple.h> |
2151 | -#include <core/dbus/types/stl/vector.h> |
2152 | - |
2153 | -#include <core/dbus/asio/executor.h> |
2154 | - |
2155 | -#include "sig_term_catcher.h" |
2156 | -#include "test_data.h" |
2157 | -#include "test_service.h" |
2158 | - |
2159 | -#include <core/testing/cross_process_sync.h> |
2160 | -#include <core/testing/fork_and_run.h> |
2161 | - |
2162 | -#include <gtest/gtest.h> |
2163 | - |
2164 | -#include <system_error> |
2165 | -#include <thread> |
2166 | - |
2167 | -#include <services/nm.h> |
2168 | -#include "mocks/urfkill.h" |
2169 | -namespace fdo = org::freedesktop; |
2170 | -namespace NM = fdo::NetworkManager; |
2171 | - |
2172 | -#include <connectivity/networking/manager.h> |
2173 | - |
2174 | -namespace dbus = core::dbus; |
2175 | - |
2176 | -namespace |
2177 | -{ |
2178 | -struct Service : public core::dbus::testing::Fixture {}; |
2179 | - |
2180 | -auto session_bus_config_file = |
2181 | - core::dbus::testing::Fixture::default_session_bus_config_file() = |
2182 | - core::testing::session_bus_configuration_file(); |
2183 | - |
2184 | -auto system_bus_config_file = |
2185 | - core::dbus::testing::Fixture::default_system_bus_config_file() = |
2186 | - core::testing::system_bus_configuration_file(); |
2187 | - |
2188 | -} |
2189 | - |
2190 | -TEST_F(Service, flightMode) |
2191 | -{ |
2192 | - core::testing::CrossProcessSync services_ready; |
2193 | - core::testing::CrossProcessSync client_ready; |
2194 | - |
2195 | - auto service = [&, this]() |
2196 | - { |
2197 | - core::testing::SigTermCatcher sc; |
2198 | - |
2199 | - auto bus = system_bus(); |
2200 | - bus->install_executor(core::dbus::asio::make_executor(bus)); |
2201 | - |
2202 | - auto nm_service = NM::Service::Mock(bus); |
2203 | - auto nm_root = nm_service.nm; |
2204 | - |
2205 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::GetDevices>([bus, nm_root](const dbus::Message::Ptr& msg) |
2206 | - { |
2207 | - auto reply = dbus::Message::make_method_return(msg); |
2208 | - reply->writer() << std::vector<dbus::types::ObjectPath>(); |
2209 | - bus->send(reply); |
2210 | - }); |
2211 | - |
2212 | - nm_root->state->set(0); |
2213 | - |
2214 | - DefaultURfkillMock urfkill(bus); |
2215 | - |
2216 | - std::thread t{[bus](){ bus->run(); }}; |
2217 | - |
2218 | - services_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
2219 | - |
2220 | - EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); |
2221 | - sc.wait_for_signal_for(std::chrono::seconds{10}); |
2222 | - |
2223 | - bus->stop(); |
2224 | - |
2225 | - if (t.joinable()) |
2226 | - t.join(); |
2227 | - |
2228 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
2229 | - }; |
2230 | - |
2231 | - auto client = [&, this]() |
2232 | - { |
2233 | - EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); |
2234 | - std::unique_ptr<connectivity::networking::Manager> mgr; |
2235 | - mgr = connectivity::networking::Manager::createInstance(); |
2236 | - |
2237 | - std::vector<connectivity::networking::Manager::FlightModeStatus> statuses; |
2238 | - try { |
2239 | - EXPECT_EQ(mgr->flightMode().get(), connectivity::networking::Manager::FlightModeStatus::off); |
2240 | - |
2241 | - mgr->flightMode().changed().connect([&statuses](connectivity::networking::Manager::FlightModeStatus status) { |
2242 | - statuses.push_back(status); |
2243 | - }); |
2244 | - |
2245 | - mgr->enableFlightMode(); |
2246 | - mgr->disableFlightMode(); |
2247 | - |
2248 | - } catch (const std::runtime_error &e) { |
2249 | - std::cout << "exception: " << e.what() << std::endl; |
2250 | - } |
2251 | - |
2252 | - sleep(1); |
2253 | - client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
2254 | - |
2255 | - EXPECT_EQ(statuses.size(), 2); |
2256 | - EXPECT_EQ(statuses.at(0), connectivity::networking::Manager::FlightModeStatus::on); |
2257 | - EXPECT_EQ(statuses.at(1), connectivity::networking::Manager::FlightModeStatus::off); |
2258 | - |
2259 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
2260 | - }; |
2261 | - |
2262 | - EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); |
2263 | -} |
2264 | |
2265 | === removed file 'tests/integration/connectivity-cpp/test_networking_status.cpp' |
2266 | --- tests/integration/connectivity-cpp/test_networking_status.cpp 2014-08-19 19:55:15 +0000 |
2267 | +++ tests/integration/connectivity-cpp/test_networking_status.cpp 1970-01-01 00:00:00 +0000 |
2268 | @@ -1,178 +0,0 @@ |
2269 | -/* |
2270 | - * Copyright Ā© 2013 Canonical Ltd. |
2271 | - * |
2272 | - * This program is free software: you can redistribute it and/or modify it |
2273 | - * under the terms of the GNU Lesser General Public License version 3, |
2274 | - * as published by the Free Software Foundation. |
2275 | - * |
2276 | - * This program is distributed in the hope that it will be useful, |
2277 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2278 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2279 | - * GNU Lesser General Public License for more details. |
2280 | - * |
2281 | - * You should have received a copy of the GNU Lesser General Public License |
2282 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2283 | - * |
2284 | - * Authored by: Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
2285 | - */ |
2286 | - |
2287 | -#include <core/dbus/dbus.h> |
2288 | -#include <core/dbus/fixture.h> |
2289 | -#include <core/dbus/object.h> |
2290 | -#include <core/dbus/property.h> |
2291 | -#include <core/dbus/service.h> |
2292 | -#include <core/dbus/interfaces/properties.h> |
2293 | -#include <core/dbus/types/stl/tuple.h> |
2294 | -#include <core/dbus/types/stl/vector.h> |
2295 | - |
2296 | -#include <core/dbus/asio/executor.h> |
2297 | - |
2298 | -#include "sig_term_catcher.h" |
2299 | -#include "test_data.h" |
2300 | -#include "test_service.h" |
2301 | - |
2302 | -#include <core/testing/cross_process_sync.h> |
2303 | -#include <core/testing/fork_and_run.h> |
2304 | - |
2305 | -#include <gtest/gtest.h> |
2306 | - |
2307 | -#include <system_error> |
2308 | -#include <thread> |
2309 | - |
2310 | -#include "mocks/urfkill.h" |
2311 | - |
2312 | -#include <services/nm.h> |
2313 | -namespace fdo = org::freedesktop; |
2314 | -namespace NM = fdo::NetworkManager; |
2315 | - |
2316 | -#include <connectivity/networking/manager.h> |
2317 | - |
2318 | -namespace dbus = core::dbus; |
2319 | - |
2320 | -namespace |
2321 | -{ |
2322 | -struct Service : public core::dbus::testing::Fixture {}; |
2323 | - |
2324 | -auto session_bus_config_file = |
2325 | - core::dbus::testing::Fixture::default_session_bus_config_file() = |
2326 | - core::testing::session_bus_configuration_file(); |
2327 | - |
2328 | -auto system_bus_config_file = |
2329 | - core::dbus::testing::Fixture::default_system_bus_config_file() = |
2330 | - core::testing::system_bus_configuration_file(); |
2331 | - |
2332 | -} |
2333 | - |
2334 | -TEST_F(Service, networkingStatus) |
2335 | -{ |
2336 | - core::testing::CrossProcessSync services_ready; |
2337 | - core::testing::CrossProcessSync client_ready; |
2338 | - core::testing::CrossProcessSync update_networking_status; |
2339 | - |
2340 | - |
2341 | - auto service = [&, this]() |
2342 | - { |
2343 | - core::testing::SigTermCatcher sc; |
2344 | - |
2345 | - auto bus = system_bus(); |
2346 | - bus->install_executor(core::dbus::asio::make_executor(bus)); |
2347 | - |
2348 | - DefaultURfkillMock urfkill(bus); |
2349 | - |
2350 | - auto nm_service = NM::Service::Mock(bus); |
2351 | - auto nm_root = nm_service.nm; |
2352 | - |
2353 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::GetDevices>([bus, nm_root](const dbus::Message::Ptr& msg) |
2354 | - { |
2355 | - auto reply = dbus::Message::make_method_return(msg); |
2356 | - reply->writer() << std::vector<dbus::types::ObjectPath>(); |
2357 | - bus->send(reply); |
2358 | - }); |
2359 | - |
2360 | - nm_root->state->set(NM_STATE_UNKNOWN); |
2361 | - |
2362 | - std::thread t{[bus](){ bus->run(); }}; |
2363 | - |
2364 | - services_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
2365 | - EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); |
2366 | - |
2367 | - NM::Interface::NetworkManager::Signal::PropertiesChanged::ArgumentType properties; |
2368 | - |
2369 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_UNKNOWN); |
2370 | - nm_root->properties_changed->emit(properties); |
2371 | - |
2372 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_ASLEEP); |
2373 | - nm_root->properties_changed->emit(properties); |
2374 | - |
2375 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_DISCONNECTED); |
2376 | - nm_root->properties_changed->emit(properties); |
2377 | - |
2378 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_CONNECTING); |
2379 | - nm_root->properties_changed->emit(properties); |
2380 | - |
2381 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_CONNECTED_LOCAL); |
2382 | - nm_root->properties_changed->emit(properties); |
2383 | - |
2384 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_CONNECTED_SITE); |
2385 | - nm_root->properties_changed->emit(properties); |
2386 | - |
2387 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_CONNECTED_GLOBAL); |
2388 | - nm_root->properties_changed->emit(properties); |
2389 | - |
2390 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_DISCONNECTING); |
2391 | - nm_root->properties_changed->emit(properties); |
2392 | - |
2393 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_DISCONNECTED); |
2394 | - nm_root->properties_changed->emit(properties); |
2395 | - |
2396 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_CONNECTING); |
2397 | - nm_root->properties_changed->emit(properties); |
2398 | - |
2399 | - properties["State"] = dbus::types::Variant::encode<std::uint32_t>(NM_STATE_CONNECTED_GLOBAL); |
2400 | - nm_root->properties_changed->emit(properties); |
2401 | - |
2402 | - // status change |
2403 | - update_networking_status.try_signal_ready_for(std::chrono::milliseconds{2000}); |
2404 | - |
2405 | - sc.wait_for_signal_for(std::chrono::seconds{10}); |
2406 | - |
2407 | - bus->stop(); |
2408 | - |
2409 | - if (t.joinable()) |
2410 | - t.join(); |
2411 | - |
2412 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
2413 | - }; |
2414 | - |
2415 | - auto client = [&, this]() |
2416 | - { |
2417 | - EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); |
2418 | - std::unique_ptr<connectivity::networking::Manager> mgr; |
2419 | - mgr = connectivity::networking::Manager::createInstance(); |
2420 | - |
2421 | - EXPECT_EQ(mgr->status().get(), connectivity::networking::Manager::NetworkingStatus::offline); |
2422 | - |
2423 | - std::vector<connectivity::networking::Manager::NetworkingStatus> states; |
2424 | - mgr->status().changed().connect([&states](connectivity::networking::Manager::NetworkingStatus status) { |
2425 | - states.push_back(status); |
2426 | - }); |
2427 | - |
2428 | - client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
2429 | - |
2430 | - EXPECT_EQ(1, update_networking_status.wait_for_signal_ready_for(std::chrono::milliseconds{2000})); |
2431 | - |
2432 | - sleep(1); |
2433 | - |
2434 | - EXPECT_EQ(states.size(), 5); |
2435 | - EXPECT_EQ(states.at(0), connectivity::networking::Manager::NetworkingStatus::connecting); |
2436 | - EXPECT_EQ(states.at(1), connectivity::networking::Manager::NetworkingStatus::online); |
2437 | - EXPECT_EQ(states.at(2), connectivity::networking::Manager::NetworkingStatus::offline); |
2438 | - EXPECT_EQ(states.at(3), connectivity::networking::Manager::NetworkingStatus::connecting); |
2439 | - EXPECT_EQ(states.at(4), connectivity::networking::Manager::NetworkingStatus::online); |
2440 | - |
2441 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
2442 | - }; |
2443 | - |
2444 | - EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); |
2445 | -} |
2446 | - |
2447 | |
2448 | === removed file 'tests/integration/connectivity-cpp/test_service.h' |
2449 | --- tests/integration/connectivity-cpp/test_service.h 2014-08-19 19:55:15 +0000 |
2450 | +++ tests/integration/connectivity-cpp/test_service.h 1970-01-01 00:00:00 +0000 |
2451 | @@ -1,124 +0,0 @@ |
2452 | -/* |
2453 | - * Copyright Ā© 2013 Canonical Ltd. |
2454 | - * |
2455 | - * This program is free software: you can redistribute it and/or modify it |
2456 | - * under the terms of the GNU Lesser General Public License version 3, |
2457 | - * as published by the Free Software Foundation. |
2458 | - * |
2459 | - * This program is distributed in the hope that it will be useful, |
2460 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2461 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2462 | - * GNU Lesser General Public License for more details. |
2463 | - * |
2464 | - * You should have received a copy of the GNU Lesser General Public License |
2465 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2466 | - * |
2467 | - * Authored by: Thomas VoĆ <thomas.voss@canonical.com> |
2468 | - */ |
2469 | - |
2470 | -#ifndef TEST_SERVICE_H_ |
2471 | -#define TEST_SERVICE_H_ |
2472 | - |
2473 | -namespace test |
2474 | -{ |
2475 | -struct Service |
2476 | -{ |
2477 | - struct Method |
2478 | - { |
2479 | - typedef Service Interface; |
2480 | - |
2481 | - inline static const std::string& name() |
2482 | - { |
2483 | - static const std::string s |
2484 | - { |
2485 | - "Method" |
2486 | - }; |
2487 | - return s; |
2488 | - } |
2489 | - |
2490 | - inline static const std::chrono::milliseconds default_timeout() |
2491 | - { |
2492 | - return std::chrono::seconds{1}; |
2493 | - } |
2494 | - }; |
2495 | - |
2496 | - struct Signals |
2497 | - { |
2498 | - struct Dummy |
2499 | - { |
2500 | - inline static std::string name() |
2501 | - { |
2502 | - return "Dummy"; |
2503 | - }; |
2504 | - typedef Service Interface; |
2505 | - typedef int64_t ArgumentType; |
2506 | - }; |
2507 | - }; |
2508 | - |
2509 | - struct Properties |
2510 | - { |
2511 | - struct Dummy |
2512 | - { |
2513 | - inline static std::string name() |
2514 | - { |
2515 | - return "Dummy"; |
2516 | - }; |
2517 | - typedef Service Interface; |
2518 | - typedef double ValueType; |
2519 | - static const bool readable = true; |
2520 | - static const bool writable = true; |
2521 | - }; |
2522 | - }; |
2523 | - |
2524 | - struct Interfaces |
2525 | - { |
2526 | - struct Foo |
2527 | - { |
2528 | - static const std::string& name() |
2529 | - { |
2530 | - static const std::string s{"this.is.unlikely.to.exist.Service.Foo"}; |
2531 | - return s; |
2532 | - } |
2533 | - |
2534 | - struct Signals |
2535 | - { |
2536 | - struct Dummy |
2537 | - { |
2538 | - inline static std::string name() |
2539 | - { |
2540 | - return "Dummy"; |
2541 | - } |
2542 | - typedef Foo Interface; |
2543 | - typedef int64_t ArgumentType; |
2544 | - }; |
2545 | - }; |
2546 | - }; |
2547 | - }; |
2548 | -}; |
2549 | -} |
2550 | - |
2551 | -#include <core/dbus/traits/service.h> |
2552 | - |
2553 | -namespace core |
2554 | -{ |
2555 | -namespace dbus |
2556 | -{ |
2557 | -namespace traits |
2558 | -{ |
2559 | -template<> |
2560 | -struct Service<test::Service> |
2561 | -{ |
2562 | - inline static const std::string& interface_name() |
2563 | - { |
2564 | - static const std::string s |
2565 | - { |
2566 | - "this.is.unlikely.to.exist.Service" |
2567 | - }; |
2568 | - return s; |
2569 | - } |
2570 | -}; |
2571 | -} |
2572 | -} |
2573 | -} |
2574 | - |
2575 | -#endif // TEST_SERVICE_H_ |
2576 | |
2577 | === removed file 'tests/integration/connectivity-cpp/test_wifi_connect.cpp' |
2578 | --- tests/integration/connectivity-cpp/test_wifi_connect.cpp 2014-08-23 18:11:18 +0000 |
2579 | +++ tests/integration/connectivity-cpp/test_wifi_connect.cpp 1970-01-01 00:00:00 +0000 |
2580 | @@ -1,278 +0,0 @@ |
2581 | -/* |
2582 | - * Copyright Ā© 2013 Canonical Ltd. |
2583 | - * |
2584 | - * This program is free software: you can redistribute it and/or modify it |
2585 | - * under the terms of the GNU Lesser General Public License version 3, |
2586 | - * as published by the Free Software Foundation. |
2587 | - * |
2588 | - * This program is distributed in the hope that it will be useful, |
2589 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2590 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2591 | - * GNU Lesser General Public License for more details. |
2592 | - * |
2593 | - * You should have received a copy of the GNU Lesser General Public License |
2594 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2595 | - * |
2596 | - * Authored by: Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
2597 | - */ |
2598 | - |
2599 | -#include <core/dbus/dbus.h> |
2600 | -#include <core/dbus/fixture.h> |
2601 | -#include <core/dbus/object.h> |
2602 | -#include <core/dbus/property.h> |
2603 | -#include <core/dbus/service.h> |
2604 | -#include <core/dbus/interfaces/properties.h> |
2605 | -#include <core/dbus/types/stl/tuple.h> |
2606 | -#include <core/dbus/types/stl/vector.h> |
2607 | - |
2608 | -#include <core/dbus/asio/executor.h> |
2609 | - |
2610 | -#include "sig_term_catcher.h" |
2611 | -#include "test_data.h" |
2612 | -#include "test_service.h" |
2613 | - |
2614 | -#include <core/testing/cross_process_sync.h> |
2615 | -#include <core/testing/fork_and_run.h> |
2616 | - |
2617 | -#include <gtest/gtest.h> |
2618 | - |
2619 | -#include <system_error> |
2620 | -#include <thread> |
2621 | - |
2622 | -#include <services/nm.h> |
2623 | -namespace fdo = org::freedesktop; |
2624 | -namespace NM = fdo::NetworkManager; |
2625 | - |
2626 | -#include "mocks/urfkill.h" |
2627 | - |
2628 | -#include <connectivity/networking/manager.h> |
2629 | -#include <connectivity/networking/wifi/link.h> |
2630 | -#include <connectivity/networking/wifi/access-point.h> |
2631 | - |
2632 | -namespace dbus = core::dbus; |
2633 | - |
2634 | -namespace |
2635 | -{ |
2636 | -struct Service : public core::dbus::testing::Fixture {}; |
2637 | - |
2638 | -auto session_bus_config_file = |
2639 | - core::dbus::testing::Fixture::default_session_bus_config_file() = |
2640 | - core::testing::session_bus_configuration_file(); |
2641 | - |
2642 | -auto system_bus_config_file = |
2643 | - core::dbus::testing::Fixture::default_system_bus_config_file() = |
2644 | - core::testing::system_bus_configuration_file(); |
2645 | - |
2646 | -} |
2647 | - |
2648 | -TEST_F(Service, wifiLink) |
2649 | -{ |
2650 | - core::testing::CrossProcessSync services_ready; |
2651 | - core::testing::CrossProcessSync client_ready; |
2652 | - core::testing::CrossProcessSync stage1; |
2653 | - core::testing::CrossProcessSync stage2; |
2654 | - |
2655 | - auto service = [&, this]() |
2656 | - { |
2657 | - core::testing::SigTermCatcher sc; |
2658 | - |
2659 | - auto bus = system_bus(); |
2660 | - bus->install_executor(core::dbus::asio::make_executor(bus)); |
2661 | - |
2662 | - auto service = NM::Service::Mock(bus); |
2663 | - auto nm_root = service.nm; |
2664 | - |
2665 | - auto wifi_dev = NM::Interface::Device(nm_root->service, |
2666 | - nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))); |
2667 | - auto ap1 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/1"))); |
2668 | - auto ap2 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/2"))); |
2669 | - |
2670 | - auto wrong_settings = NM::Interface::Connection(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Settings/1"))); |
2671 | - auto correct_settings = NM::Interface::Connection(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Settings/2"))); |
2672 | - |
2673 | - wrong_settings.object->install_method_handler<NM::Interface::Connection::Method::GetSettings>([&](const dbus::Message::Ptr& msg) |
2674 | - { |
2675 | - auto reply = dbus::Message::make_method_return(msg); |
2676 | - std::map<std::string, std::map<std::string, core::dbus::types::Variant>> conf; |
2677 | - std::map<std::string, dbus::types::Variant> wireless_conf; |
2678 | - wireless_conf["ssid"] = dbus::types::Variant::encode<std::vector<std::int8_t>>({0x64, 0x65, 0x66}); // def |
2679 | - conf["802-11-wireless"] = wireless_conf; |
2680 | - reply->writer() << conf; |
2681 | - bus->send(reply); |
2682 | - }); |
2683 | - |
2684 | - correct_settings.object->install_method_handler<NM::Interface::Connection::Method::GetSettings>([&](const dbus::Message::Ptr& msg) |
2685 | - { |
2686 | - auto reply = dbus::Message::make_method_return(msg); |
2687 | - std::map<std::string, std::map<std::string, core::dbus::types::Variant>> conf; |
2688 | - std::map<std::string, dbus::types::Variant> wireless_conf; |
2689 | - wireless_conf["ssid"] = dbus::types::Variant::encode<std::vector<std::int8_t>>({static_cast<std::int8_t>(0xC3), |
2690 | - static_cast<std::int8_t>(0xA4), |
2691 | - static_cast<std::int8_t>(0x62), |
2692 | - static_cast<std::int8_t>(0x63)}); // Ƥbc |
2693 | - conf["802-11-wireless"] = wireless_conf; |
2694 | - reply->writer() << conf; |
2695 | - bus->send(reply); |
2696 | - }); |
2697 | - |
2698 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::GetDevices>([bus, &wifi_dev](const dbus::Message::Ptr& msg) |
2699 | - { |
2700 | - auto reply = dbus::Message::make_method_return(msg); |
2701 | - std::vector<dbus::types::ObjectPath> devices; |
2702 | - devices.push_back(wifi_dev.object->path()); |
2703 | - reply->writer() << devices; |
2704 | - bus->send(reply); |
2705 | - }); |
2706 | - |
2707 | - NM::Interface::Device::Property::AvailableConnections::ValueType available_connections; |
2708 | - available_connections.push_back(wrong_settings.object->path()); |
2709 | - available_connections.push_back(correct_settings.object->path()); |
2710 | - wifi_dev.available_connections->set(available_connections); |
2711 | - |
2712 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::ActivateConnection>([&](const dbus::Message::Ptr& msg) |
2713 | - { |
2714 | - std::cout << "Server: Active Connection" << std::endl; |
2715 | - auto reader = msg->reader(); |
2716 | - |
2717 | - dbus::types::ObjectPath connection = reader.pop_object_path(); |
2718 | - dbus::types::ObjectPath device = reader.pop_object_path(); |
2719 | - dbus::types::ObjectPath specific_object = reader.pop_object_path(); |
2720 | - |
2721 | - EXPECT_EQ(connection, correct_settings.object->path()); |
2722 | - EXPECT_EQ(device, wifi_dev.object->path()); |
2723 | - EXPECT_EQ(specific_object, ap1.object->path()); |
2724 | - |
2725 | - auto reply = dbus::Message::make_method_return(msg); |
2726 | - reply->writer() << dbus::types::ObjectPath("/"); /// @todo return an actual ActiveConnection at some point. |
2727 | - bus->send(reply); |
2728 | - }); |
2729 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::AddAndActivateConnection>([&](const dbus::Message::Ptr& msg) |
2730 | - { |
2731 | - std::cout << "Server: Add and Active Connection" << std::endl; |
2732 | - auto reader = msg->reader(); |
2733 | - |
2734 | - std::map<std::string, std::map<std::string, core::dbus::types::Variant>> connection; |
2735 | - reader >> connection; |
2736 | - dbus::types::ObjectPath device = reader.pop_object_path(); |
2737 | - dbus::types::ObjectPath specific_object = reader.pop_object_path(); |
2738 | - |
2739 | - EXPECT_TRUE(connection.find("802-11-wireless") != connection.end()); |
2740 | - auto wificonf = connection["802-11-wireless"]; |
2741 | - EXPECT_TRUE(wificonf.find("ssid") != wificonf.end()); |
2742 | - EXPECT_EQ(wificonf["ssid"].as<std::vector<std::int8_t>>(), ap2.ssid->get()); |
2743 | - EXPECT_EQ(device, wifi_dev.object->path()); |
2744 | - EXPECT_EQ(specific_object, ap2.object->path()); |
2745 | - |
2746 | - auto reply = dbus::Message::make_method_return(msg); |
2747 | - auto ret = std::make_tuple(dbus::types::ObjectPath("/"), dbus::types::ObjectPath("/")); |
2748 | - reply->writer() << ret; /// @todo return actual Settings and ActiveConnection at some point. |
2749 | - bus->send(reply); |
2750 | - }); |
2751 | - |
2752 | - |
2753 | - nm_root->state->set(NM_STATE_DISCONNECTED); |
2754 | - wifi_dev.device_type->set(NM_DEVICE_TYPE_WIFI); |
2755 | - |
2756 | - std::vector<dbus::types::ObjectPath> aps; |
2757 | - wifi_dev.object->install_method_handler<NM::Interface::Device::Wireless::Method::GetAccessPoints>([bus, &aps](const dbus::Message::Ptr& msg) |
2758 | - { |
2759 | - auto reply = dbus::Message::make_method_return(msg); |
2760 | - reply->writer() << aps; |
2761 | - bus->send(reply); |
2762 | - }); |
2763 | - |
2764 | - auto ap_added = wifi_dev.object->get_signal<NM::Interface::Device::Wireless::Signal::AccessPointAdded>(); |
2765 | - auto ap_removed = wifi_dev.object->get_signal<NM::Interface::Device::Wireless::Signal::AccessPointRemoved>(); |
2766 | - |
2767 | - ap1.flags->set(NM_802_11_AP_FLAGS_PRIVACY); |
2768 | - ap1.mode->set(NM_802_11_MODE_INFRA); |
2769 | - // SSID name is Ƥbc to test that utf-8 in names works. |
2770 | - // The casts are because the underlying datatype is |
2771 | - // signed char (should be unsigned) and 0x63 > 127. |
2772 | - ap1.ssid->set({static_cast<std::int8_t>(0xC3), |
2773 | - static_cast<std::int8_t>(0xA4), |
2774 | - static_cast<std::int8_t>(0x62), |
2775 | - static_cast<std::int8_t>(0x63)}); |
2776 | - ap1.strength->set(90); |
2777 | - |
2778 | - auto ap1_pc = ap1.properties_changed; |
2779 | - |
2780 | - ap2.flags->set(NM_802_11_AP_FLAGS_NONE); |
2781 | - ap2.mode->set(NM_802_11_MODE_ADHOC); |
2782 | - ap2.ssid->set({0x31, 0x32, 0x33}); // 123 |
2783 | - ap2.strength->set(60); |
2784 | - auto ap2_pc = ap2.properties_changed; |
2785 | - |
2786 | - DefaultURfkillMock urfkill(bus); |
2787 | - |
2788 | - std::thread t{[bus](){ bus->run(); }}; |
2789 | - |
2790 | - aps.push_back(ap1.object->path()); |
2791 | - aps.push_back(ap2.object->path()); |
2792 | - |
2793 | - services_ready.try_signal_ready_for(std::chrono::milliseconds{5000}); |
2794 | - EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
2795 | - |
2796 | - |
2797 | - stage1.try_signal_ready_for(std::chrono::milliseconds{5000}); |
2798 | - |
2799 | - sleep(1); |
2800 | - |
2801 | - stage2.try_signal_ready_for(std::chrono::milliseconds{5000}); |
2802 | - |
2803 | - sc.wait_for_signal_for(std::chrono::seconds{60}); |
2804 | - |
2805 | - bus->stop(); |
2806 | - |
2807 | - if (t.joinable()) |
2808 | - t.join(); |
2809 | - |
2810 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
2811 | - }; |
2812 | - |
2813 | - auto client = [&, this]() |
2814 | - { |
2815 | - EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
2816 | - std::unique_ptr<connectivity::networking::Manager> mgr; |
2817 | - mgr = connectivity::networking::Manager::createInstance(); |
2818 | - |
2819 | - auto links = mgr->links(); |
2820 | - EXPECT_EQ(links->size(), 1); |
2821 | - |
2822 | - EXPECT_EQ((*links->begin())->type(), connectivity::networking::Link::Type::wifi); |
2823 | - auto wifilink = std::dynamic_pointer_cast<connectivity::networking::wifi::Link>(*links->begin()); |
2824 | - EXPECT_TRUE(wifilink.get() != nullptr); |
2825 | - |
2826 | - auto aps = wifilink->accessPoints().get(); |
2827 | - EXPECT_EQ(aps.size(), 2); |
2828 | - |
2829 | - std::shared_ptr<connectivity::networking::wifi::AccessPoint> ap_abc; |
2830 | - std::shared_ptr<connectivity::networking::wifi::AccessPoint> ap_123; |
2831 | - for (auto ap : aps) { |
2832 | - if (ap->ssid() == "Ƥbc") |
2833 | - ap_abc = ap; |
2834 | - if (ap->ssid() == "123") |
2835 | - ap_123 = ap; |
2836 | - } |
2837 | - |
2838 | - EXPECT_TRUE(ap_abc.get() != nullptr); |
2839 | - EXPECT_TRUE(ap_123.get() != nullptr); |
2840 | - |
2841 | - client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
2842 | - |
2843 | - wifilink->connect_to(ap_abc); |
2844 | - |
2845 | - sleep(1); |
2846 | - |
2847 | - EXPECT_EQ(1, stage1.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
2848 | - |
2849 | - wifilink->connect_to(ap_123); |
2850 | - |
2851 | - sleep(1); |
2852 | - |
2853 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
2854 | - }; |
2855 | - |
2856 | - EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); |
2857 | -} |
2858 | - |
2859 | |
2860 | === removed file 'tests/integration/connectivity-cpp/test_wifi_link.cpp' |
2861 | --- tests/integration/connectivity-cpp/test_wifi_link.cpp 2014-08-20 19:18:40 +0000 |
2862 | +++ tests/integration/connectivity-cpp/test_wifi_link.cpp 1970-01-01 00:00:00 +0000 |
2863 | @@ -1,362 +0,0 @@ |
2864 | -/* |
2865 | - * Copyright Ā© 2013 Canonical Ltd. |
2866 | - * |
2867 | - * This program is free software: you can redistribute it and/or modify it |
2868 | - * under the terms of the GNU Lesser General Public License version 3, |
2869 | - * as published by the Free Software Foundation. |
2870 | - * |
2871 | - * This program is distributed in the hope that it will be useful, |
2872 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2873 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2874 | - * GNU Lesser General Public License for more details. |
2875 | - * |
2876 | - * You should have received a copy of the GNU Lesser General Public License |
2877 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
2878 | - * |
2879 | - * Authored by: Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
2880 | - */ |
2881 | - |
2882 | -#include <core/dbus/dbus.h> |
2883 | -#include <core/dbus/fixture.h> |
2884 | -#include <core/dbus/object.h> |
2885 | -#include <core/dbus/property.h> |
2886 | -#include <core/dbus/service.h> |
2887 | -#include <core/dbus/interfaces/properties.h> |
2888 | -#include <core/dbus/types/stl/tuple.h> |
2889 | -#include <core/dbus/types/stl/vector.h> |
2890 | - |
2891 | -#include <core/dbus/asio/executor.h> |
2892 | - |
2893 | -#include "sig_term_catcher.h" |
2894 | -#include "test_data.h" |
2895 | -#include "test_service.h" |
2896 | - |
2897 | -#include <core/testing/cross_process_sync.h> |
2898 | -#include <core/testing/fork_and_run.h> |
2899 | - |
2900 | -#include <gtest/gtest.h> |
2901 | - |
2902 | -#include <system_error> |
2903 | -#include <thread> |
2904 | - |
2905 | -#include <services/nm.h> |
2906 | -namespace fdo = org::freedesktop; |
2907 | -namespace NM = fdo::NetworkManager; |
2908 | - |
2909 | -#include "mocks/urfkill.h" |
2910 | - |
2911 | -#include <connectivity/networking/manager.h> |
2912 | -#include <connectivity/networking/wifi/link.h> |
2913 | -#include <connectivity/networking/wifi/access-point.h> |
2914 | - |
2915 | -namespace dbus = core::dbus; |
2916 | - |
2917 | -namespace |
2918 | -{ |
2919 | -struct Service : public core::dbus::testing::Fixture {}; |
2920 | - |
2921 | -auto session_bus_config_file = |
2922 | - core::dbus::testing::Fixture::default_session_bus_config_file() = |
2923 | - core::testing::session_bus_configuration_file(); |
2924 | - |
2925 | -auto system_bus_config_file = |
2926 | - core::dbus::testing::Fixture::default_system_bus_config_file() = |
2927 | - core::testing::system_bus_configuration_file(); |
2928 | - |
2929 | -} |
2930 | - |
2931 | -TEST_F(Service, wifiLink) |
2932 | -{ |
2933 | - core::testing::CrossProcessSync services_ready; |
2934 | - core::testing::CrossProcessSync client_ready; |
2935 | - core::testing::CrossProcessSync stage1; |
2936 | - core::testing::CrossProcessSync stage2; |
2937 | - core::testing::CrossProcessSync stage3; |
2938 | - |
2939 | - auto service = [&, this]() |
2940 | - { |
2941 | - core::testing::SigTermCatcher sc; |
2942 | - |
2943 | - auto bus = system_bus(); |
2944 | - bus->install_executor(core::dbus::asio::make_executor(bus)); |
2945 | - |
2946 | - auto service = NM::Service::Mock(bus); |
2947 | - auto nm_root = service.nm; |
2948 | - |
2949 | - auto wifi_dev = NM::Interface::Device(nm_root->service, |
2950 | - nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))); |
2951 | - auto ap1 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/1"))); |
2952 | - auto ap2 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/2"))); |
2953 | - |
2954 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::GetDevices>([bus, &wifi_dev](const dbus::Message::Ptr& msg) |
2955 | - { |
2956 | - auto reply = dbus::Message::make_method_return(msg); |
2957 | - std::vector<dbus::types::ObjectPath> devices; |
2958 | - devices.push_back(wifi_dev.object->path()); |
2959 | - reply->writer() << devices; |
2960 | - bus->send(reply); |
2961 | - }); |
2962 | - |
2963 | - nm_root->state->set(NM_STATE_CONNECTED_GLOBAL); |
2964 | - |
2965 | - wifi_dev.device_type->set(NM_DEVICE_TYPE_WIFI); |
2966 | - |
2967 | - std::vector<dbus::types::ObjectPath> aps; |
2968 | - wifi_dev.object->install_method_handler<NM::Interface::Device::Wireless::Method::GetAccessPoints>([bus, &aps](const dbus::Message::Ptr& msg) |
2969 | - { |
2970 | - auto reply = dbus::Message::make_method_return(msg); |
2971 | - reply->writer() << aps; |
2972 | - bus->send(reply); |
2973 | - }); |
2974 | - |
2975 | - auto ap_added = wifi_dev.object->get_signal<NM::Interface::Device::Wireless::Signal::AccessPointAdded>(); |
2976 | - auto ap_removed = wifi_dev.object->get_signal<NM::Interface::Device::Wireless::Signal::AccessPointRemoved>(); |
2977 | - |
2978 | - ap1.flags->set(NM_802_11_AP_FLAGS_PRIVACY); |
2979 | - ap1.mode->set(NM_802_11_MODE_INFRA); |
2980 | - ap1.ssid->set({0x61, 0x62, 0x63}); // abc |
2981 | - ap1.strength->set(90); |
2982 | - |
2983 | - auto ap1_pc = ap1.properties_changed; |
2984 | - |
2985 | - ap2.flags->set(NM_802_11_AP_FLAGS_NONE); |
2986 | - ap2.mode->set(NM_802_11_MODE_ADHOC); |
2987 | - ap2.ssid->set({0x31, 0x32, 0x33}); // 123 |
2988 | - ap2.strength->set(60); |
2989 | - auto ap2_pc = ap2.properties_changed; |
2990 | - |
2991 | - DefaultURfkillMock urfkill(bus); |
2992 | - |
2993 | - std::thread t{[bus](){ bus->run(); }}; |
2994 | - |
2995 | - // add just one AP initially |
2996 | - aps.push_back(ap1.object->path()); |
2997 | - |
2998 | - services_ready.try_signal_ready_for(std::chrono::milliseconds{5000}); |
2999 | - EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
3000 | - |
3001 | - NM::Interface::AccessPoint::Signal::PropertiesChanged::ArgumentType properties; |
3002 | - |
3003 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(0); |
3004 | - ap1_pc->emit(properties); |
3005 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(1); |
3006 | - ap1_pc->emit(properties); |
3007 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(2); |
3008 | - ap1_pc->emit(properties); |
3009 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(3); |
3010 | - ap1_pc->emit(properties); |
3011 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(4); |
3012 | - ap1_pc->emit(properties); |
3013 | - |
3014 | - stage1.try_signal_ready_for(std::chrono::milliseconds{5000}); |
3015 | - |
3016 | - // add second ap |
3017 | - aps.push_back(ap2.object->path()); |
3018 | - ap_added->emit(ap2.object->path()); |
3019 | - |
3020 | - sleep(5); |
3021 | - |
3022 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(5); |
3023 | - ap1_pc->emit(properties); |
3024 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(6); |
3025 | - ap1_pc->emit(properties); |
3026 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(7); |
3027 | - ap1_pc->emit(properties); |
3028 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(8); |
3029 | - ap1_pc->emit(properties); |
3030 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(9); |
3031 | - ap1_pc->emit(properties); |
3032 | - |
3033 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(100); |
3034 | - ap2_pc->emit(properties); |
3035 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(99); |
3036 | - ap2_pc->emit(properties); |
3037 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(98); |
3038 | - ap2_pc->emit(properties); |
3039 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(97); |
3040 | - ap2_pc->emit(properties); |
3041 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(96); |
3042 | - ap2_pc->emit(properties); |
3043 | - ap2_pc->emit(properties); |
3044 | - |
3045 | - stage2.try_signal_ready_for(std::chrono::milliseconds{10000}); |
3046 | - |
3047 | - // remove the first ap |
3048 | - aps.clear(); |
3049 | - aps.push_back(ap2.object->path()); |
3050 | - ap_removed->emit(ap1.object->path()); |
3051 | - |
3052 | - sleep(5); |
3053 | - |
3054 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(95); |
3055 | - ap2_pc->emit(properties); |
3056 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(94); |
3057 | - ap2_pc->emit(properties); |
3058 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(93); |
3059 | - ap2_pc->emit(properties); |
3060 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(92); |
3061 | - ap2_pc->emit(properties); |
3062 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(91); |
3063 | - ap2_pc->emit(properties); |
3064 | - |
3065 | - stage3.try_signal_ready_for(std::chrono::milliseconds{10000}); |
3066 | - |
3067 | - // add the first ap back |
3068 | - aps.push_back(ap1.object->path()); |
3069 | - ap_added->emit(ap1.object->path()); |
3070 | - |
3071 | - sleep(5); |
3072 | - |
3073 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(10); |
3074 | - ap1_pc->emit(properties); |
3075 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(11); |
3076 | - ap1_pc->emit(properties); |
3077 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(12); |
3078 | - ap1_pc->emit(properties); |
3079 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(13); |
3080 | - ap1_pc->emit(properties); |
3081 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(14); |
3082 | - ap1_pc->emit(properties); |
3083 | - |
3084 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(90); |
3085 | - ap2_pc->emit(properties); |
3086 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(89); |
3087 | - ap2_pc->emit(properties); |
3088 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(88); |
3089 | - ap2_pc->emit(properties); |
3090 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(87); |
3091 | - ap2_pc->emit(properties); |
3092 | - properties["Strength"] = dbus::types::Variant::encode<std::int8_t>(86); |
3093 | - ap2_pc->emit(properties); |
3094 | - |
3095 | - sc.wait_for_signal_for(std::chrono::seconds{60}); |
3096 | - |
3097 | - bus->stop(); |
3098 | - |
3099 | - if (t.joinable()) |
3100 | - t.join(); |
3101 | - |
3102 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
3103 | - }; |
3104 | - |
3105 | - auto client = [&, this]() |
3106 | - { |
3107 | - EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3108 | - std::unique_ptr<connectivity::networking::Manager> mgr; |
3109 | - mgr = connectivity::networking::Manager::createInstance(); |
3110 | - |
3111 | - auto links = mgr->links(); |
3112 | - EXPECT_EQ(links->size(), 1); |
3113 | - |
3114 | - EXPECT_EQ((*links->begin())->type(), connectivity::networking::Link::Type::wifi); |
3115 | - auto wifilink = std::dynamic_pointer_cast<connectivity::networking::wifi::Link>(*links->begin()); |
3116 | - EXPECT_TRUE(wifilink.get() != nullptr); |
3117 | - |
3118 | - std::vector<double> values_abc; |
3119 | - std::vector<double> values_123; |
3120 | - std::map<std::shared_ptr<connectivity::networking::wifi::AccessPoint>, core::ScopedConnection> connections; |
3121 | - auto ap_connect = [&](std::shared_ptr<connectivity::networking::wifi::AccessPoint> ap) { |
3122 | - if (ap->ssid() == "abc") { |
3123 | - EXPECT_TRUE(ap->secured()); |
3124 | - EXPECT_FALSE(ap->adhoc()); |
3125 | - auto con = ap->strength().changed().connect([&values_abc](double value){ |
3126 | - values_abc.push_back(value); |
3127 | - }); |
3128 | - connections.insert(std::make_pair(ap, core::ScopedConnection(con))); |
3129 | - } else if (ap->ssid() == "123") { |
3130 | - EXPECT_FALSE(ap->secured()); |
3131 | - EXPECT_TRUE(ap->adhoc()); |
3132 | - auto con = ap->strength().changed().connect([&values_123](double value){ |
3133 | - values_123.push_back(value); |
3134 | - }); |
3135 | - connections.insert(std::make_pair(ap, core::ScopedConnection(con))); |
3136 | - } |
3137 | - }; |
3138 | - auto aps = wifilink->accessPoints().get(); |
3139 | - EXPECT_EQ(aps.size(), 1); |
3140 | - for (auto ap : aps) { |
3141 | - ap_connect(ap); |
3142 | - } |
3143 | - aps.clear(); |
3144 | - wifilink->accessPoints().changed().connect([&](std::set<std::shared_ptr<connectivity::networking::wifi::AccessPoint>> aps) { |
3145 | - connections.clear(); |
3146 | - for (auto ap: aps) |
3147 | - ap_connect(ap); |
3148 | - }); |
3149 | - |
3150 | - client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
3151 | - |
3152 | - sleep(5); |
3153 | - |
3154 | - EXPECT_EQ(values_abc.size(), 5); |
3155 | - EXPECT_EQ(values_123.size(), 0); |
3156 | - |
3157 | - EXPECT_FLOAT_EQ(values_abc[0], 0); |
3158 | - EXPECT_FLOAT_EQ(values_abc[1], 1); |
3159 | - EXPECT_FLOAT_EQ(values_abc[2], 2); |
3160 | - EXPECT_FLOAT_EQ(values_abc[3], 3); |
3161 | - EXPECT_FLOAT_EQ(values_abc[4], 4); |
3162 | - |
3163 | - values_abc.clear(); |
3164 | - values_123.clear(); |
3165 | - EXPECT_EQ(1, stage1.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3166 | - |
3167 | - sleep(5); |
3168 | - |
3169 | - EXPECT_EQ(values_abc.size(), 5); |
3170 | - EXPECT_EQ(values_123.size(), 5); |
3171 | - |
3172 | - EXPECT_FLOAT_EQ(values_abc[0], 5); |
3173 | - EXPECT_FLOAT_EQ(values_abc[1], 6); |
3174 | - EXPECT_FLOAT_EQ(values_abc[2], 7); |
3175 | - EXPECT_FLOAT_EQ(values_abc[3], 8); |
3176 | - EXPECT_FLOAT_EQ(values_abc[4], 9); |
3177 | - |
3178 | - EXPECT_FLOAT_EQ(values_123[0], 100); |
3179 | - EXPECT_FLOAT_EQ(values_123[1], 99); |
3180 | - EXPECT_FLOAT_EQ(values_123[2], 98); |
3181 | - EXPECT_FLOAT_EQ(values_123[3], 97); |
3182 | - EXPECT_FLOAT_EQ(values_123[4], 96); |
3183 | - |
3184 | - values_abc.clear(); |
3185 | - values_123.clear(); |
3186 | - EXPECT_EQ(1, stage2.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3187 | - |
3188 | - sleep(5); |
3189 | - |
3190 | - EXPECT_EQ(values_abc.size(), 0); |
3191 | - EXPECT_EQ(values_123.size(), 5); |
3192 | - |
3193 | - EXPECT_FLOAT_EQ(values_123[0], 95); |
3194 | - EXPECT_FLOAT_EQ(values_123[1], 94); |
3195 | - EXPECT_FLOAT_EQ(values_123[2], 93); |
3196 | - EXPECT_FLOAT_EQ(values_123[3], 92); |
3197 | - EXPECT_FLOAT_EQ(values_123[4], 91); |
3198 | - |
3199 | - values_abc.clear(); |
3200 | - values_123.clear(); |
3201 | - EXPECT_EQ(1, stage3.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3202 | - |
3203 | - sleep(5); |
3204 | - |
3205 | - EXPECT_EQ(values_abc.size(), 5); |
3206 | - EXPECT_EQ(values_123.size(), 5); |
3207 | - |
3208 | - EXPECT_FLOAT_EQ(values_abc[0], 10); |
3209 | - EXPECT_FLOAT_EQ(values_abc[1], 11); |
3210 | - EXPECT_FLOAT_EQ(values_abc[2], 12); |
3211 | - EXPECT_FLOAT_EQ(values_abc[3], 13); |
3212 | - EXPECT_FLOAT_EQ(values_abc[4], 14); |
3213 | - |
3214 | - EXPECT_FLOAT_EQ(values_123[0], 90); |
3215 | - EXPECT_FLOAT_EQ(values_123[1], 89); |
3216 | - EXPECT_FLOAT_EQ(values_123[2], 88); |
3217 | - EXPECT_FLOAT_EQ(values_123[3], 87); |
3218 | - EXPECT_FLOAT_EQ(values_123[4], 86); |
3219 | - |
3220 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
3221 | - }; |
3222 | - |
3223 | - EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); |
3224 | -} |
3225 | - |
3226 | |
3227 | === removed file 'tests/integration/connectivity-cpp/test_wifi_link_dedup.cpp' |
3228 | --- tests/integration/connectivity-cpp/test_wifi_link_dedup.cpp 2014-08-20 20:16:32 +0000 |
3229 | +++ tests/integration/connectivity-cpp/test_wifi_link_dedup.cpp 1970-01-01 00:00:00 +0000 |
3230 | @@ -1,240 +0,0 @@ |
3231 | -/* |
3232 | - * Copyright Ā© 2013 Canonical Ltd. |
3233 | - * |
3234 | - * This program is free software: you can redistribute it and/or modify it |
3235 | - * under the terms of the GNU Lesser General Public License version 3, |
3236 | - * as published by the Free Software Foundation. |
3237 | - * |
3238 | - * This program is distributed in the hope that it will be useful, |
3239 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3240 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3241 | - * GNU Lesser General Public License for more details. |
3242 | - * |
3243 | - * You should have received a copy of the GNU Lesser General Public License |
3244 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3245 | - * |
3246 | - * Authored by: Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
3247 | - */ |
3248 | - |
3249 | -#include <core/dbus/dbus.h> |
3250 | -#include <core/dbus/fixture.h> |
3251 | -#include <core/dbus/object.h> |
3252 | -#include <core/dbus/property.h> |
3253 | -#include <core/dbus/service.h> |
3254 | -#include <core/dbus/interfaces/properties.h> |
3255 | -#include <core/dbus/types/stl/tuple.h> |
3256 | -#include <core/dbus/types/stl/vector.h> |
3257 | - |
3258 | -#include <core/dbus/asio/executor.h> |
3259 | - |
3260 | -#include "sig_term_catcher.h" |
3261 | -#include "test_data.h" |
3262 | -#include "test_service.h" |
3263 | - |
3264 | -#include <core/testing/cross_process_sync.h> |
3265 | -#include <core/testing/fork_and_run.h> |
3266 | - |
3267 | -#include <gtest/gtest.h> |
3268 | - |
3269 | -#include <system_error> |
3270 | -#include <thread> |
3271 | - |
3272 | -#include <services/nm.h> |
3273 | -namespace fdo = org::freedesktop; |
3274 | -namespace NM = fdo::NetworkManager; |
3275 | - |
3276 | -#include "mocks/urfkill.h" |
3277 | - |
3278 | -#include <connectivity/networking/manager.h> |
3279 | -#include <connectivity/networking/wifi/link.h> |
3280 | -#include <connectivity/networking/wifi/access-point.h> |
3281 | - |
3282 | -namespace dbus = core::dbus; |
3283 | - |
3284 | -namespace |
3285 | -{ |
3286 | -struct Service : public core::dbus::testing::Fixture {}; |
3287 | - |
3288 | -auto session_bus_config_file = |
3289 | - core::dbus::testing::Fixture::default_session_bus_config_file() = |
3290 | - core::testing::session_bus_configuration_file(); |
3291 | - |
3292 | -auto system_bus_config_file = |
3293 | - core::dbus::testing::Fixture::default_system_bus_config_file() = |
3294 | - core::testing::system_bus_configuration_file(); |
3295 | - |
3296 | -} |
3297 | - |
3298 | -TEST_F(Service, wifiLink) |
3299 | -{ |
3300 | - core::testing::CrossProcessSync services_ready; |
3301 | - core::testing::CrossProcessSync client_ready; |
3302 | - core::testing::CrossProcessSync stage1; |
3303 | - core::testing::CrossProcessSync stage2; |
3304 | - core::testing::CrossProcessSync stage3; |
3305 | - core::testing::CrossProcessSync stage4; |
3306 | - |
3307 | - auto service = [&, this]() |
3308 | - { |
3309 | - core::testing::SigTermCatcher sc; |
3310 | - |
3311 | - auto bus = system_bus(); |
3312 | - bus->install_executor(core::dbus::asio::make_executor(bus)); |
3313 | - |
3314 | - auto service = NM::Service::Mock(bus); |
3315 | - auto nm_root = service.nm; |
3316 | - |
3317 | - auto wifi_dev = NM::Interface::Device(nm_root->service, |
3318 | - nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))); |
3319 | - auto ap1 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/1"))); |
3320 | - auto ap2 = NM::Interface::AccessPoint(nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/AccessPoint/2"))); |
3321 | - |
3322 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::GetDevices>([bus, &wifi_dev](const dbus::Message::Ptr& msg) |
3323 | - { |
3324 | - auto reply = dbus::Message::make_method_return(msg); |
3325 | - std::vector<dbus::types::ObjectPath> devices; |
3326 | - devices.push_back(wifi_dev.object->path()); |
3327 | - reply->writer() << devices; |
3328 | - bus->send(reply); |
3329 | - }); |
3330 | - |
3331 | - nm_root->state->set(NM_STATE_CONNECTED_GLOBAL); |
3332 | - |
3333 | - wifi_dev.device_type->set(NM_DEVICE_TYPE_WIFI); |
3334 | - |
3335 | - std::vector<dbus::types::ObjectPath> aps; |
3336 | - wifi_dev.object->install_method_handler<NM::Interface::Device::Wireless::Method::GetAccessPoints>([bus, &aps](const dbus::Message::Ptr& msg) |
3337 | - { |
3338 | - auto reply = dbus::Message::make_method_return(msg); |
3339 | - reply->writer() << aps; |
3340 | - bus->send(reply); |
3341 | - }); |
3342 | - |
3343 | - auto ap_added = wifi_dev.object->get_signal<NM::Interface::Device::Wireless::Signal::AccessPointAdded>(); |
3344 | - auto ap_removed = wifi_dev.object->get_signal<NM::Interface::Device::Wireless::Signal::AccessPointRemoved>(); |
3345 | - |
3346 | - ap1.flags->set(NM_802_11_AP_FLAGS_PRIVACY); |
3347 | - ap1.mode->set(NM_802_11_MODE_INFRA); |
3348 | - ap1.ssid->set({0x61, 0x62, 0x63}); // abc |
3349 | - ap1.strength->set(60); |
3350 | - |
3351 | - auto ap1_pc = ap1.properties_changed; |
3352 | - |
3353 | - ap2.flags->set(NM_802_11_AP_FLAGS_PRIVACY); |
3354 | - ap2.mode->set(NM_802_11_MODE_INFRA); |
3355 | - ap2.ssid->set({0x61, 0x62, 0x63}); // abc |
3356 | - ap2.strength->set(90); |
3357 | - auto ap2_pc = ap2.properties_changed; |
3358 | - |
3359 | - DefaultURfkillMock urfkill(bus); |
3360 | - |
3361 | - std::thread t{[bus](){ bus->run(); }}; |
3362 | - |
3363 | - // add just one AP initially |
3364 | - aps.push_back(ap1.object->path()); |
3365 | - |
3366 | - services_ready.try_signal_ready_for(std::chrono::milliseconds{10000}); |
3367 | - EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3368 | - |
3369 | - NM::Interface::AccessPoint::Signal::PropertiesChanged::ArgumentType properties; |
3370 | - |
3371 | - stage1.try_signal_ready_for(std::chrono::milliseconds{10000}); |
3372 | - |
3373 | - // add second ap |
3374 | - aps.push_back(ap2.object->path()); |
3375 | - ap_added->emit(ap2.object->path()); |
3376 | - |
3377 | - sleep(5); |
3378 | - |
3379 | - stage2.try_signal_ready_for(std::chrono::milliseconds{10000}); |
3380 | - |
3381 | - // remove second ap |
3382 | - aps.clear(); |
3383 | - aps.push_back(ap1.object->path()); |
3384 | - ap_removed->emit(ap2.object->path()); |
3385 | - |
3386 | - sleep(5); |
3387 | - |
3388 | - stage3.try_signal_ready_for(std::chrono::milliseconds{10000}); |
3389 | - |
3390 | - aps.clear(); |
3391 | - ap_removed->emit(ap1.object->path()); |
3392 | - |
3393 | - sleep(5); |
3394 | - |
3395 | - stage4.try_signal_ready_for(std::chrono::milliseconds{10000}); |
3396 | - |
3397 | - bus->stop(); |
3398 | - |
3399 | - if (t.joinable()) |
3400 | - t.join(); |
3401 | - |
3402 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
3403 | - }; |
3404 | - |
3405 | - auto client = [&, this]() |
3406 | - { |
3407 | - EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3408 | - std::unique_ptr<connectivity::networking::Manager> mgr; |
3409 | - mgr = connectivity::networking::Manager::createInstance(); |
3410 | - |
3411 | - auto links = mgr->links(); |
3412 | - EXPECT_EQ(links->size(), 1); |
3413 | - |
3414 | - EXPECT_EQ((*links->begin())->type(), connectivity::networking::Link::Type::wifi); |
3415 | - auto wifilink = std::dynamic_pointer_cast<connectivity::networking::wifi::Link>(*links->begin()); |
3416 | - EXPECT_TRUE(wifilink.get() != nullptr); |
3417 | - |
3418 | - std::vector<double> values_abc; |
3419 | - std::vector<double> values_123; |
3420 | - std::map<std::shared_ptr<connectivity::networking::wifi::AccessPoint>, core::ScopedConnection> connections; |
3421 | - auto ap_connect = [&](std::shared_ptr<connectivity::networking::wifi::AccessPoint> ap) { |
3422 | - EXPECT_EQ(ap->ssid(), "abc"); |
3423 | - EXPECT_TRUE(ap->secured()); |
3424 | - EXPECT_FALSE(ap->adhoc()); |
3425 | - //connections.insert(std::make_pair(ap, core::ScopedConnection(con))); |
3426 | - }; |
3427 | - |
3428 | - wifilink->accessPoints().changed().connect([&](std::set<std::shared_ptr<connectivity::networking::wifi::AccessPoint>> aps) { |
3429 | - connections.clear(); |
3430 | - for (auto ap: aps) |
3431 | - ap_connect(ap); |
3432 | - }); |
3433 | - |
3434 | - client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
3435 | - |
3436 | - auto aps = wifilink->accessPoints().get(); |
3437 | - EXPECT_EQ(aps.size(), 1); |
3438 | - EXPECT_EQ((*aps.begin())->strength().get(), 60); |
3439 | - sleep(5); |
3440 | - |
3441 | - EXPECT_EQ(1, stage1.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3442 | - |
3443 | - aps = wifilink->accessPoints().get(); |
3444 | - EXPECT_EQ(aps.size(), 1); |
3445 | - EXPECT_EQ((*aps.begin())->strength().get(), 90); |
3446 | - |
3447 | - |
3448 | - EXPECT_EQ(1, stage2.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3449 | - |
3450 | - sleep(5); |
3451 | - |
3452 | - aps = wifilink->accessPoints().get(); |
3453 | - EXPECT_EQ(aps.size(), 1); |
3454 | - EXPECT_EQ((*aps.begin())->strength().get(), 60); |
3455 | - |
3456 | - EXPECT_EQ(1, stage3.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3457 | - |
3458 | - sleep(5); |
3459 | - |
3460 | - aps = wifilink->accessPoints().get(); |
3461 | - EXPECT_EQ(aps.size(), 0); |
3462 | - |
3463 | - EXPECT_EQ(1, stage4.wait_for_signal_ready_for(std::chrono::milliseconds{10000})); |
3464 | - |
3465 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
3466 | - }; |
3467 | - |
3468 | - EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); |
3469 | -} |
3470 | - |
3471 | |
3472 | === removed file 'tests/integration/connectivity-cpp/test_wifi_link_enable_disable.cpp' |
3473 | --- tests/integration/connectivity-cpp/test_wifi_link_enable_disable.cpp 2014-08-19 19:55:15 +0000 |
3474 | +++ tests/integration/connectivity-cpp/test_wifi_link_enable_disable.cpp 1970-01-01 00:00:00 +0000 |
3475 | @@ -1,186 +0,0 @@ |
3476 | -/* |
3477 | - * Copyright Ā© 2013 Canonical Ltd. |
3478 | - * |
3479 | - * This program is free software: you can redistribute it and/or modify it |
3480 | - * under the terms of the GNU Lesser General Public License version 3, |
3481 | - * as published by the Free Software Foundation. |
3482 | - * |
3483 | - * This program is distributed in the hope that it will be useful, |
3484 | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
3485 | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
3486 | - * GNU Lesser General Public License for more details. |
3487 | - * |
3488 | - * You should have received a copy of the GNU Lesser General Public License |
3489 | - * along with this program. If not, see <http://www.gnu.org/licenses/>. |
3490 | - * |
3491 | - * Authored by: Antti KaijanmƤki <antti.kaijanmaki@canonical.com> |
3492 | - */ |
3493 | - |
3494 | -#include <core/dbus/dbus.h> |
3495 | -#include <core/dbus/fixture.h> |
3496 | -#include <core/dbus/object.h> |
3497 | -#include <core/dbus/property.h> |
3498 | -#include <core/dbus/service.h> |
3499 | -#include <core/dbus/interfaces/properties.h> |
3500 | -#include <core/dbus/types/stl/tuple.h> |
3501 | -#include <core/dbus/types/stl/vector.h> |
3502 | - |
3503 | -#include <core/dbus/asio/executor.h> |
3504 | - |
3505 | -#include "sig_term_catcher.h" |
3506 | -#include "test_data.h" |
3507 | -#include "test_service.h" |
3508 | - |
3509 | -#include <core/testing/cross_process_sync.h> |
3510 | -#include <core/testing/fork_and_run.h> |
3511 | - |
3512 | -#include <gtest/gtest.h> |
3513 | - |
3514 | -#include <system_error> |
3515 | -#include <thread> |
3516 | - |
3517 | -#include <services/nm.h> |
3518 | -namespace fdo = org::freedesktop; |
3519 | -namespace NM = fdo::NetworkManager; |
3520 | - |
3521 | -#include "mocks/urfkill.h" |
3522 | - |
3523 | -#include <connectivity/networking/manager.h> |
3524 | -#include <connectivity/networking/wifi/link.h> |
3525 | -#include <connectivity/networking/wifi/access-point.h> |
3526 | - |
3527 | -namespace dbus = core::dbus; |
3528 | - |
3529 | -namespace |
3530 | -{ |
3531 | -struct Service : public core::dbus::testing::Fixture {}; |
3532 | - |
3533 | -auto session_bus_config_file = |
3534 | - core::dbus::testing::Fixture::default_session_bus_config_file() = |
3535 | - core::testing::session_bus_configuration_file(); |
3536 | - |
3537 | -auto system_bus_config_file = |
3538 | - core::dbus::testing::Fixture::default_system_bus_config_file() = |
3539 | - core::testing::system_bus_configuration_file(); |
3540 | - |
3541 | -} |
3542 | - |
3543 | -TEST_F(Service, wifiLink) |
3544 | -{ |
3545 | - core::testing::CrossProcessSync services_ready; |
3546 | - core::testing::CrossProcessSync client_ready; |
3547 | - core::testing::CrossProcessSync stage1; |
3548 | - core::testing::CrossProcessSync stage2; |
3549 | - |
3550 | - auto service = [&, this]() |
3551 | - { |
3552 | - core::testing::SigTermCatcher sc; |
3553 | - |
3554 | - auto bus = system_bus(); |
3555 | - bus->install_executor(core::dbus::asio::make_executor(bus)); |
3556 | - |
3557 | - auto service = NM::Service::Mock(bus); |
3558 | - auto nm_root = service.nm; |
3559 | - |
3560 | - auto wifi_dev = NM::Interface::Device(nm_root->service, |
3561 | - nm_root->service->add_object_for_path(dbus::types::ObjectPath("/org/freedesktop/NetworkManager/Devices/0"))); |
3562 | - |
3563 | - nm_root->object->install_method_handler<NM::Interface::NetworkManager::Method::GetDevices>([bus, &wifi_dev](const dbus::Message::Ptr& msg) |
3564 | - { |
3565 | - auto reply = dbus::Message::make_method_return(msg); |
3566 | - std::vector<dbus::types::ObjectPath> devices; |
3567 | - devices.push_back(wifi_dev.object->path()); |
3568 | - reply->writer() << devices; |
3569 | - bus->send(reply); |
3570 | - }); |
3571 | - |
3572 | - nm_root->state->set(NM_STATE_CONNECTED_GLOBAL); |
3573 | - wifi_dev.device_type->set(NM_DEVICE_TYPE_WIFI); |
3574 | - wifi_dev.state->set(NM_DEVICE_STATE_ACTIVATED); |
3575 | - |
3576 | - wifi_dev.object->install_method_handler<NM::Interface::Device::Wireless::Method::GetAccessPoints>([&](const dbus::Message::Ptr& msg) |
3577 | - { |
3578 | - auto reply = dbus::Message::make_method_return(msg); |
3579 | - reply->writer() << std::vector<dbus::types::ObjectPath>(); |
3580 | - bus->send(reply); |
3581 | - }); |
3582 | - |
3583 | - DefaultURfkillMock urfkill(bus); |
3584 | - urfkill.wlan.state.changed().connect([&](fdo::URfkill::Interface::Killswitch::State value) { |
3585 | - typedef fdo::URfkill::Interface::Killswitch Killswitch; |
3586 | - switch (value) { |
3587 | - case Killswitch::State::not_available: |
3588 | - case Killswitch::State::unblocked: |
3589 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_REASON_SUPPLICANT_AVAILABLE)); |
3590 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_DISCONNECTED, NM_DEVICE_STATE_REASON_NONE)); |
3591 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE)); |
3592 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE)); |
3593 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_NEED_AUTH, NM_DEVICE_STATE_REASON_NONE)); |
3594 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_PREPARE, NM_DEVICE_STATE_REASON_NONE)); |
3595 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_CONFIG, NM_DEVICE_STATE_REASON_NONE)); |
3596 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_IP_CONFIG, NM_DEVICE_STATE_REASON_NONE)); |
3597 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_SECONDARIES, NM_DEVICE_STATE_REASON_NONE)); |
3598 | - break; |
3599 | - case Killswitch::State::soft_blocked: |
3600 | - case Killswitch::State::hard_blocked: |
3601 | - wifi_dev.state_changed->emit(std::make_tuple(NM_DEVICE_STATE_UNAVAILABLE, NM_DEVICE_STATE_ACTIVATED, NM_DEVICE_STATE_REASON_NONE)); |
3602 | - } |
3603 | - }); |
3604 | - |
3605 | - std::thread t{[bus](){ bus->run(); }}; |
3606 | - |
3607 | - services_ready.try_signal_ready_for(std::chrono::milliseconds{5000}); |
3608 | - EXPECT_EQ(1, client_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
3609 | - |
3610 | - |
3611 | - stage1.try_signal_ready_for(std::chrono::milliseconds{5000}); |
3612 | - sleep(1); |
3613 | - |
3614 | - stage2.try_signal_ready_for(std::chrono::milliseconds{5000}); |
3615 | - sleep(1); |
3616 | - |
3617 | - sc.wait_for_signal_for(std::chrono::seconds{60}); |
3618 | - |
3619 | - bus->stop(); |
3620 | - |
3621 | - if (t.joinable()) |
3622 | - t.join(); |
3623 | - |
3624 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
3625 | - }; |
3626 | - |
3627 | - auto client = [&, this]() |
3628 | - { |
3629 | - EXPECT_EQ(1, services_ready.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
3630 | - std::unique_ptr<connectivity::networking::Manager> mgr; |
3631 | - mgr = connectivity::networking::Manager::createInstance(); |
3632 | - |
3633 | - auto links = mgr->links(); |
3634 | - EXPECT_EQ(links->size(), 1); |
3635 | - |
3636 | - EXPECT_EQ((*links->begin())->type(), connectivity::networking::Link::Type::wifi); |
3637 | - auto wifilink = std::dynamic_pointer_cast<connectivity::networking::wifi::Link>(*links->begin()); |
3638 | - EXPECT_TRUE(wifilink.get() != nullptr); |
3639 | - |
3640 | - client_ready.try_signal_ready_for(std::chrono::milliseconds{2000}); |
3641 | - |
3642 | - wifilink->disable(); |
3643 | - sleep(1); |
3644 | - |
3645 | - EXPECT_EQ(1, stage1.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
3646 | - |
3647 | - EXPECT_EQ(wifilink->status().get(), connectivity::networking::Link::Status::disabled); |
3648 | - |
3649 | - wifilink->enable(); |
3650 | - |
3651 | - sleep(1); |
3652 | - EXPECT_EQ(1, stage2.wait_for_signal_ready_for(std::chrono::milliseconds{5000})); |
3653 | - |
3654 | - EXPECT_EQ(wifilink->status().get(), connectivity::networking::Link::Status::online); |
3655 | - |
3656 | - return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; |
3657 | - }; |
3658 | - |
3659 | - EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); |
3660 | -} |
3661 | - |
3662 | |
3663 | === removed directory 'tests/integration/indicator' |
3664 | === added file 'tests/integration/indicator-network-test-base.cpp' |
3665 | --- tests/integration/indicator-network-test-base.cpp 1970-01-01 00:00:00 +0000 |
3666 | +++ tests/integration/indicator-network-test-base.cpp 2015-04-23 13:23:11 +0000 |
3667 | @@ -0,0 +1,338 @@ |
3668 | +/* |
3669 | + * Copyright (C) 2015 Canonical, Ltd. |
3670 | + * |
3671 | + * This program is free software: you can redistribute it and/or modify it |
3672 | + * under the terms of the GNU General Public License version 3, as published |
3673 | + * by the Free Software Foundation. |
3674 | + * |
3675 | + * This program is distributed in the hope that it will be useful, but |
3676 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
3677 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
3678 | + * PURPOSE. See the GNU General Public License for more details. |
3679 | + * |
3680 | + * You should have received a copy of the GNU General Public License along |
3681 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
3682 | + * |
3683 | + * Author: Pete Woods <pete.woods@canonical.com> |
3684 | + */ |
3685 | + |
3686 | +#include <indicator-network-test-base.h> |
3687 | +#include <dbus-types.h> |
3688 | + |
3689 | +using namespace QtDBusTest; |
3690 | +using namespace QtDBusMock; |
3691 | +using namespace std; |
3692 | +using namespace testing; |
3693 | +namespace mh = menuharness; |
3694 | + |
3695 | +IndicatorNetworkTestBase::IndicatorNetworkTestBase() : |
3696 | + dbusMock(dbusTestRunner) |
3697 | +{ |
3698 | +} |
3699 | + |
3700 | +IndicatorNetworkTestBase::~IndicatorNetworkTestBase() |
3701 | +{ |
3702 | +} |
3703 | + |
3704 | +void IndicatorNetworkTestBase::SetUp() |
3705 | +{ |
3706 | + if (qEnvironmentVariableIsSet("TEST_WITH_BUSTLE")) |
3707 | + { |
3708 | + const TestInfo* const test_info = |
3709 | + UnitTest::GetInstance()->current_test_info(); |
3710 | + |
3711 | + QDir::temp().mkpath("indicator-network-tests"); |
3712 | + QDir testDir(QDir::temp().filePath("indicator-network-tests")); |
3713 | + |
3714 | + dbusTestRunner.registerService( |
3715 | + DBusServicePtr( |
3716 | + new QProcessDBusService( |
3717 | + "", QDBusConnection::SessionBus, |
3718 | + "/usr/bin/bustle-pcap", |
3719 | + QStringList{"-e", testDir.filePath(QString("%1-%2").arg(test_info->name(), "session.log"))}))); |
3720 | + dbusTestRunner.registerService( |
3721 | + DBusServicePtr( |
3722 | + new QProcessDBusService( |
3723 | + "", QDBusConnection::SystemBus, |
3724 | + "/usr/bin/bustle-pcap", |
3725 | + QStringList{"-y", testDir.filePath(QString("%1-%2").arg(test_info->name(), "system.log"))}))); |
3726 | + } |
3727 | + |
3728 | + dbusMock.registerNetworkManager(); |
3729 | + dbusMock.registerNotificationDaemon(); |
3730 | + // By default the ofono mock starts with one modem |
3731 | + dbusMock.registerOfono(); |
3732 | + dbusMock.registerURfkill(); |
3733 | + |
3734 | + dbusTestRunner.startServices(); |
3735 | + |
3736 | + // Identify the test when looking at Bustle logs |
3737 | + QDBusConnection systemConnection = dbusTestRunner.systemConnection(); |
3738 | + systemConnection.registerService("org.TestIndicatorNetworkService"); |
3739 | + QDBusConnection sessionConnection = dbusTestRunner.sessionConnection(); |
3740 | + sessionConnection.registerService("org.TestIndicatorNetworkService"); |
3741 | +} |
3742 | + |
3743 | +mh::MenuMatcher::Parameters IndicatorNetworkTestBase::phoneParameters() |
3744 | +{ |
3745 | + return mh::MenuMatcher::Parameters( |
3746 | + "com.canonical.indicator.network", |
3747 | + { { "indicator", "/com/canonical/indicator/network" } }, |
3748 | + "/com/canonical/indicator/network/phone"); |
3749 | +} |
3750 | + |
3751 | +mh::MenuMatcher::Parameters IndicatorNetworkTestBase::unlockSimParameters(std::string const& busName, int exportId) |
3752 | +{ |
3753 | + return mh::MenuMatcher::Parameters( |
3754 | + busName, |
3755 | + { { "notifications", "/com/canonical/indicator/network/unlocksim" + to_string(exportId) } }, |
3756 | + "/com/canonical/indicator/network/unlocksim" + to_string(exportId)); |
3757 | +} |
3758 | + |
3759 | +void IndicatorNetworkTestBase::startIndicator() |
3760 | +{ |
3761 | + try |
3762 | + { |
3763 | + indicator.reset( |
3764 | + new QProcessDBusService(DBusTypes::DBUS_NAME, |
3765 | + QDBusConnection::SessionBus, |
3766 | + NETWORK_SERVICE_BIN, |
3767 | + QStringList())); |
3768 | + indicator->start(dbusTestRunner.sessionConnection()); |
3769 | + } |
3770 | + catch (exception const& e) |
3771 | + { |
3772 | + cout << "startIndicator(): " << e.what() << endl; |
3773 | + throw; |
3774 | + } |
3775 | +} |
3776 | + |
3777 | +QString IndicatorNetworkTestBase::createWiFiDevice(int state, const QString& id) |
3778 | +{ |
3779 | + auto& networkManager(dbusMock.networkManagerInterface()); |
3780 | + auto reply = networkManager.AddWiFiDevice(id, "eth1", state); |
3781 | + reply.waitForFinished(); |
3782 | + return reply; |
3783 | +} |
3784 | + |
3785 | +QString IndicatorNetworkTestBase::randomMac() |
3786 | +{ |
3787 | + int high = 254; |
3788 | + int low = 1; |
3789 | + QString hardwareAddress; |
3790 | + bool first = true; |
3791 | + |
3792 | + for (unsigned int i = 0; i < 6; ++i) |
3793 | + { |
3794 | + if (!first) |
3795 | + { |
3796 | + hardwareAddress.append(":"); |
3797 | + } |
3798 | + int r = qrand() % ((high + 1) - low) + low; |
3799 | + hardwareAddress.append(QString("%1").arg(r, 2, 16, QChar('0'))); |
3800 | + first = false; |
3801 | + } |
3802 | + |
3803 | + return hardwareAddress; |
3804 | +} |
3805 | + |
3806 | +void IndicatorNetworkTestBase::enableWiFi() |
3807 | +{ |
3808 | + auto& urfkillInterface = dbusMock.urfkillInterface(); |
3809 | + urfkillInterface.Block(1, false).waitForFinished(); |
3810 | +} |
3811 | + |
3812 | +void IndicatorNetworkTestBase::disableWiFi() |
3813 | +{ |
3814 | + auto& urfkillInterface = dbusMock.urfkillInterface(); |
3815 | + urfkillInterface.Block(1, true).waitForFinished(); |
3816 | +} |
3817 | + |
3818 | +QString IndicatorNetworkTestBase::createAccessPoint(const QString& id, const QString& ssid, const QString& device, int strength, |
3819 | + Secure secure, ApMode apMode) |
3820 | +{ |
3821 | + |
3822 | + auto& networkManager(dbusMock.networkManagerInterface()); |
3823 | + auto reply = networkManager.AddAccessPoint( |
3824 | + device, id, ssid, |
3825 | + randomMac(), |
3826 | + apMode == ApMode::adhoc ? NM_802_11_MODE_ADHOC : NM_802_11_MODE_INFRA, |
3827 | + 0, 0, strength, |
3828 | + secure == Secure::secure ? NM_802_11_AP_SEC_KEY_MGMT_PSK : NM_802_11_AP_SEC_NONE); |
3829 | + reply.waitForFinished(); |
3830 | + return reply; |
3831 | +} |
3832 | + |
3833 | +void IndicatorNetworkTestBase::removeAccessPoint(const QString& device, const QString& ap) |
3834 | +{ |
3835 | + auto& nm = dbusMock.networkManagerInterface(); |
3836 | + nm.RemoveAccessPoint(device, ap).waitForFinished(); |
3837 | +} |
3838 | + |
3839 | +QString IndicatorNetworkTestBase::createAccessPointConnection(const QString& id, const QString& ssid, const QString& device) |
3840 | +{ |
3841 | + auto& networkManager(dbusMock.networkManagerInterface()); |
3842 | + auto reply = networkManager.AddWiFiConnection(device, id, ssid, |
3843 | + ""); |
3844 | + reply.waitForFinished(); |
3845 | + return reply; |
3846 | +} |
3847 | + |
3848 | +void IndicatorNetworkTestBase::removeWifiConnection(const QString& device, const QString& connection) |
3849 | +{ |
3850 | + auto& nm = dbusMock.networkManagerInterface(); |
3851 | + nm.RemoveWifiConnection(device, connection).waitForFinished(); |
3852 | +} |
3853 | + |
3854 | +QString IndicatorNetworkTestBase::createActiveConnection(const QString& id, const QString& device, const QString& connection, const QString& ap) |
3855 | +{ |
3856 | + auto& nm = dbusMock.networkManagerInterface(); |
3857 | + auto reply = nm.AddActiveConnection(QStringList() << device, |
3858 | + connection, |
3859 | + ap, |
3860 | + id, |
3861 | + NM_ACTIVE_CONNECTION_STATE_ACTIVATED); |
3862 | + reply.waitForFinished(); |
3863 | + return reply; |
3864 | +} |
3865 | + |
3866 | +void IndicatorNetworkTestBase::removeActiveConnection(const QString& device, const QString& active_connection) |
3867 | +{ |
3868 | + auto& nm = dbusMock.networkManagerInterface(); |
3869 | + nm.RemoveActiveConnection(device, active_connection).waitForFinished(); |
3870 | +} |
3871 | + |
3872 | +void IndicatorNetworkTestBase::setGlobalConnectedState(int state) |
3873 | +{ |
3874 | + auto& nm = dbusMock.networkManagerInterface(); |
3875 | + nm.SetGlobalConnectionState(state).waitForFinished(); |
3876 | +} |
3877 | + |
3878 | +void IndicatorNetworkTestBase::setNmProperty(const QString& path, const QString& iface, const QString& name, const QVariant& value) |
3879 | +{ |
3880 | + auto& nm = dbusMock.networkManagerInterface(); |
3881 | + nm.SetProperty(path, iface, name, QDBusVariant(value)).waitForFinished(); |
3882 | +} |
3883 | + |
3884 | +QString IndicatorNetworkTestBase::createModem(const QString& id) |
3885 | +{ |
3886 | + auto& ofono(dbusMock.ofonoInterface()); |
3887 | + QVariantMap modemProperties {{ "Powered", false } }; |
3888 | + return ofono.AddModem(id, modemProperties); |
3889 | +} |
3890 | + |
3891 | +void IndicatorNetworkTestBase::setModemProperty(const QString& path, const QString& propertyName, const QVariant& value) |
3892 | +{ |
3893 | + auto& ofono(dbusMock.ofonoModemInterface(path)); |
3894 | + ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
3895 | +} |
3896 | + |
3897 | +void IndicatorNetworkTestBase::setSimManagerProperty(const QString& path, const QString& propertyName, const QVariant& value) |
3898 | +{ |
3899 | + auto& ofono(dbusMock.ofonoSimManagerInterface(path)); |
3900 | + ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
3901 | +} |
3902 | + |
3903 | +void IndicatorNetworkTestBase::setConnectionManagerProperty(const QString& path, const QString& propertyName, const QVariant& value) |
3904 | +{ |
3905 | + auto& ofono(dbusMock.ofonoConnectionManagerInterface(path)); |
3906 | + ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
3907 | +} |
3908 | + |
3909 | +void IndicatorNetworkTestBase::setNetworkRegistrationProperty(const QString& path, const QString& propertyName, const QVariant& value) |
3910 | +{ |
3911 | + auto& ofono(dbusMock.ofonoNetworkRegistrationInterface(path)); |
3912 | + ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
3913 | +} |
3914 | + |
3915 | +OrgFreedesktopDBusMockInterface& IndicatorNetworkTestBase::notificationsMockInterface() |
3916 | +{ |
3917 | + return dbusMock.mockInterface("org.freedesktop.Notifications", |
3918 | + "/org/freedesktop/Notifications", |
3919 | + "org.freedesktop.Notifications", |
3920 | + QDBusConnection::SessionBus); |
3921 | +} |
3922 | + |
3923 | +OrgFreedesktopDBusMockInterface& IndicatorNetworkTestBase::modemMockInterface(const QString& path) |
3924 | +{ |
3925 | + return dbusMock.mockInterface("org.ofono", |
3926 | + path, |
3927 | + "", |
3928 | + QDBusConnection::SystemBus); |
3929 | +} |
3930 | + |
3931 | +bool IndicatorNetworkTestBase::qDBusArgumentToMap(QVariant const& variant, QVariantMap& map) |
3932 | +{ |
3933 | + if (variant.canConvert<QDBusArgument>()) |
3934 | + { |
3935 | + QDBusArgument value(variant.value<QDBusArgument>()); |
3936 | + if (value.currentType() == QDBusArgument::MapType) |
3937 | + { |
3938 | + value >> map; |
3939 | + return true; |
3940 | + } |
3941 | + } |
3942 | + return false; |
3943 | +} |
3944 | + |
3945 | +QString IndicatorNetworkTestBase::firstModem() |
3946 | +{ |
3947 | + return "/ril_0"; |
3948 | +} |
3949 | + |
3950 | +mh::MenuItemMatcher IndicatorNetworkTestBase::flightModeSwitch(bool toggled) |
3951 | +{ |
3952 | + return mh::MenuItemMatcher::checkbox() |
3953 | + .label("Flight Mode") |
3954 | + .action("indicator.airplane.enabled") |
3955 | + .toggled(toggled); |
3956 | +} |
3957 | + |
3958 | +mh::MenuItemMatcher IndicatorNetworkTestBase::accessPoint(const string& ssid, Secure secure, |
3959 | + ApMode apMode, ConnectionStatus connectionStatus, int strength) |
3960 | +{ |
3961 | + return mh::MenuItemMatcher::checkbox() |
3962 | + .label(ssid) |
3963 | + .widget("unity.widgets.systemsettings.tablet.accesspoint") |
3964 | + .toggled(connectionStatus == ConnectionStatus::connected) |
3965 | + .pass_through_attribute( |
3966 | + "x-canonical-wifi-ap-strength-action", |
3967 | + shared_ptr<GVariant>(g_variant_new_byte(strength), &mh::gvariant_deleter)) |
3968 | + .boolean_attribute("x-canonical-wifi-ap-is-secure", secure == Secure::secure) |
3969 | + .boolean_attribute("x-canonical-wifi-ap-is-adhoc", apMode == ApMode::adhoc); |
3970 | +} |
3971 | + |
3972 | +mh::MenuItemMatcher IndicatorNetworkTestBase::wifiEnableSwitch(bool toggled) |
3973 | +{ |
3974 | + return mh::MenuItemMatcher::checkbox() |
3975 | + .label("Wi-Fi") |
3976 | + .action("indicator.wifi.enable") // This action is accessed by system-settings-ui, do not change it |
3977 | + .toggled(toggled); |
3978 | +} |
3979 | + |
3980 | +mh::MenuItemMatcher IndicatorNetworkTestBase::wifiSettings() |
3981 | +{ |
3982 | + return mh::MenuItemMatcher() |
3983 | + .label("Wi-Fi settingsā¦") |
3984 | + .action("indicator.wifi.settings"); |
3985 | +} |
3986 | + |
3987 | +mh::MenuItemMatcher IndicatorNetworkTestBase::modemInfo(const string& simIdentifier, const string& label, const string& statusIcon, bool locked) |
3988 | +{ |
3989 | + return mh::MenuItemMatcher() |
3990 | + .widget("com.canonical.indicator.network.modeminfoitem") |
3991 | + .pass_through_string_attribute("x-canonical-modem-sim-identifier-label-action", simIdentifier) |
3992 | + .pass_through_string_attribute("x-canonical-modem-connectivity-icon-action", "") |
3993 | + .pass_through_string_attribute("x-canonical-modem-status-label-action", label) |
3994 | + .pass_through_string_attribute("x-canonical-modem-status-icon-action", statusIcon) |
3995 | + .pass_through_boolean_attribute("x-canonical-modem-roaming-action", false) |
3996 | + .pass_through_boolean_attribute("x-canonical-modem-locked-action", locked); |
3997 | +} |
3998 | + |
3999 | +mh::MenuItemMatcher IndicatorNetworkTestBase::cellularSettings() |
4000 | +{ |
4001 | + return mh::MenuItemMatcher() |
4002 | + .label("Cellular settingsā¦") |
4003 | + .action("indicator.cellular.settings"); |
4004 | +} |
4005 | + |
4006 | |
4007 | === added file 'tests/integration/indicator-network-test-base.h' |
4008 | --- tests/integration/indicator-network-test-base.h 1970-01-01 00:00:00 +0000 |
4009 | +++ tests/integration/indicator-network-test-base.h 2015-04-23 13:23:11 +0000 |
4010 | @@ -0,0 +1,156 @@ |
4011 | +/* |
4012 | + * Copyright (C) 2015 Canonical, Ltd. |
4013 | + * |
4014 | + * This program is free software: you can redistribute it and/or modify it |
4015 | + * under the terms of the GNU General Public License version 3, as published |
4016 | + * by the Free Software Foundation. |
4017 | + * |
4018 | + * This program is distributed in the hope that it will be useful, but |
4019 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
4020 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4021 | + * PURPOSE. See the GNU General Public License for more details. |
4022 | + * |
4023 | + * You should have received a copy of the GNU General Public License along |
4024 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
4025 | + * |
4026 | + * Author: Pete Woods <pete.woods@canonical.com> |
4027 | + */ |
4028 | + |
4029 | +#pragma once |
4030 | + |
4031 | +#include <libqtdbustest/DBusTestRunner.h> |
4032 | +#include <libqtdbustest/QProcessDBusService.h> |
4033 | +#include <libqtdbusmock/DBusMock.h> |
4034 | + |
4035 | +#include <menuharness/MatchUtils.h> |
4036 | +#include <menuharness/MenuMatcher.h> |
4037 | + |
4038 | +#include <NetworkManager.h> |
4039 | +#include <gmock/gmock.h> |
4040 | +#include <gtest/gtest.h> |
4041 | + |
4042 | +inline void PrintTo(const QVariant& variant, std::ostream* os) { |
4043 | + *os << "QVariant(" << variant.toString().toStdString() << ")"; |
4044 | +} |
4045 | + |
4046 | +#define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\ |
4047 | +{\ |
4048 | + while (signalSpy.size() < signalsExpected)\ |
4049 | + {\ |
4050 | + ASSERT_TRUE(signalSpy.wait());\ |
4051 | + }\ |
4052 | + ASSERT_EQ(signalsExpected, signalSpy.size());\ |
4053 | +} |
4054 | + |
4055 | +#define CHECK_METHOD_CALL(signalSpy, signalIndex, methodName, ...)\ |
4056 | +{\ |
4057 | + QVariantList const& call(signalSpy.at(signalIndex));\ |
4058 | + EXPECT_EQ(methodName, call.at(0));\ |
4059 | + auto arguments = vector<pair<int, QVariant>>{__VA_ARGS__};\ |
4060 | + if (!arguments.empty())\ |
4061 | + {\ |
4062 | + QVariantList const& args(call.at(1).toList());\ |
4063 | + ASSERT_LE(arguments.back().first + 1, args.size());\ |
4064 | + for (auto const& argument : arguments)\ |
4065 | + {\ |
4066 | + EXPECT_EQ(argument.second, args.at(argument.first));\ |
4067 | + }\ |
4068 | + }\ |
4069 | +} |
4070 | + |
4071 | +class IndicatorNetworkTestBase: public testing::Test |
4072 | +{ |
4073 | +public: |
4074 | + enum class Secure |
4075 | + { |
4076 | + secure, |
4077 | + insecure |
4078 | + }; |
4079 | + |
4080 | + enum class ApMode |
4081 | + { |
4082 | + infra, |
4083 | + adhoc |
4084 | + }; |
4085 | + |
4086 | + enum class ConnectionStatus |
4087 | + { |
4088 | + connected, |
4089 | + disconnected |
4090 | + }; |
4091 | + |
4092 | + IndicatorNetworkTestBase(); |
4093 | + |
4094 | + ~IndicatorNetworkTestBase(); |
4095 | + |
4096 | +protected: |
4097 | + void SetUp() override; |
4098 | + |
4099 | + static menuharness::MenuMatcher::Parameters phoneParameters(); |
4100 | + |
4101 | + static menuharness::MenuMatcher::Parameters unlockSimParameters(std::string const& busName, int exportId); |
4102 | + |
4103 | + void startIndicator(); |
4104 | + |
4105 | + QString createWiFiDevice(int state, const QString& id = "0"); |
4106 | + |
4107 | + static QString randomMac(); |
4108 | + |
4109 | + void enableWiFi(); |
4110 | + |
4111 | + void disableWiFi(); |
4112 | + |
4113 | + QString createAccessPoint(const QString& id, const QString& ssid, const QString& device, int strength = 100, |
4114 | + Secure secure = Secure::secure, ApMode apMode = ApMode::infra); |
4115 | + |
4116 | + void removeAccessPoint(const QString& device, const QString& ap); |
4117 | + |
4118 | + QString createAccessPointConnection(const QString& id, const QString& ssid, const QString& device); |
4119 | + |
4120 | + void removeWifiConnection(const QString& device, const QString& connection); |
4121 | + |
4122 | + QString createActiveConnection(const QString& id, const QString& device, const QString& connection, const QString& ap); |
4123 | + |
4124 | + void removeActiveConnection(const QString& device, const QString& active_connection); |
4125 | + |
4126 | + void setGlobalConnectedState(int state); |
4127 | + |
4128 | + void setNmProperty(const QString& path, const QString& iface, const QString& name, const QVariant& value); |
4129 | + |
4130 | + QString createModem(const QString& id); |
4131 | + |
4132 | + void setModemProperty(const QString& path, const QString& propertyName, const QVariant& value); |
4133 | + |
4134 | + void setSimManagerProperty(const QString& path, const QString& propertyName, const QVariant& value); |
4135 | + |
4136 | + void setConnectionManagerProperty(const QString& path, const QString& propertyName, const QVariant& value); |
4137 | + |
4138 | + void setNetworkRegistrationProperty(const QString& path, const QString& propertyName, const QVariant& value); |
4139 | + |
4140 | + OrgFreedesktopDBusMockInterface& notificationsMockInterface(); |
4141 | + |
4142 | + OrgFreedesktopDBusMockInterface& modemMockInterface(const QString& path); |
4143 | + |
4144 | + static bool qDBusArgumentToMap(QVariant const& variant, QVariantMap& map); |
4145 | + |
4146 | + static QString firstModem(); |
4147 | + |
4148 | + static menuharness::MenuItemMatcher flightModeSwitch(bool toggled = false); |
4149 | + |
4150 | + static menuharness::MenuItemMatcher accessPoint(const std::string& ssid, Secure secure, |
4151 | + ApMode apMode, ConnectionStatus connectionStatus, int strength = 100); |
4152 | + |
4153 | + static menuharness::MenuItemMatcher wifiEnableSwitch(bool toggled = true); |
4154 | + |
4155 | + static menuharness::MenuItemMatcher wifiSettings(); |
4156 | + |
4157 | + static menuharness::MenuItemMatcher modemInfo(const std::string& simIdentifier, const std::string& label, const std::string& statusIcon, bool locked = false); |
4158 | + |
4159 | + static menuharness::MenuItemMatcher cellularSettings(); |
4160 | + |
4161 | + QtDBusTest::DBusTestRunner dbusTestRunner; |
4162 | + |
4163 | + QtDBusMock::DBusMock dbusMock; |
4164 | + |
4165 | + QtDBusTest::DBusServicePtr indicator; |
4166 | +}; |
4167 | |
4168 | === added file 'tests/integration/test-connectivity-api.cpp' |
4169 | --- tests/integration/test-connectivity-api.cpp 1970-01-01 00:00:00 +0000 |
4170 | +++ tests/integration/test-connectivity-api.cpp 2015-04-23 13:23:11 +0000 |
4171 | @@ -0,0 +1,289 @@ |
4172 | +/* |
4173 | + * Copyright (C) 2015 Canonical, Ltd. |
4174 | + * |
4175 | + * This program is free software: you can redistribute it and/or modify it |
4176 | + * under the terms of the GNU General Public License version 3, as published |
4177 | + * by the Free Software Foundation. |
4178 | + * |
4179 | + * This program is distributed in the hope that it will be useful, but |
4180 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
4181 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
4182 | + * PURPOSE. See the GNU General Public License for more details. |
4183 | + * |
4184 | + * You should have received a copy of the GNU General Public License along |
4185 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
4186 | + * |
4187 | + * Author: Pete Woods <pete.woods@canonical.com> |
4188 | + */ |
4189 | + |
4190 | +#include <indicator-network-test-base.h> |
4191 | +#include <connectivityqt/connectivity.h> |
4192 | +#include <dbus-types.h> |
4193 | + |
4194 | +#include <QDebug> |
4195 | +#include <QTestEventLoop> |
4196 | +#include <QSignalSpy> |
4197 | + |
4198 | +using namespace std; |
4199 | +using namespace testing; |
4200 | +using namespace connectivityqt; |
4201 | + |
4202 | +namespace |
4203 | +{ |
4204 | + |
4205 | +class TestConnectivityApi: public IndicatorNetworkTestBase |
4206 | +{ |
4207 | +protected: |
4208 | + Connectivity::UPtr newConnectivity() |
4209 | + { |
4210 | + auto connectivity = make_unique<Connectivity>(dbusTestRunner.sessionConnection()); |
4211 | + |
4212 | + if (!connectivity->isInitialized()) |
4213 | + { |
4214 | + QSignalSpy initSpy(connectivity.get(), SIGNAL(initialized())); |
4215 | + initSpy.wait(); |
4216 | + } |
4217 | + |
4218 | + return connectivity; |
4219 | + } |
4220 | +}; |
4221 | + |
4222 | +TEST_F(TestConnectivityApi, FollowsFlightMode) |
4223 | +{ |
4224 | + // Set up disconnected with flight mode on |
4225 | + setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4226 | + ASSERT_TRUE(dbusMock.urfkillInterface().FlightMode(true)); |
4227 | + |
4228 | + // Start the indicator |
4229 | + ASSERT_NO_THROW(startIndicator()); |
4230 | + |
4231 | + // Connect to the service |
4232 | + auto connectivity(newConnectivity()); |
4233 | + |
4234 | + // Check flight mode is enabled |
4235 | + EXPECT_TRUE(connectivity->flightMode()); |
4236 | + |
4237 | + // Now disable flight mode |
4238 | + ASSERT_TRUE(dbusMock.urfkillInterface().FlightMode(false)); |
4239 | + |
4240 | + // Check that flight mode gets updated |
4241 | + { |
4242 | + QSignalSpy spy(connectivity.get(), SIGNAL(flightModeUpdated(bool))); |
4243 | + ASSERT_TRUE(spy.wait()); |
4244 | + ASSERT_EQ(1, spy.size()); |
4245 | + } |
4246 | + // Check that flight mode is disabled |
4247 | + EXPECT_FALSE(connectivity->flightMode()); |
4248 | +} |
4249 | + |
4250 | +TEST_F(TestConnectivityApi, FlightModeTalksToURfkill) |
4251 | +{ |
4252 | + // Start the indicator |
4253 | + ASSERT_NO_THROW(startIndicator()); |
4254 | + |
4255 | + // Connect to the UrfKill mock |
4256 | + auto& urfkillInterface = dbusMock.urfkillInterface(); |
4257 | + QSignalSpy urfkillSpy(&urfkillInterface, SIGNAL(FlightModeChanged(bool))); |
4258 | + |
4259 | + // Connect the the service |
4260 | + auto connectivity(newConnectivity()); |
4261 | + |
4262 | + // Follow the flightMode property |
4263 | + QSignalSpy flightModeSpy(connectivity.get(), SIGNAL(flightModeUpdated(bool))); |
4264 | + |
4265 | + // Follow the unstoppableOperationHappening property |
4266 | + QSignalSpy operationSpy(connectivity.get(), SIGNAL(unstoppableOperationHappeningUpdated(bool))); |
4267 | + |
4268 | + // Check that nothing is happening yet |
4269 | + EXPECT_FALSE(connectivity->unstoppableOperationHappening()); |
4270 | + |
4271 | + // Enable flight mode |
4272 | + connectivity->setFlightMode(true); |
4273 | + |
4274 | + // We should first get the unstoppable operation change |
4275 | + ASSERT_TRUE(operationSpy.wait()); |
4276 | + ASSERT_EQ(1, operationSpy.size()); |
4277 | + EXPECT_EQ(operationSpy.first(), QVariantList() << QVariant(true)); |
4278 | + |
4279 | + // Wait to be notified that flight mode was enabled |
4280 | + if (urfkillSpy.size() != 1) |
4281 | + { |
4282 | + ASSERT_TRUE(urfkillSpy.wait()); |
4283 | + } |
4284 | + ASSERT_EQ(1, urfkillSpy.size()); |
4285 | + EXPECT_EQ(urfkillSpy.first(), QVariantList() << QVariant(true)); |
4286 | + |
4287 | + // The unstoppable operation should complete |
4288 | + if (operationSpy.size() != 2) |
4289 | + { |
4290 | + ASSERT_TRUE(operationSpy.wait()); |
4291 | + } |
4292 | + ASSERT_EQ(2, operationSpy.size()); |
4293 | + EXPECT_EQ(operationSpy.last(), QVariantList() << QVariant(false)); |
4294 | + |
4295 | + // Wait for flight mode property change |
4296 | + if (flightModeSpy.size() != 1) |
4297 | + { |
4298 | + ASSERT_TRUE(flightModeSpy.wait()); |
4299 | + } |
4300 | + ASSERT_EQ(1, flightModeSpy.size()); |
4301 | + EXPECT_EQ(flightModeSpy.first(), QVariantList() << QVariant(true)); |
4302 | + |
4303 | + // Check that nothing is happening again |
4304 | + EXPECT_FALSE(connectivity->unstoppableOperationHappening()); |
4305 | + |
4306 | + // The icing on the cake |
4307 | + EXPECT_TRUE(connectivity->flightMode()); |
4308 | + |
4309 | + // Start again |
4310 | + urfkillSpy.clear(); |
4311 | + operationSpy.clear(); |
4312 | + flightModeSpy.clear(); |
4313 | + |
4314 | + // Disable flight mode |
4315 | + connectivity->setFlightMode(false); |
4316 | + |
4317 | + // We should first get the unstoppable operation change |
4318 | + ASSERT_TRUE(operationSpy.wait()); |
4319 | + ASSERT_EQ(1, operationSpy.size()); |
4320 | + EXPECT_EQ(operationSpy.first(), QVariantList() << QVariant(true)); |
4321 | + |
4322 | + // Wait to be notified that flight mode was disabled |
4323 | + if (urfkillSpy.size() != 1) |
4324 | + { |
4325 | + ASSERT_TRUE(urfkillSpy.wait()); |
4326 | + } |
4327 | + ASSERT_EQ(1, urfkillSpy.size()); |
4328 | + EXPECT_EQ(urfkillSpy.first(), QVariantList() << QVariant(false)); |
4329 | + |
4330 | + // The unstoppable operation should complete |
4331 | + if (operationSpy.size() != 2) |
4332 | + { |
4333 | + ASSERT_TRUE(operationSpy.wait()); |
4334 | + } |
4335 | + ASSERT_EQ(2, operationSpy.size()); |
4336 | + EXPECT_EQ(operationSpy.last(), QVariantList() << QVariant(false)); |
4337 | + |
4338 | + // Wait for flight mode property change |
4339 | + if (flightModeSpy.size() != 1) |
4340 | + { |
4341 | + ASSERT_TRUE(flightModeSpy.wait()); |
4342 | + } |
4343 | + ASSERT_EQ(1, flightModeSpy.size()); |
4344 | + EXPECT_EQ(flightModeSpy.first(), QVariantList() << QVariant(false)); |
4345 | + |
4346 | + // Check that nothing is happening again |
4347 | + EXPECT_FALSE(connectivity->unstoppableOperationHappening()); |
4348 | + |
4349 | + // The icing on the cake |
4350 | + EXPECT_FALSE(connectivity->flightMode()); |
4351 | +} |
4352 | + |
4353 | +TEST_F(TestConnectivityApi, WifiToggleTalksToUrfkill) |
4354 | +{ |
4355 | + // Start the indicator |
4356 | + ASSERT_NO_THROW(startIndicator()); |
4357 | + |
4358 | + // Connect to the UrfKill mock |
4359 | + OrgFreedesktopURfkillKillswitchInterface wifiKillswitchInterface( |
4360 | + DBusTypes::URFKILL_BUS_NAME, DBusTypes::URFKILL_WIFI_OBJ_PATH, |
4361 | + dbusTestRunner.systemConnection()); |
4362 | + QSignalSpy urfkillSpy(&wifiKillswitchInterface, SIGNAL(StateChanged())); |
4363 | + |
4364 | + // Connect the the service |
4365 | + auto connectivity(newConnectivity()); |
4366 | + |
4367 | + // Follow the wifiEnabled property |
4368 | + QSignalSpy wifiEnabledSpy(connectivity.get(), SIGNAL(wifiEnabledUpdated(bool))); |
4369 | + |
4370 | + // Follow the unstoppableOperationHappening property |
4371 | + QSignalSpy operationSpy(connectivity.get(), SIGNAL(unstoppableOperationHappeningUpdated(bool))); |
4372 | + |
4373 | + // Check that nothing is happening yet |
4374 | + EXPECT_FALSE(connectivity->unstoppableOperationHappening()); |
4375 | + EXPECT_TRUE(connectivity->wifiEnabled()); |
4376 | + EXPECT_EQ(0, wifiKillswitchInterface.state()); |
4377 | + |
4378 | + // Disable WiFi |
4379 | + connectivity->setwifiEnabled(false); |
4380 | + |
4381 | + // We should first get the unstoppable operation change |
4382 | + ASSERT_TRUE(operationSpy.wait()); |
4383 | + ASSERT_EQ(1, operationSpy.size()); |
4384 | + EXPECT_EQ(operationSpy.first(), QVariantList() << QVariant(true)); |
4385 | + |
4386 | + // Wait to be notified that wifi was toggled |
4387 | + if (urfkillSpy.size() != 1) |
4388 | + { |
4389 | + ASSERT_TRUE(urfkillSpy.wait()); |
4390 | + } |
4391 | + ASSERT_EQ(1, urfkillSpy.size()); |
4392 | + |
4393 | + // The unstoppable operation should complete |
4394 | + if (operationSpy.size() != 2) |
4395 | + { |
4396 | + ASSERT_TRUE(operationSpy.wait()); |
4397 | + } |
4398 | + ASSERT_EQ(2, operationSpy.size()); |
4399 | + EXPECT_EQ(operationSpy.last(), QVariantList() << QVariant(false)); |
4400 | + |
4401 | + // Wait for wifi enabled property change |
4402 | + if (wifiEnabledSpy.size() != 1) |
4403 | + { |
4404 | + ASSERT_TRUE(wifiEnabledSpy.wait()); |
4405 | + } |
4406 | + ASSERT_EQ(1, wifiEnabledSpy.size()); |
4407 | + EXPECT_EQ(wifiEnabledSpy.first(), QVariantList() << QVariant(false)); |
4408 | + |
4409 | + // Check that nothing is happening again |
4410 | + EXPECT_FALSE(connectivity->unstoppableOperationHappening()); |
4411 | + |
4412 | + // The icing on the cake |
4413 | + EXPECT_FALSE(connectivity->wifiEnabled()); |
4414 | + EXPECT_EQ(1, wifiKillswitchInterface.state()); |
4415 | + |
4416 | + // Start again |
4417 | + urfkillSpy.clear(); |
4418 | + operationSpy.clear(); |
4419 | + wifiEnabledSpy.clear(); |
4420 | + |
4421 | + // Disable flight mode |
4422 | + connectivity->setwifiEnabled(true); |
4423 | + |
4424 | + // We should first get the unstoppable operation change |
4425 | + ASSERT_TRUE(operationSpy.wait()); |
4426 | + ASSERT_EQ(1, operationSpy.size()); |
4427 | + EXPECT_EQ(operationSpy.first(), QVariantList() << QVariant(true)); |
4428 | + |
4429 | + // Wait to be notified that wifi was toggled |
4430 | + if (urfkillSpy.size() != 1) |
4431 | + { |
4432 | + ASSERT_TRUE(urfkillSpy.wait()); |
4433 | + } |
4434 | + ASSERT_EQ(1, urfkillSpy.size()); |
4435 | + |
4436 | + // The unstoppable operation should complete |
4437 | + if (operationSpy.size() != 2) |
4438 | + { |
4439 | + ASSERT_TRUE(operationSpy.wait()); |
4440 | + } |
4441 | + ASSERT_EQ(2, operationSpy.size()); |
4442 | + EXPECT_EQ(operationSpy.last(), QVariantList() << QVariant(false)); |
4443 | + |
4444 | + // Wait for wifi enabled property change |
4445 | + if (wifiEnabledSpy.size() != 1) |
4446 | + { |
4447 | + ASSERT_TRUE(wifiEnabledSpy.wait()); |
4448 | + } |
4449 | + ASSERT_EQ(1, wifiEnabledSpy.size()); |
4450 | + EXPECT_EQ(wifiEnabledSpy.first(), QVariantList() << QVariant(true)); |
4451 | + |
4452 | + // Check that nothing is happening again |
4453 | + EXPECT_FALSE(connectivity->unstoppableOperationHappening()); |
4454 | + |
4455 | + // The icing on the cake |
4456 | + EXPECT_TRUE(connectivity->wifiEnabled()); |
4457 | + EXPECT_EQ(0, wifiKillswitchInterface.state()); |
4458 | +} |
4459 | + |
4460 | +} |
4461 | |
4462 | === renamed file 'tests/integration/indicator/TestIndicatorNetworkService.cpp' => 'tests/integration/test-indicator.cpp' |
4463 | --- tests/integration/indicator/TestIndicatorNetworkService.cpp 2015-03-27 08:34:44 +0000 |
4464 | +++ tests/integration/test-indicator.cpp 2015-04-23 13:23:11 +0000 |
4465 | @@ -1,5 +1,5 @@ |
4466 | /* |
4467 | - * Copyright (C) 2013 Canonical, Ltd. |
4468 | + * Copyright (C) 2015 Canonical, Ltd. |
4469 | * |
4470 | * This program is free software: you can redistribute it and/or modify it |
4471 | * under the terms of the GNU General Public License version 3, as published |
4472 | @@ -16,397 +16,24 @@ |
4473 | * Author: Pete Woods <pete.woods@canonical.com> |
4474 | */ |
4475 | |
4476 | -#include <libqtdbustest/DBusTestRunner.h> |
4477 | -#include <libqtdbustest/QProcessDBusService.h> |
4478 | -#include <libqtdbusmock/DBusMock.h> |
4479 | - |
4480 | -#include <menuharness/MatchUtils.h> |
4481 | -#include <menuharness/MenuMatcher.h> |
4482 | - |
4483 | -#include <NetworkManager.h> |
4484 | +#include <indicator-network-test-base.h> |
4485 | |
4486 | #include <QDebug> |
4487 | #include <QTestEventLoop> |
4488 | #include <QSignalSpy> |
4489 | |
4490 | -#include <gmock/gmock.h> |
4491 | -#include <gtest/gtest.h> |
4492 | - |
4493 | -void PrintTo(const QVariant& variant, std::ostream* os) { |
4494 | - *os << "QVariant(" << variant.toString().toStdString() << ")"; |
4495 | -} |
4496 | - |
4497 | - |
4498 | -#define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\ |
4499 | -{\ |
4500 | - while (signalSpy.size() < signalsExpected)\ |
4501 | - {\ |
4502 | - ASSERT_TRUE(signalSpy.wait());\ |
4503 | - }\ |
4504 | - ASSERT_EQ(signalsExpected, signalSpy.size());\ |
4505 | -} |
4506 | - |
4507 | -#define CHECK_METHOD_CALL(signalSpy, signalIndex, methodName, ...)\ |
4508 | -{\ |
4509 | - QVariantList const& call(signalSpy.at(signalIndex));\ |
4510 | - EXPECT_EQ(methodName, call.at(0));\ |
4511 | - auto arguments = vector<pair<int, QVariant>>{__VA_ARGS__};\ |
4512 | - if (!arguments.empty())\ |
4513 | - {\ |
4514 | - QVariantList const& args(call.at(1).toList());\ |
4515 | - ASSERT_LE(arguments.back().first + 1, args.size());\ |
4516 | - for (auto const& argument : arguments)\ |
4517 | - {\ |
4518 | - EXPECT_EQ(argument.second, args.at(argument.first));\ |
4519 | - }\ |
4520 | - }\ |
4521 | -} |
4522 | - |
4523 | using namespace std; |
4524 | using namespace testing; |
4525 | -using namespace QtDBusTest; |
4526 | -using namespace QtDBusMock; |
4527 | - |
4528 | namespace mh = menuharness; |
4529 | |
4530 | namespace |
4531 | { |
4532 | -enum class Secure |
4533 | -{ |
4534 | - secure, |
4535 | - insecure |
4536 | -}; |
4537 | - |
4538 | -enum class ApMode |
4539 | -{ |
4540 | - infra, |
4541 | - adhoc |
4542 | -}; |
4543 | - |
4544 | -enum class ConnectionStatus |
4545 | -{ |
4546 | - connected, |
4547 | - disconnected |
4548 | -}; |
4549 | - |
4550 | -class TestIndicatorNetworkService : public Test |
4551 | -{ |
4552 | -protected: |
4553 | - TestIndicatorNetworkService() : |
4554 | - dbusMock(dbusTestRunner) |
4555 | - { |
4556 | - } |
4557 | - |
4558 | - void SetUp() override |
4559 | - { |
4560 | - if (qEnvironmentVariableIsSet("TEST_WITH_BUSTLE")) |
4561 | - { |
4562 | - const TestInfo* const test_info = |
4563 | - UnitTest::GetInstance()->current_test_info(); |
4564 | - |
4565 | - QDir::temp().mkpath("indicator-network-tests"); |
4566 | - QDir testDir(QDir::temp().filePath("indicator-network-tests")); |
4567 | - |
4568 | - dbusTestRunner.registerService( |
4569 | - DBusServicePtr( |
4570 | - new QProcessDBusService( |
4571 | - "", QDBusConnection::SessionBus, |
4572 | - "/usr/bin/bustle-pcap", |
4573 | - QStringList{"-e", testDir.filePath(QString("%1-%2").arg(test_info->name(), "session.log"))}))); |
4574 | - dbusTestRunner.registerService( |
4575 | - DBusServicePtr( |
4576 | - new QProcessDBusService( |
4577 | - "", QDBusConnection::SystemBus, |
4578 | - "/usr/bin/bustle-pcap", |
4579 | - QStringList{"-y", testDir.filePath(QString("%1-%2").arg(test_info->name(), "system.log"))}))); |
4580 | - } |
4581 | - |
4582 | - dbusMock.registerNetworkManager(); |
4583 | - dbusMock.registerNotificationDaemon(); |
4584 | - // By default the ofono mock starts with one modem |
4585 | - dbusMock.registerOfono(); |
4586 | - dbusMock.registerURfkill(); |
4587 | - |
4588 | - dbusTestRunner.startServices(); |
4589 | - |
4590 | - // Identify the test when looking at Bustle logs |
4591 | - QDBusConnection systemConnection = dbusTestRunner.systemConnection(); |
4592 | - systemConnection.registerService("org.TestIndicatorNetworkService"); |
4593 | - QDBusConnection sessionConnection = dbusTestRunner.sessionConnection(); |
4594 | - sessionConnection.registerService("org.TestIndicatorNetworkService"); |
4595 | - } |
4596 | - |
4597 | - static mh::MenuMatcher::Parameters phoneParameters() |
4598 | - { |
4599 | - return mh::MenuMatcher::Parameters( |
4600 | - "com.canonical.indicator.network", |
4601 | - { { "indicator", "/com/canonical/indicator/network" } }, |
4602 | - "/com/canonical/indicator/network/phone"); |
4603 | - } |
4604 | - |
4605 | - mh::MenuMatcher::Parameters unlockSimParameters(std::string const& busName, int exportId) |
4606 | - { |
4607 | - return mh::MenuMatcher::Parameters( |
4608 | - busName, |
4609 | - { { "notifications", "/com/canonical/indicator/network/unlocksim" + to_string(exportId) } }, |
4610 | - "/com/canonical/indicator/network/unlocksim" + to_string(exportId)); |
4611 | - } |
4612 | - |
4613 | - void startIndicator() |
4614 | - { |
4615 | - try |
4616 | - { |
4617 | - indicator.reset( |
4618 | - new QProcessDBusService("com.canonical.indicator.network", |
4619 | - QDBusConnection::SessionBus, |
4620 | - NETWORK_SERVICE_BIN, |
4621 | - QStringList())); |
4622 | - indicator->start(dbusTestRunner.sessionConnection()); |
4623 | - } |
4624 | - catch (exception const& e) |
4625 | - { |
4626 | - cout << "startIndicator(): " << e.what() << endl; |
4627 | - throw; |
4628 | - } |
4629 | - } |
4630 | - |
4631 | - QString createWiFiDevice(int state, const QString& id = "0") |
4632 | - { |
4633 | - auto& networkManager(dbusMock.networkManagerInterface()); |
4634 | - auto reply = networkManager.AddWiFiDevice(id, "eth1", state); |
4635 | - reply.waitForFinished(); |
4636 | - return reply; |
4637 | - } |
4638 | - |
4639 | - static QString randomMac() |
4640 | - { |
4641 | - int high = 254; |
4642 | - int low = 1; |
4643 | - QString hardwareAddress; |
4644 | - bool first = true; |
4645 | - |
4646 | - for (unsigned int i = 0; i < 6; ++i) |
4647 | - { |
4648 | - if (!first) |
4649 | - { |
4650 | - hardwareAddress.append(":"); |
4651 | - } |
4652 | - int r = qrand() % ((high + 1) - low) + low; |
4653 | - hardwareAddress.append(QString("%1").arg(r, 2, 16, QChar('0'))); |
4654 | - first = false; |
4655 | - } |
4656 | - |
4657 | - return hardwareAddress; |
4658 | - } |
4659 | - |
4660 | - void enableWiFi() |
4661 | - { |
4662 | - auto& urfkillInterface = dbusMock.urfkillInterface(); |
4663 | - urfkillInterface.Block(1, false).waitForFinished(); |
4664 | - } |
4665 | - |
4666 | - void disableWiFi() |
4667 | - { |
4668 | - auto& urfkillInterface = dbusMock.urfkillInterface(); |
4669 | - urfkillInterface.Block(1, true).waitForFinished(); |
4670 | - } |
4671 | - |
4672 | - QString createAccessPoint(const QString& id, const QString& ssid, const QString& device, int strength = 100, |
4673 | - Secure secure = Secure::secure, ApMode apMode = ApMode::infra) |
4674 | - { |
4675 | - |
4676 | - auto& networkManager(dbusMock.networkManagerInterface()); |
4677 | - auto reply = networkManager.AddAccessPoint( |
4678 | - device, id, ssid, |
4679 | - randomMac(), |
4680 | - apMode == ApMode::adhoc ? NM_802_11_MODE_ADHOC : NM_802_11_MODE_INFRA, |
4681 | - 0, 0, strength, |
4682 | - secure == Secure::secure ? NM_802_11_AP_SEC_KEY_MGMT_PSK : NM_802_11_AP_SEC_NONE); |
4683 | - reply.waitForFinished(); |
4684 | - return reply; |
4685 | - } |
4686 | - |
4687 | - void removeAccessPoint(const QString& device, const QString& ap) |
4688 | - { |
4689 | - auto& nm = dbusMock.networkManagerInterface(); |
4690 | - nm.RemoveAccessPoint(device, ap).waitForFinished(); |
4691 | - } |
4692 | - |
4693 | - QString createAccessPointConnection(const QString& id, const QString& ssid, const QString& device) |
4694 | - { |
4695 | - auto& networkManager(dbusMock.networkManagerInterface()); |
4696 | - auto reply = networkManager.AddWiFiConnection(device, id, ssid, |
4697 | - ""); |
4698 | - reply.waitForFinished(); |
4699 | - return reply; |
4700 | - } |
4701 | - |
4702 | - void removeWifiConnection(const QString& device, const QString& connection) |
4703 | - { |
4704 | - auto& nm = dbusMock.networkManagerInterface(); |
4705 | - nm.RemoveWifiConnection(device, connection).waitForFinished(); |
4706 | - } |
4707 | - |
4708 | - QString createActiveConnection(const QString& id, const QString& device, const QString& connection, const QString& ap) |
4709 | - { |
4710 | - auto& nm = dbusMock.networkManagerInterface(); |
4711 | - auto reply = nm.AddActiveConnection(QStringList() << device, |
4712 | - connection, |
4713 | - ap, |
4714 | - id, |
4715 | - NM_ACTIVE_CONNECTION_STATE_ACTIVATED); |
4716 | - reply.waitForFinished(); |
4717 | - return reply; |
4718 | - } |
4719 | - |
4720 | - void removeActiveConnection(const QString& device, const QString& active_connection) |
4721 | - { |
4722 | - auto& nm = dbusMock.networkManagerInterface(); |
4723 | - nm.RemoveActiveConnection(device, active_connection).waitForFinished(); |
4724 | - } |
4725 | - |
4726 | - void setGlobalConnectedState(int state) |
4727 | - { |
4728 | - auto& nm = dbusMock.networkManagerInterface(); |
4729 | - nm.SetGlobalConnectionState(state).waitForFinished(); |
4730 | - } |
4731 | - |
4732 | - void setNmProperty(const QString& path, const QString& iface, const QString& name, const QVariant& value) |
4733 | - { |
4734 | - auto& nm = dbusMock.networkManagerInterface(); |
4735 | - nm.SetProperty(path, iface, name, QDBusVariant(value)).waitForFinished(); |
4736 | - } |
4737 | - |
4738 | - QString createModem(const QString& id) |
4739 | - { |
4740 | - auto& ofono(dbusMock.ofonoInterface()); |
4741 | - QVariantMap modemProperties {{ "Powered", false } }; |
4742 | - return ofono.AddModem(id, modemProperties); |
4743 | - } |
4744 | - |
4745 | - void setModemProperty(const QString& path, const QString& propertyName, const QVariant& value) |
4746 | - { |
4747 | - auto& ofono(dbusMock.ofonoModemInterface(path)); |
4748 | - ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
4749 | - } |
4750 | - |
4751 | - void setSimManagerProperty(const QString& path, const QString& propertyName, const QVariant& value) |
4752 | - { |
4753 | - auto& ofono(dbusMock.ofonoSimManagerInterface(path)); |
4754 | - ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
4755 | - } |
4756 | - |
4757 | - void setConnectionManagerProperty(const QString& path, const QString& propertyName, const QVariant& value) |
4758 | - { |
4759 | - auto& ofono(dbusMock.ofonoConnectionManagerInterface(path)); |
4760 | - ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
4761 | - } |
4762 | - |
4763 | - void setNetworkRegistrationProperty(const QString& path, const QString& propertyName, const QVariant& value) |
4764 | - { |
4765 | - auto& ofono(dbusMock.ofonoNetworkRegistrationInterface(path)); |
4766 | - ofono.SetProperty(propertyName, QDBusVariant(value)).waitForFinished(); |
4767 | - } |
4768 | - |
4769 | - OrgFreedesktopDBusMockInterface* notificationsMockInterface() |
4770 | - { |
4771 | - return &dbusMock.mockInterface("org.freedesktop.Notifications", |
4772 | - "/org/freedesktop/Notifications", |
4773 | - "org.freedesktop.Notifications", |
4774 | - QDBusConnection::SessionBus); |
4775 | - } |
4776 | - |
4777 | - OrgFreedesktopDBusMockInterface* modemMockInterface(const QString& path) |
4778 | - { |
4779 | - return &dbusMock.mockInterface("org.ofono", |
4780 | - path, |
4781 | - "", |
4782 | - QDBusConnection::SystemBus); |
4783 | - } |
4784 | - |
4785 | - bool qDBusArgumentToMap(QVariant const& variant, QVariantMap& map) |
4786 | - { |
4787 | - if (variant.canConvert<QDBusArgument>()) |
4788 | - { |
4789 | - QDBusArgument value(variant.value<QDBusArgument>()); |
4790 | - if (value.currentType() == QDBusArgument::MapType) |
4791 | - { |
4792 | - value >> map; |
4793 | - return true; |
4794 | - } |
4795 | - } |
4796 | - return false; |
4797 | - } |
4798 | - |
4799 | - QString firstModem() |
4800 | - { |
4801 | - return "/ril_0"; |
4802 | - } |
4803 | - |
4804 | - static mh::MenuItemMatcher flightModeSwitch(bool toggled = false) |
4805 | - { |
4806 | - return mh::MenuItemMatcher::checkbox() |
4807 | - .label("Flight Mode") |
4808 | - .action("indicator.airplane.enabled") |
4809 | - .toggled(toggled); |
4810 | - } |
4811 | - |
4812 | - static mh::MenuItemMatcher accessPoint(const string& ssid, Secure secure, |
4813 | - ApMode apMode, ConnectionStatus connectionStatus, int strength = 100) |
4814 | - { |
4815 | - return mh::MenuItemMatcher::checkbox() |
4816 | - .label(ssid) |
4817 | - .widget("unity.widgets.systemsettings.tablet.accesspoint") |
4818 | - .toggled(connectionStatus == ConnectionStatus::connected) |
4819 | - .pass_through_attribute( |
4820 | - "x-canonical-wifi-ap-strength-action", |
4821 | - shared_ptr<GVariant>(g_variant_new_byte(strength), &mh::gvariant_deleter)) |
4822 | - .boolean_attribute("x-canonical-wifi-ap-is-secure", secure == Secure::secure) |
4823 | - .boolean_attribute("x-canonical-wifi-ap-is-adhoc", apMode == ApMode::adhoc); |
4824 | - } |
4825 | - |
4826 | - static mh::MenuItemMatcher wifiEnableSwitch(bool toggled = true) |
4827 | - { |
4828 | - return mh::MenuItemMatcher::checkbox() |
4829 | - .label("Wi-Fi") |
4830 | - .action("indicator.wifi.enable") // This action is accessed by system-settings-ui, do not change it |
4831 | - .toggled(toggled); |
4832 | - } |
4833 | - |
4834 | - static mh::MenuItemMatcher wifiSettings() |
4835 | - { |
4836 | - return mh::MenuItemMatcher() |
4837 | - .label("Wi-Fi settingsā¦") |
4838 | - .action("indicator.wifi.settings"); |
4839 | - } |
4840 | - |
4841 | - static mh::MenuItemMatcher modemInfo(const string& simIdentifier, const string& label, const string& statusIcon, bool locked = false) |
4842 | - { |
4843 | - return mh::MenuItemMatcher() |
4844 | - .widget("com.canonical.indicator.network.modeminfoitem") |
4845 | - .pass_through_string_attribute("x-canonical-modem-sim-identifier-label-action", simIdentifier) |
4846 | - .pass_through_string_attribute("x-canonical-modem-connectivity-icon-action", "") |
4847 | - .pass_through_string_attribute("x-canonical-modem-status-label-action", label) |
4848 | - .pass_through_string_attribute("x-canonical-modem-status-icon-action", statusIcon) |
4849 | - .pass_through_boolean_attribute("x-canonical-modem-roaming-action", false) |
4850 | - .pass_through_boolean_attribute("x-canonical-modem-locked-action", locked); |
4851 | - } |
4852 | - |
4853 | - static mh::MenuItemMatcher cellularSettings() |
4854 | - { |
4855 | - return mh::MenuItemMatcher() |
4856 | - .label("Cellular settingsā¦") |
4857 | - .action("indicator.cellular.settings"); |
4858 | - } |
4859 | - |
4860 | - DBusTestRunner dbusTestRunner; |
4861 | - |
4862 | - DBusMock dbusMock; |
4863 | - |
4864 | - DBusServicePtr indicator; |
4865 | -}; |
4866 | - |
4867 | -TEST_F(TestIndicatorNetworkService, BasicMenuContents) |
4868 | + |
4869 | +class TestIndicator: public IndicatorNetworkTestBase |
4870 | +{ |
4871 | +}; |
4872 | + |
4873 | +TEST_F(TestIndicator, BasicMenuContents) |
4874 | { |
4875 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4876 | ASSERT_NO_THROW(startIndicator()); |
4877 | @@ -428,7 +55,7 @@ |
4878 | ).match()); |
4879 | } |
4880 | |
4881 | -TEST_F(TestIndicatorNetworkService, OneDisconnectedAccessPointAtStartup) |
4882 | +TEST_F(TestIndicator, OneDisconnectedAccessPointAtStartup) |
4883 | { |
4884 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4885 | auto device = createWiFiDevice(NM_DEVICE_STATE_DISCONNECTED); |
4886 | @@ -456,7 +83,7 @@ |
4887 | ).match()); |
4888 | } |
4889 | |
4890 | -TEST_F(TestIndicatorNetworkService, OneConnectedAccessPointAtStartup) |
4891 | +TEST_F(TestIndicator, OneConnectedAccessPointAtStartup) |
4892 | { |
4893 | setGlobalConnectedState(NM_STATE_CONNECTED_GLOBAL); |
4894 | auto device = createWiFiDevice(NM_DEVICE_STATE_ACTIVATED); |
4895 | @@ -485,7 +112,7 @@ |
4896 | ).match()); |
4897 | } |
4898 | |
4899 | -TEST_F(TestIndicatorNetworkService, AddOneDisconnectedAccessPointAfterStartup) |
4900 | +TEST_F(TestIndicator, AddOneDisconnectedAccessPointAfterStartup) |
4901 | { |
4902 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4903 | auto device = createWiFiDevice(NM_DEVICE_STATE_DISCONNECTED); |
4904 | @@ -512,7 +139,7 @@ |
4905 | ).match()); |
4906 | } |
4907 | |
4908 | -TEST_F(TestIndicatorNetworkService, AddOneConnectedAccessPointAfterStartup) |
4909 | +TEST_F(TestIndicator, AddOneConnectedAccessPointAfterStartup) |
4910 | { |
4911 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4912 | auto device = createWiFiDevice(NM_DEVICE_STATE_DISCONNECTED); |
4913 | @@ -542,7 +169,7 @@ |
4914 | ).match()); |
4915 | } |
4916 | |
4917 | -TEST_F(TestIndicatorNetworkService, SecondModem) |
4918 | +TEST_F(TestIndicator, SecondModem) |
4919 | { |
4920 | createModem("ril_1"); // ril_0 already exists |
4921 | ASSERT_NO_THROW(startIndicator()); |
4922 | @@ -562,7 +189,7 @@ |
4923 | ).match()); |
4924 | } |
4925 | |
4926 | -TEST_F(TestIndicatorNetworkService, FlightModeTalksToURfkill) |
4927 | +TEST_F(TestIndicator, FlightModeTalksToURfkill) |
4928 | { |
4929 | ASSERT_NO_THROW(startIndicator()); |
4930 | |
4931 | @@ -583,7 +210,7 @@ |
4932 | EXPECT_EQ(urfkillSpy.first(), QVariantList() << QVariant(true)); |
4933 | } |
4934 | |
4935 | -TEST_F(TestIndicatorNetworkService, IndicatorListensToURfkill) |
4936 | +TEST_F(TestIndicator, IndicatorListensToURfkill) |
4937 | { |
4938 | setGlobalConnectedState(NM_STATE_CONNECTED_GLOBAL); |
4939 | auto device = createWiFiDevice(NM_DEVICE_STATE_ACTIVATED); |
4940 | @@ -621,7 +248,7 @@ |
4941 | ).match()); |
4942 | } |
4943 | |
4944 | -TEST_F(TestIndicatorNetworkService, SimStates_NoSIM) |
4945 | +TEST_F(TestIndicator, SimStates_NoSIM) |
4946 | { |
4947 | // set flight mode off, wifi off, and cell data off |
4948 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4949 | @@ -646,7 +273,7 @@ |
4950 | ).match()); |
4951 | } |
4952 | |
4953 | -TEST_F(TestIndicatorNetworkService, SimStates_NoSIM2) |
4954 | +TEST_F(TestIndicator, SimStates_NoSIM2) |
4955 | { |
4956 | // set flight mode off, wifi off, and cell data off |
4957 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4958 | @@ -673,7 +300,7 @@ |
4959 | ).match()); |
4960 | } |
4961 | |
4962 | -TEST_F(TestIndicatorNetworkService, SimStates_LockedSIM) |
4963 | +TEST_F(TestIndicator, SimStates_LockedSIM) |
4964 | { |
4965 | // set flight mode off, wifi off, and cell data off, and sim in |
4966 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4967 | @@ -717,7 +344,7 @@ |
4968 | ).match()); |
4969 | } |
4970 | |
4971 | -TEST_F(TestIndicatorNetworkService, SimStates_LockedSIM2) |
4972 | +TEST_F(TestIndicator, SimStates_LockedSIM2) |
4973 | { |
4974 | // set flight mode off, wifi off, and cell data off, and sim in |
4975 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4976 | @@ -762,7 +389,7 @@ |
4977 | ).match()); |
4978 | } |
4979 | |
4980 | -TEST_F(TestIndicatorNetworkService, SimStates_UnlockedSIM) |
4981 | +TEST_F(TestIndicator, SimStates_UnlockedSIM) |
4982 | { |
4983 | // set flight mode off, wifi off, cell data off, sim in, and sim unlocked |
4984 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4985 | @@ -886,7 +513,7 @@ |
4986 | ).match()); |
4987 | } |
4988 | |
4989 | -TEST_F(TestIndicatorNetworkService, SimStates_UnlockedSIM2) |
4990 | +TEST_F(TestIndicator, SimStates_UnlockedSIM2) |
4991 | { |
4992 | // set flight mode off, wifi off, cell data off, sim in, and sim unlocked |
4993 | setGlobalConnectedState(NM_STATE_DISCONNECTED); |
4994 | @@ -1018,7 +645,7 @@ |
4995 | ).match()); |
4996 | } |
4997 | |
4998 | -TEST_F(TestIndicatorNetworkService, FlightMode_NoSIM) |
4999 | +TEST_F(TestIndicator, FlightMode_NoSIM) |
5000 | { |
PASSED: Continuous integration, rev:495 jenkins. qa.ubuntu. com/job/ indicator- network- ci/333/ jenkins. qa.ubuntu. com/job/ indicator- network- vivid-amd64- ci/122 jenkins. qa.ubuntu. com/job/ indicator- network- vivid-armhf- ci/122 jenkins. qa.ubuntu. com/job/ indicator- network- vivid-armhf- ci/122/ 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/333/ rebuild
http://