Merge lp:~unity-team/qtmir/fix-some-lifecycle-bugs into lp:qtmir

Proposed by Michael Zanetti
Status: Merged
Approved by: Albert Astals Cid
Approved revision: 255
Merged at revision: 264
Proposed branch: lp:~unity-team/qtmir/fix-some-lifecycle-bugs
Merge into: lp:qtmir
Diff against target: 456 lines (+236/-24)
9 files modified
debian/control (+1/-1)
src/modules/Unity/Application/application.cpp (+2/-2)
src/modules/Unity/Application/application.h (+1/-2)
src/modules/Unity/Application/application_manager.cpp (+43/-2)
src/modules/Unity/Application/application_manager.h (+3/-0)
src/modules/Unity/Application/taskcontroller.cpp (+13/-7)
src/modules/Unity/Application/taskcontroller.h (+2/-2)
tests/modules/ApplicationManager/application_manager_test.cpp (+148/-0)
tests/modules/TaskController/taskcontroller_test.cpp (+23/-8)
To merge this branch: bzr merge lp:~unity-team/qtmir/fix-some-lifecycle-bugs
Reviewer Review Type Date Requested Status
Albert Astals Cid (community) Approve
PS Jenkins bot (community) continuous-integration Needs Fixing
Gerry Boland (community) Needs Fixing
Review via email: mp+234087@code.launchpad.net

Commit message

Fix some bugs in app lifecycle management.

* Correctly determine PID of apps not started by UAL
* Delayed suspending of apps if the first suspending failed because of them being in Starting phase still

Description of the change

* Are there any related MPs required for this MP to build/function as expected? Please list.

https://code.launchpad.net/~mzanetti/unity8/async-dashcommunicator/+merge/235272
https://code.launchpad.net/~mzanetti/unity-api/dashActive/+merge/235273

 * Did you perform an exploratory manual test run of your code change and any related functionality?

yes

 * Did you make sure that your branch does not contain spurious tags?

yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

no

 * If you changed the UI, has there been a design review?

no

To post a comment you must log in.
Revision history for this message
Michael Zanetti (mzanetti) :
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

+bool TaskController::suspend(Application* app)
const Application* please. Same for resume.

Could we also get a test checking if you start app1 & app2, one after the other, and if app2 comes up first, that app1 is suspended when it comes up. I believe your code fixes that too?

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

Testing problem:
- installed package, rebooted phone, verified dash suspended via SSH. Unlocked screen. Dash was there, but only wallpaper was to be seen, no scope contents was visible. When I entered spread and selected Dash, it finally drew the scope contents.

review: Needs Fixing
Revision history for this message
Gerry Boland (gerboland) wrote :

Nitpick not related to this MR - I noticed Dash remains suspended when greeter is shown, but resumed when lock-screen is revealed by swiping greeter away.

I think this MR fixes these bugs too:
https://bugs.launchpad.net/qtmir/+bug/1326906
https://bugs.launchpad.net/qtmir/+bug/1343259
please associate them with this MR.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Testing problem:
> - installed package, rebooted phone, verified dash suspended via SSH. Unlocked
> screen. Dash was there, but only wallpaper was to be seen, no scope contents
> was visible. When I entered spread and selected Dash, it finally drew the
> scope contents.

Did you install the related unity8 branch? I believe this happened because unity8 trunk doesn't focus any already running app when starting up. The linked branch fixes that in unity8.

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> +bool TaskController::suspend(Application* app)
> const Application* please. Same for resume.

done

>
> Could we also get a test checking if you start app1 & app2, one after the
> other, and if app2 comes up first, that app1 is suspended when it comes up. I
> believe your code fixes that too?

done

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> Nitpick not related to this MR - I noticed Dash remains suspended when greeter
> is shown, but resumed when lock-screen is revealed by swiping greeter away.
>

Right... ApplicationManager::suspended is tied to the greeter but not the lockscreen. Not sure if that should be even changed. In any case, that's a different issue and its in unity8, not qtmir.

> I think this MR fixes these bugs too:
> https://bugs.launchpad.net/qtmir/+bug/1326906
> https://bugs.launchpad.net/qtmir/+bug/1343259
> please associate them with this MR.

done.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote :

All good, thanks!

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

https://code.launchpad.net/~mzanetti/unity8/focus-first-if-running-at-startup/+merge/234124
this was superceded by a branch which merged, it can be removed from the prereq list

