on xenial help sign in
introduce ApplicationManager.suspended and make use of it when the Greeter is locked
9911d22Michael Zanetti
cmake/modules/QmlTest.cmake+1
@@ -86,6 +86,7 @@ macro(add_qml_test SUBPATH COMPONENT_NAME)
86 ${qmltestrunner_imports}
86 ${qmltestrunner_imports}
87 -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
87 -o ${CMAKE_BINARY_DIR}/${qmltest_TARGET}.xml,xunitxml
88 -o -,txt
88 -o -,txt
89+ $(TESTCASE)
89 )
90 )
90 add_custom_target(${qmltest_TARGET} ${qmltest_command})
91 add_custom_target(${qmltest_TARGET} ${qmltest_command})
91
92
qml/Shell.qml+6−3
@@ -345,9 +345,6 @@ FocusScope {
345
345
346 dragHandleWidth: shell.edgeSize
346 dragHandleWidth: shell.edgeSize
347
347
348− property var previousMainApp: null
349− property var previousSideApp: null
350−
351 onShownChanged: {
348 onShownChanged: {
352 if (shown) {
349 if (shown) {
353 lockscreen.reset();
350 lockscreen.reset();
@@ -374,6 +371,12 @@ FocusScope {
374 launcher.tease();
371 launcher.tease();
375 }
372 }
376 }
373 }
374+
375+ Binding {
376+ target: ApplicationManager
377+ property: "suspended"
378+ value: greeter.shown
379+ }
377 }
380 }
378
381
379 InputFilterArea {
382 InputFilterArea {
tests/mocks/Unity/Application/ApplicationInfo.cpp+3−2
@@ -20,12 +20,13 @@
20#include <QQuickItem>
20#include <QQuickItem>
21#include <QQuickView>
21#include <QQuickView>
22#include <QQmlComponent>
22#include <QQmlComponent>
23+#include <QTimer>
23
24
24ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
25ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
25 : ApplicationInfoInterface(appId, parent)
26 : ApplicationInfoInterface(appId, parent)
26 ,m_appId(appId)
27 ,m_appId(appId)
27 ,m_stage(MainStage)
28 ,m_stage(MainStage)
28− ,m_state(Starting)
29+ ,m_state(Running)
29 ,m_focused(false)
30 ,m_focused(false)
30 ,m_fullscreen(false)
31 ,m_fullscreen(false)
31 ,m_windowItem(0)
32 ,m_windowItem(0)
@@ -37,7 +38,7 @@ ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
37ApplicationInfo::ApplicationInfo(QObject *parent)
38ApplicationInfo::ApplicationInfo(QObject *parent)
38 : ApplicationInfoInterface(QString(), parent)
39 : ApplicationInfoInterface(QString(), parent)
39 ,m_stage(MainStage)
40 ,m_stage(MainStage)
40− ,m_state(Starting)
41+ ,m_state(Running)
41 ,m_focused(false)
42 ,m_focused(false)
42 ,m_fullscreen(false)
43 ,m_fullscreen(false)
43 ,m_windowItem(0)
44 ,m_windowItem(0)
tests/mocks/Unity/Application/ApplicationManager.cpp+20
@@ -30,6 +30,7 @@
30
30
31ApplicationManager::ApplicationManager(QObject *parent)
31ApplicationManager::ApplicationManager(QObject *parent)
32 : ApplicationManagerInterface(parent)
32 : ApplicationManagerInterface(parent)
33+ , m_suspended(false)
33 , m_mainStageComponent(0)
34 , m_mainStageComponent(0)
34 , m_mainStage(0)
35 , m_mainStage(0)
35 , m_sideStageComponent(0)
36 , m_sideStageComponent(0)
@@ -231,6 +232,25 @@ QString ApplicationManager::focusedApplicationId() const {
231 return QString();
232 return QString();
232}
233}
233
234
235+bool ApplicationManager::suspended() const
236+{
237+ return m_suspended;
238+}
239+
240+void ApplicationManager::setSuspended(bool suspended)
241+{
242+ ApplicationInfo *focusedApp = findApplication(focusedApplicationId());
243+ if (focusedApp) {
244+ if (suspended) {
245+ focusedApp->setState(ApplicationInfo::Suspended);
246+ } else {
247+ focusedApp->setState(ApplicationInfo::Running);
248+ }
249+ }
250+ m_suspended = suspended;
251+ Q_EMIT suspendedChanged();
252+}
253+
234bool ApplicationManager::focusApplication(const QString &appId)
254bool ApplicationManager::focusApplication(const QString &appId)
235{
255{
236 ApplicationInfo *application = findApplication(appId);
256 ApplicationInfo *application = findApplication(appId);
tests/mocks/Unity/Application/ApplicationManager.h+3
@@ -96,6 +96,8 @@ class ApplicationManager : public ApplicationManagerInterface {
96 Q_INVOKABLE void updateScreenshot(const QString &appId) override;
96 Q_INVOKABLE void updateScreenshot(const QString &appId) override;
97
97
98 QString focusedApplicationId() const override;
98 QString focusedApplicationId() const override;
99+ bool suspended() const;
100+ void setSuspended(bool suspended);
99
101
100 Q_SIGNALS:
102 Q_SIGNALS:
101 void keyboardHeightChanged();
103 void keyboardHeightChanged();
@@ -115,6 +117,7 @@ class ApplicationManager : public ApplicationManagerInterface {
115 void createSideStage();
117 void createSideStage();
116 int m_keyboardHeight;
118 int m_keyboardHeight;
117 bool m_keyboardVisible;
119 bool m_keyboardVisible;
120+ bool m_suspended;
118 QList<ApplicationInfo*> m_runningApplications;
121 QList<ApplicationInfo*> m_runningApplications;
119 QList<ApplicationInfo*> m_availableApplications;
122 QList<ApplicationInfo*> m_availableApplications;
120 QQmlComponent *m_mainStageComponent;
123 QQmlComponent *m_mainStageComponent;
tests/plugins/Unity/Launcher/launchermodeltest.cpp+2
@@ -95,6 +95,8 @@ public:
95 }
95 }
96 void updateScreenshot(const QString &appId) { Q_UNUSED(appId); }
96 void updateScreenshot(const QString &appId) { Q_UNUSED(appId); }
97 void activateApplication(const QString &appId) { Q_UNUSED(appId); }
97 void activateApplication(const QString &appId) { Q_UNUSED(appId); }
98+ bool suspended() const { return false; }
99+ void setSuspended(bool) {}
98
100
99private:
101private:
100 QList<MockApp*> m_list;
102 QList<MockApp*> m_list;
tests/qmltests/tst_Shell.qml+13−5
@@ -188,26 +188,34 @@ Item {
188 tapOnAppIconInLauncher();
188 tapOnAppIconInLauncher();
189 waitUntilApplicationWindowIsFullyVisible();
189 waitUntilApplicationWindowIsFullyVisible();
190
190
191− var mainApp = ApplicationManager.focusedApplicationId;
191+ var mainAppId = ApplicationManager.focusedApplicationId;
192− verify(mainApp != "");
192+ verify(mainAppId != "");
193+ var mainApp = ApplicationManager.findApplication(mainAppId);
194+ verify(mainApp);
195+ tryCompare(mainApp.state, ApplicationInfo.Running);
193
196
194 // Try to suspend while proximity is engaged...
197 // Try to suspend while proximity is engaged...
195 Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
198 Powerd.displayPowerStateChange(Powerd.Off, Powerd.UseProximity);
196 tryCompare(greeter, "showProgress", 0);
199 tryCompare(greeter, "showProgress", 0);
197
200
198 // Now really suspend
201 // Now really suspend
202+ print("suspending")
199 Powerd.displayPowerStateChange(Powerd.Off, 0);
203 Powerd.displayPowerStateChange(Powerd.Off, 0);
204+ print("done suspending")
200 tryCompare(greeter, "showProgress", 1);
205 tryCompare(greeter, "showProgress", 1);
206+
201− tryCompare(ApplicationManager, "focusedApplicationId", "");
207+ tryCompare(ApplicationManager, "suspended", true);
208+ compare(mainApp.state, ApplicationInfo.Suspended);
202
209
203 // And wake up
210 // And wake up
204 Powerd.displayPowerStateChange(Powerd.On, 0);
211 Powerd.displayPowerStateChange(Powerd.On, 0);
205− tryCompare(ApplicationManager, "focusedApplicationId", "");
206 tryCompare(greeter, "showProgress", 1);
212 tryCompare(greeter, "showProgress", 1);
207
213
208 // Swipe away greeter to focus app
214 // Swipe away greeter to focus app
209 swipeAwayGreeter();
215 swipeAwayGreeter();
210− tryCompare(ApplicationManager, "focusedApplicationId", mainApp);
216+ tryCompare(ApplicationManager, "suspended", false);
217+ compare(mainApp.state, ApplicationInfo.Running);
218+ tryCompare(ApplicationManager, "focusedApplicationId", mainAppId);
211 }
219 }
212
220
213 function swipeAwayGreeter() {
221 function swipeAwayGreeter() {