Merge lp:~pete-woods/indicator-network/connectivity-api-fixes into lp:indicator-network/15.10

Proposed by Pete Woods
Status: Merged
Approved by: Pete Woods
Approved revision: 557
Merged at revision: 557
Proposed branch: lp:~pete-woods/indicator-network/connectivity-api-fixes
Merge into: lp:indicator-network/15.10
Prerequisite: lp:~pete-woods/indicator-network/pptp
Diff against target: 292 lines (+76/-36)
7 files modified
debian/changelog (+1/-0)
doc/qt/cpp/examples/example_networking_status.cpp (+9/-11)
doc/qt/qml/examples/example_networking_status.qml (+14/-12)
src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h (+6/-11)
src/connectivity-api/connectivity-qt/ubuntu/connectivity/networking-status.h (+8/-2)
tests/integration/test-connectivity-api-vpn.cpp (+5/-0)
tests/integration/test-connectivity-api.cpp (+33/-0)
To merge this branch: bzr merge lp:~pete-woods/indicator-network/connectivity-api-fixes
Reviewer Review Type Date Requested Status
Charles Kerr (community) Approve
Review via email: mp+282573@code.launchpad.net

Commit message

Fix Connectivity::status property (Qt metatype issues)

Description of the change

Fix Connectivity::status property (Qt metatype issues)

To post a comment you must log in.
Revision history for this message
Charles Kerr (charlesk) wrote :

