Merge lp:~jonas-drange/ubuntu-system-settings/fix-1441192 into lp:ubuntu-system-settings
- fix-1441192
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Ken VanDine |
Approved revision: | 1386 |
Merged at revision: | 1446 |
Proposed branch: | lp:~jonas-drange/ubuntu-system-settings/fix-1441192 |
Merge into: | lp:ubuntu-system-settings |
Diff against target: |
341 lines (+98/-53) 4 files modified
plugins/wifi/wifidbushelper.cpp (+44/-2) tests/autopilot/ubuntu_system_settings/__init__.py (+9/-5) tests/autopilot/ubuntu_system_settings/tests/__init__.py (+22/-0) tests/autopilot/ubuntu_system_settings/tests/test_wifi.py (+23/-46) |
To merge this branch: | bzr merge lp:~jonas-drange/ubuntu-system-settings/fix-1441192 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
PS Jenkins bot | continuous-integration | Needs Fixing | |
Sebastien Bacher (community) | Approve | ||
Review via email: mp+255402@code.launchpad.net |
Commit message
[wifi] skip some tests that cannot be mocked and use specific object when found during connection
Description of the change
* Let the wifi dbus helper use a specific object (access point) if one is found.
* Skip tests that depends on mock not currently in python-dbusmock (with comments)
PS Jenkins bot (ps-jenkins) wrote : | # |
Sebastien Bacher (seb128) wrote : | # |
Thanks, if those are not currently ignored does it mean they are failing? Note that the CI run hit a "autopilot.
- 1383. By Jonas G. Drange
-
merge trunk
- 1384. By Jonas G. Drange
-
merge trunk
- 1385. By Jonas G. Drange
-
be specific when it comes to not found exceptions
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1385
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1385
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1385
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1385
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
SUCCESS: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1385
http://
Executed test runs:
UNSTABLE: http://
FAILURE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
- 1386. By Jonas G. Drange
-
merge trunk
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1385
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:1386
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Jonas G. Drange (jonas-drange) wrote : | # |
There was a problem with the test, at the time of your comment seb, but the last failures I believe were transient ones with the root cause being the CI itself.
Thanks
Sebastien Bacher (seb128) wrote : | # |
k, seems fine to me, thanks
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1386
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1386
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1386
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1387
http://
Executed test runs:
FAILURE: http://
SUCCESS: http://
SUCCESS: http://
FAILURE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1387
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:1387
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Preview Diff
1 | === modified file 'plugins/wifi/wifidbushelper.cpp' |
2 | --- plugins/wifi/wifidbushelper.cpp 2014-10-10 14:10:52 +0000 |
3 | +++ plugins/wifi/wifidbushelper.cpp 2015-06-25 12:53:56 +0000 |
4 | @@ -31,7 +31,9 @@ |
5 | |
6 | #define NM_SERVICE "org.freedesktop.NetworkManager" |
7 | #define NM_PATH "/org/freedesktop/NetworkManager" |
8 | +#define NM_AP_IFACE "org.freedesktop.NetworkManager.AccessPoint" |
9 | #define NM_DEVICE_IFACE "org.freedesktop.NetworkManager.Device" |
10 | +#define NM_DEVICE_WIRELESS_IFACE "org.freedesktop.NetworkManager.Device.Wireless" |
11 | #define NM_ACTIVE_CONNECTION_IFACE "org.freedesktop.NetworkManager.Connection.Active" |
12 | |
13 | typedef QMap<QString,QVariantMap> ConfigurationData; |
14 | @@ -86,7 +88,6 @@ |
15 | |
16 | configuration["802-11-wireless"] = wireless; |
17 | |
18 | - |
19 | // find the first wlan adapter for now |
20 | auto reply1 = mgr.GetDevices(); |
21 | reply1.waitForFinished(); |
22 | @@ -97,6 +98,7 @@ |
23 | auto devices = reply1.value(); |
24 | |
25 | QDBusObjectPath dev; |
26 | + QDBusObjectPath access_point("/"); |
27 | for (const auto &d : devices) { |
28 | QDBusInterface iface(NM_SERVICE, |
29 | d.path(), |
30 | @@ -105,7 +107,47 @@ |
31 | |
32 | auto type_v = iface.property("DeviceType"); |
33 | if (type_v.toUInt() == 2 /* NM_DEVICE_TYPE_WIFI */) { |
34 | + |
35 | + // We found the device we want to connect. |
36 | dev = d; |
37 | + |
38 | + // Create a proxy for Device.Wireless. |
39 | + QDBusInterface wiface(NM_SERVICE, |
40 | + d.path(), |
41 | + NM_DEVICE_WIRELESS_IFACE, |
42 | + QDBusConnection::systemBus()); |
43 | + |
44 | + // Get a list of access points and use ssid to find the |
45 | + // one we're trying to connect to. |
46 | + QDBusMessage ap_msg = wiface.call("GetAllAccessPoints"); |
47 | + if (ap_msg.type() == QDBusMessage::ReplyMessage && ap_msg.arguments().count() == 1) { |
48 | + |
49 | + // Get arguments. |
50 | + QList<QVariant> ap_variant = ap_msg.arguments(); |
51 | + |
52 | + // Cast the first QVariant argument as QDBusArgument. |
53 | + QDBusArgument ap_argument = ap_variant.at(0).value<QDBusArgument>(); |
54 | + |
55 | + // Cast the argument to a list of DBus object paths. |
56 | + QList<QDBusObjectPath> ap_list = qdbus_cast<QList<QDBusObjectPath>>(ap_argument); |
57 | + |
58 | + // Loop through the list of paths looking for our ssid. |
59 | + for(int i=0; i<ap_list.size(); ++i){ |
60 | + |
61 | + // Proxy for AccessPoint. |
62 | + QDBusInterface aiface(NM_SERVICE, |
63 | + ap_list[i].path(), |
64 | + NM_AP_IFACE, |
65 | + QDBusConnection::systemBus()); |
66 | + |
67 | + auto ssid_v = aiface.property("Ssid"); |
68 | + |
69 | + if (QString::compare(ssid.toLatin1(), ssid_v.toString(), Qt::CaseSensitive) == 0) { |
70 | + access_point = ap_list[i]; |
71 | + break; |
72 | + } |
73 | + } |
74 | + } |
75 | break; |
76 | } |
77 | } |
78 | @@ -135,7 +177,7 @@ |
79 | QDBusObjectPath tmp; |
80 | auto reply2 = mgr.AddAndActivateConnection(configuration, |
81 | dev, |
82 | - QDBusObjectPath("/"), |
83 | + access_point, |
84 | tmp); |
85 | if(!reply2.isValid()) { |
86 | qWarning() << "Could not connect: " << reply2.error().message() << "\n"; |
87 | |
88 | === modified file 'tests/autopilot/ubuntu_system_settings/__init__.py' |
89 | --- tests/autopilot/ubuntu_system_settings/__init__.py 2015-05-12 16:29:02 +0000 |
90 | +++ tests/autopilot/ubuntu_system_settings/__init__.py 2015-06-25 12:53:56 +0000 |
91 | @@ -28,6 +28,7 @@ |
92 | import autopilot.logging |
93 | import ubuntuuitoolkit |
94 | from autopilot import introspection |
95 | +from autopilot.exceptions import StateNotFoundError |
96 | from ubuntu_system_settings.utils.i18n import ugettext as _ |
97 | |
98 | logger = logging.getLogger(__name__) |
99 | @@ -945,8 +946,8 @@ |
100 | @autopilot.logging.log_action(logger.debug) |
101 | def have_wireless(self): |
102 | try: |
103 | - self.wait_select_single('SwitchMenuItem', text=_('Wi-Fi')) |
104 | - except: |
105 | + self.wait_select_single('SwitchMenu', text=_('Wi-Fi')) |
106 | + except StateNotFoundError: |
107 | return False |
108 | return True |
109 | |
110 | @@ -957,11 +958,11 @@ |
111 | @autopilot.logging.log_action(logger.debug) |
112 | def get_wireless(self): |
113 | return self.wait_select_single( |
114 | - 'SwitchMenuItem', text=_('Wi-Fi')).checked |
115 | + 'SwitchMenu', text=_('Wi-Fi')).checked |
116 | |
117 | @autopilot.logging.log_action(logger.debug) |
118 | def _set_wireless(self, state): |
119 | - obj = self.wait_select_single('SwitchMenuItem', text=_('Wi-Fi')) |
120 | + obj = self.wait_select_single('SwitchMenu', text=_('Wi-Fi')) |
121 | if obj.checked != state: |
122 | self.pointing_device.click_object(obj) |
123 | |
124 | @@ -1076,7 +1077,10 @@ |
125 | :returns: None |
126 | |
127 | """ |
128 | - self._set_security(security) |
129 | + |
130 | + # We only set security if not none, since none is default |
131 | + if security != 'none': |
132 | + self._set_security(security) |
133 | |
134 | @autopilot.logging.log_action(logger.debug) |
135 | def _expand_security_list(self): |
136 | |
137 | === modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py' |
138 | --- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-04-16 15:24:41 +0000 |
139 | +++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-06-25 12:53:56 +0000 |
140 | @@ -20,6 +20,7 @@ |
141 | import dbus |
142 | import dbusmock |
143 | import os |
144 | +import random |
145 | import subprocess |
146 | from datetime import datetime |
147 | from time import sleep |
148 | @@ -27,6 +28,8 @@ |
149 | import ubuntuuitoolkit |
150 | from autopilot import platform |
151 | from autopilot.matchers import Eventually |
152 | +from dbusmock.templates.networkmanager import (InfrastructureMode, |
153 | + NM80211ApSecurityFlags) |
154 | from fixtures import EnvironmentVariable |
155 | from gi.repository import UPowerGlib |
156 | from testtools.matchers import Equals, NotEquals, GreaterThan |
157 | @@ -871,5 +874,24 @@ |
158 | NM_SERVICE, self.device_path), |
159 | dbusmock.MOCK_IFACE) |
160 | |
161 | + self.ap_mock = self.create_access_point('test_ap', 'test_ap') |
162 | + |
163 | super(WifiBaseTestCase, self).setUp() |
164 | self.wifi_page = self.main_view.go_to_wifi_page() |
165 | + |
166 | + def create_access_point(self, name, ssid, secured=True): |
167 | + |
168 | + if secured: |
169 | + security = NM80211ApSecurityFlags.NM_802_11_AP_SEC_KEY_MGMT_PSK |
170 | + else: |
171 | + security = NM80211ApSecurityFlags.NM_802_11_AP_SEC_NONE |
172 | + |
173 | + return self.dbusmock.AddAccessPoint( |
174 | + self.device_path, name, ssid, self.random_mac_address(), |
175 | + InfrastructureMode.NM_802_11_MODE_INFRA, 2425, 5400, 82, security) |
176 | + |
177 | + def random_mac_address(self): |
178 | + """Returns a random Mac Address""" |
179 | + mac = [0x00, 0x16, 0x3e, random.randint(0x00, 0x7f), |
180 | + random.randint(0x00, 0xff), random.randint(0x00, 0xff)] |
181 | + return ':'.join(map(lambda x: "%02x" % x, mac)) |
182 | |
183 | === modified file 'tests/autopilot/ubuntu_system_settings/tests/test_wifi.py' |
184 | --- tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-04-01 12:35:10 +0000 |
185 | +++ tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-06-25 12:53:56 +0000 |
186 | @@ -7,9 +7,7 @@ |
187 | |
188 | from __future__ import absolute_import |
189 | from autopilot.matchers import Eventually |
190 | -from dbusmock.templates.networkmanager import (DEVICE_IFACE, |
191 | - InfrastructureMode, |
192 | - NM80211ApSecurityFlags) |
193 | +from dbusmock.templates.networkmanager import DEVICE_IFACE |
194 | from testtools.matchers import Equals |
195 | from time import sleep |
196 | from ubuntu_system_settings.tests import WifiBaseTestCase |
197 | @@ -33,23 +31,13 @@ |
198 | self.wifi_page._set_wireless, self.wifi_page.get_wireless()) |
199 | self.wifi_page.enable_wireless() |
200 | dialog = self.wifi_page.connect_to_hidden_network( |
201 | - 'yeah', |
202 | + 'test_ap', |
203 | scroll_to_and_click=self.main_view |
204 | .scroll_to_and_click) |
205 | |
206 | # allow backend to set up listeners |
207 | sleep(0.3) |
208 | |
209 | - """Mock a StateChanged signal on the Device, using a likely |
210 | - scenario of a not found SSID: |
211 | - newState = 120 # NM_DEVICE_STATE_FAILED |
212 | - oldState = 0 # does not matter |
213 | - reason = 53 # NM_DEVICE_STATE_REASON_SSID_NOT_FOUND |
214 | - """ |
215 | - |
216 | - self.device_mock.EmitSignal( |
217 | - DEVICE_IFACE, 'StateChanged', 'uuu', [100, 0, 0]) |
218 | - |
219 | if dialog: |
220 | dialog.wait_until_destroyed() |
221 | |
222 | @@ -60,7 +48,7 @@ |
223 | self.wifi_page._set_wireless, self.wifi_page.get_wireless()) |
224 | self.wifi_page.enable_wireless() |
225 | dialog = self.wifi_page.connect_to_hidden_network( |
226 | - 'yeah', |
227 | + 'n/a', |
228 | scroll_to_and_click=self.main_view |
229 | .scroll_to_and_click) |
230 | |
231 | @@ -72,6 +60,11 @@ |
232 | newState = 120 # NM_DEVICE_STATE_FAILED |
233 | oldState = 0 # does not matter |
234 | reason = 53 # NM_DEVICE_STATE_REASON_SSID_NOT_FOUND |
235 | + |
236 | + We manually emit this signal, because the networkmanager mock |
237 | + currently does not support this. See [1]. |
238 | + |
239 | + [1] https://github.com/martinpitt/python-dbusmock/issues/8 |
240 | """ |
241 | |
242 | self.device_mock.EmitSignal( |
243 | @@ -81,7 +74,8 @@ |
244 | dialog.text, Eventually(Equals( |
245 | _('The Wi-Fi network could not be found')))) |
246 | |
247 | - @skip('skipped due to bug 1337556') |
248 | + @skip('skipped due to %s' % ( |
249 | + 'https://github.com/martinpitt/python-dbusmock/issues/7')) |
250 | def test_connect_to_hidden_network_using_secrets(self): |
251 | if not self.wifi_page.have_wireless(): |
252 | self.skipTest('Cannot test wireless since it cannot be enabled') |
253 | @@ -89,27 +83,18 @@ |
254 | self.wifi_page._set_wireless, self.wifi_page.get_wireless()) |
255 | self.wifi_page.enable_wireless() |
256 | dialog = self.wifi_page.connect_to_hidden_network( |
257 | - 'yeah', security='wpa', password='abcdefgh', |
258 | + 'test_ap', security='wpa', password='abcdefgh', |
259 | scroll_to_and_click=self.main_view |
260 | .scroll_to_and_click) |
261 | |
262 | # allow backend to set up listeners |
263 | sleep(0.3) |
264 | |
265 | - """Mock a StateChanged signal on the Device, which |
266 | - lets the backend know it was the wrong secret: |
267 | - newState = 100 # NM_DEVICE_STATE_ACTIVATED |
268 | - oldState = 0 # does not matter |
269 | - reason = 0 # does not matter |
270 | - """ |
271 | - |
272 | - self.device_mock.EmitSignal( |
273 | - DEVICE_IFACE, 'StateChanged', 'uuu', [100, 0, 0]) |
274 | - |
275 | if dialog: |
276 | dialog.wait_until_destroyed() |
277 | |
278 | - @skip('skipped due to bug 1337556') |
279 | + @skip('skipped due to %s' % ( |
280 | + 'https://github.com/martinpitt/python-dbusmock/issues/7')) |
281 | def test_connect_to_hidden_network_using_incorrect_secrets(self): |
282 | if not self.wifi_page.have_wireless(): |
283 | self.skipTest('Cannot test wireless since it cannot be enabled') |
284 | @@ -117,26 +102,18 @@ |
285 | self.wifi_page._set_wireless, self.wifi_page.get_wireless()) |
286 | self.wifi_page.enable_wireless() |
287 | dialog = self.wifi_page.connect_to_hidden_network( |
288 | - 'yeah', security='wpa', password='abcdefgh', |
289 | + 'test_ap', security='wpa', password='abcdefgh', |
290 | scroll_to_and_click=self.main_view |
291 | .scroll_to_and_click) |
292 | + |
293 | # allow backend to set up listeners |
294 | sleep(0.3) |
295 | |
296 | - """Mock a StateChanged signal on the Device, which |
297 | - lets the backend know it was the wrong secret: |
298 | - newState = 120 # NM_DEVICE_STATE_FAILED |
299 | - oldState = 0 # does not matter |
300 | - reason = 7 # NM_DEVICE_STATE_REASON_NO_SECRETS |
301 | - """ |
302 | - |
303 | - self.device_mock.EmitSignal( |
304 | - DEVICE_IFACE, 'StateChanged', 'uuu', [120, 0, 7]) |
305 | - |
306 | self.assertThat( |
307 | dialog.text, Eventually(Equals( |
308 | _('Your authentication details were incorrect')))) |
309 | |
310 | + @skip('networkmanager mock does not yet support deletion of cons') |
311 | def test_connect_to_hidden_network_then_cancel(self): |
312 | if not self.wifi_page.have_wireless(): |
313 | self.skipTest('Cannot test wireless since it cannot be enabled') |
314 | @@ -176,14 +153,10 @@ |
315 | access_points = ['Series of Tubes', 'dev/null', 'Mi-Fi', |
316 | 'MonkeySphere'] |
317 | |
318 | - for idx, ap in enumerate(access_points): |
319 | - self.dbusmock.AddAccessPoint( |
320 | - self.device_path, 'Mock_AP%d' % idx, ap, '00:23:F8:7E:12:BB', |
321 | - InfrastructureMode.NM_802_11_MODE_INFRA, 2425, 5400, 82, |
322 | - NM80211ApSecurityFlags.NM_802_11_AP_SEC_KEY_MGMT_PSK) |
323 | - |
324 | + for idx, ssid in enumerate(access_points): |
325 | + self.create_access_point('Mock_AP%d' % idx, ssid) |
326 | self.dbusmock.AddWiFiConnection( |
327 | - self.device_path, 'Mock_Con%d' % idx, ap, '') |
328 | + self.device_path, 'Mock_Con%d' % idx, ssid, '') |
329 | |
330 | self.wifi_page.remove_previous_network( |
331 | access_points[0], scroll_to_and_click=click_method) |
332 | @@ -192,5 +165,9 @@ |
333 | |
334 | # wait for ui to update |
335 | sleep(2) |
336 | + |
337 | self.wifi_page.remove_previous_network( |
338 | access_points[2], scroll_to_and_click=click_method) |
339 | + |
340 | + # We cannot make any assertions, because connection deletion |
341 | + # is currently not supported. |
FAILED: Continuous integration, rev:1382 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- ci/2103/ jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- vivid-touch/ 2843 jenkins. qa.ubuntu. com/job/ ubuntu- system- settings- vivid-i386- ci/373 jenkins. qa.ubuntu. com/job/ generic- deb-autopilot- runner- vivid-mako/ 2435 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2841 jenkins. qa.ubuntu. com/job/ generic- mediumtests- builder- vivid-armhf/ 2841/artifact/ work/output/ *zip*/output. zip s-jenkins. ubuntu- ci:8080/ job/touch- flash-device/ 20534
http://
Executed test runs:
UNSTABLE: http://
SUCCESS: http://
UNSTABLE: http://
SUCCESS: http://
deb: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/ubuntu- system- settings- ci/2103/ rebuild
http://