Merge lp:~pete-woods/indicator-network/testing-improvements into lp:indicator-network
- testing-improvements
- Merge into trunk
Proposed by
Pete Woods
Status: | Merged |
---|---|
Approved by: | Pete Woods |
Approved revision: | 647 |
Merged at revision: | 643 |
Proposed branch: | lp:~pete-woods/indicator-network/testing-improvements |
Merge into: | lp:indicator-network |
Diff against target: |
573 lines (+79/-202) 7 files modified
src/indicator/menu-builder.cpp (+14/-14) src/indicator/nmofono/nm-device-statistics-monitor.cpp (+2/-2) tests/data/networkmanager.py (+2/-1) tests/integration/CMakeLists.txt (+10/-13) tests/integration/indicator-network-test-base.cpp (+9/-13) tests/integration/test-connectivity-api.cpp (+31/-145) tests/integration/test-indicator.cpp (+11/-14) |
To merge this branch: | bzr merge lp:~pete-woods/indicator-network/testing-improvements |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Indicator Applet Developers | Pending | ||
Review via email: mp+309587@code.launchpad.net |
Commit message
Try again to make the tests more reliable
Description of the change
Try again to make the tests more reliable
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/indicator/menu-builder.cpp' |
2 | --- src/indicator/menu-builder.cpp 2016-07-04 17:43:21 +0000 |
3 | +++ src/indicator/menu-builder.cpp 2016-11-08 16:47:33 +0000 |
4 | @@ -179,20 +179,6 @@ |
5 | d->m_phoneMenu->addSection(d->m_vpnSection); |
6 | d->m_phoneGreeterMenu->addSection(d->m_vpnSection); |
7 | |
8 | - d->m_desktopMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/desktop", d->m_desktopMenu->menu()); |
9 | - d->m_desktopGreeterMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/desktop_greeter", d->m_desktopGreeterMenu->menu()); |
10 | - d->m_desktopWifiSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/desktop_wifi_settings", d->m_wifiSection->settingsModel()); |
11 | - |
12 | - d->m_tabletpMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/tablet", d->m_tabletMenu->menu()); |
13 | - d->m_tabletGreeterMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/tablet_greeter", d->m_tabletGreeterMenu->menu()); |
14 | - d->m_tabletWifiSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/tablet_wifi_settings", d->m_wifiSection->settingsModel()); |
15 | - |
16 | - d->m_phoneMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone", d->m_phoneMenu->menu()); |
17 | - d->m_phoneGreeterMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone_greeter", d->m_phoneGreeterMenu->menu()); |
18 | - d->m_phoneWifiSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone_wifi_settings", d->m_wifiSection->settingsModel()); |
19 | - |
20 | - d->m_ubiquityMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/ubiquity", d->m_ubiquityMenu->menu()); |
21 | - |
22 | // we have a single actiongroup for all the menus. |
23 | d->m_actionGroupMerger = factory.newActionGroupMerger(); |
24 | d->m_actionGroupMerger->add(d->m_flightModeSwitch->actionGroup()); |
25 | @@ -205,6 +191,20 @@ |
26 | d->m_actionGroupExporter = factory.newActionGroupExporter(d->m_actionGroupMerger->actionGroup(), |
27 | "/com/canonical/indicator/network"); |
28 | |
29 | + d->m_desktopMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/desktop", d->m_desktopMenu->menu()); |
30 | + d->m_desktopGreeterMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/desktop_greeter", d->m_desktopGreeterMenu->menu()); |
31 | + d->m_desktopWifiSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/desktop_wifi_settings", d->m_wifiSection->settingsModel()); |
32 | + |
33 | + d->m_tabletpMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/tablet", d->m_tabletMenu->menu()); |
34 | + d->m_tabletGreeterMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/tablet_greeter", d->m_tabletGreeterMenu->menu()); |
35 | + d->m_tabletWifiSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/tablet_wifi_settings", d->m_wifiSection->settingsModel()); |
36 | + |
37 | + d->m_phoneMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone", d->m_phoneMenu->menu()); |
38 | + d->m_phoneGreeterMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone_greeter", d->m_phoneGreeterMenu->menu()); |
39 | + d->m_phoneWifiSettingsMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/phone_wifi_settings", d->m_wifiSection->settingsModel()); |
40 | + |
41 | + d->m_ubiquityMenuExporter = factory.newMenuExporter("/com/canonical/indicator/network/ubiquity", d->m_ubiquityMenu->menu()); |
42 | + |
43 | d->m_busName = factory.newBusName("com.canonical.indicator.network", |
44 | [](std::string) { |
45 | #ifdef INDICATOR_NETWORK_TRACE_MESSAGES |
46 | |
47 | === modified file 'src/indicator/nmofono/nm-device-statistics-monitor.cpp' |
48 | --- src/indicator/nmofono/nm-device-statistics-monitor.cpp 2016-10-30 15:13:34 +0000 |
49 | +++ src/indicator/nmofono/nm-device-statistics-monitor.cpp 2016-11-08 16:47:33 +0000 |
50 | @@ -82,10 +82,10 @@ |
51 | GSettings *settings{nullptr}; |
52 | if (qEnvironmentVariableIsSet("INDICATOR_NETWORK_UNDER_TESTING")) |
53 | { |
54 | - Q_ASSERT(qEnvironmentVariableIsSet("INDICATOR_NETWOR_TESTING_GSETTINGS_INI")); |
55 | + Q_ASSERT(qEnvironmentVariableIsSet("INDICATOR_NETWORK_TESTING_GSETTINGS_INI")); |
56 | Q_ASSERT(qEnvironmentVariableIsSet("GSETTINGS_SCHEMA_DIR")); |
57 | |
58 | - GSettingsBackend *backend = g_keyfile_settings_backend_new(qgetenv("INDICATOR_NETWOR_TESTING_GSETTINGS_INI"), |
59 | + GSettingsBackend *backend = g_keyfile_settings_backend_new(qgetenv("INDICATOR_NETWORK_TESTING_GSETTINGS_INI"), |
60 | "/com/canonical/indicator/network/", |
61 | "root"); |
62 | |
63 | |
64 | === modified file 'tests/data/networkmanager.py' |
65 | --- tests/data/networkmanager.py 2016-10-30 15:13:34 +0000 |
66 | +++ tests/data/networkmanager.py 2016-11-08 16:47:33 +0000 |
67 | @@ -591,7 +591,7 @@ |
68 | main_connections.append(connection_path) |
69 | settings_obj.Set(SETTINGS_IFACE, 'Connections', main_connections) |
70 | |
71 | - settings_obj.EmitSignal(SETTINGS_IFACE, 'NewConnection', 'o', [ap_path]) |
72 | + settings_obj.EmitSignal(SETTINGS_IFACE, 'NewConnection', 'o', [connection_path]) |
73 | |
74 | return connection_path |
75 | |
76 | @@ -621,6 +621,7 @@ |
77 | self.AddObject(active_connection_path, |
78 | ACTIVE_CONNECTION_IFACE, |
79 | { |
80 | + 'Id': name, |
81 | 'Devices': device_objects, |
82 | 'Default6': False, |
83 | 'Default': True, |
84 | |
85 | === modified file 'tests/integration/CMakeLists.txt' |
86 | --- tests/integration/CMakeLists.txt 2016-10-30 18:44:54 +0000 |
87 | +++ tests/integration/CMakeLists.txt 2016-11-08 16:47:33 +0000 |
88 | @@ -1,5 +1,14 @@ |
89 | |
90 | -add_definitions(-DNETWORK_SERVICE_BIN="${CMAKE_BINARY_DIR}/src/indicator/indicator-network-service") |
91 | +set(INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR "${CMAKE_BINARY_DIR}/data") #need this somewhere higher up in the hierarchy |
92 | +#set(INDICATOR_NETWORK_UNDER_TESTING 1) |
93 | +#set(INDICATOR_NETWORK_TESTING_GSETTINGS_INI=${CMAKE_BINARY_DIR}/data/test_gsettings.ini) |
94 | +#set(GSETTINGS_SCHEMA_DIR="${INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR}") |
95 | + |
96 | +add_definitions( |
97 | + -DNETWORK_SERVICE_BIN="${CMAKE_BINARY_DIR}/src/indicator/indicator-network-service" |
98 | + -DINDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR="${INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR}" |
99 | + -DINDICATOR_NETWORK_TESTING_GSETTINGS_INI="${CMAKE_BINARY_DIR}/data/test_gsettings.ini" |
100 | +) |
101 | |
102 | include_directories( |
103 | "${CMAKE_SOURCE_DIR}/src/connectivity-api/connectivity-qt" |
104 | @@ -45,18 +54,6 @@ |
105 | integration-tests |
106 | ) |
107 | |
108 | -set(INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR ${CMAKE_BINARY_DIR}/data) #need this somewhere higher up in the hierarchy |
109 | - |
110 | -set(TEST_ENV_VARS |
111 | - INDICATOR_NETWORK_UNDER_TESTING=1 |
112 | - INDICATOR_NETWOR_TESTING_GSETTINGS_INI=${CMAKE_BINARY_DIR}/data/test_gsettings.ini |
113 | - GSETTINGS_SCHEMA_DIR=${INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR} |
114 | -) |
115 | -set_tests_properties( |
116 | - integration-tests |
117 | - PROPERTIES |
118 | - ENVIRONMENT "${TEST_ENV_VARS}" |
119 | -) |
120 | |
121 | add_custom_command(OUTPUT ${INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR}/gschemas.compiled |
122 | COMMAND glib-compile-schemas --targetdir=${INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR} --strict ${CMAKE_SOURCE_DIR}/data |
123 | |
124 | === modified file 'tests/integration/indicator-network-test-base.cpp' |
125 | --- tests/integration/indicator-network-test-base.cpp 2016-10-30 15:13:34 +0000 |
126 | +++ tests/integration/indicator-network-test-base.cpp 2016-11-08 16:47:33 +0000 |
127 | @@ -48,14 +48,15 @@ |
128 | void IndicatorNetworkTestBase::SetUp() |
129 | { |
130 | qputenv("INDICATOR_NETWORK_SETTINGS_PATH", temporaryDir.path().toUtf8().constData()); |
131 | + qputenv("INDICATOR_NETWORK_UNDER_TESTING", "1"); |
132 | + qputenv("GSETTINGS_SCHEMA_DIR", INDICATOR_NETWORK_TESTING_GSETTINGS_SCHEMA_DIR); |
133 | + qputenv("INDICATOR_NETWORK_TESTING_GSETTINGS_INI", INDICATOR_NETWORK_TESTING_GSETTINGS_INI); |
134 | |
135 | - Q_ASSERT(qEnvironmentVariableIsSet("INDICATOR_NETWOR_TESTING_GSETTINGS_INI")); |
136 | - QString inipath = qgetenv("INDICATOR_NETWOR_TESTING_GSETTINGS_INI"); |
137 | - if (QFile::exists(inipath)) |
138 | + if (QFile::exists(INDICATOR_NETWORK_TESTING_GSETTINGS_INI)) |
139 | { |
140 | - QFile::remove(inipath); |
141 | + QFile::remove(INDICATOR_NETWORK_TESTING_GSETTINGS_INI); |
142 | } |
143 | - QFile inifile(inipath); |
144 | + QFile inifile(INDICATOR_NETWORK_TESTING_GSETTINGS_INI); |
145 | inifile.open(QIODevice::WriteOnly | QIODevice::Text); |
146 | QTextStream out(&inifile); |
147 | out << "[root]\ndata-usage-indication=false\n"; |
148 | @@ -83,7 +84,6 @@ |
149 | QStringList{"-y", testDir.filePath(QString("%1-%2").arg(test_info->name(), "system.log"))}))); |
150 | } |
151 | |
152 | - qDebug() << NETWORK_MANAGER_TEMPLATE_PATH; |
153 | dbusMock.registerTemplate(NM_DBUS_SERVICE, NETWORK_MANAGER_TEMPLATE_PATH, {}, QDBusConnection::SystemBus); |
154 | dbusMock.registerNotificationDaemon(); |
155 | // By default the ofono mock starts with one modem |
156 | @@ -179,19 +179,15 @@ |
157 | |
158 | void IndicatorNetworkTestBase::TearDown() |
159 | { |
160 | - Q_ASSERT(qEnvironmentVariableIsSet("INDICATOR_NETWOR_TESTING_GSETTINGS_INI")); |
161 | - QString inipath = qgetenv("INDICATOR_NETWOR_TESTING_GSETTINGS_INI"); |
162 | - if (QFile::exists(inipath)) |
163 | + if (QFile::exists(INDICATOR_NETWORK_TESTING_GSETTINGS_INI)) |
164 | { |
165 | - QFile::remove(inipath); |
166 | + QFile::remove(INDICATOR_NETWORK_TESTING_GSETTINGS_INI); |
167 | } |
168 | } |
169 | |
170 | void IndicatorNetworkTestBase::setDataUsageIndicationSetting(bool value) |
171 | { |
172 | - Q_ASSERT(qEnvironmentVariableIsSet("INDICATOR_NETWOR_TESTING_GSETTINGS_INI")); |
173 | - |
174 | - GSettingsBackend *backend = g_keyfile_settings_backend_new(qgetenv("INDICATOR_NETWOR_TESTING_GSETTINGS_INI"), |
175 | + GSettingsBackend *backend = g_keyfile_settings_backend_new(INDICATOR_NETWORK_TESTING_GSETTINGS_INI, |
176 | "/com/canonical/indicator/network/", |
177 | "root"); |
178 | GSettings *settings = g_settings_new_with_backend("com.canonical.indicator.network", |
179 | |
180 | === modified file 'tests/integration/test-connectivity-api.cpp' |
181 | --- tests/integration/test-connectivity-api.cpp 2016-08-03 14:16:10 +0000 |
182 | +++ tests/integration/test-connectivity-api.cpp 2016-11-08 16:47:33 +0000 |
183 | @@ -124,50 +124,23 @@ |
184 | // Enable flight mode |
185 | connectivity->setFlightMode(true); |
186 | |
187 | - // We should first get the switch disabled change |
188 | - WAIT_FOR_SIGNALS(flightModeSwitchSpy, 1); |
189 | - EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
190 | - if (wifiSwitchSpy.size() != 1) |
191 | - { |
192 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
193 | - } |
194 | - ASSERT_EQ(1, wifiSwitchSpy.size()); |
195 | - EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
196 | - if (hotspotSwitchSpy.size() != 1) |
197 | - { |
198 | - ASSERT_TRUE(hotspotSwitchSpy.wait()); |
199 | - } |
200 | - ASSERT_EQ(1, hotspotSwitchSpy.size()); |
201 | + WAIT_FOR_SIGNALS(hotspotSwitchSpy, 1) |
202 | EXPECT_EQ(hotspotSwitchSpy.first(), QVariantList() << QVariant(false)); |
203 | |
204 | // Wait to be notified that flight mode was enabled |
205 | - if (urfkillSpy.size() != 1) |
206 | - { |
207 | - ASSERT_TRUE(urfkillSpy.wait()); |
208 | - } |
209 | - ASSERT_EQ(1, urfkillSpy.size()); |
210 | + WAIT_FOR_SIGNALS(urfkillSpy, 1) |
211 | EXPECT_EQ(urfkillSpy.first(), QVariantList() << QVariant(true)); |
212 | |
213 | // The switch enabled change should complete |
214 | - if (flightModeSwitchSpy.size() != 2) |
215 | - { |
216 | - ASSERT_TRUE(flightModeSwitchSpy.wait()); |
217 | - } |
218 | - ASSERT_EQ(2, flightModeSwitchSpy.size()); |
219 | + WAIT_FOR_SIGNALS(flightModeSwitchSpy, 2) |
220 | + EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
221 | EXPECT_EQ(flightModeSwitchSpy.last(), QVariantList() << QVariant(true)); |
222 | - if (wifiSwitchSpy.size() != 2) |
223 | - { |
224 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
225 | - } |
226 | - ASSERT_EQ(2, wifiSwitchSpy.size()); |
227 | + WAIT_FOR_SIGNALS(wifiSwitchSpy, 2) |
228 | + EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
229 | EXPECT_EQ(wifiSwitchSpy.last(), QVariantList() << QVariant(true)); |
230 | |
231 | // Wait for flight mode property change |
232 | - if (flightModeSpy.size() != 1) |
233 | - { |
234 | - ASSERT_TRUE(flightModeSpy.wait()); |
235 | - } |
236 | - ASSERT_EQ(1, flightModeSpy.size()); |
237 | + WAIT_FOR_SIGNALS(flightModeSpy, 1) |
238 | EXPECT_EQ(flightModeSpy.first(), QVariantList() << QVariant(true)); |
239 | |
240 | // Check that nothing is happening again |
241 | @@ -192,49 +165,23 @@ |
242 | |
243 | // We should first get the unstoppable operation change |
244 | ASSERT_TRUE(flightModeSwitchSpy.wait()); |
245 | - ASSERT_EQ(1, flightModeSwitchSpy.size()); |
246 | - EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
247 | - if (wifiSwitchSpy.size() != 1) |
248 | - { |
249 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
250 | - } |
251 | - ASSERT_EQ(1, wifiSwitchSpy.size()); |
252 | - EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
253 | |
254 | // Wait to be notified that flight mode was disabled |
255 | - if (urfkillSpy.size() != 1) |
256 | - { |
257 | - ASSERT_TRUE(urfkillSpy.wait()); |
258 | - } |
259 | - ASSERT_EQ(1, urfkillSpy.size()); |
260 | + WAIT_FOR_SIGNALS(urfkillSpy, 1) |
261 | EXPECT_EQ(urfkillSpy.first(), QVariantList() << QVariant(false)); |
262 | |
263 | // The toggles should become enabled again |
264 | - if (flightModeSwitchSpy.size() != 2) |
265 | - { |
266 | - ASSERT_TRUE(flightModeSwitchSpy.wait()); |
267 | - } |
268 | - ASSERT_EQ(2, flightModeSwitchSpy.size()); |
269 | - EXPECT_EQ(wifiSwitchSpy.last(), QVariantList() << QVariant(true)); |
270 | - if (wifiSwitchSpy.size() != 2) |
271 | - { |
272 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
273 | - } |
274 | - ASSERT_EQ(2, wifiSwitchSpy.size()); |
275 | - EXPECT_EQ(wifiSwitchSpy.last(), QVariantList() << QVariant(true)); |
276 | - if (hotspotSwitchSpy.size() != 1) |
277 | - { |
278 | - ASSERT_TRUE(hotspotSwitchSpy.wait()); |
279 | - } |
280 | - ASSERT_EQ(1, hotspotSwitchSpy.size()); |
281 | + WAIT_FOR_SIGNALS(flightModeSwitchSpy, 2) |
282 | + EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
283 | + EXPECT_EQ(flightModeSwitchSpy.last(), QVariantList() << QVariant(true)); |
284 | + WAIT_FOR_SIGNALS(wifiSwitchSpy, 2) |
285 | + EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
286 | + EXPECT_EQ(wifiSwitchSpy.last(), QVariantList() << QVariant(true)); |
287 | + WAIT_FOR_SIGNALS(hotspotSwitchSpy, 1) |
288 | EXPECT_EQ(hotspotSwitchSpy.first(), QVariantList() << QVariant(true)); |
289 | |
290 | // Wait for flight mode property change |
291 | - if (flightModeSpy.size() != 1) |
292 | - { |
293 | - ASSERT_TRUE(flightModeSpy.wait()); |
294 | - } |
295 | - ASSERT_EQ(1, flightModeSpy.size()); |
296 | + WAIT_FOR_SIGNALS(flightModeSpy, 1) |
297 | EXPECT_EQ(flightModeSpy.first(), QVariantList() << QVariant(false)); |
298 | |
299 | // Check that nothing is happening again |
300 | @@ -280,50 +227,21 @@ |
301 | |
302 | // Check the switch enabled flags change |
303 | ASSERT_TRUE(flightModeSwitchSpy.wait()); |
304 | - ASSERT_EQ(1, flightModeSwitchSpy.size()); |
305 | - EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
306 | - |
307 | - if (wifiSwitchSpy.size() != 1) |
308 | - { |
309 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
310 | - } |
311 | - ASSERT_EQ(1, wifiSwitchSpy.size()); |
312 | - EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
313 | - |
314 | - if (hotspotSwitchSpy.size() != 1) |
315 | - { |
316 | - ASSERT_TRUE(hotspotSwitchSpy.wait()); |
317 | - } |
318 | - ASSERT_EQ(1, hotspotSwitchSpy.size()); |
319 | - EXPECT_EQ(hotspotSwitchSpy.first(), QVariantList() << QVariant(false)); |
320 | |
321 | // Wait to be notified that wifi was toggled |
322 | - if (urfkillSpy.size() != 1) |
323 | - { |
324 | - ASSERT_TRUE(urfkillSpy.wait()); |
325 | - } |
326 | - ASSERT_EQ(1, urfkillSpy.size()); |
327 | + WAIT_FOR_SIGNALS(urfkillSpy, 1) |
328 | |
329 | // Switch should be re-enabled now |
330 | - if (flightModeSwitchSpy.size() != 2) |
331 | - { |
332 | - ASSERT_TRUE(flightModeSwitchSpy.wait()); |
333 | - } |
334 | - ASSERT_EQ(2, flightModeSwitchSpy.size()); |
335 | + WAIT_FOR_SIGNALS(flightModeSwitchSpy, 2) |
336 | + EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
337 | EXPECT_EQ(flightModeSwitchSpy.last(), QVariantList() << QVariant(true)); |
338 | |
339 | - if (hotspotSwitchSpy.size() != 2) |
340 | - { |
341 | - ASSERT_TRUE(hotspotSwitchSpy.wait()); |
342 | - } |
343 | - ASSERT_EQ(2, hotspotSwitchSpy.size()); |
344 | + WAIT_FOR_SIGNALS(hotspotSwitchSpy, 2) |
345 | + EXPECT_EQ(hotspotSwitchSpy.first(), QVariantList() << QVariant(false)); |
346 | EXPECT_EQ(hotspotSwitchSpy.last(), QVariantList() << QVariant(true)); |
347 | |
348 | - if (wifiSwitchSpy.size() != 2) |
349 | - { |
350 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
351 | - } |
352 | - ASSERT_EQ(2, wifiSwitchSpy.size()); |
353 | + WAIT_FOR_SIGNALS(wifiSwitchSpy, 2) |
354 | + EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
355 | EXPECT_EQ(wifiSwitchSpy.last(), QVariantList() << QVariant(true)); |
356 | |
357 | // Wait for wifi enabled property change |
358 | @@ -355,59 +273,27 @@ |
359 | |
360 | // Toggles should be disabled |
361 | ASSERT_TRUE(flightModeSwitchSpy.wait()); |
362 | - ASSERT_EQ(1, flightModeSwitchSpy.size()); |
363 | - EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
364 | - |
365 | - if (wifiSwitchSpy.size() != 1) |
366 | - { |
367 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
368 | - } |
369 | - ASSERT_EQ(1, wifiSwitchSpy.size()); |
370 | - EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
371 | - |
372 | - if (hotspotSwitchSpy.size() != 1) |
373 | - { |
374 | - ASSERT_TRUE(hotspotSwitchSpy.wait()); |
375 | - } |
376 | - ASSERT_EQ(1, hotspotSwitchSpy.size()); |
377 | - EXPECT_EQ(hotspotSwitchSpy.first(), QVariantList() << QVariant(false)); |
378 | |
379 | // Wait to be notified that wifi was toggled |
380 | - if (urfkillSpy.size() != 1) |
381 | - { |
382 | - ASSERT_TRUE(urfkillSpy.wait()); |
383 | - } |
384 | - ASSERT_EQ(1, urfkillSpy.size()); |
385 | + WAIT_FOR_SIGNALS(urfkillSpy, 1) |
386 | |
387 | // Toggles should be re-enabled |
388 | - if (flightModeSwitchSpy.size() != 2) |
389 | - { |
390 | - ASSERT_TRUE(flightModeSwitchSpy.wait()); |
391 | - } |
392 | + WAIT_FOR_SIGNALS(flightModeSwitchSpy, 2) |
393 | ASSERT_EQ(2, flightModeSwitchSpy.size()); |
394 | + EXPECT_EQ(flightModeSwitchSpy.first(), QVariantList() << QVariant(false)); |
395 | EXPECT_EQ(wifiSwitchSpy.last(), QVariantList() << QVariant(true)); |
396 | |
397 | - if (wifiSwitchSpy.size() != 2) |
398 | - { |
399 | - ASSERT_TRUE(wifiSwitchSpy.wait()); |
400 | - } |
401 | - ASSERT_EQ(2, wifiSwitchSpy.size()); |
402 | + WAIT_FOR_SIGNALS(wifiSwitchSpy, 2) |
403 | + EXPECT_EQ(wifiSwitchSpy.first(), QVariantList() << QVariant(false)); |
404 | EXPECT_EQ(wifiSwitchSpy.last(), QVariantList() << QVariant(true)); |
405 | |
406 | // Hotspot should become available again |
407 | - if (hotspotSwitchSpy.size() != 2) |
408 | - { |
409 | - ASSERT_TRUE(hotspotSwitchSpy.wait()); |
410 | - } |
411 | - ASSERT_EQ(2, hotspotSwitchSpy.size()); |
412 | + WAIT_FOR_SIGNALS(hotspotSwitchSpy, 2) |
413 | + EXPECT_EQ(hotspotSwitchSpy.first(), QVariantList() << QVariant(false)); |
414 | EXPECT_EQ(hotspotSwitchSpy.last(), QVariantList() << QVariant(true)); |
415 | |
416 | // Wait for wifi enabled property change |
417 | - if (wifiEnabledSpy.size() != 1) |
418 | - { |
419 | - ASSERT_TRUE(wifiEnabledSpy.wait()); |
420 | - } |
421 | - ASSERT_EQ(1, wifiEnabledSpy.size()); |
422 | + WAIT_FOR_SIGNALS(wifiEnabledSpy, 1) |
423 | EXPECT_EQ(wifiEnabledSpy.first(), QVariantList() << QVariant(true)); |
424 | |
425 | // All toggles should be enabled |
426 | |
427 | === modified file 'tests/integration/test-indicator.cpp' |
428 | --- tests/integration/test-indicator.cpp 2016-10-30 15:13:34 +0000 |
429 | +++ tests/integration/test-indicator.cpp 2016-11-08 16:47:33 +0000 |
430 | @@ -2214,11 +2214,11 @@ |
431 | .item(flightModeSwitch()) |
432 | .item(mh::MenuItemMatcher() |
433 | .section() |
434 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
435 | .item(mobileDataSwitch()) |
436 | .item(modemInfo("", "SIM Locked", "simcard-locked", true) |
437 | .pass_through_activate("x-canonical-modem-locked-action") |
438 | ) |
439 | - .item(cellularSettings()) |
440 | ) |
441 | ).match()); |
442 | |
443 | @@ -2307,11 +2307,11 @@ |
444 | .item(flightModeSwitch()) |
445 | .item(mh::MenuItemMatcher() |
446 | .section() |
447 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
448 | .item(mobileDataSwitch()) |
449 | .item(modemInfo("", "SIM Locked", "simcard-locked", true) |
450 | .pass_through_activate("x-canonical-modem-locked-action") |
451 | ) |
452 | - .item(cellularSettings()) |
453 | ) |
454 | ).match()); |
455 | |
456 | @@ -2364,11 +2364,11 @@ |
457 | .item(flightModeSwitch()) |
458 | .item(mh::MenuItemMatcher() |
459 | .section() |
460 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
461 | .item(mobileDataSwitch()) |
462 | .item(modemInfo("", "SIM Locked", "simcard-locked", true) |
463 | .pass_through_activate("x-canonical-modem-locked-action") |
464 | ) |
465 | - .item(cellularSettings()) |
466 | ) |
467 | ).match()); |
468 | |
469 | @@ -2432,12 +2432,12 @@ |
470 | .item(flightModeSwitch()) |
471 | .item(mh::MenuItemMatcher() |
472 | .section() |
473 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
474 | .item(mobileDataSwitch()) |
475 | .item(modemInfo("SIM 1", "SIM Locked", "simcard-locked", true) |
476 | .pass_through_activate("x-canonical-modem-locked-action") |
477 | ) |
478 | .item(modemInfo("SIM 2", "SIM Locked", "simcard-locked", true)) |
479 | - .item(cellularSettings()) |
480 | ) |
481 | ).match()); |
482 | |
483 | @@ -2490,12 +2490,12 @@ |
484 | .item(flightModeSwitch()) |
485 | .item(mh::MenuItemMatcher() |
486 | .section() |
487 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
488 | .item(mobileDataSwitch()) |
489 | .item(modemInfo("SIM 1", "SIM Locked", "simcard-locked", true)) |
490 | .item(modemInfo("SIM 2", "SIM Locked", "simcard-locked", true) |
491 | .pass_through_activate("x-canonical-modem-locked-action") |
492 | ) |
493 | - .item(cellularSettings()) |
494 | ) |
495 | ).match()); |
496 | |
497 | @@ -2558,11 +2558,11 @@ |
498 | .item(flightModeSwitch()) |
499 | .item(mh::MenuItemMatcher() |
500 | .section() |
501 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
502 | .item(mobileDataSwitch()) |
503 | .item(modemInfo("", "SIM Locked", "simcard-locked", true) |
504 | .pass_through_activate("x-canonical-modem-locked-action") |
505 | ) |
506 | - .item(cellularSettings()) |
507 | ) |
508 | ).match()); |
509 | |
510 | @@ -2643,11 +2643,11 @@ |
511 | .item(flightModeSwitch()) |
512 | .item(mh::MenuItemMatcher() |
513 | .section() |
514 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
515 | .item(mobileDataSwitch()) |
516 | .item(modemInfo("", "SIM Locked", "simcard-locked", true) |
517 | .pass_through_activate("x-canonical-modem-locked-action") |
518 | ) |
519 | - .item(cellularSettings()) |
520 | ) |
521 | ).match()); |
522 | |
523 | @@ -2927,12 +2927,12 @@ |
524 | .item(flightModeSwitch()) |
525 | .item(mh::MenuItemMatcher() |
526 | .section() |
527 | + .mode(mh::MenuItemMatcher::Mode::starts_with) |
528 | .item(mobileDataSwitch()) |
529 | .item(modemInfo("SIM 1", "fake.tel", "gsm-3g-full")) |
530 | .item(modemInfo("SIM 2", "SIM Locked", "simcard-locked", true) |
531 | .pass_through_activate("x-canonical-modem-locked-action") |
532 | ) |
533 | - .item(cellularSettings()) |
534 | ) |
535 | ).match()); |
536 | |
537 | @@ -3213,7 +3213,7 @@ |
538 | .item(mh::MenuItemMatcher() |
539 | .mode(mh::MenuItemMatcher::Mode::starts_with) |
540 | .submenu() |
541 | - .item(flightModeSwitch()) |
542 | + .item(flightModeSwitch(false)) |
543 | .item(mh::MenuItemMatcher() |
544 | .mode(mh::MenuItemMatcher::Mode::starts_with) |
545 | .section() |
546 | @@ -3229,7 +3229,7 @@ |
547 | .item(mh::MenuItemMatcher() |
548 | .mode(mh::MenuItemMatcher::Mode::starts_with) |
549 | .submenu() |
550 | - .item(flightModeSwitch()) |
551 | + .item(flightModeSwitch(true)) |
552 | .item(mh::MenuItemMatcher() |
553 | .mode(mh::MenuItemMatcher::Mode::starts_with) |
554 | .section() |
555 | @@ -3246,7 +3246,7 @@ |
556 | .item(mh::MenuItemMatcher() |
557 | .mode(mh::MenuItemMatcher::Mode::starts_with) |
558 | .submenu() |
559 | - .item(flightModeSwitch()) |
560 | + .item(flightModeSwitch(false)) |
561 | .item(mh::MenuItemMatcher() |
562 | .mode(mh::MenuItemMatcher::Mode::starts_with) |
563 | .section() |
564 | @@ -3348,9 +3348,6 @@ |
565 | * Disabled by default because containst sleeps and what not other horrible things. |
566 | * There are timers involved, so this will be flaky |
567 | * To manually run, do following inside ${CMAKE_BINARY_DIR} |
568 | - * $ export INDICATOR_NETWORK_UNDER_TESTING=1 |
569 | - * $ export INDICATOR_NETWOR_TESTING_GSETTINGS_INI=./data/test_gsettings.ini |
570 | - * $ export GSETTINGS_SCHEMA_DIR=./data |
571 | * $ tests/integration/integration-tests --gtest_filter=TestIndicator.DISABLED_DataUsageIndication_enabled --gtest_also_run_disabled_tests |
572 | */ |
573 | TEST_F(TestIndicator, DISABLED_DataUsageIndication_enabled) |