on xenial help sign in
Merge from sim-unlock-on-boot
9e784f8Michael Terry
plugins/Ubuntu/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1+add_subdirectory(Connectivity)
1add_subdirectory(Gestures)
2add_subdirectory(Gestures)
2add_subdirectory(DownloadDaemonListener)
3add_subdirectory(DownloadDaemonListener)
3add_subdirectory(Payments)
4add_subdirectory(Payments)
plugins/Ubuntu/Connectivity/CMakeLists.txtnew file+10
@@ -0,0 +1,10 @@
1+set(CONNECTIVITY_SOURCES
2+ plugin.cpp
3+ Connectivity.cpp
4+)
5+
6+add_library(Connectivity MODULE ${CONNECTIVITY_SOURCES})
7+
8+qt5_use_modules(Connectivity Qml DBus Core)
9+
10+add_unity8_plugin(Ubuntu.Connectivity 0.1 Ubuntu/Connectivity TARGETS Connectivity)
plugins/Ubuntu/Connectivity/Connectivity.cppnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "Connectivity.h"
18+#include <QDBusConnection>
19+#include <QDBusInterface>
20+#include <QDBusPendingCall>
21+
22+Connectivity::Connectivity(QObject *parent)
23+ : QObject(parent)
24+{
25+}
26+
27+void Connectivity::unlockAllModems()
28+{
29+ QDBusInterface iface("com.ubuntu.connectivity1",
30+ "/com/ubuntu/connectivity1/Private",
31+ "com.ubuntu.connectivity1.Private");
32+ iface.asyncCall("UnlockAllModems");
33+}
plugins/Ubuntu/Connectivity/Connectivity.hnew file+33
@@ -0,0 +1,33 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef CONNECTIVITY_H
18+#define CONNECTIVITY_H
19+
20+#include <QObject>
21+
22+class Connectivity : public QObject
23+{
24+ Q_OBJECT
25+ Q_DISABLE_COPY(Connectivity)
26+
27+public:
28+ explicit Connectivity(QObject *parent = 0);
29+
30+ Q_INVOKABLE void unlockAllModems();
31+};
32+
33+#endif // CONNECTIVITY_H
plugins/Ubuntu/Connectivity/Connectivity.qmltypesnew file+17
@@ -0,0 +1,17 @@
1+import QtQuick.tooling 1.1
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable Ubuntu.Connectivity 0.1 plugins'
8+
9+Module {
10+ Component {
11+ name: "Connectivity"
12+ prototype: "QObject"
13+ exports: ["Ubuntu.Connectivity/Connectivity 0.1"]
14+ exportMetaObjectRevisions: [0]
15+ Method { name: "unlockAllModems" }
16+ }
17+}
plugins/Ubuntu/Connectivity/plugin.cppnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "plugin.h"
18+#include "Connectivity.h"
19+
20+#include <QtQml>
21+
22+static QObject *service_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
23+{
24+ Q_UNUSED(engine)
25+ Q_UNUSED(scriptEngine)
26+ return new Connectivity();
27+}
28+
29+void BackendPlugin::registerTypes(const char *uri)
30+{
31+ Q_ASSERT(uri == QLatin1String("Ubuntu.Connectivity"));
32+
33+ qmlRegisterSingletonType<Connectivity>(uri, 0, 1, "Connectivity", service_provider);
34+}
plugins/Ubuntu/Connectivity/plugin.hnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef CONNECTIVITY_PLUGIN_H
18+#define CONNECTIVITY_PLUGIN_H
19+
20+#include <QQmlExtensionPlugin>
21+
22+class BackendPlugin : public QQmlExtensionPlugin
23+{
24+ Q_OBJECT
25+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26+
27+public:
28+ void registerTypes(const char *uri);
29+};
30+
31+#endif // CONNECTIVITY_PLUGIN_H
plugins/Ubuntu/Connectivity/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Ubuntu.Connectivity
2+plugin Connectivity
3+typeinfo Connectivity.qmltypes
qml/Notifications/NotificationMenuItemFactory.qml+5
@@ -127,6 +127,11 @@ Loader {
127 onCancel: {
127 onCancel: {
128 menuModel.activate(menuIndex, false);
128 menuModel.activate(menuIndex, false);
129 }
129 }
130+
131+ onEmergencyCall: {
132+ shell.activateApplication("dialer-app")
133+ menuModel.activate(menuIndex, false)
134+ }
130 }
135 }
131 }
136 }
132}
137}
qml/Shell.qml+5
@@ -20,6 +20,7 @@ import GSettings 1.0
20import Unity.Application 0.1
20import Unity.Application 0.1
21import Ubuntu.Components 0.1
21import Ubuntu.Components 0.1
22import Ubuntu.Components.Popups 1.0
22import Ubuntu.Components.Popups 1.0
23+import Ubuntu.Connectivity 0.1
23import Ubuntu.Gestures 0.1
24import Ubuntu.Gestures 0.1
24import Ubuntu.SystemImage 0.1
25import Ubuntu.SystemImage 0.1
25import Unity.Launcher 0.1
26import Unity.Launcher 0.1
@@ -416,6 +417,10 @@ Item {
416 }
417 }
417 }
418 }
418
419
420+ Component.onCompleted: {
421+ Connectivity.unlockAllModems()
422+ }
423+
419 onUnlocked: greeter.hide()
424 onUnlocked: greeter.hide()
420 onSelected: {
425 onSelected: {
421 // Update launcher items for new user
426 // Update launcher items for new user
tests/mocks/Ubuntu/CMakeLists.txt+1
@@ -1,3 +1,4 @@
1+add_subdirectory(Connectivity)
1add_subdirectory(DownloadDaemonListener)
2add_subdirectory(DownloadDaemonListener)
2add_subdirectory(Payments)
3add_subdirectory(Payments)
3add_subdirectory(SystemImage)
4add_subdirectory(SystemImage)
tests/mocks/Ubuntu/Connectivity/CMakeLists.txtnew file+10
@@ -0,0 +1,10 @@
1+set(MOCK_CONNECTIVITY_SOURCES
2+ plugin.cpp
3+ MockConnectivity.cpp
4+)
5+
6+add_library(MockConnectivity MODULE ${MOCK_CONNECTIVITY_SOURCES})
7+
8+qt5_use_modules(MockConnectivity Qml Quick Core)
9+
10+add_unity8_mock(Ubuntu.Connectivity 0.1 Ubuntu/Connectivity TARGETS MockConnectivity)
tests/mocks/Ubuntu/Connectivity/Connectivity.qmltypesnew file+18
@@ -0,0 +1,18 @@
1+import QtQuick.tooling 1.1
2+
3+// This file describes the plugin-supplied types contained in the library.
4+// It is used for QML tooling purposes only.
5+//
6+// This file was auto-generated by:
7+// 'qmlplugindump -notrelocatable Ubuntu.Connectivity 0.1 plugins'
8+
9+Module {
10+ Component {
11+ name: "MockConnectivity"
12+ prototype: "QObject"
13+ exports: ["Ubuntu.Connectivity/Connectivity 0.1"]
14+ exportMetaObjectRevisions: [0]
15+ Signal { name: "unlockingAllModems" }
16+ Method { name: "unlockAllModems" }
17+ }
18+}
tests/mocks/Ubuntu/Connectivity/MockConnectivity.cppnew file+27
@@ -0,0 +1,27 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "MockConnectivity.h"
18+
19+MockConnectivity::MockConnectivity(QObject *parent)
20+ : QObject(parent)
21+{
22+}
23+
24+void MockConnectivity::unlockAllModems()
25+{
26+ Q_EMIT unlockingAllModems();
27+}
tests/mocks/Ubuntu/Connectivity/MockConnectivity.hnew file+36
@@ -0,0 +1,36 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef MOCK_CONNECTIVITY_H
18+#define MOCK_CONNECTIVITY_H
19+
20+#include <QObject>
21+
22+class MockConnectivity : public QObject
23+{
24+ Q_OBJECT
25+ Q_DISABLE_COPY(MockConnectivity)
26+
27+public:
28+ explicit MockConnectivity(QObject *parent = 0);
29+
30+ Q_INVOKABLE void unlockAllModems();
31+
32+Q_SIGNALS:
33+ void unlockingAllModems(); // only for mock
34+};
35+
36+#endif // MOCK_CONNECTIVITY_H
tests/mocks/Ubuntu/Connectivity/plugin.cppnew file+34
@@ -0,0 +1,34 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#include "plugin.h"
18+#include "MockConnectivity.h"
19+
20+#include <QtQml>
21+
22+static QObject *service_provider(QQmlEngine *engine, QJSEngine *scriptEngine)
23+{
24+ Q_UNUSED(engine)
25+ Q_UNUSED(scriptEngine)
26+ return new MockConnectivity();
27+}
28+
29+void BackendPlugin::registerTypes(const char *uri)
30+{
31+ Q_ASSERT(uri == QLatin1String("Ubuntu.Connectivity"));
32+
33+ qmlRegisterSingletonType<MockConnectivity>(uri, 0, 1, "Connectivity", service_provider);
34+}
tests/mocks/Ubuntu/Connectivity/plugin.hnew file+31
@@ -0,0 +1,31 @@
1+/*
2+ * Copyright (C) 2014 Canonical, Ltd.
3+ *
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
7+ *
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
12+ *
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
15+ */
16+
17+#ifndef MOCK_CONNECTIVITY_PLUGIN_H
18+#define MOCK_CONNECTIVITY_PLUGIN_H
19+
20+#include <QQmlExtensionPlugin>
21+
22+class BackendPlugin : public QQmlExtensionPlugin
23+{
24+ Q_OBJECT
25+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
26+
27+public:
28+ void registerTypes(const char *uri);
29+};
30+
31+#endif // MOCK_CONNECTIVITY_PLUGIN_H
tests/mocks/Ubuntu/Connectivity/qmldirnew file+3
@@ -0,0 +1,3 @@
1+module Ubuntu.Connectivity
2+plugin MockConnectivity
3+typeinfo Connectivity.qmltypes
tests/qmltests/tst_Shell.qml+21
@@ -21,6 +21,7 @@ import QtQuick 2.0
21import QtTest 1.0
21import QtTest 1.0
22import GSettings 1.0
22import GSettings 1.0
23import LightDM 0.1 as LightDM
23import LightDM 0.1 as LightDM
24+import Ubuntu.Connectivity 0.1
24import Unity.Application 0.1
25import Unity.Application 0.1
25import Unity.Test 0.1 as UT
26import Unity.Test 0.1 as UT
26import Powerd 0.1
27import Powerd 0.1
@@ -28,6 +29,7 @@ import Powerd 0.1
28import "../../qml"
29import "../../qml"
29
30
30Item {
31Item {
32+ id: root
31 width: shell.width
33 width: shell.width
32 height: shell.height
34 height: shell.height
33
35
@@ -51,6 +53,11 @@ Item {
51 id: shell
53 id: shell
52 }
54 }
53
55
56+ Component {
57+ id: shellComponent
58+ Shell {}
59+ }
60+
54 SignalSpy {
61 SignalSpy {
55 id: sessionSpy
62 id: sessionSpy
56 signalName: "sessionStarted"
63 signalName: "sessionStarted"
@@ -61,6 +68,12 @@ Item {
61 signalName: "setCurrentScopeCalled"
68 signalName: "setCurrentScopeCalled"
62 }
69 }
63
70
71+ SignalSpy {
72+ id: unlockAllModemsSpy
73+ target: Connectivity
74+ signalName: "unlockingAllModems"
75+ }
76+
64 UT.UnityTestCase {
77 UT.UnityTestCase {
65 name: "Shell"
78 name: "Shell"
66 when: windowShown
79 when: windowShown
@@ -442,5 +455,13 @@ Item {
442 var indicators = findChild(shell, "indicators")
455 var indicators = findChild(shell, "indicators")
443 tryCompare(indicators, "available", true)
456 tryCompare(indicators, "available", true)
444 }
457 }
458+
459+ function test_unlockAllModemsOnBoot() {
460+ unlockAllModemsSpy.clear()
461+ // actually create an object so we notice the onCompleted signal
462+ var greeter = shellComponent.createObject(root)
463+ tryCompare(unlockAllModemsSpy, "count", 1)
464+ greeter.destroy()
465+ }
445 }
466 }
446}
467}