Merge lp:~jonas-drange/ubuntu-system-settings/handle-ssid-bssid into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Ken VanDine
Approved revision: 1461
Merged at revision: 1463
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/handle-ssid-bssid
Merge into: lp:ubuntu-system-settings
Diff against target: 235 lines (+85/-19)
6 files modified
plugins/wifi/OtherNetwork.qml (+12/-2)
plugins/wifi/PageComponent.qml (+21/-9)
src/qml/MainWindow.qml (+1/-1)
tests/autopilot/ubuntu_system_settings/__init__.py (+2/-2)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+18/-2)
tests/autopilot/ubuntu_system_settings/tests/test_wifi.py (+31/-3)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/handle-ssid-bssid
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ken VanDine Approve
Review via email: mp+263664@code.launchpad.net

Commit message

Lets the Wi-Fi panel respond to an SSID provided by dispatcher by launching a "Connect to" dialogue.

To post a comment you must log in.
1459. By Jonas G. Drange

rename new test classes

1460. By Jonas G. Drange

fix broken test

1461. By Jonas G. Drange

assume that pluginOptions can be absent

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Ken VanDine (ken-vandine) wrote :

This looks good, I tested this with:

url-dispatcher "settings:///wifi?ssid=FooBar"

Worked properly, lets make sure we don't forget to change the string after OTA-5 ships.

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1462. By Jonas G. Drange

invoke dialog on pluginOptions change as well

Revision history for this message
Pete Woods (pete-woods) wrote :

This last change doesn't help with triggering the network quite enough. If you're triggering the same network again, I'm guessing the plugin parameters don't change. Is there not a more precise signal to fire the dialogue on, that indicates an actual incoming URI?

Revision history for this message
Jonas G. Drange (jonas-drange) wrote :

Maybe we unset it?

