Merge lp:~jonas-drange/ubuntu-system-settings/port-eduroamtest-qml into lp:ubuntu-system-settings
- port-eduroamtest-qml
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ken VanDine |
Approved revision: | 1699 |
Merged at revision: | 1699 |
Proposed branch: | lp:~jonas-drange/ubuntu-system-settings/port-eduroamtest-qml |
Merge into: | lp:ubuntu-system-settings |
Prerequisite: | lp:~jonas-drange/ubuntu-system-settings/makeqmltest |
Diff against target: |
1539 lines (+939/-340) 25 files modified
plugins/mouse/TapArea.qml (+1/-0) plugins/wifi/CMakeLists.txt (+1/-1) plugins/wifi/OtherNetwork.qml (+0/-1) plugins/wifi/wifidbushelper.cpp (+13/-7) plugins/wifi/wifidbushelper.h (+1/-0) tests/CMakeLists.txt (+1/-1) tests/autopilot/ubuntu_system_settings/__init__.py (+0/-197) tests/autopilot/ubuntu_system_settings/tests/test_wifi.py (+0/-129) tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt (+1/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/CMakeLists.txt (+26/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.cpp (+103/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.h (+92/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.cpp (+76/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.h (+57/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.cpp (+42/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.h (+32/-0) tests/mocks/Ubuntu/SystemSettings/Wifi/qmldir (+2/-0) tests/mocks/plugins/wifi/fakenetworkmanager.cpp (+65/-0) tests/mocks/plugins/wifi/fakenetworkmanager.h (+56/-0) tests/plugins/CMakeLists.txt (+11/-3) tests/plugins/mouse/tst_mouse.qml (+2/-1) tests/plugins/wifi/CMakeLists.txt (+23/-0) tests/plugins/wifi/WifiSource/qmldir (+2/-0) tests/plugins/wifi/tst_OtherNetwork.qml (+169/-0) tests/plugins/wifi/tst_wifidbushelper.cpp (+163/-0) |
To merge this branch: | bzr merge lp:~jonas-drange/ubuntu-system-settings/port-eduroamtest-qml |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Ken VanDine | Approve | ||
system-apps-ci-bot | continuous-integration | Approve | |
Review via email: mp+303081@code.launchpad.net |
Commit message
Port most autopilot tests in test_wifi to qml tests and ctests.
Description of the change
- 1694. By Jonas G. Drange
-
revert some changes that were made in error
Jonas G. Drange (jonas-drange) : | # |
- 1695. By Jonas G. Drange
-
fix minor inaccuracies
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1695
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 1696. By Jonas G. Drange
-
set xvfb cmd
- 1697. By Jonas G. Drange
-
make mouse test less flaky
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1697
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild:
https:/
- 1698. By Jonas G. Drange
-
put clicks in middle of button, and drop qmenumodel import as it is unused
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1698
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 1699. By Jonas G. Drange
-
harden mouse test
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1699
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
FAILED: Continuous integration, rev:1699
https:/
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
FAILURE: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
system-apps-ci-bot (system-apps-ci-bot) wrote : | # |
PASSED: Continuous integration, rev:1699
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
Ken VanDine (ken-vandine) wrote : | # |
This is a great improvement
- 1700. By Jonas G. Drange
-
sync with trunk
Preview Diff
1 | === modified file 'plugins/mouse/TapArea.qml' |
2 | --- plugins/mouse/TapArea.qml 2016-01-25 18:32:08 +0000 |
3 | +++ plugins/mouse/TapArea.qml 2016-08-19 12:48:19 +0000 |
4 | @@ -30,6 +30,7 @@ |
5 | |
6 | Timer { |
7 | id: clickTimer |
8 | + objectName: "clickTimer" |
9 | triggeredOnStart: false |
10 | repeat: false |
11 | interval: doubleTapSpeed |
12 | |
13 | === modified file 'plugins/wifi/CMakeLists.txt' |
14 | --- plugins/wifi/CMakeLists.txt 2016-04-13 18:49:49 +0000 |
15 | +++ plugins/wifi/CMakeLists.txt 2016-08-19 12:48:19 +0000 |
16 | @@ -40,7 +40,7 @@ |
17 | |
18 | set(PLUG_DIR ${PLUGIN_PRIVATE_MODULE_DIR}/Ubuntu/SystemSettings/Wifi) |
19 | install(TARGETS UbuntuWifiPanel DESTINATION ${PLUG_DIR}) |
20 | -install(FILES qmldir DESTINATION ${PLUG_DIR}) |
21 | +install(FILES qmldir.in DESTINATION ${PLUG_DIR} RENAME qmldir) |
22 | install(FILES wifi.settings DESTINATION ${PLUGIN_MANIFEST_DIR}) |
23 | install(FILES settings-wifi.svg DESTINATION ${PLUGIN_MANIFEST_DIR}/icons) |
24 | install(FILES ${QML_SOURCES} DESTINATION ${PLUGIN_QML_DIR}/wifi) |
25 | |
26 | === modified file 'plugins/wifi/OtherNetwork.qml' |
27 | --- plugins/wifi/OtherNetwork.qml 2016-07-14 13:51:56 +0000 |
28 | +++ plugins/wifi/OtherNetwork.qml 2016-08-19 12:48:19 +0000 |
29 | @@ -21,7 +21,6 @@ |
30 | import Ubuntu.Components.ListItems 1.3 as ListItems |
31 | import Ubuntu.Components.Popups 1.3 |
32 | import Ubuntu.SystemSettings.Wifi 1.0 |
33 | -import QMenuModel 0.1 |
34 | |
35 | Component { |
36 | |
37 | |
38 | === renamed file 'plugins/wifi/qmldir' => 'plugins/wifi/qmldir.in' |
39 | === modified file 'plugins/wifi/wifidbushelper.cpp' |
40 | --- plugins/wifi/wifidbushelper.cpp 2016-07-13 19:43:56 +0000 |
41 | +++ plugins/wifi/wifidbushelper.cpp 2016-08-19 12:48:19 +0000 |
42 | @@ -40,8 +40,14 @@ |
43 | typedef QMap<QString,QVariantMap> ConfigurationData; |
44 | Q_DECLARE_METATYPE(ConfigurationData) |
45 | |
46 | -WifiDbusHelper::WifiDbusHelper(QObject *parent) : QObject(parent), |
47 | - m_systemBusConnection(QDBusConnection::systemBus()) |
48 | +WifiDbusHelper::WifiDbusHelper(QObject *parent) |
49 | + : WifiDbusHelper(QDBusConnection::systemBus(), parent) |
50 | +{ |
51 | +} |
52 | + |
53 | +WifiDbusHelper::WifiDbusHelper(const QDBusConnection &dbus, QObject *parent) |
54 | + : QObject(parent) |
55 | + , m_systemBusConnection(dbus) |
56 | { |
57 | qDBusRegisterMetaType<ConfigurationData>(); |
58 | } |
59 | @@ -194,7 +200,7 @@ |
60 | QDBusInterface iface(NM_SERVICE, |
61 | d.path(), |
62 | NM_DEVICE_IFACE, |
63 | - QDBusConnection::systemBus()); |
64 | + m_systemBusConnection); |
65 | |
66 | auto type_v = iface.property("DeviceType"); |
67 | if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) { |
68 | @@ -206,7 +212,7 @@ |
69 | QDBusInterface wiface(NM_SERVICE, |
70 | d.path(), |
71 | NM_DEVICE_WIRELESS_IFACE, |
72 | - QDBusConnection::systemBus()); |
73 | + m_systemBusConnection); |
74 | |
75 | // Get a list of access points and use ssid to find the |
76 | // one we're trying to connect to. |
77 | @@ -229,7 +235,7 @@ |
78 | QDBusInterface aiface(NM_SERVICE, |
79 | ap_list[i].path(), |
80 | NM_AP_IFACE, |
81 | - QDBusConnection::systemBus()); |
82 | + m_systemBusConnection); |
83 | |
84 | auto ssid_v = aiface.property("Ssid"); |
85 | |
86 | @@ -484,7 +490,7 @@ |
87 | OrgFreedesktopNetworkManagerSettingsInterface foo |
88 | (NM_SERVICE, |
89 | "/org/freedesktop/NetworkManager/Settings", |
90 | - QDBusConnection::systemBus()); |
91 | + m_systemBusConnection); |
92 | auto reply = foo.ListConnections(); |
93 | reply.waitForFinished(); |
94 | if (reply.isValid()) { |
95 | @@ -520,7 +526,7 @@ |
96 | OrgFreedesktopNetworkManagerSettingsConnectionInterface bar |
97 | (NM_SERVICE, |
98 | dbus_path, |
99 | - QDBusConnection::systemBus()); |
100 | + m_systemBusConnection); |
101 | auto reply = bar.Delete(); |
102 | reply.waitForFinished(); |
103 | if(!reply.isValid()) { |
104 | |
105 | === modified file 'plugins/wifi/wifidbushelper.h' |
106 | --- plugins/wifi/wifidbushelper.h 2015-06-03 19:35:09 +0000 |
107 | +++ plugins/wifi/wifidbushelper.h 2016-08-19 12:48:19 +0000 |
108 | @@ -35,6 +35,7 @@ |
109 | |
110 | public: |
111 | explicit WifiDbusHelper(QObject *parent = nullptr); |
112 | + explicit WifiDbusHelper(const QDBusConnection &dbus, QObject *parent = nullptr); |
113 | ~WifiDbusHelper() {}; |
114 | |
115 | Q_INVOKABLE void connect(QString ssid, int security, int auth, QStringList usernames, QStringList password, QStringList certs, int p2auth); |
116 | |
117 | === modified file 'tests/CMakeLists.txt' |
118 | --- tests/CMakeLists.txt 2016-08-16 11:42:49 +0000 |
119 | +++ tests/CMakeLists.txt 2016-08-19 12:48:19 +0000 |
120 | @@ -66,7 +66,7 @@ |
121 | |
122 | add_subdirectory(utils) |
123 | |
124 | -# QML tests that require graphical capabitlies. |
125 | +# QML tests that require graphical capabilities. |
126 | add_custom_target(qmluitests) |
127 | add_dependencies(qmluitests UbuntuTest) |
128 | |
129 | |
130 | === modified file 'tests/autopilot/ubuntu_system_settings/__init__.py' |
131 | --- tests/autopilot/ubuntu_system_settings/__init__.py 2016-08-03 12:02:13 +0000 |
132 | +++ tests/autopilot/ubuntu_system_settings/__init__.py 2016-08-19 12:48:19 +0000 |
133 | @@ -1548,60 +1548,6 @@ |
134 | if obj.checked != state: |
135 | self.pointing_device.click_object(obj) |
136 | |
137 | - """Connects to hidden network |
138 | - |
139 | - :param name: Network name string (SSID) |
140 | - :kwarg security: A string that is either "none", "wpa" or "wep |
141 | - :kwarg password: A string/hex secret |
142 | - :kwarg cancel: A boolean deciding whether we press cancel or not |
143 | - |
144 | - :returns: If we are connecting, it returns the dialog, |
145 | - if we cancel, it returns itself |
146 | - |
147 | - """ |
148 | - @autopilot.logging.log_action(logger.debug) |
149 | - def connect_to_hidden_network(self, name, security='none', username=None, |
150 | - password=None, auth=None, protocol=None, |
151 | - cancel=False): |
152 | - dialog = self._click_connect_to_hidden_network() |
153 | - dialog._scroll_to_and_click = self._scroll_to_and_click |
154 | - dialog.enter_name(name) |
155 | - utils.dismiss_osk() |
156 | - |
157 | - if security: |
158 | - dialog.set_security(security) |
159 | - if auth: |
160 | - dialog.set_auth(auth) |
161 | - if protocol: |
162 | - dialog.set_protocol(protocol) |
163 | - if username: |
164 | - dialog.enter_username(username) |
165 | - utils.dismiss_osk() |
166 | - if password: |
167 | - dialog.enter_password(password) |
168 | - utils.dismiss_osk() |
169 | - if cancel: |
170 | - utils.dismiss_osk() |
171 | - dialog.cancel() |
172 | - return self |
173 | - else: |
174 | - utils.dismiss_osk() |
175 | - dialog.connect() |
176 | - return dialog |
177 | - |
178 | - @autopilot.logging.log_action(logger.debug) |
179 | - def _click_connect_to_hidden_network(self): |
180 | - |
181 | - # we can't mock the qunitymenu items, so we |
182 | - # have to wait for them to be built |
183 | - sleep(0.5) |
184 | - |
185 | - button = self.select_single('*', |
186 | - objectName='connectToHiddenNetwork') |
187 | - self._scroll_to_and_click(button) |
188 | - return self.get_root_instance().wait_select_single( |
189 | - objectName='otherNetworkDialog') |
190 | - |
191 | @autopilot.logging.log_action(logger.debug) |
192 | def go_to_previous_networks(self): |
193 | return self._click_previous_network() |
194 | @@ -1647,79 +1593,6 @@ |
195 | return True |
196 | return False |
197 | |
198 | - # FIXME: Use ListItem methods instead. |
199 | - @autopilot.logging.log_action(logger.debug) |
200 | - def _expand_list(self, list_name): |
201 | - item_list = self.select_single( |
202 | - '*', objectName=list_name) |
203 | - active_child = item_list.select_single( |
204 | - '*', objectName='listContainer') |
205 | - self._scroll_to_and_click(active_child) |
206 | - # wait for it to expand |
207 | - sleep(0.5) |
208 | - return item_list |
209 | - |
210 | - @autopilot.logging.log_action(logger.debug) |
211 | - def enter_name(self, name): |
212 | - self._enter_name(name) |
213 | - |
214 | - @autopilot.logging.log_action(logger.debug) |
215 | - def _enter_name(self, name): |
216 | - namefield = self.wait_select_single('TextField', |
217 | - objectName='networkname') |
218 | - self._scroll_to_and_click(namefield) |
219 | - namefield.write(name) |
220 | - |
221 | - @autopilot.logging.log_action(logger.debug) |
222 | - def enter_username(self, username): |
223 | - self._enter_username(username) |
224 | - |
225 | - @autopilot.logging.log_action(logger.debug) |
226 | - def _enter_username(self, username): |
227 | - namefield = self.wait_select_single('TextField', |
228 | - objectName='username') |
229 | - self._scroll_to_and_click(namefield) |
230 | - namefield.write(username) |
231 | - |
232 | - @autopilot.logging.log_action(logger.debug) |
233 | - def set_security(self, security): |
234 | - """Sets the hidden network's security |
235 | - |
236 | - :param security: Either 'none', 'wpa', 'wep', 'wpa-ep', 'dewp', 'leap' |
237 | - |
238 | - :returns: None |
239 | - """ |
240 | - |
241 | - # We only set security if not none, since none is default |
242 | - if security != 'none': |
243 | - self._set_security(security) |
244 | - |
245 | - @autopilot.logging.log_action(logger.debug) |
246 | - def _set_security(self, security): |
247 | - s_list = self._expand_list('securityList') |
248 | - item = None |
249 | - if security == 'none': |
250 | - item = s_list.wait_select_single('*', text=_('None')) |
251 | - elif security == 'wpa': |
252 | - item = s_list.wait_select_single('*', |
253 | - text=_('WPA & WPA2 Personal')) |
254 | - elif security == 'wep': |
255 | - item = s_list.wait_select_single('*', text=_('WEP')) |
256 | - elif security == 'wpa-ep': |
257 | - item = s_list.wait_select_single('*', |
258 | - text=_('WPA & WPA2 Enterprise')) |
259 | - elif security == 'dwep': |
260 | - item = s_list.wait_select_single('*', |
261 | - text=_('Dynamic WEP (802.1x)')) |
262 | - elif security == 'leap': |
263 | - item = s_list.wait_select_single('*', text=_('LEAP')) |
264 | - elif security is not None: |
265 | - raise ValueError('security type %s is not valid' % security) |
266 | - |
267 | - self.pointing_device.click_object(item) |
268 | - # wait for ui to change |
269 | - sleep(0.5) |
270 | - |
271 | @autopilot.logging.log_action(logger.debug) |
272 | def enter_password(self, password): |
273 | self._enter_password(password) |
274 | @@ -1732,76 +1605,6 @@ |
275 | pwdfield.write(password) |
276 | |
277 | @autopilot.logging.log_action(logger.debug) |
278 | - def set_protocol(self, protocol): |
279 | - """Sets the hidden network's protocol. |
280 | - |
281 | - :param protocol: Either 'pap', 'mschapv2', 'mschap', 'chap', 'gtc', |
282 | - or 'md5'. |
283 | - """ |
284 | - self._set_protocol(protocol) |
285 | - |
286 | - @autopilot.logging.log_action(logger.debug) |
287 | - def _set_protocol(self, protocol): |
288 | - p_list = self._expand_list('p2authList') |
289 | - item = None |
290 | - if protocol == 'pap': |
291 | - item = p_list.wait_select_single(text='PAP') |
292 | - elif protocol == 'mschapv2': |
293 | - item = p_list.wait_select_single(text='MSCHAPv2') |
294 | - elif protocol == 'mschap': |
295 | - item = p_list.wait_select_single(text='MSCHAP') |
296 | - elif protocol == 'chap': |
297 | - item = p_list.wait_select_single(text='CHAP') |
298 | - elif protocol == 'gtc': |
299 | - item = p_list.wait_select_single(text='GTC') |
300 | - elif protocol == 'md5': |
301 | - item = p_list.wait_select_single(text='MD5') |
302 | - elif protocol is not None: |
303 | - raise ValueError('protocol type %s is not valid' % protocol) |
304 | - |
305 | - self.pointing_device.click_object(item) |
306 | - # wait for ui to change |
307 | - sleep(0.5) |
308 | - |
309 | - @autopilot.logging.log_action(logger.debug) |
310 | - def set_auth(self, auth): |
311 | - """Sets the hidden network's protocol. |
312 | - |
313 | - :param auth: Either 'tls', 'ttls', 'leap', 'fast' or 'peap'. |
314 | - """ |
315 | - self._set_auth(auth) |
316 | - |
317 | - @autopilot.logging.log_action(logger.debug) |
318 | - def _set_auth(self, auth): |
319 | - a_list = self._expand_list('authList') |
320 | - item = None |
321 | - if auth == 'tls': |
322 | - item = a_list.wait_select_single(text='TLS') |
323 | - elif auth == 'ttls': |
324 | - item = a_list.wait_select_single(text='TTLS') |
325 | - elif auth == 'leap': |
326 | - item = a_list.wait_select_single(text='LEAP') |
327 | - elif auth == 'fast': |
328 | - item = a_list.wait_select_single(text='FAST') |
329 | - elif auth == 'peap': |
330 | - item = a_list.wait_select_single(text='PEAP') |
331 | - elif auth is not None: |
332 | - raise ValueError('auth type %s is not valid' % auth) |
333 | - |
334 | - self.pointing_device.click_object(item) |
335 | - # wait for ui to change |
336 | - sleep(0.5) |
337 | - |
338 | - @autopilot.logging.log_action(logger.debug) |
339 | - def cancel(self): |
340 | - self._click_cancel() |
341 | - |
342 | - @autopilot.logging.log_action(logger.debug) |
343 | - def _click_cancel(self): |
344 | - button = self.select_single('Button', objectName='cancel') |
345 | - self._scroll_to_and_click(button) |
346 | - |
347 | - @autopilot.logging.log_action(logger.debug) |
348 | def connect(self): |
349 | self._click_connect() |
350 | |
351 | |
352 | === modified file 'tests/autopilot/ubuntu_system_settings/tests/test_wifi.py' |
353 | --- tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-09-04 14:32:16 +0000 |
354 | +++ tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2016-08-19 12:48:19 +0000 |
355 | @@ -10,15 +10,11 @@ |
356 | import dbus |
357 | |
358 | from autopilot.matchers import Eventually |
359 | -from dbusmock.templates.networkmanager import ( |
360 | - DEVICE_IFACE, NM80211ApSecurityFlags |
361 | -) |
362 | from testtools.matchers import Equals |
363 | from time import sleep |
364 | from ubuntu_system_settings.tests import (WifiBaseTestCase, |
365 | WifiWithSSIDBaseTestCase) |
366 | from ubuntu_system_settings.utils.i18n import ugettext as _ |
367 | -from unittest import skip |
368 | |
369 | |
370 | class WifiEnabledTestCase(WifiBaseTestCase): |
371 | @@ -30,131 +26,6 @@ |
372 | self.wifi_page.title, |
373 | Equals(_('Wi-Fi'))) |
374 | |
375 | - def test_connect_to_hidden_network(self): |
376 | - dialog = self.wifi_page.connect_to_hidden_network( |
377 | - 'test_ap', |
378 | - password='abcdefgh',) |
379 | - |
380 | - # allow backend to set up listeners |
381 | - sleep(0.3) |
382 | - |
383 | - if dialog: |
384 | - dialog.wait_until_destroyed() |
385 | - |
386 | - def test_connect_to_eduroam(self): |
387 | - self.create_access_point( |
388 | - 'eduroam', 'eduroam', |
389 | - security=NM80211ApSecurityFlags.NM_802_11_AP_SEC_KEY_MGMT_802_1X |
390 | - ) |
391 | - |
392 | - dialog = self.wifi_page.connect_to_hidden_network( |
393 | - 'eduroam', |
394 | - username='student', |
395 | - password='a', |
396 | - security='wpa-ep', |
397 | - auth='peap', |
398 | - protocol='mschapv2', |
399 | - ) |
400 | - |
401 | - # allow backend to set up listeners |
402 | - sleep(0.3) |
403 | - |
404 | - if dialog: |
405 | - dialog.wait_until_destroyed() |
406 | - |
407 | - dev = dbus.Interface(self.dbus_con.get_object( |
408 | - 'org.freedesktop.NetworkManager', self.device_path), |
409 | - 'org.freedesktop.DBus.Properties') |
410 | - |
411 | - conn_obj = dev.Get( |
412 | - 'org.freedesktop.NetworkManager.Device', 'AvailableConnections' |
413 | - )[0] |
414 | - conn = dbus.Interface(self.dbus_con.get_object( |
415 | - 'org.freedesktop.NetworkManager', conn_obj), |
416 | - 'org.freedesktop.NetworkManager.Settings.Connection') |
417 | - |
418 | - conn_settings = conn.GetSettings() |
419 | - wconn = conn_settings['connection'] |
420 | - w802_11_sec = conn_settings['802-11-wireless-security'] |
421 | - w802_1x = conn_settings['802-1x'] |
422 | - |
423 | - self.assertEquals(wconn['type'], '802-11-wireless') |
424 | - self.assertEquals(w802_11_sec['key-mgmt'], 'wpa-eap') |
425 | - self.assertIn('peap', w802_1x['eap']) |
426 | - self.assertEquals(w802_1x['identity'], 'student') |
427 | - self.assertEquals(w802_1x['password'], 'a') |
428 | - self.assertEquals(w802_1x['phase2-auth'], 'mschapv2') |
429 | - |
430 | - def test_connect_to_nonexistant_hidden_network(self): |
431 | - dialog = self.wifi_page.connect_to_hidden_network( |
432 | - 'n/a', |
433 | - password='abcdefgh', |
434 | - ) |
435 | - |
436 | - # allow backend to set up listeners |
437 | - sleep(0.3) |
438 | - |
439 | - """Mock a StateChanged signal on the Device, using a likely |
440 | - scenario of a not found SSID: |
441 | - newState = 120 # NM_DEVICE_STATE_FAILED |
442 | - oldState = 0 # does not matter |
443 | - reason = 53 # NM_DEVICE_STATE_REASON_SSID_NOT_FOUND |
444 | - |
445 | - We manually emit this signal, because the networkmanager mock |
446 | - currently does not support this. See [1]. |
447 | - |
448 | - [1] https://github.com/martinpitt/python-dbusmock/issues/8 |
449 | - """ |
450 | - |
451 | - self.device_mock.EmitSignal( |
452 | - DEVICE_IFACE, 'StateChanged', 'uuu', [120, 0, 53]) |
453 | - |
454 | - self.assertThat( |
455 | - dialog.text, Eventually(Equals( |
456 | - _('The Wi-Fi network could not be found')))) |
457 | - |
458 | - @skip('skipped due to %s' % ( |
459 | - 'https://github.com/martinpitt/python-dbusmock/issues/7')) |
460 | - def test_connect_to_hidden_network_using_secrets(self): |
461 | - dialog = self.wifi_page.connect_to_hidden_network( |
462 | - 'test_ap', security='wpa', password='abcdefgh', |
463 | - ) |
464 | - |
465 | - # allow backend to set up listeners |
466 | - sleep(0.3) |
467 | - |
468 | - if dialog: |
469 | - dialog.wait_until_destroyed() |
470 | - |
471 | - @skip('skipped due to %s' % ( |
472 | - 'https://github.com/martinpitt/python-dbusmock/issues/7')) |
473 | - def test_connect_to_hidden_network_using_incorrect_secrets(self): |
474 | - dialog = self.wifi_page.connect_to_hidden_network( |
475 | - 'test_ap', |
476 | - security='wpa', |
477 | - password='abcdefgh', |
478 | - ) |
479 | - |
480 | - # allow backend to set up listeners |
481 | - sleep(0.3) |
482 | - |
483 | - self.assertThat( |
484 | - dialog.text, Eventually(Equals( |
485 | - _('Your authentication details were incorrect')))) |
486 | - |
487 | - @skip('networkmanager mock does not yet support deletion of cons') |
488 | - def test_connect_to_hidden_network_then_cancel(self): |
489 | - dialog = self.wifi_page.connect_to_hidden_network('foo',) |
490 | - |
491 | - # allow backend to set up listeners |
492 | - sleep(0.3) |
493 | - |
494 | - dialog.cancel() |
495 | - |
496 | - self.assertThat( |
497 | - lambda: len(self.active_connection_mock.GetMethodCalls('Delete')), |
498 | - Eventually(Equals(1))) |
499 | - |
500 | def test_remove_previous_network(self): |
501 | access_points = ['Series of Tubes', 'dev/null', 'Mi-Fi', |
502 | 'MonkeySphere'] |
503 | |
504 | === modified file 'tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt' |
505 | --- tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt 2016-07-25 13:54:08 +0000 |
506 | +++ tests/mocks/Ubuntu/SystemSettings/CMakeLists.txt 2016-08-19 12:48:19 +0000 |
507 | @@ -1,2 +1,3 @@ |
508 | add_subdirectory(Notifications) |
509 | add_subdirectory(Update) |
510 | +add_subdirectory(Wifi) |
511 | |
512 | === added directory 'tests/mocks/Ubuntu/SystemSettings/Wifi' |
513 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/CMakeLists.txt' |
514 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
515 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/CMakeLists.txt 2016-08-19 12:48:19 +0000 |
516 | @@ -0,0 +1,26 @@ |
517 | +include_directories( |
518 | + ${CMAKE_CURRENT_BINARY_DIR} |
519 | + ${CMAKE_SOURCE_DIR}/plugins/wifi/ |
520 | + ${Qt5Core_INCLUDE_DIRS} |
521 | + ${Qt5Quick_INCLUDE_DIRS} |
522 | + ${Qt5Qml_INCLUDE_DIRS} |
523 | +) |
524 | + |
525 | +set(MOCK_WIFI_SRCS |
526 | + MockCertHandler.h |
527 | + MockCertHandler.cpp |
528 | + MockDbusHelper.h |
529 | + MockDbusHelper.cpp |
530 | + plugin.cpp |
531 | +) |
532 | + |
533 | +add_library(MockUbuntuWifiPanel SHARED ${MOCK_WIFI_SRCS}) |
534 | + |
535 | +target_link_libraries(MockUbuntuWifiPanel |
536 | + ${Qt5Core_LIBRARIES} |
537 | + ${Qt5Quick_LIBRARIES} |
538 | + ${Qt5Qml_LIBRARIES} |
539 | +) |
540 | + |
541 | +add_uss_mock(Ubuntu.SystemSettings.Wifi 1.0 Ubuntu/SystemSettings/Wifi |
542 | + TARGETS MockUbuntuWifiPanel) |
543 | |
544 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.cpp' |
545 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.cpp 1970-01-01 00:00:00 +0000 |
546 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.cpp 2016-08-19 12:48:19 +0000 |
547 | @@ -0,0 +1,103 @@ |
548 | +/* |
549 | + * This file is part of system-settings |
550 | + * |
551 | + * Copyright (C) 2016 Canonical Ltd. |
552 | + * |
553 | + * This program is free software: you can redistribute it and/or modify it |
554 | + * under the terms of the GNU General Public License version 3, as published |
555 | + * by the Free Software Foundation. |
556 | + * |
557 | + * This program is distributed in the hope that it will be useful, but |
558 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
559 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
560 | + * PURPOSE. See the GNU General Public License for more details. |
561 | + * |
562 | + * You should have received a copy of the GNU General Public License along |
563 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
564 | + */ |
565 | + |
566 | +#include "MockCertHandler.h" |
567 | + |
568 | +MockAbstractListModel::MockAbstractListModel(QObject *parent) |
569 | +{ |
570 | +} |
571 | + |
572 | +QHash<int, QByteArray> MockAbstractListModel::roleNames() const |
573 | +{ |
574 | + QHash<int, QByteArray> roles; |
575 | + |
576 | + roles[CNRole] = "CommonName"; |
577 | + roles[ORole] = "Organization"; |
578 | + roles[expDateRole] = "expiryDate"; |
579 | + |
580 | + roles[keyName] = "KeyName"; |
581 | + roles[keyType] = "KeyType"; |
582 | + roles[keyAlgorithm] = "KeyAlgorithm"; |
583 | + roles[keyLength] = "KeyLength"; |
584 | + |
585 | + roles[pacFileName] = "pacFileName"; |
586 | + |
587 | + return roles; |
588 | +} |
589 | + |
590 | +int MockAbstractListModel::rowCount(const QModelIndex &parent) const |
591 | +{ |
592 | + return m_files.size(); |
593 | +} |
594 | + |
595 | +QString MockAbstractListModel::getfileName(const int selectedIndex) const |
596 | +{ |
597 | + return m_files[selectedIndex].fileName; |
598 | +} |
599 | + |
600 | +void MockAbstractListModel::dataupdate() |
601 | +{ |
602 | +} |
603 | + |
604 | +QVariant MockAbstractListModel::data(const QModelIndex &index, int role) const |
605 | +{ |
606 | + auto ret = QVariant(); |
607 | + switch (role) { |
608 | + case CNRole: |
609 | + return m_files[index.row()].commonName; |
610 | + case ORole: |
611 | + return m_files[index.row()].organization; |
612 | + case expDateRole: |
613 | + return m_files[index.row()].expiryDate; |
614 | + case keyName: |
615 | + return m_files[index.row()].keyName; |
616 | + case keyType: |
617 | + return m_files[index.row()].keyType; |
618 | + case keyAlgorithm: |
619 | + return m_files[index.row()].keyAlgorithm; |
620 | + case keyLength: |
621 | + return m_files[index.row()].keyLength; |
622 | + case pacFileName: |
623 | + return m_files[index.row()].pacFileName; |
624 | + } |
625 | +} |
626 | + |
627 | +QByteArray MockFileHandler::getCertContent(QString filename) |
628 | +{ |
629 | + return QByteArray(); |
630 | +} |
631 | + |
632 | +QString MockFileHandler::moveCertFile(QString filename) |
633 | +{ |
634 | + return QString(); |
635 | +} |
636 | + |
637 | +QString MockFileHandler::moveKeyFile(QString filename) |
638 | +{ |
639 | + return QString(); |
640 | +} |
641 | + |
642 | +QString MockFileHandler::movePacFile(QString filename) |
643 | +{ |
644 | + return QString(); |
645 | +} |
646 | + |
647 | +bool MockFileHandler::removeFile(QString filename) |
648 | +{ |
649 | + return false; |
650 | +} |
651 | |
652 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.h' |
653 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.h 1970-01-01 00:00:00 +0000 |
654 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/MockCertHandler.h 2016-08-19 12:48:19 +0000 |
655 | @@ -0,0 +1,92 @@ |
656 | +/* |
657 | + * This file is part of system-settings |
658 | + * |
659 | + * Copyright (C) 2016 Canonical Ltd. |
660 | + * |
661 | + * This program is free software: you can redistribute it and/or modify it |
662 | + * under the terms of the GNU General Public License version 3, as published |
663 | + * by the Free Software Foundation. |
664 | + * |
665 | + * This program is distributed in the hope that it will be useful, but |
666 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
667 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
668 | + * PURPOSE. See the GNU General Public License for more details. |
669 | + * |
670 | + * You should have received a copy of the GNU General Public License along |
671 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
672 | + */ |
673 | + |
674 | +#ifndef MOCK_CERTHANDLER_H |
675 | +#define MOCK_CERTHANDLER_H |
676 | + |
677 | +#include <QAbstractListModel> |
678 | +#include <QObject> |
679 | +#include <QList> |
680 | + |
681 | +struct MockFile { |
682 | + QString fileName; |
683 | + QString commonName; |
684 | + QString organization; |
685 | + QString expiryDate; // dd.mm.yyyy |
686 | + |
687 | + QString keyName; |
688 | + QString keyType; |
689 | + QString keyAlgorithm; |
690 | + uint keyLength; |
691 | + |
692 | + QString pacFileName; |
693 | +}; |
694 | + |
695 | +class MockAbstractListModel : public QAbstractListModel |
696 | +{ |
697 | + Q_OBJECT |
698 | +public: |
699 | + enum Roles { |
700 | + CNRole = Qt::UserRole + 1, |
701 | + ORole, |
702 | + expDateRole, |
703 | + |
704 | + keyName, |
705 | + keyType, |
706 | + keyAlgorithm, |
707 | + keyLength, |
708 | + |
709 | + pacFileName |
710 | + }; |
711 | + explicit MockAbstractListModel(QObject *parent = 0); |
712 | + ~MockAbstractListModel() {}; |
713 | + QHash<int, QByteArray> roleNames() const; |
714 | + Q_INVOKABLE int rowCount(const QModelIndex &parent = QModelIndex()) const; |
715 | + Q_INVOKABLE QString getfileName(const int selectedIndex) const; |
716 | + Q_INVOKABLE void dataupdate(); |
717 | + QVariant data(const QModelIndex &index, int role) const; |
718 | + QList<MockFile> m_files = QList<MockFile>(); |
719 | +}; |
720 | + |
721 | +class MockFileHandler : public QObject |
722 | +{ |
723 | + Q_OBJECT |
724 | +public: |
725 | + Q_INVOKABLE QByteArray getCertContent(QString filename); |
726 | + Q_INVOKABLE QString moveCertFile(QString filename); |
727 | + Q_INVOKABLE QString moveKeyFile(QString filename); |
728 | + Q_INVOKABLE QString movePacFile(QString filename); |
729 | + Q_INVOKABLE bool removeFile(QString filename); |
730 | +}; |
731 | + |
732 | +class MockCertificateListModel : public MockAbstractListModel |
733 | +{ |
734 | + Q_OBJECT |
735 | +}; |
736 | + |
737 | +class MockPrivatekeyListModel : public MockAbstractListModel |
738 | +{ |
739 | + Q_OBJECT |
740 | +}; |
741 | + |
742 | +class MockPacFileListModel : public MockAbstractListModel |
743 | +{ |
744 | + Q_OBJECT |
745 | +}; |
746 | + |
747 | +#endif // MOCK_CERTHANDLER_H |
748 | |
749 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.cpp' |
750 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.cpp 1970-01-01 00:00:00 +0000 |
751 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.cpp 2016-08-19 12:48:19 +0000 |
752 | @@ -0,0 +1,76 @@ |
753 | +/* |
754 | + * This file is part of system-settings |
755 | + * |
756 | + * Copyright (C) 2016 Canonical Ltd. |
757 | + * |
758 | + * This program is free software: you can redistribute it and/or modify it |
759 | + * under the terms of the GNU General Public License version 3, as published |
760 | + * by the Free Software Foundation. |
761 | + * |
762 | + * This program is distributed in the hope that it will be useful, but |
763 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
764 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
765 | + * PURPOSE. See the GNU General Public License for more details. |
766 | + * |
767 | + * You should have received a copy of the GNU General Public License along |
768 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
769 | + */ |
770 | + |
771 | +#include "MockDbusHelper.h" |
772 | + |
773 | +MockDbusHelper::MockDbusHelper(QObject *parent) |
774 | +{ |
775 | + Q_UNUSED(parent); |
776 | +} |
777 | + |
778 | +void MockDbusHelper::connect(QString ssid, int security, int auth, QStringList usernames, QStringList password, QStringList certs, int p2auth) |
779 | +{ |
780 | + m_connect["ssid"] = ssid; |
781 | + m_connect["security"] = security; |
782 | + m_connect["auth"] = auth; |
783 | + m_connect["usernames"] = usernames; |
784 | + m_connect["password"] = password; |
785 | + m_connect["certs"] = certs; |
786 | + m_connect["p2auth"] = p2auth; |
787 | +} |
788 | + |
789 | +QList<QStringList> MockDbusHelper::getPreviouslyConnectedWifiNetworks() |
790 | +{ |
791 | + return QList<QStringList>(); |
792 | +} |
793 | + |
794 | +void MockDbusHelper::forgetConnection(const QString dbus_path) |
795 | +{ |
796 | + Q_UNUSED(dbus_path); |
797 | +} |
798 | + |
799 | +bool MockDbusHelper::forgetActiveDevice() |
800 | +{ |
801 | + forgetActiveDeviceCalled = true; |
802 | + return true; |
803 | +} |
804 | + |
805 | +void MockDbusHelper::nmDeviceStateChanged(uint, uint, uint) |
806 | +{ |
807 | +} |
808 | + |
809 | +QString MockDbusHelper::getWifiIpAddress() |
810 | +{ |
811 | + return QString(); |
812 | +} |
813 | + |
814 | +void MockDbusHelper::mockDeviceStateChanged(uint newState, uint reason) |
815 | +{ |
816 | + Q_EMIT deviceStateChanged(newState, reason); |
817 | +} |
818 | + |
819 | +QVariantMap MockDbusHelper::getConnectArguments() |
820 | +{ |
821 | + return m_connect; |
822 | +} |
823 | + |
824 | +bool MockDbusHelper::getForgetActiveDeviceCalled() |
825 | +{ |
826 | + return forgetActiveDeviceCalled; |
827 | +} |
828 | + |
829 | |
830 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.h' |
831 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.h 1970-01-01 00:00:00 +0000 |
832 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/MockDbusHelper.h 2016-08-19 12:48:19 +0000 |
833 | @@ -0,0 +1,57 @@ |
834 | +/* |
835 | + * This file is part of system-settings |
836 | + * |
837 | + * Copyright (C) 2016 Canonical Ltd. |
838 | + * |
839 | + * This program is free software: you can redistribute it and/or modify it |
840 | + * under the terms of the GNU General Public License version 3, as published |
841 | + * by the Free Software Foundation. |
842 | + * |
843 | + * This program is distributed in the hope that it will be useful, but |
844 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
845 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
846 | + * PURPOSE. See the GNU General Public License for more details. |
847 | + * |
848 | + * You should have received a copy of the GNU General Public License along |
849 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
850 | + */ |
851 | + |
852 | +#ifndef MOCK_WIFI_DBUS_HELPER_H |
853 | +#define MOCK_WIFI_DBUS_HELPER_H |
854 | + |
855 | +#include <QObject> |
856 | +#include <QStringList> |
857 | +#include <QVariantMap> |
858 | + |
859 | +class MockDbusHelper : public QObject |
860 | +{ |
861 | + Q_OBJECT |
862 | + Q_PROPERTY(QString wifiIp4Address READ getWifiIpAddress |
863 | + NOTIFY wifiIp4AddressChanged) |
864 | +public: |
865 | + explicit MockDbusHelper(QObject *parent = nullptr); |
866 | + ~MockDbusHelper() {}; |
867 | + |
868 | + Q_INVOKABLE void connect(QString ssid, int security, int auth, QStringList usernames, QStringList password, QStringList certs, int p2auth); |
869 | + Q_INVOKABLE QList<QStringList> getPreviouslyConnectedWifiNetworks(); |
870 | + Q_INVOKABLE void forgetConnection(const QString dbus_path); |
871 | + Q_INVOKABLE bool forgetActiveDevice(); |
872 | + QString getWifiIpAddress(); |
873 | + |
874 | + Q_INVOKABLE void mockDeviceStateChanged(uint newState, uint reason); |
875 | + Q_INVOKABLE QVariantMap getConnectArguments(); // mock only |
876 | + Q_INVOKABLE bool getForgetActiveDeviceCalled(); // mock only |
877 | + |
878 | +public Q_SLOTS: |
879 | + void nmDeviceStateChanged(uint, uint, uint); |
880 | + |
881 | +Q_SIGNALS: |
882 | + void wifiIp4AddressChanged(QString wifiIp4Address); |
883 | + void deviceStateChanged(uint newState, uint reason); |
884 | +private: |
885 | + // This stores params passed to connect(). |
886 | + bool forgetActiveDeviceCalled = false; |
887 | + QVariantMap m_connect = QVariantMap(); |
888 | +}; |
889 | + |
890 | +#endif // MOCK_WIFI_DBUS_HELPER_H |
891 | |
892 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.cpp' |
893 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.cpp 1970-01-01 00:00:00 +0000 |
894 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.cpp 2016-08-19 12:48:19 +0000 |
895 | @@ -0,0 +1,42 @@ |
896 | +/* |
897 | + * This file is part of system-settings |
898 | + * |
899 | + * Copyright (C) 2016 Canonical Ltd. |
900 | + * |
901 | + * This program is free software: you can redistribute it and/or modify it |
902 | + * under the terms of the GNU General Public License version 3, as published |
903 | + * by the Free Software Foundation. |
904 | + * |
905 | + * This program is distributed in the hope that it will be useful, but |
906 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
907 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
908 | + * PURPOSE. See the GNU General Public License for more details. |
909 | + * |
910 | + * You should have received a copy of the GNU General Public License along |
911 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
912 | + */ |
913 | + |
914 | +#include "plugin.h" |
915 | +#include "MockCertHandler.h" |
916 | +#include "MockDbusHelper.h" |
917 | + |
918 | +#include <QtQml> |
919 | + |
920 | +#define MAKE_SINGLETON_FACTORY(type) \ |
921 | + static QObject* type##_singleton_factory(QQmlEngine* engine, QJSEngine* scriptEngine) { \ |
922 | + Q_UNUSED(engine); \ |
923 | + Q_UNUSED(scriptEngine); \ |
924 | + return new type(); \ |
925 | + } |
926 | + |
927 | +MAKE_SINGLETON_FACTORY(MockDbusHelper) |
928 | + |
929 | +void BackendPlugin::registerTypes(const char *uri) |
930 | +{ |
931 | + Q_ASSERT(uri == QLatin1String("Ubuntu.SystemSettings.Wifi")); |
932 | + qmlRegisterSingletonType<MockDbusHelper>(uri, 1, 0, "DbusHelper", MockDbusHelper_singleton_factory); |
933 | + qmlRegisterType<MockCertificateListModel>(uri, 1, 0, "CertificateListModel"); |
934 | + qmlRegisterType<MockPrivatekeyListModel>(uri, 1, 0, "PrivatekeyListModel"); |
935 | + qmlRegisterType<MockPacFileListModel>(uri, 1, 0, "PacFileListModel"); |
936 | + qmlRegisterType<MockFileHandler>(uri, 1, 0, "FileHandler"); |
937 | +} |
938 | |
939 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.h' |
940 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.h 1970-01-01 00:00:00 +0000 |
941 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/plugin.h 2016-08-19 12:48:19 +0000 |
942 | @@ -0,0 +1,32 @@ |
943 | +/* |
944 | + * This file is part of system-settings |
945 | + * |
946 | + * Copyright (C) 2016 Canonical Ltd. |
947 | + * |
948 | + * This program is free software: you can redistribute it and/or modify it |
949 | + * under the terms of the GNU General Public License version 3, as published |
950 | + * by the Free Software Foundation. |
951 | + * |
952 | + * This program is distributed in the hope that it will be useful, but |
953 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
954 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
955 | + * PURPOSE. See the GNU General Public License for more details. |
956 | + * |
957 | + * You should have received a copy of the GNU General Public License along |
958 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
959 | + */ |
960 | + |
961 | +#ifndef MOCK_SYSTEMSETTINGS_WIFI_PLUGIN_H |
962 | +#define MOCK_SYSTEMSETTINGS_WIFI_PLUGIN_H |
963 | + |
964 | +#include <QQmlExtensionPlugin> |
965 | + |
966 | +class BackendPlugin : public QQmlExtensionPlugin |
967 | +{ |
968 | + Q_OBJECT |
969 | + Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") |
970 | +public: |
971 | + void registerTypes(const char *uri) override; |
972 | +}; |
973 | + |
974 | +#endif // MOCK_SYSTEMSETTINGS_WIFI_PLUGIN_H |
975 | |
976 | === added file 'tests/mocks/Ubuntu/SystemSettings/Wifi/qmldir' |
977 | --- tests/mocks/Ubuntu/SystemSettings/Wifi/qmldir 1970-01-01 00:00:00 +0000 |
978 | +++ tests/mocks/Ubuntu/SystemSettings/Wifi/qmldir 2016-08-19 12:48:19 +0000 |
979 | @@ -0,0 +1,2 @@ |
980 | +module Ubuntu.SystemSettings.Wifi |
981 | +plugin MockUbuntuWifiPanel |
982 | |
983 | === added directory 'tests/mocks/plugins/wifi' |
984 | === added file 'tests/mocks/plugins/wifi/fakenetworkmanager.cpp' |
985 | --- tests/mocks/plugins/wifi/fakenetworkmanager.cpp 1970-01-01 00:00:00 +0000 |
986 | +++ tests/mocks/plugins/wifi/fakenetworkmanager.cpp 2016-08-19 12:48:19 +0000 |
987 | @@ -0,0 +1,65 @@ |
988 | +/* |
989 | + * This file is part of system-settings |
990 | + * |
991 | + * Copyright (C) 2016 Canonical Ltd. |
992 | + * |
993 | + * This program is free software: you can redistribute it and/or modify it |
994 | + * under the terms of the GNU General Public License version 3, as published |
995 | + * by the Free Software Foundation. |
996 | + * |
997 | + * This program is distributed in the hope that it will be useful, but |
998 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
999 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1000 | + * PURPOSE. See the GNU General Public License for more details. |
1001 | + * |
1002 | + * You should have received a copy of the GNU General Public License along |
1003 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1004 | + */ |
1005 | + |
1006 | +#include "fakenetworkmanager.h" |
1007 | + |
1008 | +FakeNetworkManager::FakeNetworkManager(const QVariantMap ¶meters, |
1009 | + QObject *parent) |
1010 | + : QObject(parent) |
1011 | + , m_dbusTestRunner() |
1012 | + , m_dbusMock(m_dbusTestRunner) |
1013 | +{ |
1014 | + DBusMock::registerMetaTypes(); |
1015 | + qDBusRegisterMetaType<QMap<QString, QString> >(); |
1016 | + |
1017 | + /* NETWORK_MANAGER_TEMPLATE is the path to the networkmanager.py file, |
1018 | + defined in the consuming tests makefile. */ |
1019 | + m_dbusMock.registerTemplate(NM_SERVICE, NETWORK_MANAGER_TEMPLATE, parameters, |
1020 | + QDBusConnection::SystemBus); |
1021 | + |
1022 | + m_dbusTestRunner.startServices(); |
1023 | + m_nmMock = new QDBusInterface(NM_SERVICE, |
1024 | + NM_MAIN_OBJECT, |
1025 | + NM_IFACE, |
1026 | + m_dbusTestRunner.systemConnection()); |
1027 | +} |
1028 | + |
1029 | +FakeNetworkManager::~FakeNetworkManager() |
1030 | +{ |
1031 | + delete m_nmMock; |
1032 | +} |
1033 | + |
1034 | +QVariant FakeNetworkManager::getProperty(const QString &path, |
1035 | + const QString &interface, |
1036 | + const QString &property) |
1037 | +{ |
1038 | + QDBusInterface iface(NM_SERVICE, path, |
1039 | + FREEDESKTOP_PROPERTIES_IFACE, |
1040 | + m_dbusTestRunner.systemConnection()); |
1041 | + |
1042 | + QDBusReply<QVariant> reply = iface.call("Get", interface, property); |
1043 | + |
1044 | + if (reply.isValid()) { |
1045 | + return reply.value(); |
1046 | + } else { |
1047 | + qWarning() << "Error getting property from mock:" |
1048 | + << reply.error().message(); |
1049 | + } |
1050 | + |
1051 | + return reply.isValid() ? reply.value() : QVariant(); |
1052 | +} |
1053 | |
1054 | === added file 'tests/mocks/plugins/wifi/fakenetworkmanager.h' |
1055 | --- tests/mocks/plugins/wifi/fakenetworkmanager.h 1970-01-01 00:00:00 +0000 |
1056 | +++ tests/mocks/plugins/wifi/fakenetworkmanager.h 2016-08-19 12:48:19 +0000 |
1057 | @@ -0,0 +1,56 @@ |
1058 | +/* |
1059 | + * This file is part of system-settings |
1060 | + * |
1061 | + * Copyright (C) 2016 Canonical Ltd. |
1062 | + * |
1063 | + * This program is free software: you can redistribute it and/or modify it |
1064 | + * under the terms of the GNU General Public License version 3, as published |
1065 | + * by the Free Software Foundation. |
1066 | + * |
1067 | + * This program is distributed in the hope that it will be useful, but |
1068 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1069 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1070 | + * PURPOSE. See the GNU General Public License for more details. |
1071 | + * |
1072 | + * You should have received a copy of the GNU General Public License along |
1073 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1074 | + */ |
1075 | + |
1076 | +#ifndef FAKE_NETWORK_MANAGER_H |
1077 | +#define FAKE_NETWORK_MANAGER_H |
1078 | + |
1079 | +#include <QObject> |
1080 | +#include <QVariant> |
1081 | +#include <QString> |
1082 | +#include <QDBusConnection> |
1083 | +#include <QDBusInterface> |
1084 | + |
1085 | +#include <libqtdbusmock/DBusMock.h> |
1086 | +#include <libqtdbustest/DBusTestRunner.h> |
1087 | + |
1088 | +#define NM_SERVICE "org.freedesktop.NetworkManager" |
1089 | +#define NM_IFACE "org.freedesktop.NetworkManager" |
1090 | +#define NM_MAIN_OBJECT "/org/freedesktop/NetworkManager" |
1091 | +#define FREEDESKTOP_PROPERTIES_IFACE "org.freedesktop.DBus.Properties" |
1092 | + |
1093 | +using namespace QtDBusTest; |
1094 | +using namespace QtDBusMock; |
1095 | + |
1096 | +class FakeNetworkManager : public QObject |
1097 | +{ |
1098 | + Q_OBJECT |
1099 | +public: |
1100 | + explicit FakeNetworkManager(const QVariantMap ¶meters, QObject *parent = 0); |
1101 | + ~FakeNetworkManager(); |
1102 | + |
1103 | + const QDBusConnection & dbus() { return m_dbusTestRunner.systemConnection(); } |
1104 | + QVariant getProperty(const QString &path, |
1105 | + const QString &interface, |
1106 | + const QString &property); |
1107 | +private: |
1108 | + DBusTestRunner m_dbusTestRunner; |
1109 | + DBusMock m_dbusMock; |
1110 | + QDBusInterface *m_nmMock; |
1111 | +}; |
1112 | + |
1113 | +#endif // FAKE_NETWORK_MANAGER_H |
1114 | |
1115 | === modified file 'tests/plugins/CMakeLists.txt' |
1116 | --- tests/plugins/CMakeLists.txt 2016-08-12 12:15:26 +0000 |
1117 | +++ tests/plugins/CMakeLists.txt 2016-08-19 12:48:19 +0000 |
1118 | @@ -4,6 +4,7 @@ |
1119 | add_subdirectory(security-privacy) |
1120 | add_subdirectory(system-update) |
1121 | add_subdirectory(bluetooth) |
1122 | +add_subdirectory(wifi) |
1123 | add_subdirectory(notifications) |
1124 | |
1125 | set(qmltest_DEFAULT_TARGETS qmluitests) |
1126 | @@ -13,9 +14,16 @@ |
1127 | ) |
1128 | |
1129 | add_qml_test(mouse mouse |
1130 | - IMPORT_PATHS |
1131 | - ${CMAKE_SOURCE_DIR}/tests/plugins/mouse |
1132 | -) |
1133 | + IMPORT_PATHS |
1134 | + ${CMAKE_SOURCE_DIR}/tests/plugins/mouse |
1135 | + ${qmltest_DEFAULT_IMPORT_PATHS}) |
1136 | + |
1137 | +add_qml_test(wifi OtherNetwork |
1138 | + IMPORT_PATHS |
1139 | + ${CMAKE_BINARY_DIR}/tests/mocks/ |
1140 | + ${CMAKE_SOURCE_DIR}/src |
1141 | + ${CMAKE_CURRENT_SOURCE_DIR}/wifi |
1142 | + ${qmltest_DEFAULT_IMPORT_PATHS}) |
1143 | |
1144 | set(SYSTEMUPDATE_IMPORT_PATHS |
1145 | ${CMAKE_SOURCE_DIR}/src |
1146 | |
1147 | === modified file 'tests/plugins/mouse/tst_mouse.qml' |
1148 | --- tests/plugins/mouse/tst_mouse.qml 2016-07-30 02:04:45 +0000 |
1149 | +++ tests/plugins/mouse/tst_mouse.qml 2016-08-19 12:48:19 +0000 |
1150 | @@ -51,8 +51,9 @@ |
1151 | compare(area.message, i18n.tr("Double-clicked")); |
1152 | } |
1153 | function test_double_click_fail() { |
1154 | + var timer = findInvisibleChild(testRoot, "clickTimer"); |
1155 | mouseClick(area); |
1156 | - wait(220); |
1157 | + tryCompare(timer, "running", false); |
1158 | mouseClick(area); |
1159 | compare(area.message, i18n.tr("Not fast enough")); |
1160 | } |
1161 | |
1162 | === added directory 'tests/plugins/wifi' |
1163 | === added file 'tests/plugins/wifi/CMakeLists.txt' |
1164 | --- tests/plugins/wifi/CMakeLists.txt 1970-01-01 00:00:00 +0000 |
1165 | +++ tests/plugins/wifi/CMakeLists.txt 2016-08-19 12:48:19 +0000 |
1166 | @@ -0,0 +1,23 @@ |
1167 | +include_directories( |
1168 | + ${CMAKE_SOURCE_DIR}/plugins/wifi |
1169 | + ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/wifi |
1170 | + ${CMAKE_CURRENT_BINARY_DIR} |
1171 | + ${QTDBUSMOCK_INCLUDE_DIRS} |
1172 | + ${QTDBUSTEST_INCLUDE_DIRS} |
1173 | +) |
1174 | + |
1175 | +add_definitions(-DNETWORK_MANAGER_TEMPLATE="${CMAKE_SOURCE_DIR}/tests/autopilot/ubuntu_system_settings/tests/networkmanager.py") |
1176 | + |
1177 | +add_executable(tst-wifidbushelper |
1178 | + tst_wifidbushelper.cpp |
1179 | + |
1180 | + ${CMAKE_SOURCE_DIR}/plugins/wifi/nm_manager_proxy.h |
1181 | + ${CMAKE_SOURCE_DIR}/plugins/wifi/nm_settings_proxy.h |
1182 | + ${CMAKE_SOURCE_DIR}/plugins/wifi/nm_settings_connection_proxy.h |
1183 | + |
1184 | + ${CMAKE_SOURCE_DIR}/plugins/wifi/wifidbushelper.cpp |
1185 | + ${CMAKE_SOURCE_DIR}/tests/mocks/plugins/wifi/fakenetworkmanager.cpp |
1186 | +) |
1187 | +qt5_use_modules(tst-wifidbushelper Core DBus Network Test) |
1188 | +target_link_libraries(tst-wifidbushelper ${QTDBUSMOCK_LIBRARIES} ${QTDBUSTEST_LIBRARIES}) |
1189 | +add_test(tst-wifidbushelper tst-wifidbushelper) |
1190 | |
1191 | === added directory 'tests/plugins/wifi/WifiSource' |
1192 | === added file 'tests/plugins/wifi/WifiSource/qmldir' |
1193 | --- tests/plugins/wifi/WifiSource/qmldir 1970-01-01 00:00:00 +0000 |
1194 | +++ tests/plugins/wifi/WifiSource/qmldir 2016-08-19 12:48:19 +0000 |
1195 | @@ -0,0 +1,2 @@ |
1196 | +module WifiSource |
1197 | +OtherNetwork 1.0 ../../../../plugins/wifi/OtherNetwork.qml |
1198 | |
1199 | === added file 'tests/plugins/wifi/tst_OtherNetwork.qml' |
1200 | --- tests/plugins/wifi/tst_OtherNetwork.qml 1970-01-01 00:00:00 +0000 |
1201 | +++ tests/plugins/wifi/tst_OtherNetwork.qml 2016-08-19 12:48:19 +0000 |
1202 | @@ -0,0 +1,169 @@ |
1203 | +/* |
1204 | + * This file is part of system-settings |
1205 | + * |
1206 | + * Copyright (C) 2016 Canonical Ltd. |
1207 | + * |
1208 | + * This program is free software: you can redistribute it and/or modify it |
1209 | + * under the terms of the GNU General Public License version 3, as published |
1210 | + * by the Free Software Foundation. |
1211 | + * |
1212 | + * This program is distributed in the hope that it will be useful, but |
1213 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1214 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1215 | + * PURPOSE. See the GNU General Public License for more details. |
1216 | + * |
1217 | + * You should have received a copy of the GNU General Public License along |
1218 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1219 | + */ |
1220 | + |
1221 | +import QtQuick 2.4 |
1222 | +import QtTest 1.0 |
1223 | +import Ubuntu.Components 1.3 |
1224 | +import Ubuntu.Components.Popups 1.3 |
1225 | +import Ubuntu.SystemSettings.Wifi 1.0 |
1226 | +import Ubuntu.Test 0.1 |
1227 | + |
1228 | +import WifiSource 1.0 |
1229 | + |
1230 | +Item { |
1231 | + id: testRoot |
1232 | + width: units.gu(50) |
1233 | + height: units.gu(90) |
1234 | + |
1235 | + OtherNetwork { |
1236 | + id: otherNetworkDialog |
1237 | + } |
1238 | + |
1239 | + UbuntuTestCase { |
1240 | + name: "OtherNetworkTest" |
1241 | + when: windowShown |
1242 | + |
1243 | + property var instance |
1244 | + |
1245 | + function init() { |
1246 | + instance = PopupUtils.open(otherNetworkDialog); |
1247 | + } |
1248 | + |
1249 | + function cleanup() { |
1250 | + if (instance) { |
1251 | + instance.destroy(); |
1252 | + tryCompareFunction(function () { |
1253 | + return !!findChild(testRoot, "otherNetworkDialog"); |
1254 | + }, false); |
1255 | + } |
1256 | + } |
1257 | + |
1258 | + function setSelectedIndex(objectName, index) { |
1259 | + findChild(instance, objectName).selectedIndex = index; |
1260 | + } |
1261 | + |
1262 | + function setName(name) { |
1263 | + findChild(instance, "networkname").text = name; |
1264 | + } |
1265 | + |
1266 | + function setSecurity(index) { |
1267 | + setSelectedIndex("securityList", index); |
1268 | + } |
1269 | + |
1270 | + function setAuth(index) { |
1271 | + setSelectedIndex("authList", index); |
1272 | + } |
1273 | + |
1274 | + function setP2auth(index) { |
1275 | + setSelectedIndex("p2authList", index); |
1276 | + } |
1277 | + |
1278 | + function setPeapVersion(index) { |
1279 | + setSelectedIndex("peapVersionList", index); |
1280 | + } |
1281 | + |
1282 | + function setUsername(username) { |
1283 | + findChild(instance, "username").text = username; |
1284 | + } |
1285 | + |
1286 | + function setPassword(password) { |
1287 | + findChild(instance, "password").text = password; |
1288 | + } |
1289 | + |
1290 | + function cancel() { |
1291 | + var btn = findChild(instance, "cancel"); |
1292 | + mouseClick(btn, btn.width / 2, btn.height / 2); |
1293 | + } |
1294 | + |
1295 | + function connect() { |
1296 | + var btn = findChild(instance, "connect"); |
1297 | + mouseClick(btn, btn.width / 2, btn.height / 2); |
1298 | + } |
1299 | + |
1300 | + function test_connect_to_hidden_network() { |
1301 | + setName("test_ap"); |
1302 | + setPassword("abcdefgh"); |
1303 | + connect(); |
1304 | + DbusHelper.mockDeviceStateChanged(100, 0); |
1305 | + |
1306 | + tryCompare(instance, "state", "SUCCEEDED"); |
1307 | + compare(DbusHelper.getConnectArguments()["ssid"], "test_ap"); |
1308 | + compare(DbusHelper.getConnectArguments()["password"], ["abcdefgh", "false"]); |
1309 | + } |
1310 | + |
1311 | + function test_connect_to_nonexistant_hidden_network() { |
1312 | + setName("n/a"); |
1313 | + setPassword("abcdefgh"); |
1314 | + connect(); |
1315 | + DbusHelper.mockDeviceStateChanged(120, 53); |
1316 | + tryCompare(instance, "state", "FAILED"); |
1317 | + |
1318 | + compare(instance.text, i18n.tr('The Wi-Fi network could not be found')); |
1319 | + } |
1320 | + |
1321 | + function test_connect_to_hidden_network_using_secrets() { |
1322 | + setName("test_ap"); |
1323 | + setPassword("abcdefgh"); |
1324 | + setSecurity(1); |
1325 | + connect(); |
1326 | + DbusHelper.mockDeviceStateChanged(100, 0); |
1327 | + |
1328 | + compare(DbusHelper.getConnectArguments()["security"], 1); |
1329 | + } |
1330 | + |
1331 | + function test_connect_to_hidden_network_using_incorrect_secrets() { |
1332 | + setName("test_ap"); |
1333 | + setPassword("wrongpassword"); |
1334 | + setSecurity(1); |
1335 | + connect(); |
1336 | + DbusHelper.mockDeviceStateChanged(120, 7); |
1337 | + |
1338 | + compare(instance.text, i18n.tr('Your authentication details were incorrect')); |
1339 | + } |
1340 | + |
1341 | + function test_connect_to_hidden_network_then_cancel() { |
1342 | + setName("test_ap"); |
1343 | + setPassword("abcdefgh"); |
1344 | + connect(); |
1345 | + cancel(); |
1346 | + |
1347 | + verify(DbusHelper.getForgetActiveDeviceCalled()); |
1348 | + } |
1349 | + |
1350 | + function test_connect_to_eduroam() { |
1351 | + setName("eduroam"); |
1352 | + setUsername("student"); |
1353 | + setPassword("abcdefgh"); |
1354 | + setSecurity(2); // wpa-ep |
1355 | + setAuth(4); // PEAP |
1356 | + setP2auth(1); // MSCHAPv2 |
1357 | + connect(); |
1358 | + DbusHelper.mockDeviceStateChanged(100, 0); |
1359 | + |
1360 | + compare(DbusHelper.getConnectArguments(), { |
1361 | + "auth": 4, |
1362 | + "certs": ["", "", "", "", "1", "2"], |
1363 | + "p2auth": 1, |
1364 | + "password": ["abcdefgh", "false"], |
1365 | + "security": 2, |
1366 | + "ssid": "eduroam", |
1367 | + "usernames": ["student", ""] |
1368 | + }); |
1369 | + } |
1370 | + } |
1371 | +} |
1372 | |
1373 | === added file 'tests/plugins/wifi/tst_wifidbushelper.cpp' |
1374 | --- tests/plugins/wifi/tst_wifidbushelper.cpp 1970-01-01 00:00:00 +0000 |
1375 | +++ tests/plugins/wifi/tst_wifidbushelper.cpp 2016-08-19 12:48:19 +0000 |
1376 | @@ -0,0 +1,163 @@ |
1377 | +/* |
1378 | + * This file is part of system-settings |
1379 | + * |
1380 | + * Copyright (C) 2016 Canonical Ltd. |
1381 | + * |
1382 | + * This program is free software: you can redistribute it and/or modify it |
1383 | + * under the terms of the GNU General Public License version 3, as published |
1384 | + * by the Free Software Foundation. |
1385 | + * |
1386 | + * This program is distributed in the hope that it will be useful, but |
1387 | + * WITHOUT ANY WARRANTY; without even the implied warranties of |
1388 | + * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR |
1389 | + * PURPOSE. See the GNU General Public License for more details. |
1390 | + * |
1391 | + * You should have received a copy of the GNU General Public License along |
1392 | + * with this program. If not, see <http://www.gnu.org/licenses/>. |
1393 | + */ |
1394 | + |
1395 | +#include "wifidbushelper.h" |
1396 | +#include "fakenetworkmanager.h" |
1397 | + |
1398 | +#include <libqtdbusmock/MethodCall.h> |
1399 | + |
1400 | +#include <QDBusMetaType> |
1401 | +#include <QTest> |
1402 | +#include <QSignalSpy> |
1403 | + |
1404 | +class TstDbusHelper: public QObject |
1405 | +{ |
1406 | + Q_OBJECT |
1407 | +private Q_SLOTS: |
1408 | + void init() |
1409 | + { |
1410 | + QVariantMap parameters; |
1411 | + m_nmMock = new FakeNetworkManager(parameters); |
1412 | + m_dbus = new QDBusConnection(m_nmMock->dbus()); |
1413 | + m_instance = new WifiDbusHelper(*m_dbus); |
1414 | + m_mock = new QDBusInterface(NM_SERVICE, |
1415 | + NM_MAIN_OBJECT, |
1416 | + "org.freedesktop.DBus.Mock", |
1417 | + *m_dbus); |
1418 | + m_methodSpy = new QSignalSpy( |
1419 | + m_mock, SIGNAL(MethodCalled(const QString&, const QVariantList&)) |
1420 | + ); |
1421 | + |
1422 | + // Add a Wi-Fi device. |
1423 | + auto devCall = m_mock->asyncCall("AddWiFiDevice", "0", "wlan0", 100); |
1424 | + QDBusPendingCallWatcher devWatcher(devCall); |
1425 | + devWatcher.waitForFinished(); |
1426 | + auto reply = QDBusPendingReply<QString>(devWatcher); |
1427 | + if (reply.isError()) { |
1428 | + QFAIL("Failed to create device"); |
1429 | + } else { |
1430 | + m_devPath = reply.argumentAt<0>(); |
1431 | + } |
1432 | + |
1433 | + // Add access points. |
1434 | + auto wpa = QList<QVariant>(); |
1435 | + wpa << m_devPath << "test_ap_wpa" << "test_ap_wpa" << "00:00:00:00:00:00" << (uint) 3 |
1436 | + << (uint) 60 << (uint) 128 << QVariant::fromValue(uchar(0)) << (uint) 0x00000100; |
1437 | + m_mock->callWithArgumentList(QDBus::Block, "AddAccessPoint", wpa); |
1438 | + |
1439 | + auto wpaep = QList<QVariant>(); |
1440 | + wpaep << m_devPath << "test_ap_wpaep" << "test_ap_wpaep" << "11:11:11:11:11:11" << (uint) 3 |
1441 | + << (uint) 60 << (uint) 128 << QVariant::fromValue(uchar(0)) << (uint) 0x00000200; |
1442 | + m_mock->callWithArgumentList(QDBus::Block, "AddAccessPoint", wpaep); |
1443 | + } |
1444 | + void cleanup() |
1445 | + { |
1446 | + m_devPath = QString::null; |
1447 | + delete m_methodSpy; |
1448 | + delete m_nmMock; |
1449 | + delete m_instance; |
1450 | + delete m_mock; |
1451 | + delete m_dbus; |
1452 | + } |
1453 | + void testConnect_data() |
1454 | + { |
1455 | + QTest::addColumn<QString>("ssid"); |
1456 | + QTest::addColumn<int>("security"); |
1457 | + QTest::addColumn<int>("auth"); |
1458 | + QTest::addColumn<QStringList>("usernames"); |
1459 | + QTest::addColumn<QStringList>("password"); |
1460 | + QTest::addColumn<QStringList>("certs"); |
1461 | + QTest::addColumn<int>("p2auth"); |
1462 | + |
1463 | + { |
1464 | + QString ssid("test_ap_wpa"); |
1465 | + int security = 1; |
1466 | + int auth = 0; |
1467 | + QStringList usernames; |
1468 | + usernames << "user" << "" << ""; |
1469 | + QStringList password; |
1470 | + password << "password" << "false"; |
1471 | + QStringList certs; |
1472 | + certs << "" << "" << "" << "" << "" << ""; |
1473 | + int p2auth = 0; |
1474 | + |
1475 | + QTest::newRow("WPA2") << ssid << security << auth << usernames << password << certs << p2auth; |
1476 | + } |
1477 | + { |
1478 | + QString ssid("test_ap_wpaep"); |
1479 | + int security = 2; |
1480 | + int auth = 0; |
1481 | + QStringList usernames; |
1482 | + usernames << "user" << "" << ""; |
1483 | + QStringList password; |
1484 | + password << "password" << "false"; |
1485 | + QStringList certs; |
1486 | + certs << "" << "" << "" << "" << "" << ""; |
1487 | + int p2auth = 0; |
1488 | + |
1489 | + QTest::newRow("WPA2 Enterprise") << ssid << security << auth << usernames << password << certs << p2auth; |
1490 | + } |
1491 | + } |
1492 | + void testConnect() |
1493 | + { |
1494 | + QFETCH(QString, ssid); |
1495 | + QFETCH(int, security); |
1496 | + QFETCH(int, auth); |
1497 | + QFETCH(QStringList, usernames); |
1498 | + QFETCH(QStringList, password); |
1499 | + QFETCH(QStringList, certs); |
1500 | + QFETCH(int, p2auth); |
1501 | + |
1502 | + QSignalSpy activeConnectionSpy( |
1503 | + m_mock, SIGNAL(MethodCalled(const QString &, const QVariantList &)) |
1504 | + ); |
1505 | + |
1506 | + m_instance->connect(ssid, security, auth, usernames, password, certs, p2auth); |
1507 | + |
1508 | + QVERIFY(m_methodSpy->wait()); |
1509 | + QDBusReply<QList<MethodCall>> reply = m_mock->call("GetMethodCalls", "AddAndActivateConnection"); |
1510 | + QVERIFY2(reply.isValid(), "Method was not called correctly."); |
1511 | + QCOMPARE(reply.value().size(), 1); // Called once. |
1512 | + |
1513 | + // Ensure active connection is that of the ssid we connected to. |
1514 | + auto path_v = m_nmMock->getProperty(m_devPath, |
1515 | + "org.freedesktop.NetworkManager.Device", |
1516 | + "ActiveConnection"); |
1517 | + auto path = qdbus_cast<QDBusObjectPath>(path_v).path(); |
1518 | + QCOMPARE(path, |
1519 | + QString("/org/freedesktop/NetworkManager/ActiveConnection/%1") |
1520 | + .arg(ssid)); |
1521 | + |
1522 | + // Ensure device state is OK (100). |
1523 | + auto state_v = m_nmMock->getProperty(m_devPath, |
1524 | + "org.freedesktop.NetworkManager.Device", |
1525 | + "State"); |
1526 | + auto state = qdbus_cast<uint>(state_v); |
1527 | + QCOMPARE(state, (uint) 100); |
1528 | + } |
1529 | +private: |
1530 | + QSignalSpy *m_methodSpy; |
1531 | + FakeNetworkManager *m_nmMock; |
1532 | + QDBusInterface *m_mock; |
1533 | + WifiDbusHelper *m_instance; |
1534 | + QDBusConnection *m_dbus; |
1535 | + QString m_devPath = QString::null; |
1536 | +}; |
1537 | + |
1538 | +QTEST_GUILESS_MAIN(TstDbusHelper) |
1539 | +#include "tst_wifidbushelper.moc" |
FAILED: Continuous integration, rev:1694 /code.launchpad .net/~jonas- drange/ ubuntu- system- settings/ port-eduroamtes t-qml/+ merge/303081/ +edit-commit- message
No commit message was specified in the merge proposal. Click on the following link and set the commit message (if you want a jenkins rebuild you need to trigger it yourself):
https:/
https:/ /jenkins. canonical. com/system- apps/job/ lp-ubuntu- system- settings- ci/108/ /jenkins. canonical. com/system- apps/job/ build/1216/ console /jenkins. canonical. com/system- apps/job/ build-0- fetch/1216 /jenkins. canonical. com/system- apps/job/ build-1- sourcepkg/ release= vivid+overlay/ 1090 /jenkins. canonical. com/system- apps/job/ build-1- sourcepkg/ release= xenial+ overlay/ 1090 /jenkins. canonical. com/system- apps/job/ build-1- sourcepkg/ release= yakkety/ 1090 /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= vivid+overlay/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=amd64, release= yakkety/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= vivid+overlay/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=armhf, release= yakkety/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= vivid+overlay/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1078/console /jenkins. canonical. com/system- apps/job/ build-2- binpkg/ arch=i386, release= yakkety/ 1078/console
Executed test runs:
FAILURE: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
FAILURE: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/system- apps/job/ lp-ubuntu- system- settings- ci/108/ rebuild
https:/