Merge lp:~jonas-drange/ubuntu-system-settings/allow-insecure-hotspot into lp:ubuntu-system-settings

Proposed by Jonas G. Drange
Status: Merged
Approved by: Ken VanDine
Approved revision: 1527
Merged at revision: 1526
Proposed branch: lp:~jonas-drange/ubuntu-system-settings/allow-insecure-hotspot
Merge into: lp:ubuntu-system-settings
Diff against target: 846 lines (+421/-106)
14 files modified
debian/control (+2/-2)
plugins/hotspot/CMakeLists.txt (+2/-0)
plugins/hotspot/HotspotSetup.qml (+95/-42)
plugins/hotspot/PageComponent.qml (+3/-10)
plugins/hotspot/hotspot.settings (+2/-1)
plugins/hotspot/plugin/CMakeLists.txt (+8/-0)
plugins/hotspot/plugin/hotspot-plugin.cpp (+88/-0)
plugins/hotspot/plugin/hotspot-plugin.h (+39/-0)
tests/autopilot/ubuntu_system_settings/__init__.py (+15/-0)
tests/autopilot/ubuntu_system_settings/tests/__init__.py (+70/-41)
tests/autopilot/ubuntu_system_settings/tests/connectivity.py (+12/-0)
tests/autopilot/ubuntu_system_settings/tests/systemimage.py (+48/-0)
tests/autopilot/ubuntu_system_settings/tests/test_hotspot.py (+22/-9)
tests/autopilot/ubuntu_system_settings/tests/test_plugins.py (+15/-1)
To merge this branch: bzr merge lp:~jonas-drange/ubuntu-system-settings/allow-insecure-hotspot
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Needs Fixing
Ken VanDine Approve
Matthew Paul Thomas (community) Needs Fixing
Pete Woods Pending
Review via email: mp+269671@code.launchpad.net

Commit message

[hotspot] allow insecure hotspot, hide hotspot for mako, make autopilot tests run on mako, and change packaging so we get a newer Connectivity API (provided by indicator-network).

Description of the change

* Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes
 * Did you build your software in a clean sbuild/pbuilder chroot or ppa?
Yes
 * Did you build your software in a clean sbuild/pbuilder armhf chroot or ppa?
Yes
 * Has your component "TestPlan” been executed successfully on emulator, N4?
Yes
 * Has a 5 minute exploratory testing run been executed on N4?
N/A
 * If you changed the packaging (debian), did you subscribe a core-dev to this MP?
Yes, and Ken VanDine is subscribed.
 * If you changed the UI, did you subscribe the design-reviewers to this MP?
Yes (mpt)
 * What components might get impacted by your changes?
Hotspot
 * Have you requested review by the teams of these owning components?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
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 :

The latest CI run did have a hotspot related failure:
ubuntu_system_settings.tests.test_hotspot.HotspotSetupTestCase.test_insecure_setup

The other failures look unrelated

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

Thanks for this refinement!

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

> The latest CI run did have a hotspot related failure:
> ubuntu_system_settings.tests.test_hotspot.HotspotSetupTestCase.test_insecure_s
> etup
>
> The other failures look unrelated
Right, we need a newer Connectivity API for insecure setup to work, so this is expected. I'll bump deps to make the CI fail completely.

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

On 3 September 2015 at 13:18, Matthew Paul Thomas <email address hidden> wrote:

> Review: Needs Fixing
>
> ​… ​
> If you check the checkbox, the password field should be focused
> automatically.
>

​Not sure I understand your comment, but I've added a note about this being
a workaround with reference to lp:1415023

​​

> How is settingsValid() ever true when passwordRequiredSwitch is unchecked?
>

settingsValid tests if 1) ssid is a string (not "") and 2) if the
passwordRequired checkbox is checked, it sees if the password length is >=
8.

Could you file a bug about hexadecimal passwords so we can have a
discussion about it? I want to make sure NetworkManager/wpa_supplicant can
handle it before implementing it. Thanks!

As for the rest, I would love another peek at the updated diff (r1519).

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

create plugin for hotspot

1521. By Jonas G. Drange

refactor test classes for re-use, refactor dynamic visibility logic

1522. By Jonas G. Drange

remove mako exceptions in setup code now that the plugin is hidden altogether

1523. By Jonas G. Drange

remove visibility exception in test objects, prune diff

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

I, very informally, measured the start up time of System Settings on mako before and after adding the dynamic visibility of the hotspot entry.

Static hotspot visibility, start up time (in seconds):
4.8
4.7
4.7
4.6
4.6
5.1

Dynamic hotspot visibility, start up time (in seconds):
4.8
4.9
5.1
5.1
4.9
4.7

A 0.1 to 0.3 seconds penalty was added.

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 :

See inline comment

review: Needs Fixing
1524. By Jonas G. Drange

unnecessary comment

1525. By Jonas G. Drange

make mako comment clearer

1526. By Jonas G. Drange

remove qstringlist and qdebug include

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 :

There are 2 places where the strings don't match the design (not necessarily part of this MR, but lets fix it here)

HotSpotSetup.qml
- i18n.tr("Change hotspot setup") : i18n.tr("Setup hotspot")
+ i18n.tr("Change Hotspot Setup") : i18n.tr("Set Up Hotspot")

PageComponent.qml
- i18n.tr("Change password/setup…") : i18n.tr("Set up hotspot…")
+ i18n.tr("Change Password/Setup…") : i18n.tr("Set Up Hotspot…")