On Tuesday, 7 July 2015, Pete Woods <email address hidden> wrote:
> This last change doesn't help with triggering the network quite enough.
If you're triggering the same network again, I'm guessing the plugin
parameters don't change. Is there not a more precise signal to fire the
dialogue on, that indicates an actual incoming URI?
> --
>
https://code.launchpad.net/~jonas-drange/ubuntu-system-settings/handle-ssid-bssid/+merge/263664
> You are the owner of
lp:~jonas-drange/ubuntu-system-settings/handle-ssid-bssid.
>

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/wifi/OtherNetwork.qml'
2--- plugins/wifi/OtherNetwork.qml 2015-07-01 18:55:51 +0000
3+++ plugins/wifi/OtherNetwork.qml 2015-07-08 11:49:37 +0000
4@@ -31,6 +31,9 @@
5 objectName: "otherNetworkDialog"
6 anchorToKeyboard: true
7
8+ property string ssid
9+ property string bssid
10+
11 function settingsValid () {
12 if (networkname.length === 0) {
13 return false;
14@@ -80,7 +83,11 @@
15 });
16 }
17
18- title: i18n.tr("Connect to Hidden Network")
19+ title: ssid ?
20+ /* TODO(jgdx): Hack to avoid breaking string freeze. This will be
21+ changed to i18n.tr("Connect to %1").arg(ssid) per spec. */
22+ i18n.tr("Connect to Wi‑Fi") + " " + ssid :
23+ i18n.tr("Connect to Hidden Network")
24 text: feedback.enabled ? feedback.text : "";
25
26 Common {
27@@ -278,6 +285,7 @@
28 font.bold: false
29 color: Theme.palette.selected.backgroundText
30 elide: Text.ElideRight
31+ visible: !ssid
32 }
33
34 TextField {
35@@ -286,6 +294,8 @@
36 width: parent.width
37 placeholderText: i18n.tr("SSID")
38 inputMethodHints: Qt.ImhNoPredictiveText
39+ visible: !ssid
40+ text: ssid ? ssid : ""
41 Component.onCompleted: forceActiveFocus()
42 }
43
44@@ -491,7 +501,7 @@
45 authList.selectedIndex === 1 ||
46 authList.selectedIndex === 3 ||
47 authList.selectedIndex === 4) &&
48- cacertSelector.selectedIndex === 0
49+ cacertSelector.selectedIndex === 0
50 }
51
52 Label {
53
54=== modified file 'plugins/wifi/PageComponent.qml'
55--- plugins/wifi/PageComponent.qml 2015-05-26 15:03:02 +0000
56+++ plugins/wifi/PageComponent.qml 2015-07-08 11:49:37 +0000
57@@ -26,6 +26,9 @@
58 id: wifibase
59 objectName: "wifiPage"
60 title: i18n.tr("Wi-Fi")
61+ property bool wifiEnabled: actionGroup.actionObject.valid ?
62+ actionGroup.actionObject.state : false
63+ property var pluginOptions
64
65 UnityMenuModel {
66 id: menuModel
67@@ -55,13 +58,6 @@
68 }
69 }
70
71- // workaround of getting the following error on startup:
72- // WARNING - file:///usr/..../wifi/PageComponent.qml:24:1: QML Page: Binding loop detected for property "flickable"
73- flickable: null
74- Component.onCompleted: {
75- flickable = pageFlickable
76- }
77-
78 Flickable {
79 id: pageFlickable
80 anchors.fill: parent
81@@ -140,8 +136,7 @@
82 ListItem.SingleValue {
83 objectName: "connectToHiddenNetwork"
84 text: i18n.tr("Connect to hidden network…")
85- visible : (actionGroup.actionObject.valid ?
86- actionGroup.actionObject.state : false)
87+ visible : wifibase.wifiEnabled
88 onClicked: {
89 otherNetworLoader.source = "OtherNetwork.qml";
90 PopupUtils.open(otherNetworLoader.item);
91@@ -159,4 +154,21 @@
92 Flickable.DragAndOvershootBounds :
93 Flickable.StopAtBounds
94 }
95+
96+ Connections {
97+ target: wifibase
98+
99+ function invokeWiFiConfigurationDialog () {
100+ if (wifiEnabled && pluginOptions && pluginOptions['ssid']) {
101+ otherNetworLoader.source = "OtherNetwork.qml";
102+ PopupUtils.open(otherNetworLoader.item, wifibase, {
103+ 'ssid': pluginOptions['ssid'],
104+ 'bssid': pluginOptions['bssid']
105+ });
106+ }
107+ }
108+
109+ onWifiEnabledChanged: invokeWiFiConfigurationDialog()
110+ onPluginOptionsChanged: invokeWiFiConfigurationDialog()
111+ }
112 }
113
114=== modified file 'src/qml/MainWindow.qml'
115--- src/qml/MainWindow.qml 2015-02-19 07:11:47 +0000
116+++ src/qml/MainWindow.qml 2015-07-08 11:49:37 +0000
117@@ -62,7 +62,7 @@
118 i18n.bindtextdomain("ubuntu-system-settings", i18nDirectory)
119 pageStack.push(mainPage)
120 if (defaultPlugin) {
121- if (!loadPluginByName(defaultPlugin))
122+ if (!loadPluginByName(defaultPlugin, pluginOptions))
123 Qt.quit()
124 }
125 }
126
127=== modified file 'tests/autopilot/ubuntu_system_settings/__init__.py'
128--- tests/autopilot/ubuntu_system_settings/__init__.py 2015-07-03 16:08:57 +0000
129+++ tests/autopilot/ubuntu_system_settings/__init__.py 2015-07-08 11:49:37 +0000
130@@ -1174,12 +1174,12 @@
131
132 class WifiPage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
133
134- """Autopilot helper for the Sound page."""
135+ """Autopilot helper for the WiFi page."""
136
137 @classmethod
138 def validate_dbus_object(cls, path, state):
139 name = introspection.get_classname_from_path(path)
140- if name == b'ItemPage':
141+ if name == b'PageComponent':
142 if state['objectName'][1] == 'wifiPage':
143 return True
144 return False
145
146=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
147--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-07-03 16:08:57 +0000
148+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-07-08 11:49:37 +0000
149@@ -884,8 +884,13 @@
150 security=NM80211ApSecurityFlags.NM_802_11_AP_SEC_KEY_MGMT_PSK
151 )
152
153- super(WifiBaseTestCase, self).setUp()
154- self.wifi_page = self.main_view.go_to_wifi_page()
155+ super(WifiBaseTestCase, self).setUp(panel)
156+ if panel:
157+ self.wifi_page = self.main_view.wait_select_single(
158+ objectName='wifiPage'
159+ )
160+ else:
161+ self.wifi_page = self.main_view.go_to_wifi_page()
162
163 def create_access_point(self, name, ssid, security=None):
164 """Creates access point.
165@@ -909,3 +914,14 @@
166 mac = [0x00, 0x16, 0x3e, random.randint(0x00, 0x7f),
167 random.randint(0x00, 0xff), random.randint(0x00, 0xff)]
168 return ':'.join(map(lambda x: "%02x" % x, mac))
169+
170+
171+class WifiWithSSIDBaseTestCase(WifiBaseTestCase):
172+ """ Class for Wi-Fi settings tests launches with an SSID."""
173+
174+ ssid = None
175+
176+ def setUp(self, panel=None):
177+ super(WifiWithSSIDBaseTestCase, self).setUp(
178+ panel='settings:///wifi/?ssid=%s' % self.ssid
179+ )
180
181=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_wifi.py'
182--- tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-06-26 10:49:57 +0000
183+++ tests/autopilot/ubuntu_system_settings/tests/test_wifi.py 2015-07-08 11:49:37 +0000
184@@ -15,7 +15,8 @@
185 )
186 from testtools.matchers import Equals
187 from time import sleep
188-from ubuntu_system_settings.tests import WifiBaseTestCase
189+from ubuntu_system_settings.tests import (WifiBaseTestCase,
190+ WifiWithSSIDBaseTestCase)
191 from ubuntu_system_settings.utils.i18n import ugettext as _
192 from unittest import skip
193
194@@ -208,8 +209,10 @@
195
196 for idx, ssid in enumerate(access_points):
197 self.create_access_point('Mock_AP%d' % idx, ssid)
198- self.dbusmock.AddWiFiConnection(
199- self.device_path, 'Mock_Con%d' % idx, ssid, '')
200+ self.obj_nm.AddWiFiConnection(
201+ self.device_path, 'Mock_Con%d' % idx, ssid, '',
202+ dbus.Dictionary(signature='sa{sv}')
203+ )
204
205 self.wifi_page.remove_previous_network(access_points[0],)
206
207@@ -222,3 +225,28 @@
208
209 # We cannot make any assertions, because connection deletion
210 # is currently not supported.
211+
212+
213+class WifiWithTestSSIDTestCase(WifiWithSSIDBaseTestCase):
214+
215+ ssid = 'test_ap'
216+
217+ def test_handle_wifi_url_with_ssid(self):
218+ if not self.wifi_page.have_wireless():
219+ self.skipTest('Cannot test wireless since it cannot be enabled')
220+ self.addCleanup(
221+ self.wifi_page._set_wireless, self.wifi_page.get_wireless())
222+
223+ self.wifi_page.enable_wireless()
224+ dialog = self.main_view.wait_select_single(
225+ objectName='otherNetworkDialog'
226+ )
227+ dialog._scroll_to_and_click = self.main_view.scroll_to_and_click
228+ dialog.enter_password('abcdefgh')
229+ dialog.connect()
230+
231+ # allow backend to set up listeners
232+ sleep(0.3)
233+
234+ if dialog:
235+ dialog.wait_until_destroyed()

Subscribers

People subscribed via source and target branches