on xenial help sign in
fix up mocks and add tests
d4f11dbMichael Zanetti
qml/Components/UnityInputInfo/UnityInputInfo.qml+3
@@ -8,6 +8,8 @@ Item {
8 readonly property alias mice: priv.miceCount
8 readonly property alias mice: priv.miceCount
9 readonly property alias keyboards: priv.keyboardCount
9 readonly property alias keyboards: priv.keyboardCount
10
10
11+ property alias inputInfo: inputInfo
12+
11 QtObject {
13 QtObject {
12 id: priv
14 id: priv
13
15
@@ -45,6 +47,7 @@ Item {
45
47
46 InputDeviceInfo {
48 InputDeviceInfo {
47 id: inputInfo
49 id: inputInfo
50+ objectName: "inputDeviceInfo"
48
51
49 onNewDevice: {
52 onNewDevice: {
50 var device = inputInfo.get(inputInfo.indexOf(devicePath));
53 var device = inputInfo.get(inputInfo.indexOf(devicePath));
qml/OrientedShell.qml+3−5
@@ -41,14 +41,11 @@ Rectangle {
41 name: applicationArguments.deviceName
41 name: applicationArguments.deviceName
42 }
42 }
43
43
44− GSettings {
45− id: oskSettings
46− schema.id: "com.canonical.keyboard.maliit"
47− }
48−
49
44
50 // to be overwritten by tests
45 // to be overwritten by tests
51 property var usageModeSettings: GSettings { schema.id: "com.canonical.Unity8" }
46 property var usageModeSettings: GSettings { schema.id: "com.canonical.Unity8" }
47+ property var oskSettings: GSettings { schema.id: "com.canonical.keyboard.maliit" }
48+
52 property int physicalOrientation: Screen.orientation
49 property int physicalOrientation: Screen.orientation
53 property bool orientationLocked: OrientationLock.enabled
50 property bool orientationLocked: OrientationLock.enabled
54 property var orientationLock: OrientationLock
51 property var orientationLock: OrientationLock
@@ -158,6 +155,7 @@ Rectangle {
158 nativeOrientation: root.nativeOrientation
155 nativeOrientation: root.nativeOrientation
159 nativeWidth: root.width
156 nativeWidth: root.width
160 nativeHeight: root.height
157 nativeHeight: root.height
158+ mode: applicationArguments.mode
161
159
162 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
160 // TODO: Factor in the connected input devices (eg: physical keyboard, mouse, touchscreen),
163 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
161 // what's the output device (eg: big TV, desktop monitor, phone display), etc.
qml/Shell.qml+13−15
@@ -55,6 +55,7 @@ Item {
55 property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
55 property alias indicatorAreaShowProgress: panel.indicatorAreaShowProgress
56 property bool beingResized
56 property bool beingResized
57 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
57 property string usageScenario: "phone" // supported values: "phone", "tablet" or "desktop"
58+ property string mode: "full-greeter"
58 function updateFocusedAppOrientation() {
59 function updateFocusedAppOrientation() {
59 applicationsDisplayLoader.item.updateFocusedAppOrientation();
60 applicationsDisplayLoader.item.updateFocusedAppOrientation();
60 }
61 }
@@ -68,9 +69,9 @@ Item {
68
69
69 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
70 readonly property bool orientationChangesEnabled: panel.indicators.fullyClosed
70 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
71 && (applicationsDisplayLoader.item && applicationsDisplayLoader.item.orientationChangesEnabled)
71− && !greeter.animating
72+ && (!greeter || !greeter.animating)
72
73
73− readonly property bool showingGreeter: greeter.shown
74+ readonly property bool showingGreeter: greeter && greeter.shown
74
75
75 property bool startingUp: true
76 property bool startingUp: true
76 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
77 Timer { id: finishStartUpTimer; interval: 500; onTriggered: startingUp = false }
@@ -79,7 +80,7 @@ Item {
79 if (startingUp) {
80 if (startingUp) {
80 // Ensure we don't rotate during start up
81 // Ensure we don't rotate during start up
81 return Qt.PrimaryOrientation;
82 return Qt.PrimaryOrientation;
82− } else if (greeter.shown) {
83+ } else if (greeter && greeter.shown) {
83 return Qt.PrimaryOrientation;
84 return Qt.PrimaryOrientation;
84 } else if (mainApp) {
85 } else if (mainApp) {
85 return mainApp.supportedOrientations;
86 return mainApp.supportedOrientations;
@@ -101,16 +102,13 @@ Item {
101
102
102 // Disable everything while greeter is waiting, so that the user can't swipe
103 // Disable everything while greeter is waiting, so that the user can't swipe
103 // the greeter or launcher until we know whether the session is locked.
104 // the greeter or launcher until we know whether the session is locked.
104− enabled: !greeter.waiting
105+ enabled: greeter && !greeter.waiting
105
106
106 property real edgeSize: units.gu(2)
107 property real edgeSize: units.gu(2)
107 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
108 property url defaultBackground: Qt.resolvedUrl(shell.width >= units.gu(60) ? "graphics/tablet_background.jpg" : "graphics/phone_background.jpg")
108 property url background: asImageTester.status == Image.Ready ? asImageTester.source
109 property url background: asImageTester.status == Image.Ready ? asImageTester.source
109 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
110 : gsImageTester.status == Image.Ready ? gsImageTester.source : defaultBackground
110
111
111− // This is _only_ used to expose the property to autopilot tests
112− readonly property string testShellMode: shellMode
113−
114 readonly property alias greeter: greeterLoader.item
112 readonly property alias greeter: greeterLoader.item
115
113
116 function activateApplication(appId) {
114 function activateApplication(appId) {
@@ -264,7 +262,7 @@ Item {
264 ? "phone"
262 ? "phone"
265 : shell.usageScenario
263 : shell.usageScenario
266 source: {
264 source: {
267− if(shellMode === "greeter") {
265+ if(shell.mode === "greeter") {
268 return "Stages/ShimStage.qml"
266 return "Stages/ShimStage.qml"
269 } else if (applicationsDisplayLoader.usageScenario === "phone") {
267 } else if (applicationsDisplayLoader.usageScenario === "phone") {
270 return "Stages/PhoneStage.qml";
268 return "Stages/PhoneStage.qml";
@@ -276,7 +274,7 @@ Item {
276 }
274 }
277
275
278 property bool interactive: tutorial.spreadEnabled
276 property bool interactive: tutorial.spreadEnabled
279− && !greeter.shown
277+ && (!greeter || !greeter.shown)
280 && panel.indicators.fullyClosed
278 && panel.indicators.fullyClosed
281 && launcher.progress == 0
279 && launcher.progress == 0
282 && !notifications.useModal
280 && !notifications.useModal
@@ -307,12 +305,12 @@ Item {
307 Binding {
305 Binding {
308 target: applicationsDisplayLoader.item
306 target: applicationsDisplayLoader.item
309 property: "spreadEnabled"
307 property: "spreadEnabled"
310− value: tutorial.spreadEnabled && !greeter.hasLockedApp
308+ value: tutorial.spreadEnabled && (!greeter || !greeter.hasLockedApp)
311 }
309 }
312 Binding {
310 Binding {
313 target: applicationsDisplayLoader.item
311 target: applicationsDisplayLoader.item
314 property: "inverseProgress"
312 property: "inverseProgress"
315− value: greeter.locked ? 0 : launcher.progress
313+ value: greeter && greeter.locked ? 0 : launcher.progress
316 }
314 }
317 Binding {
315 Binding {
318 target: applicationsDisplayLoader.item
316 target: applicationsDisplayLoader.item
@@ -422,7 +420,7 @@ Item {
422 id: greeterLoader
420 id: greeterLoader
423 anchors.fill: parent
421 anchors.fill: parent
424 anchors.topMargin: panel.panelHeight
422 anchors.topMargin: panel.panelHeight
425− sourceComponent: shellMode != "shell" ? integratedGreeter :
423+ sourceComponent: shell.mode != "shell" ? integratedGreeter :
426 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
424 Qt.createComponent(Qt.resolvedUrl("Greeter/ShimGreeter.qml"));
427 onLoaded: {
425 onLoaded: {
428 item.objectName = "greeter"
426 item.objectName = "greeter"
@@ -434,7 +432,7 @@ Item {
434 Greeter {
432 Greeter {
435
433
436 hides: [launcher, panel.indicators]
434 hides: [launcher, panel.indicators]
437− tabletMode: shell.sideStageEnabled
435+ tabletMode: shell.usageScenario != "phone"
438 launcherOffset: launcher.progress
436 launcherOffset: launcher.progress
439 forcedUnlock: tutorial.running
437 forcedUnlock: tutorial.running
440 background: shell.background
438 background: shell.background
@@ -550,8 +548,8 @@ Item {
550 indicators {
548 indicators {
551 hides: [launcher]
549 hides: [launcher]
552 available: tutorial.panelEnabled
550 available: tutorial.panelEnabled
553− && (!greeter.locked || AccountsService.enableIndicatorsWhileLocked)
551+ && ((!greeter || !greeter.locked) || AccountsService.enableIndicatorsWhileLocked)
554− && !greeter.hasLockedApp
552+ && (!greeter || !greeter.hasLockedApp)
555 contentEnabled: tutorial.panelContentEnabled
553 contentEnabled: tutorial.panelContentEnabled
556 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
554 width: parent.width > units.gu(60) ? units.gu(40) : parent.width
557
555
src/ApplicationArguments.h+5
@@ -27,14 +27,19 @@ class ApplicationArguments : public QObject
27{
27{
28 Q_OBJECT
28 Q_OBJECT
29 Q_PROPERTY(QString deviceName READ deviceName CONSTANT)
29 Q_PROPERTY(QString deviceName READ deviceName CONSTANT)
30+ Q_PROPERTY(QString mode READ mode CONSTANT)
30public:
31public:
31 ApplicationArguments(QObject *parent = nullptr);
32 ApplicationArguments(QObject *parent = nullptr);
32
33
33 void setDeviceName(QString deviceName) { m_deviceName = deviceName; }
34 void setDeviceName(QString deviceName) { m_deviceName = deviceName; }
34 QString deviceName() const { return m_deviceName; }
35 QString deviceName() const { return m_deviceName; }
35
36
37+ void setMode(QString mode) { m_mode = mode; }
38+ QString mode() const { return m_mode; }
39+
36private:
40private:
37 QString m_deviceName;
41 QString m_deviceName;
42+ QString m_mode;
38};
43};
39
44
40#endif // APPLICATION_ARGUMENTS_H
45#endif // APPLICATION_ARGUMENTS_H
src/main.cpp+2−1
@@ -60,6 +60,8 @@ int main(int argc, const char *argv[])
60 qmlArgs.setDeviceName(QString(buffer));
60 qmlArgs.setDeviceName(QString(buffer));
61 }
61 }
62
62
63+ qmlArgs.setMode(parser.mode());
64+
63 // The testability driver is only loaded by QApplication but not by QGuiApplication.
65 // The testability driver is only loaded by QApplication but not by QGuiApplication.
64 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
66 // However, QApplication depends on QWidget which would add some unneeded overhead => Let's load the testability driver on our own.
65 if (parser.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {
67 if (parser.hasTestability() || getenv("QT_LOAD_TESTABILITY")) {
@@ -92,7 +94,6 @@ int main(int argc, const char *argv[])
92
94
93 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
95 view->engine()->setBaseUrl(QUrl::fromLocalFile(::qmlDirectory()));
94 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
96 view->rootContext()->setContextProperty("applicationArguments", &qmlArgs);
95− view->rootContext()->setContextProperty("shellMode", parser.mode());
96 if (parser.hasFrameless()) {
97 if (parser.hasFrameless()) {
97 view->setFlags(Qt::FramelessWindowHint);
98 view->setFlags(Qt::FramelessWindowHint);
98 }
99 }
tests/autopilot/unity8/greeter/tests/test_args.py+6−6
@@ -28,27 +28,27 @@ class GreeterArgsTest(GreeterTestCase):
28 def test_full_greeter_mode(self):
28 def test_full_greeter_mode(self):
29 unity_proxy = self.launch_unity(mode='full-greeter')
29 unity_proxy = self.launch_unity(mode='full-greeter')
30 shell = self.get_shell(unity_proxy)
30 shell = self.get_shell(unity_proxy)
31− self.assertTrue(shell.testShellMode == 'full-greeter')
31+ self.assertTrue(shell.mode == 'full-greeter')
32
32
33 def test_full_shell_mode(self):
33 def test_full_shell_mode(self):
34 unity_proxy = self.launch_unity(mode='full-shell')
34 unity_proxy = self.launch_unity(mode='full-shell')
35 shell = self.get_shell(unity_proxy)
35 shell = self.get_shell(unity_proxy)
36− self.assertTrue(shell.testShellMode == 'full-shell')
36+ self.assertTrue(shell.mode == 'full-shell')
37
37
38 def test_greeter_mode(self):
38 def test_greeter_mode(self):
39 unity_proxy = self.launch_unity(mode='greeter')
39 unity_proxy = self.launch_unity(mode='greeter')
40 shell = self.get_shell(unity_proxy)
40 shell = self.get_shell(unity_proxy)
41− self.assertTrue(shell.testShellMode == 'greeter')
41+ self.assertTrue(shell.mode == 'greeter')
42
42
43 def test_nonexistent_mode(self):
43 def test_nonexistent_mode(self):
44 unity_proxy = self.launch_unity(mode=self.NONEXISTENT_MODE)
44 unity_proxy = self.launch_unity(mode=self.NONEXISTENT_MODE)
45 shell = self.get_shell(unity_proxy)
45 shell = self.get_shell(unity_proxy)
46− self.assertTrue(shell.testShellMode == self.DEFAULT_SHELL_MODE,
46+ self.assertTrue(shell.mode == self.DEFAULT_SHELL_MODE,
47 "Shell mode was {} but should have been {}"
47 "Shell mode was {} but should have been {}"
48− .format(shell.testShellMode,
48+ .format(shell.mode,
49 self.DEFAULT_SHELL_MODE))
49 self.DEFAULT_SHELL_MODE))
50
50
51 def test_shell_mode(self):
51 def test_shell_mode(self):
52 unity_proxy = self.launch_unity(mode='shell')
52 unity_proxy = self.launch_unity(mode='shell')
53 shell = self.get_shell(unity_proxy)
53 shell = self.get_shell(unity_proxy)
54− self.assertTrue(shell.testShellMode == 'shell')
54+ self.assertTrue(shell.mode == 'shell')
tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo.cpp+33
@@ -1,6 +1,7 @@
1/****************************************************************************
1/****************************************************************************
2**
2**
3** Copyright (C) 2015 Jolla.
3** Copyright (C) 2015 Jolla.
4+** Copyright (C) 2015 Canonical Ltd.
4** Contact: http://www.qt-project.org/legal
5** Contact: http://www.qt-project.org/legal
5**
6**
6** This file is part of the QtSystems module of the Qt Toolkit.
7** This file is part of the QtSystems module of the Qt Toolkit.
@@ -44,6 +45,8 @@ QDeclarativeInputDeviceInfo::QDeclarativeInputDeviceInfo(QObject *parent) :
44 QAbstractListModel(parent),
45 QAbstractListModel(parent),
45 deviceInfo(new QInputDeviceInfo)
46 deviceInfo(new QInputDeviceInfo)
46{
47{
48+ connect(deviceInfo, &QInputDeviceInfo::deviceAdded,this,&QDeclarativeInputDeviceInfo::addedDevice);
49+ connect(deviceInfo, &QInputDeviceInfo::deviceRemoved,this,&QDeclarativeInputDeviceInfo::removedDevice);
47}
50}
48
51
49QDeclarativeInputDeviceInfo::~QDeclarativeInputDeviceInfo()
52QDeclarativeInputDeviceInfo::~QDeclarativeInputDeviceInfo()
@@ -86,6 +89,36 @@ QInputDevice *QDeclarativeInputDeviceInfo::get(int index) const
86 return inputDevices.value(index);
89 return inputDevices.value(index);
87}
90}
88
91
92+void QDeclarativeInputDeviceInfo::addMockMouse()
93+{
94+ deviceInfo->addMockDevice(QInputDeviceInfo::Mouse);
95+}
96+
97+void QDeclarativeInputDeviceInfo::addMockKeyboard()
98+{
99+ deviceInfo->addMockDevice(QInputDeviceInfo::Keyboard);
100+}
101+
102+void QDeclarativeInputDeviceInfo::removeMockMouse()
103+{
104+ for (int i = 0; i < inputDevices.count(); i++) {
105+ if (inputDevices.at(i)->types().testFlag(QInputDeviceInfo::Mouse)) {
106+ deviceInfo->removeMockDevice(i);
107+ return;
108+ }
109+ }
110+}
111+
112+void QDeclarativeInputDeviceInfo::removeMockKeyboard()
113+{
114+ for (int i = 0; i < inputDevices.count(); i++) {
115+ if (inputDevices.at(i)->types().testFlag(QInputDeviceInfo::Keyboard)) {
116+ deviceInfo->removeMockDevice(i);
117+ return;
118+ }
119+ }
120+}
121+
89void QDeclarativeInputDeviceInfo::updateDeviceList()
122void QDeclarativeInputDeviceInfo::updateDeviceList()
90{
123{
91 QVector <QInputDevice *> newDevices = deviceInfo->deviceList();
124 QVector <QInputDevice *> newDevices = deviceInfo->deviceList();
tests/mocks/Unity/InputInfo/mockqdeclarativeinputdeviceinfo_p.h+7−2
@@ -1,6 +1,7 @@
1/****************************************************************************
1/****************************************************************************
2**
2**
3** Copyright (C) 2015 Jolla.
3** Copyright (C) 2015 Jolla.
4+** Copyright (C) 2015 Canoncal Ltd.
4** Contact: http://www.qt-project.org/legal
5** Contact: http://www.qt-project.org/legal
5**
6**
6** This file is part of the QtSystems module of the Qt Toolkit.
7** This file is part of the QtSystems module of the Qt Toolkit.
@@ -68,6 +69,12 @@ public:
68
69
69 Q_INVOKABLE QInputDevice *get(int index) const;
70 Q_INVOKABLE QInputDevice *get(int index) const;
70
71
72+ // For testing
73+ Q_INVOKABLE void addMockMouse();
74+ Q_INVOKABLE void addMockKeyboard();
75+ Q_INVOKABLE void removeMockMouse();
76+ Q_INVOKABLE void removeMockKeyboard();
77+
71Q_SIGNALS:
78Q_SIGNALS:
72 void newDevice(const QString &devicePath);
79 void newDevice(const QString &devicePath);
73 void deviceRemoved(const QString &devicePath);
80 void deviceRemoved(const QString &devicePath);
@@ -75,8 +82,6 @@ Q_SIGNALS:
75public Q_SLOTS:
82public Q_SLOTS:
76 void updateDeviceList();
83 void updateDeviceList();
77
84
78−
79−
80private:
85private:
81 QInputDeviceInfo *deviceInfo;
86 QInputDeviceInfo *deviceInfo;
82 QVector<QInputDevice *> inputDevices;
87 QVector<QInputDevice *> inputDevices;
tests/mocks/Unity/InputInfo/mockqinputinfo.cpp+8−2
@@ -1,6 +1,6 @@
1/****************************************************************************
1/****************************************************************************
2**
2**
3−** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
3+** Copyright (C) 2015 Canonical, Ltd. and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
4** Contact: http://www.qt-project.org/legal
5**
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
6** This file is part of the QtSystems module of the Qt Toolkit.
@@ -59,7 +59,12 @@ void QInputDevice::setName(const QString &name)
59
59
60QString QInputDevice::devicePath() const
60QString QInputDevice::devicePath() const
61{
61{
62− return "/mock/device/path";
62+ return m_devicePath;
63+}
64+
65+void QInputDevice::setDevicePath(const QString &path)
66+{
67+ m_devicePath = path;
63}
68}
64
69
65QList <int> QInputDevice::buttons() const
70QList <int> QInputDevice::buttons() const
@@ -112,6 +117,7 @@ void QInputDeviceInfo::removeMockDevice(int index)
112void QInputDeviceInfo::addMockDevice(QInputDeviceInfo::InputType inputType)
117void QInputDeviceInfo::addMockDevice(QInputDeviceInfo::InputType inputType)
113{
118{
114 QInputDevice *device = new QInputDevice(this);
119 QInputDevice *device = new QInputDevice(this);
120+ device->setDevicePath("/mock/device/" + QString::number(m_counter++));
115 device->setTypes({inputType});
121 device->setTypes({inputType});
116 m_list.append(device);
122 m_list.append(device);
117 Q_EMIT deviceAdded(device->devicePath());
123 Q_EMIT deviceAdded(device->devicePath());
tests/mocks/Unity/InputInfo/mockqinputinfo.h+4−1
@@ -1,6 +1,6 @@
1/****************************************************************************
1/****************************************************************************
2**
2**
3−** Copyright (C) 2014 Canonical, Ltd. and/or its subsidiary(-ies).
3+** Copyright (C) 2015 Canonical, Ltd. and/or its subsidiary(-ies).
4** Contact: http://www.qt-project.org/legal
4** Contact: http://www.qt-project.org/legal
5**
5**
6** This file is part of the QtSystems module of the Qt Toolkit.
6** This file is part of the QtSystems module of the Qt Toolkit.
@@ -87,6 +87,8 @@ Q_SIGNALS:
87
87
88private:
88private:
89 QVector<QInputDevice*> m_list;
89 QVector<QInputDevice*> m_list;
90+
91+ int m_counter = 0;
90};
92};
91
93
92class QInputDevice : public QObject
94class QInputDevice : public QObject
@@ -125,6 +127,7 @@ Q_SIGNALS:
125private:
127private:
126 void setName(const QString &name);
128 void setName(const QString &name);
127 void setTypes(QInputDeviceInfo::InputTypes types);
129 void setTypes(QInputDeviceInfo::InputTypes types);
130+ void setDevicePath(const QString &path);
128
131
129 QString m_name;
132 QString m_name;
130 QInputDeviceInfo::InputTypes m_types;
133 QInputDeviceInfo::InputTypes m_types;
tests/mocks/Unity/InputInfo/plugin.cpp−1
@@ -27,7 +27,6 @@ void InputInfoPlugin::registerTypes(const char *uri)
27{
27{
28 int major = 0;
28 int major = 0;
29 int minor = 1;
29 int minor = 1;
30− qDebug() << "****************** creating inputplugin";
31 qmlRegisterType<QDeclarativeInputDeviceInfo>(uri, major, minor, "InputDeviceInfo");
30 qmlRegisterType<QDeclarativeInputDeviceInfo>(uri, major, minor, "InputDeviceInfo");
32 qmlRegisterType<QInputDevice>(uri, major, minor, "InputInfo");
31 qmlRegisterType<QInputDevice>(uri, major, minor, "InputInfo");
33}
32}
tests/qmltests/Tutorial/tst_Tutorial.qml+3−10
@@ -17,7 +17,6 @@
17import QtQuick 2.0
17import QtQuick 2.0
18import QtTest 1.0
18import QtTest 1.0
19import AccountsService 0.1
19import AccountsService 0.1
20−import GSettings 1.0
21import LightDM 0.1 as LightDM
20import LightDM 0.1 as LightDM
22import Ubuntu.Components 1.1
21import Ubuntu.Components 1.1
23import Unity.Application 0.1
22import Unity.Application 0.1
@@ -46,11 +45,6 @@ Item {
46 }
45 }
47 }
46 }
48
47
49− GSettings {
50− id: unity8Settings
51− schema.id: "com.canonical.Unity8"
52− }
53−
54 Component.onCompleted: {
48 Component.onCompleted: {
55 // must set the mock mode before loading the Shell
49 // must set the mock mode before loading the Shell
56 LightDM.Greeter.mockMode = "single-pin";
50 LightDM.Greeter.mockMode = "single-pin";
@@ -73,7 +67,6 @@ Item {
73 sourceComponent: Component {
67 sourceComponent: Component {
74 Shell {
68 Shell {
75 property string indicatorProfile: "phone"
69 property string indicatorProfile: "phone"
76− property string shellMode: "full-greeter" /* default */
77
70
78 Component.onDestruction: {
71 Component.onDestruction: {
79 shellLoader.itemDestroyed = true;
72 shellLoader.itemDestroyed = true;
@@ -119,7 +112,7 @@ Item {
119
112
120 function init() {
113 function init() {
121 tryCompare(shell, "enabled", true); // enabled by greeter when ready
114 tryCompare(shell, "enabled", true); // enabled by greeter when ready
122− unity8Settings.usageMode = "Staged";
115+
123 AccountsService.demoEdges = false;
116 AccountsService.demoEdges = false;
124 AccountsService.demoEdges = true;
117 AccountsService.demoEdges = true;
125 swipeAwayGreeter();
118 swipeAwayGreeter();
@@ -193,7 +186,7 @@ Item {
193 }
186 }
194
187
195 function checkRightEdge() {
188 function checkRightEdge() {
196− if (unity8Settings.usageMode === "Staged") {
189+ if (shell.usageScenario === "phone") {
197 touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
190 touchFlick(shell, shell.width, halfHeight, halfWidth, halfHeight);
198
191
199 var stage = findChild(shell, "stage");
192 var stage = findChild(shell, "stage");
@@ -271,7 +264,7 @@ Item {
271 }
264 }
272
265
273 function test_walkthroughOnDesktop() {
266 function test_walkthroughOnDesktop() {
274− unity8Settings.usageMode = "Windowed";
267+ shell.usageScenario = "desktop";
275 var page = goToPage("tutorialLeftFinish");
268 var page = goToPage("tutorialLeftFinish");
276 var tick = findChild(page, "tick");
269 var tick = findChild(page, "tick");
277 tap(tick);
270 tap(tick);
tests/qmltests/tst_OrientedShell.qml+65−13
@@ -23,8 +23,10 @@ import Unity.Application 0.1
23import Unity.Test 0.1
23import Unity.Test 0.1
24import LightDM 0.1 as LightDM
24import LightDM 0.1 as LightDM
25import Powerd 0.1
25import Powerd 0.1
26+import Unity.InputInfo 0.1
26
27
27import "../../qml"
28import "../../qml"
29+import "../../qml/Components/UnityInputInfo"
28
30
29Rectangle {
31Rectangle {
30 id: root
32 id: root
@@ -34,19 +36,8 @@ Rectangle {
34
36
35 QtObject {
37 QtObject {
36 id: applicationArguments
38 id: applicationArguments
37−
38− function hasGeometry() {
39− return false;
40− }
41−
42− function width() {
43− return 0;
44− }
45−
46− function height() {
47− return 0;
48− }
49 property string deviceName: "mako"
39 property string deviceName: "mako"
40+ property string mode: "full-greeter"
50 }
41 }
51
42
52 QtObject {
43 QtObject {
@@ -59,6 +50,11 @@ Rectangle {
59 property string usageMode: usageModeSelector.model[usageModeSelector.selectedIndex]
50 property string usageMode: usageModeSelector.model[usageModeSelector.selectedIndex]
60 }
51 }
61
52
53+ QtObject{
54+ id: mockOskSettings
55+ property bool stayHidden: false;
56+ }
57+
62 property int physicalOrientation0
58 property int physicalOrientation0
63 property int physicalOrientation90
59 property int physicalOrientation90
64 property int physicalOrientation180
60 property int physicalOrientation180
@@ -130,6 +126,7 @@ Rectangle {
130 OrientedShell {
126 OrientedShell {
131 anchors.fill: parent
127 anchors.fill: parent
132 usageModeSettings: mockUsageModeSettings
128 usageModeSettings: mockUsageModeSettings
129+ oskSettings: mockOskSettings
133 physicalOrientation: root.physicalOrientation0
130 physicalOrientation: root.physicalOrientation0
134 orientationLocked: orientationLockedCheckBox.checked
131 orientationLocked: orientationLockedCheckBox.checked
135 orientationLock: mockOrientationLock
132 orientationLock: mockOrientationLock
@@ -305,6 +302,35 @@ Rectangle {
305 }
302 }
306 }
303 }
307 }
304 }
305+
306+ Row {
307+ Button {
308+ text: "Add mouse"
309+ onClicked: {
310+ UnityInputInfo.inputInfo.addMockMouse()
311+ }
312+ }
313+ Button {
314+ text: "Remove mouse"
315+ onClicked: {
316+ UnityInputInfo.inputInfo.removeMockMouse()
317+ }
318+ }
319+ }
320+ Row {
321+ Button {
322+ text: "Add kbd"
323+ onClicked: {
324+ UnityInputInfo.inputInfo.addMockKeyboard()
325+ }
326+ }
327+ Button {
328+ text: "Remove kbd"
329+ onClicked: {
330+ UnityInputInfo.inputInfo.removeMockKeyboard()
331+ }
332+ }
333+ }
308 }
334 }
309 }
335 }
310
336
@@ -898,6 +924,33 @@ Rectangle {
898 tryCompare(shell, "transformRotationAngle", 0);
924 tryCompare(shell, "transformRotationAngle", 0);
899 }
925 }
900
926
927+ function test_attachRemoveInputDevices() {
928+ usageModeSelector.selectedIndex = 2;
929+ tryCompare(mockUsageModeSettings, "usageMode", "Automatic")
930+
931+ loadShell("mako")
932+ var shell = findChild(orientedShell, "shell");
933+
934+ tryCompare(shell, "usageScenario", "phone");
935+ tryCompare(mockOskSettings, "stayHidden", false);
936+
937+ UnityInputInfo.inputInfo.addMockKeyboard();
938+ tryCompare(shell, "usageScenario", "phone");
939+ tryCompare(mockOskSettings, "stayHidden", true);
940+
941+ UnityInputInfo.inputInfo.addMockMouse();
942+ tryCompare(shell, "usageScenario", "desktop");
943+ tryCompare(mockOskSettings, "stayHidden", true);
944+
945+ UnityInputInfo.inputInfo.removeMockKeyboard();
946+ tryCompare(shell, "usageScenario", "desktop");
947+ tryCompare(mockOskSettings, "stayHidden", false);
948+
949+ UnityInputInfo.inputInfo.removeMockMouse();
950+ tryCompare(shell, "usageScenario", "phone");
951+ tryCompare(mockOskSettings, "stayHidden", false);
952+ }
953+
901 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
954 // angle - rotation angle in degrees clockwise, relative to the primary orientation.
902 function rotateTo(angle) {
955 function rotateTo(angle) {
903 switch (angle) {
956 switch (angle) {
@@ -1147,5 +1200,4 @@ Rectangle {
1147 return found;
1200 return found;
1148 }
1201 }
1149 }
1202 }
1150−
1151}
1203}
tests/qmltests/tst_Shell.qml−2
@@ -81,8 +81,6 @@ Rectangle {
81 property bool itemDestroyed: false
81 property bool itemDestroyed: false
82 sourceComponent: Component {
82 sourceComponent: Component {
83 Shell {
83 Shell {
84− property string shellMode: "full-greeter" /* default */
85−
86 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
84 usageScenario: usageScenarioSelector.model[usageScenarioSelector.selectedIndex]
87 orientation: Qt.PortraitOrientation
85 orientation: Qt.PortraitOrientation
88 primaryOrientation: Qt.PortraitOrientation
86 primaryOrientation: Qt.PortraitOrientation
tests/qmltests/tst_ShellWithPin.qml−2
@@ -69,8 +69,6 @@ Item {
69 property bool itemDestroyed: false
69 property bool itemDestroyed: false
70 sourceComponent: Component {
70 sourceComponent: Component {
71 Shell {
71 Shell {
72− property string shellMode: "full-greeter" /* default */
73−
74 Component.onDestruction: {
72 Component.onDestruction: {
75 shellLoader.itemDestroyed = true
73 shellLoader.itemDestroyed = true
76 }
74 }