review: Needs Fixing
1527. By Jonas G. Drange

be consistent in casing and setup vs set up

Revision history for this message
Ken VanDine (ken-vandine) wrote :

Thanks, looks good!

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2015-08-24 07:50:13 +0000
+++ debian/control 2015-09-10 15:34:03 +0000
@@ -23,7 +23,7 @@
23 libunity-api-dev,23 libunity-api-dev,
24 libupower-glib-dev,24 libupower-glib-dev,
25 pkg-config,25 pkg-config,
26 qml-module-ubuntu-connectivity (>= 0.5.3),26 qml-module-ubuntu-connectivity (>= 0.5.4),
27 qt5-default,27 qt5-default,
28 qtbase5-dev,28 qtbase5-dev,
29 qtdeclarative5-dev,29 qtdeclarative5-dev,
@@ -71,7 +71,7 @@
71 powerd (>= 0.15) | gnome-settings-daemon,71 powerd (>= 0.15) | gnome-settings-daemon,
72 qmenumodel-qml,72 qmenumodel-qml,
73 qml-module-qt-labs-folderlistmodel,73 qml-module-qt-labs-folderlistmodel,
74 qml-module-ubuntu-connectivity (>= 0.5.3),74 qml-module-ubuntu-connectivity (>= 0.5.4),
75 qml-module-qtmultimedia | qml-module-qtmultimedia-gles,75 qml-module-qtmultimedia | qml-module-qtmultimedia-gles,
76 qtdeclarative5-gsettings1.0 (>=0.1+14.10.20140801.1),76 qtdeclarative5-gsettings1.0 (>=0.1+14.10.20140801.1),
77 qtdeclarative5-ofono0.2 (>=0.70~),77 qtdeclarative5-ofono0.2 (>=0.70~),
7878
=== modified file 'plugins/hotspot/CMakeLists.txt'
--- plugins/hotspot/CMakeLists.txt 2015-08-12 15:06:37 +0000
+++ plugins/hotspot/CMakeLists.txt 2015-09-10 15:34:03 +0000
@@ -1,3 +1,5 @@
1add_subdirectory(plugin)
2
1set(QML_SOURCES3set(QML_SOURCES
2 Common.qml4 Common.qml
3 HotspotSetup.qml5 HotspotSetup.qml
46
=== modified file 'plugins/hotspot/HotspotSetup.qml'
--- plugins/hotspot/HotspotSetup.qml 2015-08-17 15:35:08 +0000
+++ plugins/hotspot/HotspotSetup.qml 2015-09-10 15:34:03 +0000
@@ -43,11 +43,21 @@
43 anchorToKeyboard: true43 anchorToKeyboard: true
4444
45 function settingsValid() {45 function settingsValid() {
46 return ssidField.text != "" && passwordField.length >= 8;46 var ssidValid = ssidField.text !== "";
47 var passwordValid = passwordRequiredToggle.checked ?
48 passwordField.length >= 8 : true;
49 return ssidValid && passwordValid;
50 }
51
52 function updateHotspotSettings () {
53 Connectivity.hotspotSsid = ssidField.text;
54 Connectivity.hotspotPassword = passwordField.text;
55 Connectivity.hotspotAuth = passwordRequiredToggle.checked ?
56 "wpa-psk" : "none";
47 }57 }
4858
49 title: stored ?59 title: stored ?
50 i18n.tr("Change hotspot setup") : i18n.tr("Setup hotspot")60 i18n.tr("Change Hotspot Setup") : i18n.tr("Set Up Hotspot")
51 text: feedback.enabled ? feedback.text : "";61 text: feedback.enabled ? feedback.text : "";
5262
53 Common {63 Common {
@@ -70,7 +80,11 @@
70 enabled: false80 enabled: false
71 }81 }
72 PropertyChanges {82 PropertyChanges {
73 target: passwordLabel83 target: passwordRequired
84 enabled: false
85 }
86 PropertyChanges {
87 target: passwordRequiredLabel
74 opacity: 0.588 opacity: 0.5
75 }89 }
76 PropertyChanges {90 PropertyChanges {
@@ -117,14 +131,18 @@
117 opacity: 0.5131 opacity: 0.5
118 }132 }
119 PropertyChanges {133 PropertyChanges {
134 target: passwordRequired
135 enabled: false
136 }
137 PropertyChanges {
138 target: passwordRequiredLabel
139 opacity: 0.5
140 }
141 PropertyChanges {
120 target: ssidField142 target: ssidField
121 enabled: false143 enabled: false
122 }144 }
123 PropertyChanges {145 PropertyChanges {
124 target: passwordLabel
125 opacity: 0.5
126 }
127 PropertyChanges {
128 target: passwordField146 target: passwordField
129 enabled: false147 enabled: false
130 }148 }
@@ -132,10 +150,6 @@
132 target: confirmButton150 target: confirmButton
133 enabled: false151 enabled: false
134 }152 }
135 PropertyChanges {
136 target: enableWifiCaption
137 visible: false
138 }
139 }153 }
140 ]154 ]
141155
@@ -157,8 +171,8 @@
157171
158 Label {172 Label {
159 id: ssidLabel173 id: ssidLabel
160 text: i18n.tr("Hotspot name")174 text: hotspotSetupDialog.stored ? i18n.tr("Hotspot name") :
161 fontSize: "medium"175 i18n.tr("Choose a name")
162 font.bold: true176 font.bold: true
163 color: Theme.palette.selected.backgroundText177 color: Theme.palette.selected.backgroundText
164 elide: Text.ElideRight178 elide: Text.ElideRight
@@ -173,43 +187,78 @@
173 width: parent.width187 width: parent.width
174 }188 }
175189
176 Label {190 ListItem.Empty {
177 id: passwordLabel191 id: passwordRequired
178 // TRANSLATORS: “Password (optional)” is hidden.192 onClicked: passwordRequiredToggle.trigger()
179 text: showAllUI ? i18n.tr("Password (optional)") :193
180 i18n.tr("Key (must be 8 characters or longer)")194 CheckBox {
181 fontSize: "medium"195 id: passwordRequiredToggle
182 font.bold: true196 objectName: "passwordRequiredToggle"
183 color: Theme.palette.selected.backgroundText197 checked: Connectivity.hotspotAuth === "wpa-psk"
184 wrapMode: Text.WordWrap198 anchors {
185 width: parent.width199 left: parent.left
186 }200 verticalCenter: parent.verticalCenter
187201 }
188 Label {202 // FIXME: Workaround for lp:1415023
189 visible: showAllUI203 activeFocusOnPress: false
190 // TRANSLATORS: This string is hidden.204 }
191 text: i18n.tr("If you do not enter a password, the hotspot will be insecure.")205
206 Label {
207 id: passwordRequiredLabel
208 anchors {
209 left: passwordRequiredToggle.right
210 leftMargin: units.gu(1)
211 right: parent.right
212 verticalCenter: parent.verticalCenter
213 }
214
215 // FIXME: Workaround for label not wrapping (lp:1442851)
216 wrapMode: Text.Wrap
217 text: i18n.tr("Require a password (recommended):")
218 }
192 }219 }
193220
194 TextField {221 TextField {
195 id: passwordField222 id: passwordField
196 objectName: "passwordField"223 objectName: "passwordField"
224 enabled: passwordRequiredToggle.checked
197 text: Connectivity.hotspotPassword225 text: Connectivity.hotspotPassword
198 echoMode: passwordVisibleSwitch.checked ?226 echoMode: passwordVisibleToggle.checked ?
199 TextInput.Normal : TextInput.Password227 TextInput.Normal : TextInput.Password
200 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText228 inputMethodHints: Qt.ImhNoAutoUppercase | Qt.ImhNoPredictiveText
201 width: parent.width229 width: parent.width
202 }230 }
203231
204 ListItem.Standard {232 ListItem.Empty {
205 // TRANSLATORS: “Show password” is hidden.
206 text: showAllUI ? i18n.tr("Show password") : i18n.tr("Show key")
207 id: passwordVisible233 id: passwordVisible
208 onClicked: passwordVisibleSwitch.trigger()234 enabled: passwordRequiredToggle.checked
209 control: Switch {235 onClicked: passwordVisibleToggle.trigger()
210 id: passwordVisibleSwitch236
237 CheckBox {
238 id: passwordVisibleToggle
239 enabled: parent.enabled
240 anchors {
241 left: parent.left
242 verticalCenter: parent.verticalCenter
243 }
244
245 // FIXME: Workaround for lp:1415023
211 activeFocusOnPress: false246 activeFocusOnPress: false
212 }247 }
248
249 Label {
250 id: passwordVisibleLabel
251
252 /* FIXME: use enabled when lp:1491802 is fixed, or use
253 CheckBox.text once lp:1323238 is fixed. */
254 opacity: passwordRequiredToggle.checked ? 1 : 0.5
255 anchors {
256 left: passwordVisibleToggle.right
257 leftMargin: units.gu(1)
258 verticalCenter: parent.verticalCenter
259 }
260 text: i18n.tr("Show password")
261 }
213 }262 }
214263
215 ListItem.Caption {264 ListItem.Caption {
@@ -218,8 +267,10 @@
218 left: parent.left267 left: parent.left
219 right: parent.right268 right: parent.right
220 }269 }
221 text: i18n.tr("In order to create a hotspot, you need to turn Wi-Fi on.")270 text: i18n.tr("Starting the hotspot will turn on Wi-Fi.")
222 visible: !Connectivity.wifiEnabled && !hotspotSetupDialog.stored271 visible: !Connectivity.wifiEnabled &&
272 !hotspotSetupDialog.stored &&
273 hotspotSetupDialog.state !== "SUCCEEDED"
223 }274 }
224275
225 Row {276 Row {
@@ -235,6 +286,8 @@
235 id: cancelButton286 id: cancelButton
236 width: (parent.width / 2) - units.gu(1)287 width: (parent.width / 2) - units.gu(1)
237 text: i18n.tr("Cancel")288 text: i18n.tr("Cancel")
289
290 // FIXME: Workaround for lp:1415023
238 activeFocusOnPress: false291 activeFocusOnPress: false
239 onClicked: PopupUtils.close(hotspotSetupDialog)292 onClicked: PopupUtils.close(hotspotSetupDialog)
240 }293 }
@@ -246,6 +299,8 @@
246 text: hotspotSetupDialog.stored ? i18n.tr("Change") :299 text: hotspotSetupDialog.stored ? i18n.tr("Change") :
247 i18n.tr("Start")300 i18n.tr("Start")
248 enabled: settingsValid()301 enabled: settingsValid()
302
303 // FIXME: Workaround for lp:1415023
249 activeFocusOnPress: false304 activeFocusOnPress: false
250 onClicked: {305 onClicked: {
251 if (!Connectivity.wifiEnabled &&306 if (!Connectivity.wifiEnabled &&
@@ -309,8 +364,7 @@
309 }364 }
310 }365 }
311366
312 Connectivity.hotspotSsid = ssidField.text;367 hotspotSetupDialog.updateHotspotSettings();
313 Connectivity.hotspotPassword = passwordField.text;
314 Connectivity.hotspotEnabledUpdated.connect(hotspotEnabledHandler);368 Connectivity.hotspotEnabledUpdated.connect(hotspotEnabledHandler);
315 Connectivity.hotspotEnabled = true;369 Connectivity.hotspotEnabled = true;
316 }370 }
@@ -338,8 +392,7 @@
338 }392 }
339 }393 }
340394
341 Connectivity.hotspotSsid = ssidField.text;395 hotspotSetupDialog.updateHotspotSettings();
342 Connectivity.hotspotPassword = passwordField.text;
343396
344 if (Connectivity.hotspotEnabled) {397 if (Connectivity.hotspotEnabled) {
345 hotspotSetupDialog.state = "STARTING";398 hotspotSetupDialog.state = "STARTING";
346399
=== modified file 'plugins/hotspot/PageComponent.qml'
--- plugins/hotspot/PageComponent.qml 2015-08-17 21:41:30 +0000
+++ plugins/hotspot/PageComponent.qml 2015-09-10 15:34:03 +0000
@@ -25,11 +25,6 @@
25import Ubuntu.Components.Popups 0.125import Ubuntu.Components.Popups 0.1
26import Ubuntu.Connectivity 1.026import Ubuntu.Connectivity 1.0
2727
28/* This is a temporary solution to the issue of Hotspots failing on mako. If
29the device is mako, we hide the hotspot entry. Will be removed once lp:1434591
30has been resolved. */
31import Ubuntu.SystemSettings.Update 1.0
32
33ItemPage {28ItemPage {
3429
35 id: root30 id: root
@@ -40,10 +35,8 @@
40 State {35 State {
41 name: "disabled"36 name: "disabled"
42 // Undefined WifiEnabled means Connectivity is unavailable.37 // Undefined WifiEnabled means Connectivity is unavailable.
43 // Disable for mako (see lp:1434591).38 when: typeof Connectivity.wifiEnabled === "undefined" ||
44 when: (typeof Connectivity.wifiEnabled === "undefined" ||39 Connectivity.FlightMode
45 UpdateManager.deviceName === "mako") ||
46 Connectivity.FlightMode
47 PropertyChanges {40 PropertyChanges {
48 target: hotspotItem41 target: hotspotItem
49 enabled: false42 enabled: false
@@ -124,7 +117,7 @@
124 anchors.horizontalCenter: parent.horizontalCenter117 anchors.horizontalCenter: parent.horizontalCenter
125 width: parent.width - units.gu(4)118 width: parent.width - units.gu(4)
126 text: Connectivity.hotspotStored ?119 text: Connectivity.hotspotStored ?
127 i18n.tr("Change password/setup…") : i18n.tr("Set up hotspot…")120 i18n.tr("Change Password/Setup…") : i18n.tr("Set Up Hotspot…")
128 onClicked: {121 onClicked: {
129 setup.setSource(Qt.resolvedUrl("HotspotSetup.qml"));122 setup.setSource(Qt.resolvedUrl("HotspotSetup.qml"));
130 PopupUtils.open(setup.item, root, {});123 PopupUtils.open(setup.item, root, {});
131124
=== modified file 'plugins/hotspot/hotspot.settings'
--- plugins/hotspot/hotspot.settings 2015-08-12 15:06:37 +0000
+++ plugins/hotspot/hotspot.settings 2015-09-10 15:34:03 +0000
@@ -1,6 +1,7 @@
1{1{
2 "icon": "preferences-network-hotspot-symbolic",2 "icon": "preferences-network-hotspot-symbolic",
3 "name": "Hotspot",3 "name": "Hotspot",
4 "plugin": "hotspot-plugin",
4 "translations": "ubuntu-system-settings",5 "translations": "ubuntu-system-settings",
5 "category": "network",6 "category": "network",
6 "priority": 2,7 "priority": 2,
@@ -13,6 +14,6 @@
13 "tethering"14 "tethering"
14 ],15 ],
15 "has-dynamic-keywords": false,16 "has-dynamic-keywords": false,
16 "has-dynamic-visibility": false,17 "has-dynamic-visibility": true,
17 "page-component": "PageComponent.qml"18 "page-component": "PageComponent.qml"
18}19}
1920
=== added directory 'plugins/hotspot/plugin'
=== added file 'plugins/hotspot/plugin/CMakeLists.txt'
--- plugins/hotspot/plugin/CMakeLists.txt 1970-01-01 00:00:00 +0000
+++ plugins/hotspot/plugin/CMakeLists.txt 2015-09-10 15:34:03 +0000
@@ -0,0 +1,8 @@
1include_directories(${CMAKE_CURRENT_BINARY_DIR})
2
3add_definitions(-DQT_NO_KEYWORDS)
4
5add_library(hotspot-plugin SHARED hotspot-plugin.h hotspot-plugin.cpp)
6qt5_use_modules(hotspot-plugin Core Qml DBus)
7target_link_libraries(hotspot-plugin SystemSettings)
8install(TARGETS hotspot-plugin DESTINATION ${PLUGIN_MODULE_DIR})
09
=== added file 'plugins/hotspot/plugin/hotspot-plugin.cpp'
--- plugins/hotspot/plugin/hotspot-plugin.cpp 1970-01-01 00:00:00 +0000
+++ plugins/hotspot/plugin/hotspot-plugin.cpp 2015-09-10 15:34:03 +0000
@@ -0,0 +1,88 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2015 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#include "hotspot-plugin.h"
23
24#include <QDBusInterface>
25#include <QDBusPendingReply>
26#include <QProcessEnvironment>
27#include <QtDBus>
28#include <SystemSettings/ItemBase>
29
30using namespace SystemSettings;
31
32typedef QMap<QString,QString> VersionDetail;
33Q_DECLARE_METATYPE(VersionDetail)
34
35class HotspotItem: public ItemBase
36{
37 Q_OBJECT
38
39public:
40 explicit HotspotItem(const QVariantMap &staticData, QObject *parent = 0);
41 void setVisibility(bool visible);
42};
43
44
45HotspotItem::HotspotItem(const QVariantMap &staticData, QObject *parent):
46 ItemBase(staticData, parent)
47{
48 qDBusRegisterMetaType<VersionDetail>();
49
50 QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
51 if (env.contains(QLatin1String("USS_SHOW_ALL_UI"))) {
52 QString showAllS = env.value("USS_SHOW_ALL_UI", QString());
53
54 if(!showAllS.isEmpty()) {
55 setVisibility(true);
56 return;
57 }
58 }
59
60 bool supportedDevice(true);
61
62 // TODO: Remove check for mako (lp:1434591).
63 QDBusInterface m_SystemServiceIface("com.canonical.SystemImage",
64 "/Service",
65 "com.canonical.SystemImage",
66 QDBusConnection::systemBus());
67 QDBusPendingReply<int, QString, QString, QString, QMap<QString, QString> > reply = m_SystemServiceIface.call("Info");
68 reply.waitForFinished();
69 if (reply.isValid()) {
70 QString device = reply.argumentAt<1>();
71 supportedDevice = !(device == "mako" || device == "flo");
72 }
73
74 setVisibility(supportedDevice);
75}
76
77void HotspotItem::setVisibility(bool visible)
78{
79 setVisible(visible);
80}
81
82ItemBase *HotspotPlugin::createItem(const QVariantMap &staticData,
83 QObject *parent)
84{
85 return new HotspotItem(staticData, parent);
86}
87
88#include "hotspot-plugin.moc"
089
=== added file 'plugins/hotspot/plugin/hotspot-plugin.h'
--- plugins/hotspot/plugin/hotspot-plugin.h 1970-01-01 00:00:00 +0000
+++ plugins/hotspot/plugin/hotspot-plugin.h 2015-09-10 15:34:03 +0000
@@ -0,0 +1,39 @@
1/*
2 * This file is part of system-settings
3 *
4 * Copyright (C) 2015 Canonical Ltd.
5 *
6 * Contact: Jonas G. Drange <jonas.drange@canonical.com>
7 *
8 * This program is free software: you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 3, as published
10 * by the Free Software Foundation.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranties of
14 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef SYSTEM_SETTINGS_HOTSPOT_PLUGIN_H
23#define SYSTEM_SETTINGS_HOTSPOT_PLUGIN_H
24
25#include <QObject>
26#include <SystemSettings/PluginInterface>
27
28class HotspotPlugin: public QObject, public SystemSettings::PluginInterface2
29{
30 Q_OBJECT
31 Q_PLUGIN_METADATA(IID "com.ubuntu.SystemSettings.PluginInterface/2.0")
32 Q_INTERFACES(SystemSettings::PluginInterface2)
33
34public:
35 SystemSettings::ItemBase *createItem(const QVariantMap &staticData,
36 QObject *parent = 0);
37};
38
39#endif // SYSTEM_SETTINGS_HOTSPOT_PLUGIN_H
040
=== modified file 'tests/autopilot/ubuntu_system_settings/__init__.py'
--- tests/autopilot/ubuntu_system_settings/__init__.py 2015-08-25 14:09:22 +0000
+++ tests/autopilot/ubuntu_system_settings/__init__.py 2015-09-10 15:34:03 +0000
@@ -394,8 +394,11 @@
394 if config:394 if config:
395 if 'ssid' in config:395 if 'ssid' in config:
396 setup.set_ssid(config['ssid'])396 setup.set_ssid(config['ssid'])
397 if 'auth' in config:
398 setup.set_auth(config['auth'])
397 if 'password' in config:399 if 'password' in config:
398 setup.set_password(config['password'])400 setup.set_password(config['password'])
401 utils.dismiss_osk()
399 setup.enable()402 setup.enable()
400 if setup:403 if setup:
401 setup.wait_until_destroyed()404 setup.wait_until_destroyed()
@@ -456,6 +459,11 @@
456 return self.wait_select_single(459 return self.wait_select_single(
457 'Button', objectName='confirmButton')460 'Button', objectName='confirmButton')
458461
462 @property
463 def _password_required_check(self):
464 return self.wait_select_single(
465 'CheckBox', objectName='passwordRequiredToggle')
466
459 @autopilot.logging.log_action(logger.debug)467 @autopilot.logging.log_action(logger.debug)
460 def set_ssid(self, ssid):468 def set_ssid(self, ssid):
461 self._ssid_field.write(ssid)469 self._ssid_field.write(ssid)
@@ -465,6 +473,13 @@
465 self._password_field.write(password)473 self._password_field.write(password)
466474
467 @autopilot.logging.log_action(logger.debug)475 @autopilot.logging.log_action(logger.debug)
476 def set_auth(self, auth):
477 if auth == 'wpa-psk':
478 self._password_required_check.check()
479 else:
480 self._password_required_check.uncheck()
481
482 @autopilot.logging.log_action(logger.debug)
468 def enable(self):483 def enable(self):
469 self.pointing_device.click_object(self._enable_button)484 self.pointing_device.click_object(self._enable_button)
470485
471486
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/__init__.py'
--- tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-08-06 20:05:56 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/__init__.py 2015-09-10 15:34:03 +0000
@@ -173,6 +173,75 @@
173 self.add_mock_battery()173 self.add_mock_battery()
174174
175175
176class UbuntuSystemSettingsHotspotTestCase(UbuntuSystemSettingsTestCase,
177 dbusmock.DBusTestCase):
178 """Base class for tests that tests the hotspot functionality."""
179 connectivity_parameters = {}
180 indicatornetwork_parameters = {}
181 systemimage_parameters = {'device': 'ideal'}
182
183 @classmethod
184 def setUpClass(cls):
185 cls.session_con = cls.get_dbus(False)
186
187 cls.start_system_bus()
188
189 si_tmpl = os.path.join(os.path.dirname(__file__), 'systemimage.py')
190 (cls.si_mock, cls.si_obj) = cls.spawn_server_template(
191 si_tmpl, parameters=cls.systemimage_parameters,
192 stdout=subprocess.PIPE)
193
194 super(UbuntuSystemSettingsHotspotTestCase, cls).setUpClass()
195
196 def setUp(self):
197 if is_process_running(INDICATOR_NETWORK):
198 _stop_process(INDICATOR_NETWORK)
199 self.addCleanup(_start_process, INDICATOR_NETWORK)
200
201 ctv_tmpl = os.path.join(os.path.dirname(__file__), 'connectivity.py')
202 (self.ctv_mock, self.obj_ctv) = self.spawn_server_template(
203 ctv_tmpl, parameters=self.connectivity_parameters,
204 stdout=subprocess.PIPE)
205
206 self.ctv_private = dbus.Interface(
207 self.session_con.get_object(CTV_IFACE, CTV_PRIV_OBJ),
208 'org.freedesktop.DBus.Properties')
209
210 self.ctv_nets = dbus.Interface(
211 self.session_con.get_object(CTV_IFACE, CTV_NETS_OBJ),
212 'org.freedesktop.DBus.Properties')
213
214 inetwork = os.path.join(
215 os.path.dirname(__file__), 'indicatornetwork.py'
216 )
217 (self.inetwork_mock, self.obj_inetwork) = self.spawn_server_template(
218 inetwork, parameters=self.indicatornetwork_parameters,
219 stdout=subprocess.PIPE)
220
221 super(UbuntuSystemSettingsHotspotTestCase, self).setUp()
222
223 def tearDown(self):
224 self.ctv_mock.terminate()
225 self.ctv_mock.wait()
226 self.inetwork_mock.terminate()
227 self.inetwork_mock.wait()
228 super(UbuntuSystemSettingsHotspotTestCase, self).tearDown()
229
230 @classmethod
231 def tearDownClass(cls):
232 cls.si_mock.terminate()
233 cls.si_mock.wait()
234 if dbusmock.DBusTestCase.system_bus_pid is not None:
235 cls.stop_dbus(dbusmock.DBusTestCase.system_bus_pid)
236 del os.environ['DBUS_SYSTEM_BUS_ADDRESS']
237 dbusmock.DBusTestCase.system_bus_pid = None
238 if dbusmock.DBusTestCase.session_bus_pid is not None:
239 cls.stop_dbus(dbusmock.DBusTestCase.session_bus_pid)
240 del os.environ['DBUS_SESSION_BUS_ADDRESS']
241 dbusmock.DBusTestCase.session_bus_pid = None
242 super(UbuntuSystemSettingsHotspotTestCase, cls).tearDownClass()
243
244
176class UbuntuSystemSettingsOfonoTestCase(UbuntuSystemSettingsTestCase,245class UbuntuSystemSettingsOfonoTestCase(UbuntuSystemSettingsTestCase,
177 dbusmock.DBusTestCase):246 dbusmock.DBusTestCase):
178 """Class for cellular tests which sets up an Ofono mock """247 """Class for cellular tests which sets up an Ofono mock """
@@ -395,52 +464,12 @@
395 context.SetProperty(key, value)464 context.SetProperty(key, value)
396465
397466
398class HotspotBaseTestCase(UbuntuSystemSettingsTestCase,467class HotspotBaseTestCase(UbuntuSystemSettingsHotspotTestCase):
399 dbusmock.DBusTestCase):
400
401 connectivity_parameters = {}
402 indicatornetwork_parameters = {}
403
404 @classmethod
405 def setUpClass(cls):
406 cls.session_con = cls.get_dbus(False)
407 super(HotspotBaseTestCase, cls).setUpClass()
408468
409 def setUp(self):469 def setUp(self):
410 if is_process_running(INDICATOR_NETWORK):
411 _stop_process(INDICATOR_NETWORK)
412 self.addCleanup(_start_process, INDICATOR_NETWORK)
413
414 ctv_tmpl = os.path.join(os.path.dirname(__file__), 'connectivity.py')
415 (self.ctv_mock, self.obj_ctv) = self.spawn_server_template(
416 ctv_tmpl, parameters=self.connectivity_parameters,
417 stdout=subprocess.PIPE)
418
419 self.ctv_private = dbus.Interface(
420 self.session_con.get_object(CTV_IFACE, CTV_PRIV_OBJ),
421 'org.freedesktop.DBus.Properties')
422
423 self.ctv_nets = dbus.Interface(
424 self.session_con.get_object(CTV_IFACE, CTV_NETS_OBJ),
425 'org.freedesktop.DBus.Properties')
426
427 inetwork = os.path.join(
428 os.path.dirname(__file__), 'indicatornetwork.py'
429 )
430 (self.inetwork_mock, self.obj_inetwork) = self.spawn_server_template(
431 inetwork, parameters=self.indicatornetwork_parameters,
432 stdout=subprocess.PIPE)
433
434 super(HotspotBaseTestCase, self).setUp()470 super(HotspotBaseTestCase, self).setUp()
435 self.hotspot_page = self.main_view.go_to_hotspot_page()471 self.hotspot_page = self.main_view.go_to_hotspot_page()
436472
437 def tearDown(self):
438 self.ctv_mock.terminate()
439 self.ctv_mock.wait()
440 self.inetwork_mock.terminate()
441 self.inetwork_mock.wait()
442 super(HotspotBaseTestCase, self).tearDown()
443
444473
445class BluetoothBaseTestCase(UbuntuSystemSettingsTestCase):474class BluetoothBaseTestCase(UbuntuSystemSettingsTestCase):
446475
447476
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/connectivity.py'
--- tests/autopilot/ubuntu_system_settings/tests/connectivity.py 2015-08-17 15:35:08 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/connectivity.py 2015-09-10 15:34:03 +0000
@@ -47,6 +47,10 @@
47 self.SetProperty(PRIV_OBJ, PRIV_IFACE, 'HotspotPassword', value)47 self.SetProperty(PRIV_OBJ, PRIV_IFACE, 'HotspotPassword', value)
4848
4949
50def set_hotspot_auth(self, value):
51 self.SetProperty(PRIV_OBJ, PRIV_IFACE, 'HotspotAuth', value)
52
53
50def set_wifi_enabled(self, value):54def set_wifi_enabled(self, value):
51 self.SetProperty(NETS_OBJ, NETS_IFACE, 'WifiEnabled', value)55 self.SetProperty(NETS_OBJ, NETS_IFACE, 'WifiEnabled', value)
5256
@@ -59,6 +63,7 @@
59 mock.set_hotspot_ssid = set_hotspot_ssid63 mock.set_hotspot_ssid = set_hotspot_ssid
60 mock.set_hotspot_password = set_hotspot_password64 mock.set_hotspot_password = set_hotspot_password
61 mock.set_wifi_enabled = set_wifi_enabled65 mock.set_wifi_enabled = set_wifi_enabled
66 mock.set_hotspot_auth = set_hotspot_auth
6267
63 mock.AddObject(68 mock.AddObject(
64 NETS_OBJ,69 NETS_OBJ,
@@ -95,6 +100,9 @@
95 {100 {
96 'HotspotPassword': _parameters.get(101 'HotspotPassword': _parameters.get(
97 'HotspotPassword', dbus.String('abcdefgh')102 'HotspotPassword', dbus.String('abcdefgh')
103 ),
104 'HotspotAuth': _parameters.get(
105 'HotspotAuth', dbus.String('wpa-psk')
98 )106 )
99 },107 },
100 [108 [
@@ -123,6 +131,10 @@
123 'objects["/"].set_hotspot_password(self, args[0])'131 'objects["/"].set_hotspot_password(self, args[0])'
124 ),132 ),
125 (133 (
134 'SetHotspotAuth', 's', '',
135 'objects["/"].set_hotspot_auth(self, args[0])'
136 ),
137 (
126 'SetHotspotEnabled', 'b', '',138 'SetHotspotEnabled', 'b', '',
127 'objects["/"].set_hotspot_enabled(self, args[0])'139 'objects["/"].set_hotspot_enabled(self, args[0])'
128 ),140 ),
129141
=== added file 'tests/autopilot/ubuntu_system_settings/tests/systemimage.py'
--- tests/autopilot/ubuntu_system_settings/tests/systemimage.py 1970-01-01 00:00:00 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/systemimage.py 2015-09-10 15:34:03 +0000
@@ -0,0 +1,48 @@
1'''system image D-BUS mock template'''
2
3# This program is free software; you can redistribute it and/or modify it under
4# the terms of the GNU Lesser General Public License as published by the Free
5# Software Foundation; either version 3 of the License, or (at your option) any
6# later version. See http://www.gnu.org/copyleft/lgpl.html for the full text
7# of the license.
8import dbus
9
10__author__ = 'Jonas G. Drange'
11__email__ = 'jonas.drange@canonical.com'
12__copyright__ = '(c) 2015 Canonical Ltd.'
13__license__ = 'LGPL 3+'
14
15BUS_NAME = 'com.canonical.SystemImage'
16MAIN_IFACE = 'com.canonical.SystemImage'
17MAIN_OBJ = '/Service'
18SYSTEM_BUS = True
19
20
21def load(mock, parameters):
22 global _parameters
23 _parameters = parameters
24
25 mock.props = {
26 'build_number': _parameters.get('build_number', 0),
27 'device': _parameters.get('device', ''),
28 'channel': _parameters.get('channel', ''),
29 'last_update_date': _parameters.get('last_update_date', ''),
30 'last_check_date': _parameters.get('last_check_date', ''),
31 'target_build_number': _parameters.get('target_build_number', -1),
32 'target_version_detail': _parameters.get('target_version_detail', ''),
33 'version_detail': _parameters.get(
34 'version_detail', dbus.Dictionary({}, signature='ss')
35 )
36 }
37
38
39@dbus.service.method(MAIN_IFACE,
40 in_signature='', out_signature='isssa{ss}')
41def Info(self):
42 return (
43 self.props['build_number'],
44 self.props['device'],
45 self.props['channel'],
46 self.props['last_update_date'],
47 self.props['version_detail']
48 )
049
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_hotspot.py'
--- tests/autopilot/ubuntu_system_settings/tests/test_hotspot.py 2015-08-17 15:35:08 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/test_hotspot.py 2015-09-10 15:34:03 +0000
@@ -56,6 +56,26 @@
56 Eventually(Equals(True))56 Eventually(Equals(True))
57 )57 )
5858
59 def test_insecure_setup(self):
60 ssid = 'bar'
61 auth = 'none'
62 config = {'ssid': ssid, 'auth': auth}
63
64 self.hotspot_page.setup_hotspot(config)
65
66 # Assert that the switch is on.
67 self.assertTrue(self.hotspot_page.get_hotspot_status())
68
69 self.assertThat(
70 lambda: self.ctv_private.Get(CTV_PRIV_IFACE, 'HotspotAuth'),
71 Eventually(Equals(auth))
72 )
73
74 self.assertThat(
75 lambda: self.ctv_nets.Get(CTV_NETS_IFACE, 'HotspotStored'),
76 Eventually(Equals(True))
77 )
78
5979
60class HotspotExistsTestCase(HotspotBaseTestCase):80class HotspotExistsTestCase(HotspotBaseTestCase):
6181
@@ -80,8 +100,7 @@
80100
81 def test_changing(self):101 def test_changing(self):
82 ssid = 'bar'102 ssid = 'bar'
83 password = 'zomgzomg'103 config = {'ssid': ssid}
84 config = {'ssid': ssid, 'password': password}
85 self.hotspot_page.setup_hotspot(config)104 self.hotspot_page.setup_hotspot(config)
86105
87 self.assertThat(106 self.assertThat(
@@ -91,11 +110,6 @@
91 Eventually(Equals(ssid))110 Eventually(Equals(ssid))
92 )111 )
93112
94 self.assertThat(
95 lambda: self.ctv_private.Get(CTV_PRIV_IFACE, 'HotspotPassword'),
96 Eventually(Equals(password))
97 )
98
99113
100class HotspotRunningTestCase(HotspotBaseTestCase):114class HotspotRunningTestCase(HotspotBaseTestCase):
101115
@@ -166,8 +180,7 @@
166180
167 def test_setup(self):181 def test_setup(self):
168 ssid = 'bar'182 ssid = 'bar'
169 password = 'zomgzomg'183 config = {'ssid': ssid}
170 config = {'ssid': ssid, 'password': password}
171184
172 self.assertThat(185 self.assertThat(
173 lambda: self.ctv_nets.Get(CTV_NETS_IFACE, 'HotspotStored'),186 lambda: self.ctv_nets.Get(CTV_NETS_IFACE, 'HotspotStored'),
174187
=== modified file 'tests/autopilot/ubuntu_system_settings/tests/test_plugins.py'
--- tests/autopilot/ubuntu_system_settings/tests/test_plugins.py 2015-08-13 13:31:31 +0000
+++ tests/autopilot/ubuntu_system_settings/tests/test_plugins.py 2015-09-10 15:34:03 +0000
@@ -12,7 +12,8 @@
12from ubuntu_system_settings.tests import (12from ubuntu_system_settings.tests import (
13 UbuntuSystemSettingsTestCase,13 UbuntuSystemSettingsTestCase,
14 UbuntuSystemSettingsUpowerTestCase,14 UbuntuSystemSettingsUpowerTestCase,
15 UbuntuSystemSettingsBatteryTestCase15 UbuntuSystemSettingsBatteryTestCase,
16 UbuntuSystemSettingsHotspotTestCase
16)17)
17from ubuntu_system_settings.utils.i18n import ugettext as _18from ubuntu_system_settings.utils.i18n import ugettext as _
1819
@@ -175,3 +176,16 @@
175 objectName='entryComponent-battery'176 objectName='entryComponent-battery'
176 )177 )
177 self.assertThat(plugin, NotEquals(None))178 self.assertThat(plugin, NotEquals(None))
179
180
181class SystemSettingsHotspotTestCases(UbuntuSystemSettingsHotspotTestCase):
182 systemimage_parameters = {'device': 'mako'}
183
184 # TODO: remove once lp:1434591 has been resolved.
185 def test_hotspot_plugin(self):
186 """ Checks that the Hotspot plugin is not available
187 as it is broken on mako."""
188 self.assertThat(lambda: self.main_view.select_single(
189 objectName='entryComponent-hotspot'),
190 raises(StateNotFoundError)
191 )

Subscribers

People subscribed via source and target branches