One optional change commented inline, but not a blocker. Otherwise LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2016-01-14 13:40:22 +0000
3+++ debian/changelog 2016-01-14 13:40:22 +0000
4@@ -1,5 +1,6 @@
5 indicator-network (0.7.0-0ubuntu1) UNRELEASED; urgency=medium
6
7+ * Fix Connectivity::status property. (LP: #1531380)
8 * Add PPTP support to VPN editor.
9
10 -- Pete Woods <pete.woods@canonical.com> Tue, 12 Jan 2016 18:10:06 +0000
11
12=== modified file 'doc/qt/cpp/examples/example_networking_status.cpp'
13--- doc/qt/cpp/examples/example_networking_status.cpp 2015-05-07 10:03:46 +0000
14+++ doc/qt/cpp/examples/example_networking_status.cpp 2016-01-14 13:40:22 +0000
15@@ -26,6 +26,12 @@
16 using namespace connectivityqt;
17 //! [include]
18
19+static const QMap<Connectivity::Status, QString> STATUS_MAP {
20+ {Connectivity::Status::Offline, "Offline"},
21+ {Connectivity::Status::Connecting, "Connecting"},
22+ {Connectivity::Status::Online, "Online"},
23+};
24+
25 int
26 main(int argc, char *argv[])
27 {
28@@ -47,20 +53,12 @@
29 &Connectivity::statusUpdated,
30 [](Connectivity::Status value)
31 {
32- switch(value) {
33- case Connectivity::Status::Offline:
34- qDebug() << "System networking status changed to: Offline";
35- break;
36- case Connectivity::Status::Connecting:
37- qDebug() << "System networking status changed to: Connecting";
38- break;
39- case Connectivity::Status::Online:
40- qDebug() << "System networking status changed to: Online";
41- break;
42- }
43+ qDebug() << "System networking status changed to: " + STATUS_MAP[value];
44 });
45 //! [status]
46
47+ qDebug() << "System networking status: " + STATUS_MAP[ns->status()];
48+
49 //! [limitations]
50 // normal getter
51 if (ns->limitations().isEmpty())
52
53=== modified file 'doc/qt/qml/examples/example_networking_status.qml'
54--- doc/qt/qml/examples/example_networking_status.qml 2015-05-07 10:03:46 +0000
55+++ doc/qt/qml/examples/example_networking_status.qml 2016-01-14 13:40:22 +0000
56@@ -22,27 +22,24 @@
57 MainView {
58 id: root
59 objectName: "mainView"
60- applicationName: "NetworkingStatus"
61+ applicationName: "Connectivity"
62
63 width: units.gu(100)
64 height: units.gu(75)
65
66 property real margins: units.gu(2)
67 property real buttonWidth: units.gu(9)
68+
69+ property var statusMap: ["Offline", "Connecting", "Online"]
70
71 Connections {
72- target: NetworkingStatus
73+ target: Connectivity
74
75 // full status can be retrieved from the base C++ class
76 // status property
77- onStatusChanged: {
78- if (status === NetworkingStatus.Offline)
79- console.log("Status: Offline")
80- if (status === NetworkingStatus.Connecting)
81- console.log("Status: Connecting")
82- if (status === NetworkingStatus.Online)
83- console.log("Status: Online")
84- }
85+ onStatusChanged: console.log("Status: " + statusMap[Connectivity.status])
86+
87+ onOnlineChanged: console.log("Online: " + Connectivity.online)
88 }
89
90 Page {
91@@ -52,12 +49,17 @@
92 anchors.centerIn: parent
93 Label {
94 // use the online property
95- text: NetworkingStatus.online ? "Online" : "Not online"
96+ text: Connectivity.online ? "Online" : "Not online"
97+ fontSize: "large"
98+ }
99+ Label {
100+ // use the status property
101+ text: "Status: " + statusMap[Connectivity.status]
102 fontSize: "large"
103 }
104 Label {
105 // use the limitedBandwith property
106- text: NetworkingStatus.limitedBandwith ? "Bandwith limited" : "Bandwith not limited"
107+ text: Connectivity.limitedBandwith ? "Bandwith limited" : "Bandwith not limited"
108 fontSize: "large"
109 }
110 }
111
112=== modified file 'src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h'
113--- src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2015-12-04 13:18:04 +0000
114+++ src/connectivity-api/connectivity-qt/connectivityqt/connectivity.h 2016-01-14 13:40:22 +0000
115@@ -50,7 +50,7 @@
116 /**
117 * @brief enum for networking limitations
118 *
119- * Networking limitations may be accessed through the NetworkingStatus::limitations property.
120+ * Networking limitations may be accessed through the Connectivity::limitations property.
121 */
122 enum class Limitations
123 {
124@@ -64,7 +64,7 @@
125 /**
126 * @brief enum for networking status
127 *
128- * Networking status may be accessed through the NetworkingStatus::status property.
129+ * Networking status may be accessed through the Connectivity::status property.
130 */
131 enum class Status
132 {
133@@ -82,7 +82,6 @@
134 ~Connectivity();
135
136 Q_PROPERTY(bool flightMode READ flightMode WRITE setFlightMode NOTIFY flightModeUpdated)
137- Q_PROPERTY(bool FlightMode READ flightMode WRITE setFlightMode NOTIFY flightModeUpdated)
138 bool flightMode() const;
139
140 Q_PROPERTY(bool online READ online NOTIFY onlineUpdated)
141@@ -94,25 +93,21 @@
142 Q_PROPERTY(QVector<Limitations> Limitations READ limitations NOTIFY limitationsUpdated)
143 QVector<Limitations> limitations() const;
144
145- Q_PROPERTY(connectivityqt::Connectivity::Status Status READ status NOTIFY statusUpdated)
146- Status status() const;
147+ Q_PROPERTY(connectivityqt::Connectivity::Status status READ status NOTIFY statusUpdated)
148+ connectivityqt::Connectivity::Status status() const;
149
150 Q_PROPERTY(bool wifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
151- Q_PROPERTY(bool WifiEnabled READ wifiEnabled WRITE setwifiEnabled NOTIFY wifiEnabledUpdated)
152 bool wifiEnabled() const;
153
154- Q_PROPERTY(bool UnstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated)
155+ Q_PROPERTY(bool unstoppableOperationHappening READ unstoppableOperationHappening NOTIFY unstoppableOperationHappeningUpdated)
156 bool unstoppableOperationHappening() const;
157
158- Q_PROPERTY(bool FlightModeSwitchEnabled READ flightModeSwitchEnabled NOTIFY flightModeSwitchEnabledUpdated)
159 Q_PROPERTY(bool flightModeSwitchEnabled READ flightModeSwitchEnabled NOTIFY flightModeSwitchEnabledUpdated)
160 bool flightModeSwitchEnabled() const;
161
162- Q_PROPERTY(bool WifiSwitchEnabled READ wifiSwitchEnabled NOTIFY wifiSwitchEnabledUpdated)
163 Q_PROPERTY(bool wifiSwitchEnabled READ wifiSwitchEnabled NOTIFY wifiSwitchEnabledUpdated)
164 bool wifiSwitchEnabled() const;
165
166- Q_PROPERTY(bool HotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
167 Q_PROPERTY(bool hotspotSwitchEnabled READ hotspotSwitchEnabled NOTIFY hotspotSwitchEnabledUpdated)
168 bool hotspotSwitchEnabled() const;
169
170@@ -137,7 +132,7 @@
171 Q_PROPERTY(bool hotspotStored READ hotspotStored NOTIFY hotspotStoredUpdated)
172 bool hotspotStored() const;
173
174- Q_PROPERTY(bool Initialized READ isInitialized NOTIFY initialized)
175+ Q_PROPERTY(bool initialized READ isInitialized NOTIFY initialized)
176 bool isInitialized() const;
177
178 Q_PROPERTY(QAbstractItemModel* vpnConnections READ vpnConnections NOTIFY vpnConnectionsUpdated)
179
180=== modified file 'src/connectivity-api/connectivity-qt/ubuntu/connectivity/networking-status.h'
181--- src/connectivity-api/connectivity-qt/ubuntu/connectivity/networking-status.h 2015-05-19 10:28:57 +0000
182+++ src/connectivity-api/connectivity-qt/ubuntu/connectivity/networking-status.h 2016-01-14 13:40:22 +0000
183@@ -30,6 +30,8 @@
184 /**
185 * @brief Overall system networking status.
186 *
187+ * NOTE: This class is deprecated, please move to using connectivityqt::Connectivity
188+ *
189 * This is the top-level class for accessing networking information.
190 *
191 * * For system networking status, see NetworkingStatus::status.
192@@ -38,7 +40,7 @@
193 * Examples:
194 * - @ref networking-status "Getting the networking status."
195 */
196-class Q_DECL_EXPORT NetworkingStatus : public QObject
197+class Q_DECL_DEPRECATED Q_DECL_EXPORT NetworkingStatus : public QObject
198 {
199 Q_OBJECT
200 Q_DISABLE_COPY(NetworkingStatus)
201@@ -68,7 +70,7 @@
202 *
203 * \snippet example_networking_status.cpp status
204 */
205- Q_PROPERTY(Status status
206+ Q_PROPERTY(ubuntu::connectivity::NetworkingStatus::Status status
207 READ status
208 NOTIFY statusChanged)
209
210@@ -102,16 +104,20 @@
211
212
213 /** @see NetworkingStatus::limitations */
214+ Q_DECL_DEPRECATED
215 QVector<Limitations> limitations() const;
216
217 /** @see NetworkingStatus::status */
218+ Q_DECL_DEPRECATED
219 Status status() const;
220
221 Q_SIGNALS:
222 /** @see NetworkingStatus::limitations */
223+ Q_DECL_DEPRECATED
224 void limitationsChanged();
225
226 /** @see NetworkingStatus::status */
227+ Q_DECL_DEPRECATED
228 void statusChanged(Status value);
229
230 private:
231
232=== modified file 'tests/integration/test-connectivity-api-vpn.cpp'
233--- tests/integration/test-connectivity-api-vpn.cpp 2015-12-16 10:29:52 +0000
234+++ tests/integration/test-connectivity-api-vpn.cpp 2016-01-14 13:40:22 +0000
235@@ -50,6 +50,11 @@
236 class TestConnectivityApiVpn: public IndicatorNetworkTestBase
237 {
238 protected:
239+ static void SetUpTestCase()
240+ {
241+ Connectivity::registerMetaTypes();
242+ }
243+
244 CSL vpnList(QAbstractItemModel& model)
245 {
246 CSL connectionStates;
247
248=== modified file 'tests/integration/test-connectivity-api.cpp'
249--- tests/integration/test-connectivity-api.cpp 2015-11-20 13:14:50 +0000
250+++ tests/integration/test-connectivity-api.cpp 2016-01-14 13:40:22 +0000
251@@ -33,8 +33,41 @@
252
253 class TestConnectivityApi: public IndicatorNetworkTestBase
254 {
255+protected:
256+ static void SetUpTestCase()
257+ {
258+ Connectivity::registerMetaTypes();
259+ }
260 };
261
262+TEST_F(TestConnectivityApi, OnlineStatus)
263+{
264+ // Set up disconnected
265+ setGlobalConnectedState(NM_STATE_DISCONNECTED);
266+
267+ // Start the indicator
268+ ASSERT_NO_THROW(startIndicator());
269+
270+ // Connect to the service
271+ auto connectivity(newConnectivity());
272+ QSignalSpy spy(connectivity.get(), &Connectivity::statusUpdated);
273+
274+ // Check we are connected
275+ EXPECT_EQ(Connectivity::Status::Offline, connectivity->status());
276+
277+ // Now we are connecting
278+ spy.clear();
279+ setGlobalConnectedState(NM_STATE_CONNECTING);
280+ WAIT_FOR_SIGNALS(spy, 1);
281+ EXPECT_EQ(Connectivity::Status::Connecting, connectivity->status());
282+
283+ // Now we are connecting
284+ spy.clear();
285+ setGlobalConnectedState(NM_STATE_CONNECTED_GLOBAL);
286+ WAIT_FOR_SIGNALS(spy, 1);
287+ EXPECT_EQ(Connectivity::Status::Online, connectivity->status());
288+}
289+
290 TEST_F(TestConnectivityApi, FollowsFlightMode)
291 {
292 // Set up disconnected with flight mode on

Subscribers

People subscribed via source and target branches