Revision history for this message
Gerry Boland (gerboland) wrote :

+ qWarning() << "Dash doesn't seem to be running... Ignoring.";
By your own edict, needs fixing :)

+ && m_sideStageApplication != dashApp) {
possible?? I hope not

+ if (m_dashActive && application->appId() == "unity8-dash") {
+ return false;
+ }
resumeApplication should have this too, no?

Test for the new dashActive property would be good. And test to make sure dash isn't changed by suspendApplication & resumeApplication

review: Needs Fixing
253. By Michael Zanetti

merge/update

254. By Michael Zanetti

dashActive -> forceDashActive

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)
255. By Michael Zanetti

add a test for forceDashActive

Revision history for this message
Michael Zanetti (mzanetti) wrote :

> + qWarning() << "Dash doesn't seem to be running... Ignoring.";
> By your own edict, needs fixing :)
>

fixed

> + && m_sideStageApplication != dashApp) {
> possible?? I hope not

not atm, but yeah, should be according to design.

>
> + if (m_dashActive && application->appId() == "unity8-dash") {
> + return false;
> + }
> resumeApplication should have this too, no?

I don't think so...

>
>
> Test for the new dashActive property would be good. And test to make sure dash
> isn't changed by suspendApplication & resumeApplication

done

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

Looks good codewise, need to test.

Revision history for this message
Albert Astals Cid (aacid) wrote :

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Yes

 * Did CI run pass? If not, please explain why.
No, requires other packages to build not present in the archive

 * Did you make sure that the branch does not contain spurious tags?
Yes

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/control'
--- debian/control 2014-09-22 17:38:38 +0000
+++ debian/control 2014-09-29 10:34:35 +0000
@@ -19,7 +19,7 @@
19 libubuntu-app-launch2-dev,19 libubuntu-app-launch2-dev,
20 libubuntu-application-api-dev (>= 2.1.0),20 libubuntu-application-api-dev (>= 2.1.0),
21 libudev-dev,21 libudev-dev,
22 libunity-api-dev (>= 7.91),22 libunity-api-dev (>= 7.92),
23 liburl-dispatcher1-dev,23 liburl-dispatcher1-dev,
24 libxkbcommon-dev,24 libxkbcommon-dev,
25 libxrender-dev,25 libxrender-dev,
2626
=== modified file 'src/modules/Unity/Application/application.cpp'
--- src/modules/Unity/Application/application.cpp 2014-09-22 17:38:38 +0000
+++ src/modules/Unity/Application/application.cpp 2014-09-29 10:34:35 +0000
@@ -325,13 +325,13 @@
325void Application::onSessionSuspended()325void Application::onSessionSuspended()
326{326{
327 qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionSuspended - appId=" << appId();327 qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionSuspended - appId=" << appId();
328 m_taskController->suspend(longAppId());328 m_taskController->suspend(this);
329}329}
330330
331void Application::onSessionResumed()331void Application::onSessionResumed()
332{332{
333 qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionResumed - appId=" << appId();333 qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionResumed - appId=" << appId();
334 m_taskController->resume(longAppId());334 m_taskController->resume(this);
335}335}
336336
337void Application::respawn()337void Application::respawn()
338338
=== modified file 'src/modules/Unity/Application/application.h'
--- src/modules/Unity/Application/application.h 2014-09-22 17:38:38 +0000
+++ src/modules/Unity/Application/application.h 2014-09-29 10:34:35 +0000
@@ -105,7 +105,7 @@
105 Stages supportedStages() const;105 Stages supportedStages() const;
106 SupportedOrientations supportedOrientations() const;106 SupportedOrientations supportedOrientations() const;
107107
108 bool containsProcess(pid_t pid) const;108 pid_t pid() const;
109109
110Q_SIGNALS:110Q_SIGNALS:
111 void fullscreenChanged(bool fullscreen);111 void fullscreenChanged(bool fullscreen);
@@ -120,7 +120,6 @@
120120
121private:121private:
122 QString longAppId() const;122 QString longAppId() const;
123 pid_t pid() const;
124 void setPid(pid_t pid);123 void setPid(pid_t pid);
125 void setArguments(const QStringList arguments);124 void setArguments(const QStringList arguments);
126 void setFocused(bool focus);125 void setFocused(bool focus);
127126
=== modified file 'src/modules/Unity/Application/application_manager.cpp'
--- src/modules/Unity/Application/application_manager.cpp 2014-09-22 17:38:38 +0000
+++ src/modules/Unity/Application/application_manager.cpp 2014-09-29 10:34:35 +0000
@@ -196,6 +196,7 @@
196 , m_desktopFileReaderFactory(desktopFileReaderFactory)196 , m_desktopFileReaderFactory(desktopFileReaderFactory)
197 , m_procInfo(procInfo)197 , m_procInfo(procInfo)
198 , m_suspended(false)198 , m_suspended(false)
199 , m_forceDashActive(false)
199{200{
200 qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this;201 qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this;
201 setObjectName("qtmir::ApplicationManager");202 setObjectName("qtmir::ApplicationManager");
@@ -320,6 +321,35 @@
320 }321 }
321}322}
322323
324bool ApplicationManager::forceDashActive() const
325{
326 return m_forceDashActive;
327}
328
329void ApplicationManager::setForceDashActive(bool forceDashActive)
330{
331 if (m_forceDashActive == forceDashActive) {
332 return;
333 }
334
335 m_forceDashActive = forceDashActive;
336 Q_EMIT forceDashActiveChanged();
337
338 Application *dashApp = findApplication("unity8-dash");
339 if (!dashApp) {
340 qCWarning(QTMIR_APPLICATIONS) << "Dash doesn't seem to be running... Ignoring.";
341 return;
342 }
343
344 if (m_forceDashActive && dashApp->state() != Application::Running) {
345 resumeApplication(dashApp);
346 } else if (!m_forceDashActive && dashApp->state() == Application::Running
347 && m_mainStageApplication != dashApp
348 && m_sideStageApplication != dashApp) {
349 suspendApplication(dashApp);
350 }
351}
352
323bool ApplicationManager::suspendApplication(Application *application)353bool ApplicationManager::suspendApplication(Application *application)
324{354{
325 if (application == nullptr)355 if (application == nullptr)
@@ -330,6 +360,10 @@
330 if (!m_lifecycleExceptions.filter(application->appId().section('_',0,0)).empty())360 if (!m_lifecycleExceptions.filter(application->appId().section('_',0,0)).empty())
331 return false;361 return false;
332362
363 if (m_forceDashActive && application->appId() == "unity8-dash") {
364 return false;
365 }
366
333 if (application->state() == Application::Running)367 if (application->state() == Application::Running)
334 application->setState(Application::Suspended);368 application->setState(Application::Suspended);
335369
@@ -370,10 +404,14 @@
370404
371 if (application->stage() == Application::MainStage) {405 if (application->stage() == Application::MainStage) {
372 m_mainStageApplication = application;406 m_mainStageApplication = application;
373 resumeApplication(m_sideStageApplication); // in case unfocusCurrentApplication() was last called
374 } else {407 } else {
375 m_sideStageApplication = application;408 m_sideStageApplication = application;
376 resumeApplication(m_mainStageApplication); // in case unfocusCurrentApplication() was last called409 }
410
411 if (!m_suspended) {
412 resumeApplication(application); // in case unfocusCurrentApplication() was last called
413 } else {
414 suspendApplication(application); // Make sure we also have this one suspended if everything is suspended
377 }415 }
378416
379 m_focusedApplication = application;417 m_focusedApplication = application;
@@ -801,6 +839,9 @@
801 if (application && application->state() == Application::Starting) {839 if (application && application->state() == Application::Starting) {
802 m_dbusWindowStack->WindowCreated(0, application->appId());840 m_dbusWindowStack->WindowCreated(0, application->appId());
803 application->setState(Application::Running);841 application->setState(Application::Running);
842 if ((application != m_mainStageApplication && application != m_sideStageApplication) || m_suspended) {
843 suspendApplication(application);
844 }
804 }845 }
805}846}
806847
807848
=== modified file 'src/modules/Unity/Application/application_manager.h'
--- src/modules/Unity/Application/application_manager.h 2014-09-08 21:05:15 +0000
+++ src/modules/Unity/Application/application_manager.h 2014-09-29 10:34:35 +0000
@@ -91,6 +91,8 @@
91 QString focusedApplicationId() const override;91 QString focusedApplicationId() const override;
92 bool suspended() const override;92 bool suspended() const override;
93 void setSuspended(bool suspended) override;93 void setSuspended(bool suspended) override;
94 bool forceDashActive() const override;
95 void setForceDashActive(bool forceDashActive) override;
94 Q_INVOKABLE qtmir::Application* get(int index) const override;96 Q_INVOKABLE qtmir::Application* get(int index) const override;
95 Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override;97 Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override;
96 Q_INVOKABLE bool requestFocusApplication(const QString &appId) override;98 Q_INVOKABLE bool requestFocusApplication(const QString &appId) override;
@@ -161,6 +163,7 @@
161 static ApplicationManager* the_application_manager;163 static ApplicationManager* the_application_manager;
162 QList<pid_t> m_hiddenPIDs;164 QList<pid_t> m_hiddenPIDs;
163 bool m_suspended;165 bool m_suspended;
166 bool m_forceDashActive;
164167
165 friend class Application;168 friend class Application;
166 friend class DBusWindowStack;169 friend class DBusWindowStack;
167170
=== modified file 'src/modules/Unity/Application/taskcontroller.cpp'
--- src/modules/Unity/Application/taskcontroller.cpp 2014-07-17 16:36:50 +0000
+++ src/modules/Unity/Application/taskcontroller.cpp 2014-09-29 10:34:35 +0000
@@ -109,10 +109,13 @@
109 return m_appController->findDesktopFileForAppId(appId);109 return m_appController->findDesktopFileForAppId(appId);
110}110}
111111
112bool TaskController::suspend(const QString& appId)112bool TaskController::suspend(const Application* app)
113{113{
114 qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << appId;114 qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << app->appId();
115 pid_t pid = m_appController->primaryPidForAppId(appId);115 pid_t pid = m_appController->primaryPidForAppId(app->appId());
116 if (pid == 0) {
117 pid = app->pid();
118 }
116 m_processController->oomController()->ensureProcessLikelyToBeKilled(pid);119 m_processController->oomController()->ensureProcessLikelyToBeKilled(pid);
117120
118 if (pid) {121 if (pid) {
@@ -125,10 +128,13 @@
125 }128 }
126}129}
127130
128bool TaskController::resume(const QString& appId)131bool TaskController::resume(const Application* app)
129{132{
130 qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << appId;133 qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << app->appId();
131 pid_t pid = m_appController->primaryPidForAppId(appId);134 pid_t pid = m_appController->primaryPidForAppId(app->appId());
135 if (pid == 0) {
136 pid = app->pid();
137 }
132138
133 m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid);139 m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid);
134140
@@ -139,7 +145,7 @@
139 return m_processController->sigContinueProcessGroupForPid(pid);145 return m_processController->sigContinueProcessGroupForPid(pid);
140 return true;146 return true;
141 } else {147 } else {
142 qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - couldn't find PID to resume for appId=" << appId;148 qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - couldn't find PID to resume for appId=" << app->appId();
143 return false;149 return false;
144 }150 }
145}151}
146152
=== modified file 'src/modules/Unity/Application/taskcontroller.h'
--- src/modules/Unity/Application/taskcontroller.h 2014-07-17 16:36:50 +0000
+++ src/modules/Unity/Application/taskcontroller.h 2014-09-29 10:34:35 +0000
@@ -41,8 +41,8 @@
41 bool start(const QString &appId, const QStringList &args);41 bool start(const QString &appId, const QStringList &args);
42 bool stop(const QString &appId);42 bool stop(const QString &appId);
4343
44 bool suspend(const QString &appId);44 bool suspend(const Application* app);
45 bool resume(const QString &appId);45 bool resume(const Application* app);
4646
47 bool appIdHasProcessId(const QString &appId, const quint64 pid) const;47 bool appIdHasProcessId(const QString &appId, const quint64 pid) const;
48 QFileInfo findDesktopFileForAppId(const QString &appId) const;48 QFileInfo findDesktopFileForAppId(const QString &appId) const;
4949
=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
--- tests/modules/ApplicationManager/application_manager_test.cpp 2014-09-18 12:00:38 +0000
+++ tests/modules/ApplicationManager/application_manager_test.cpp 2014-09-29 10:34:35 +0000
@@ -393,6 +393,7 @@
393 applicationManager.authorizeSession(a_procId, authed);393 applicationManager.authorizeSession(a_procId, authed);
394394
395 onSessionStarting(first_session);395 onSessionStarting(first_session);
396 applicationManager.focusApplication(an_app_id);
396 applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);397 applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
397 onSessionStarting(second_session);398 onSessionStarting(second_session);
398399
@@ -441,6 +442,152 @@
441 EXPECT_EQ(true, the_app->focused());442 EXPECT_EQ(true, the_app->focused());
442}443}
443444
445TEST_F(ApplicationManagerTests,suspended_suspends_starting_app_when_it_gets_ready)
446{
447 using namespace ::testing;
448 quint64 a_procId = 5921;
449 const char an_app_id[] = "some_app";
450 QByteArray a_cmd( "/usr/bin/app1 --desktop_file_hint=some_app");
451 std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
452
453 ON_CALL(procInfo,command_line(_)).WillByDefault(Return(a_cmd));
454
455 ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
456
457 bool authed = true;
458
459 std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", a_procId);
460 applicationManager.authorizeSession(a_procId, authed);
461
462 onSessionStarting(first_session);
463
464 Application * the_app = applicationManager.findApplication(an_app_id);
465 applicationManager.focusApplication(an_app_id);
466 EXPECT_EQ(Application::Starting, the_app->state());
467
468 applicationManager.setSuspended(true);
469
470 // Not suspending yet, as it's still starting
471 EXPECT_EQ(Application::Starting, the_app->state());
472
473 // This signals the app is ready now
474 applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
475
476 // And given that the AppManager is suspended now, this should go to suspended too
477 EXPECT_EQ(Application::Suspended, the_app->state());
478 EXPECT_EQ(false, the_app->focused());
479
480 applicationManager.setSuspended(false);
481
482 EXPECT_EQ(Application::Running, the_app->state());
483 EXPECT_EQ(true, the_app->focused());
484}
485
486TEST_F(ApplicationManagerTests,focus_change_suspends_starting_app_when_it_gets_ready)
487{
488 using namespace ::testing;
489 quint64 first_procId = 5921;
490 quint64 second_procId = 5922;
491 std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
492 QByteArray first_cmdLine( "/usr/bin/app1 --desktop_file_hint=app1");
493 QByteArray second_cmdLine( "/usr/bin/app2--desktop_file_hint=app2");
494
495 EXPECT_CALL(procInfo,command_line(first_procId))
496 .Times(1)
497 .WillOnce(Return(first_cmdLine));
498
499 ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
500
501 EXPECT_CALL(procInfo,command_line(second_procId))
502 .Times(1)
503 .WillOnce(Return(second_cmdLine));
504
505 bool authed = true;
506
507 std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", first_procId);
508 std::shared_ptr<mir::scene::Session> second_session = std::make_shared<MockSession>("oO", second_procId);
509 applicationManager.authorizeSession(first_procId, authed);
510 applicationManager.authorizeSession(second_procId, authed);
511 onSessionStarting(first_session);
512
513 Application * app1 = applicationManager.findApplication("app1");
514 applicationManager.focusApplication("app1");
515
516 // First app starting...
517 EXPECT_EQ(Application::Starting, app1->state());
518
519 onSessionStarting(second_session);
520 Application * app2 = applicationManager.findApplication("app2");
521 applicationManager.focusApplication("app2");
522
523 // Second app starting...
524 EXPECT_EQ(Application::Starting, app2->state());
525
526 // Make sure first one is still in starting state
527 EXPECT_EQ(Application::Starting, app1->state());
528
529 // Signal app1 is ready now
530 applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
531
532 // Make sure AppMan suspended it now that its ready
533 EXPECT_EQ(Application::Suspended, app1->state());
534}
535
536TEST_F(ApplicationManagerTests,forceDashActive_activates_dash_while_not_focused)
537{
538 using namespace ::testing;
539 quint64 first_procId = 5921;
540 quint64 second_procId = 5922;
541 std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
542 QByteArray first_cmdLine( "/usr/bin/app1 --desktop_file_hint=unity8-dash");
543 QByteArray second_cmdLine( "/usr/bin/app2--desktop_file_hint=app2");
544
545 EXPECT_CALL(procInfo,command_line(first_procId))
546 .Times(1)
547 .WillOnce(Return(first_cmdLine));
548
549 ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
550
551 EXPECT_CALL(procInfo,command_line(second_procId))
552 .Times(1)
553 .WillOnce(Return(second_cmdLine));
554
555 bool authed = true;
556
557 std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", first_procId);
558 std::shared_ptr<mir::scene::Session> second_session = std::make_shared<MockSession>("oO", second_procId);
559 applicationManager.authorizeSession(first_procId, authed);
560 applicationManager.authorizeSession(second_procId, authed);
561 onSessionStarting(first_session);
562
563 Application * dashApp = applicationManager.findApplication("unity8-dash");
564 applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
565 applicationManager.focusApplication("unity8-dash");
566
567 // Dash app should be ready now...
568 EXPECT_EQ(Application::Running, dashApp->state());
569
570 // Launch second app
571 onSessionStarting(second_session);
572 applicationManager.onSessionCreatedSurface(second_session.get(), aSurface);
573 applicationManager.focusApplication("app2");
574 EXPECT_EQ(applicationManager.focusedApplicationId(), "app2");
575
576 // Make sure the dash is suspended
577 EXPECT_EQ(dashApp->state(), Application::Suspended);
578
579 // Now set the dashactive flag
580 applicationManager.setForceDashActive(true);
581
582 // And make sure the dash is woken up but not focused
583 EXPECT_EQ(applicationManager.focusedApplicationId(), "app2");
584 EXPECT_EQ(dashApp->state(), Application::Running);
585
586 // Unset the dashactive flag
587 applicationManager.setForceDashActive(false);
588 EXPECT_EQ(dashApp->state(), Application::Suspended);
589}
590
444TEST_F(ApplicationManagerTests,requestFocusApplication)591TEST_F(ApplicationManagerTests,requestFocusApplication)
445{592{
446 using namespace ::testing;593 using namespace ::testing;
@@ -871,6 +1018,7 @@
8711018
872 applicationManager.startApplication(appId, ApplicationManager::NoFlag);1019 applicationManager.startApplication(appId, ApplicationManager::NoFlag);
873 applicationManager.onProcessStarting(appId);1020 applicationManager.onProcessStarting(appId);
1021 applicationManager.focusApplication(appId);
8741022
875 std::shared_ptr<mir::scene::Session> session = std::make_shared<MockSession>("", procId);1023 std::shared_ptr<mir::scene::Session> session = std::make_shared<MockSession>("", procId);
8761024
8771025
=== modified file 'tests/modules/TaskController/taskcontroller_test.cpp'
--- tests/modules/TaskController/taskcontroller_test.cpp 2014-07-01 13:38:06 +0000
+++ tests/modules/TaskController/taskcontroller_test.cpp 2014-09-29 10:34:35 +0000
@@ -16,9 +16,12 @@
16 */16 */
1717
18#include <Unity/Application/taskcontroller.h>18#include <Unity/Application/taskcontroller.h>
19#include <Unity/Application/desktopfilereader.h>
20#include <Unity/Application/application.h>
1921
20#include "mock_oom_controller.h"22#include "mock_oom_controller.h"
21#include "mock_process_controller.h"23#include "mock_process_controller.h"
24#include "mock_desktop_file_reader.h"
2225
23#include <core/posix/fork.h>26#include <core/posix/fork.h>
24#include <core/posix/linux/proc/process/oom_score_adj.h>27#include <core/posix/linux/proc/process/oom_score_adj.h>
@@ -141,11 +144,17 @@
141144
142 EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(-1)).Times(1);145 EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(-1)).Times(1);
143146
144 TaskController taskController(nullptr,147 auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr,
145 appControllerPtr,148 appControllerPtr,
146 processControllerPtr);149 processControllerPtr));
147150
148 taskController.suspend(appId);151
152 auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
153 ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
154 ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
155 Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr);
156 taskController->suspend(app);
157 delete app;
149}158}
150159
151TEST(TaskController, resumingAnApplicationAdjustsOomScoreForCorrectPid)160TEST(TaskController, resumingAnApplicationAdjustsOomScoreForCorrectPid)
@@ -173,11 +182,17 @@
173182
174 EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(-1)).Times(1);183 EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(-1)).Times(1);
175184
176 TaskController taskController(nullptr,185 auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr,
177 appControllerPtr,186 appControllerPtr,
178 processControllerPtr);187 processControllerPtr));
179188
180 taskController.resume(appId);189
190 auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
191 ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
192 ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
193 Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr);
194 taskController->resume(app);
195 delete app;
181}196}
182197
183TEST(TaskController, aStartedApplicationIsOomScoreAdjusted)198TEST(TaskController, aStartedApplicationIsOomScoreAdjusted)

Subscribers

People subscribed via source and target branches