on xenial help sign in
Some improvements:
8d372d5Daniel d'Andrada
tests/mocks/Unity/Application/ApplicationManager.h+3−1
@@ -34,6 +34,7 @@ class ApplicationManager : public ApplicationManagerInterface {
34 Q_FLAGS(ExecFlags)
34 Q_FLAGS(ExecFlags)
35
35
36 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
36 Q_PROPERTY(bool empty READ isEmpty NOTIFY emptyChanged)
37+ Q_PROPERTY(QStringList availableApplications READ availableApplications NOTIFY availableApplicationsChanged)
37
38
38 public:
39 public:
39 ApplicationManager(QObject *parent = nullptr);
40 ApplicationManager(QObject *parent = nullptr);
@@ -75,7 +76,7 @@ class ApplicationManager : public ApplicationManagerInterface {
75 void setForceDashActive(bool forceDashActive) override;
76 void setForceDashActive(bool forceDashActive) override;
76
77
77 // Only for testing
78 // Only for testing
78− Q_INVOKABLE QStringList availableApplications();
79+ QStringList availableApplications();
79 Q_INVOKABLE ApplicationInfo* add(QString appId);
80 Q_INVOKABLE ApplicationInfo* add(QString appId);
80
81
81 QModelIndex findIndex(ApplicationInfo* application);
82 QModelIndex findIndex(ApplicationInfo* application);
@@ -85,6 +86,7 @@ class ApplicationManager : public ApplicationManagerInterface {
85 Q_SIGNALS:
86 Q_SIGNALS:
86 void focusRequested(const QString &appId);
87 void focusRequested(const QString &appId);
87 void emptyChanged(bool empty);
88 void emptyChanged(bool empty);
89+ void availableApplicationsChanged(QStringList list);
88
90
89 private Q_SLOTS:
91 private Q_SLOTS:
90 void onWindowCreatedTimerTimeout();
92 void onWindowCreatedTimerTimeout();
tests/qmltests/Stages/ApplicationCheckBox.qml+20−1
@@ -24,15 +24,23 @@ RowLayout {
24 property string appId
24 property string appId
25 property alias checked: checkbox.checked
25 property alias checked: checkbox.checked
26
26
27+ enabled: appId !== "unity8-dash"
28+
27 Layout.fillWidth: true
29 Layout.fillWidth: true
28 CheckBox {
30 CheckBox {
29 id: checkbox
31 id: checkbox
30 checked: false
32 checked: false
31 activeFocusOnPress: false
33 activeFocusOnPress: false
34+ property bool noop: false
32 onCheckedChanged: {
35 onCheckedChanged: {
36+ if (noop) {
37+ return;
38+ }
33 if (checked) {
39 if (checked) {
34− ApplicationManager.startApplication(root.appId);
40+ var application = ApplicationManager.startApplication(root.appId);
41+ appConnections.target = application;
35 } else {
42 } else {
43+ appConnections.target = null;
36 ApplicationManager.stopApplication(root.appId);
44 ApplicationManager.stopApplication(root.appId);
37 }
45 }
38 }
46 }
@@ -42,4 +50,15 @@ RowLayout {
42 color: "white"
50 color: "white"
43 anchors.verticalCenter: parent.verticalCenter
51 anchors.verticalCenter: parent.verticalCenter
44 }
52 }
53+
54+ Connections {
55+ id: appConnections
56+ onStateChanged: {
57+ if (target.state == ApplicationInfoInterface.Stopped) {
58+ checkbox.noop = true;
59+ checkbox.checked = false;
60+ checkbox.noop = false;
61+ }
62+ }
63+ }
45}
64}
tests/qmltests/Stages/tst_DesktopStage.qml+23−19
@@ -92,13 +92,11 @@ Rectangle {
92 Column {
92 Column {
93 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
93 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
94 spacing: units.gu(1)
94 spacing: units.gu(1)
95− ApplicationCheckBox {
95+ Repeater {
96− id: webbrowserCheckBox
96+ model: ApplicationManager.availableApplications
97− appId: "webbrowser-app"
97+ ApplicationCheckBox {
98+ appId: modelData
98− }
99+ }
99− ApplicationCheckBox {
100− id: dialerCheckBox
101− appId: "dialer-app"
102 }
100 }
103 }
101 }
104 }
102 }
@@ -125,14 +123,20 @@ Rectangle {
125 // Shell instance gets destroyed.
123 // Shell instance gets destroyed.
126 tryCompare(desktopStageLoader, "itemDestroyed", true);
124 tryCompare(desktopStageLoader, "itemDestroyed", true);
127
125
128− // kill all (fake) running apps
126+ killAllRunningApps();
129− webbrowserCheckBox.checked = false;
130− dialerCheckBox.checked = false;
131
127
132 desktopStageLoader.active = true;
128 desktopStageLoader.active = true;
133 tryCompare(desktopStageLoader, "status", Loader.Ready);
129 tryCompare(desktopStageLoader, "status", Loader.Ready);
134 }
130 }
135
131
132+ function killAllRunningApps() {
133+ while (ApplicationManager.count > 1) {
134+ var appIndex = ApplicationManager.get(0).appId == "unity8-dash" ? 1 : 0
135+ ApplicationManager.stopApplication(ApplicationManager.get(appIndex).appId);
136+ }
137+ compare(ApplicationManager.count, 1)
138+ }
139+
136 function waitUntilAppSurfaceShowsUp(appId) {
140 function waitUntilAppSurfaceShowsUp(appId) {
137 var appWindow = findChild(desktopStage, "appWindow_" + appId);
141 var appWindow = findChild(desktopStage, "appWindow_" + appId);
138 verify(appWindow);
142 verify(appWindow);
@@ -141,7 +145,7 @@ Rectangle {
141 tryCompare(appWindowStates, "state", "surface");
145 tryCompare(appWindowStates, "state", "surface");
142 }
146 }
143
147
144− function rectsOverlap(aLocal, bLocal) {
148+ function rectsIntersect(aLocal, bLocal) {
145
149
146 var a = aLocal.mapToItem(null, 0, 0, aLocal.width, aLocal.height);
150 var a = aLocal.mapToItem(null, 0, 0, aLocal.width, aLocal.height);
147 var b = bLocal.mapToItem(null, 0, 0, bLocal.width, bLocal.height);
151 var b = bLocal.mapToItem(null, 0, 0, bLocal.width, bLocal.height);
@@ -153,16 +157,16 @@ Rectangle {
153 }
157 }
154
158
155 function test_tappingOnWindowChangesFocusedApp() {
159 function test_tappingOnWindowChangesFocusedApp() {
156− webbrowserCheckBox.checked = true;
160+ ApplicationManager.startApplication("webbrowser-app");
157− waitUntilAppSurfaceShowsUp(webbrowserCheckBox.appId);
161+ waitUntilAppSurfaceShowsUp("webbrowser-app");
158
162
159− var webbrowserWindow = findChild(desktopStage, "appWindow_" + webbrowserCheckBox.appId);
163+ var webbrowserWindow = findChild(desktopStage, "appWindow_webbrowser-app");
160 verify(webbrowserWindow);
164 verify(webbrowserWindow);
161 var dashWindow = findChild(desktopStage, "appWindow_unity8-dash");
165 var dashWindow = findChild(desktopStage, "appWindow_unity8-dash");
162 verify(dashWindow);
166 verify(dashWindow);
163
167
164 // some sanity check
168 // some sanity check
165− compare(rectsOverlap(dashWindow, webbrowserWindow), false);
169+ compare(rectsIntersect(dashWindow, webbrowserWindow), false);
166
170
167 tap(dashWindow);
171 tap(dashWindow);
168 compare(dashWindow.application.session.surface.activeFocus, true);
172 compare(dashWindow.application.session.surface.activeFocus, true);
@@ -172,10 +176,10 @@ Rectangle {
172 }
176 }
173
177
174 function test_tappingOnWindowTitleChangesFocusedApp() {
178 function test_tappingOnWindowTitleChangesFocusedApp() {
175− webbrowserCheckBox.checked = true;
179+ ApplicationManager.startApplication("webbrowser-app");
176− waitUntilAppSurfaceShowsUp(webbrowserCheckBox.appId);
180+ waitUntilAppSurfaceShowsUp("webbrowser-app");
177
181
178− var webbrowserWindow = findChild(desktopStage, "decoratedWindow_" + webbrowserCheckBox.appId);
182+ var webbrowserWindow = findChild(desktopStage, "decoratedWindow_webbrowser-app");
179 verify(webbrowserWindow);
183 verify(webbrowserWindow);
180 var webbrowserWindowTitle = findChild(webbrowserWindow, "windowDecorationTitle");
184 var webbrowserWindowTitle = findChild(webbrowserWindow, "windowDecorationTitle");
181 verify(webbrowserWindowTitle);
185 verify(webbrowserWindowTitle);
@@ -185,7 +189,7 @@ Rectangle {
185 verify(dashWindowTitle);
189 verify(dashWindowTitle);
186
190
187 // some sanity check
191 // some sanity check
188− compare(rectsOverlap(dashWindow, webbrowserWindow), false);
192+ compare(rectsIntersect(dashWindow, webbrowserWindow), false);
189
193
190 tap(dashWindowTitle);
194 tap(dashWindowTitle);
191 compare(dashWindow.application.session.surface.activeFocus, true);
195 compare(dashWindow.application.session.surface.activeFocus, true);
tests/qmltests/Stages/tst_PhoneStage.qml+1−1
@@ -116,7 +116,7 @@ Item {
116 function addApps(count) {
116 function addApps(count) {
117 if (count == undefined) count = 1;
117 if (count == undefined) count = 1;
118 for (var i = 0; i < count; i++) {
118 for (var i = 0; i < count; i++) {
119− var app = ApplicationManager.startApplication(ApplicationManager.availableApplications()[ApplicationManager.count])
119+ var app = ApplicationManager.startApplication(ApplicationManager.availableApplications[ApplicationManager.count])
120 tryCompare(app, "state", ApplicationInfoInterface.Running)
120 tryCompare(app, "state", ApplicationInfoInterface.Running)
121 var spreadView = findChild(phoneStage, "spreadView");
121 var spreadView = findChild(phoneStage, "spreadView");
122 tryCompare(spreadView, "contentX", -spreadView.shift);
122 tryCompare(spreadView, "contentX", -spreadView.shift);