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
1=== modified file 'debian/control'
2--- debian/control 2014-09-22 17:38:38 +0000
3+++ debian/control 2014-09-29 10:34:35 +0000
4@@ -19,7 +19,7 @@
5 libubuntu-app-launch2-dev,
6 libubuntu-application-api-dev (>= 2.1.0),
7 libudev-dev,
8- libunity-api-dev (>= 7.91),
9+ libunity-api-dev (>= 7.92),
10 liburl-dispatcher1-dev,
11 libxkbcommon-dev,
12 libxrender-dev,
13
14=== modified file 'src/modules/Unity/Application/application.cpp'
15--- src/modules/Unity/Application/application.cpp 2014-09-22 17:38:38 +0000
16+++ src/modules/Unity/Application/application.cpp 2014-09-29 10:34:35 +0000
17@@ -325,13 +325,13 @@
18 void Application::onSessionSuspended()
19 {
20 qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionSuspended - appId=" << appId();
21- m_taskController->suspend(longAppId());
22+ m_taskController->suspend(this);
23 }
24
25 void Application::onSessionResumed()
26 {
27 qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionResumed - appId=" << appId();
28- m_taskController->resume(longAppId());
29+ m_taskController->resume(this);
30 }
31
32 void Application::respawn()
33
34=== modified file 'src/modules/Unity/Application/application.h'
35--- src/modules/Unity/Application/application.h 2014-09-22 17:38:38 +0000
36+++ src/modules/Unity/Application/application.h 2014-09-29 10:34:35 +0000
37@@ -105,7 +105,7 @@
38 Stages supportedStages() const;
39 SupportedOrientations supportedOrientations() const;
40
41- bool containsProcess(pid_t pid) const;
42+ pid_t pid() const;
43
44 Q_SIGNALS:
45 void fullscreenChanged(bool fullscreen);
46@@ -120,7 +120,6 @@
47
48 private:
49 QString longAppId() const;
50- pid_t pid() const;
51 void setPid(pid_t pid);
52 void setArguments(const QStringList arguments);
53 void setFocused(bool focus);
54
55=== modified file 'src/modules/Unity/Application/application_manager.cpp'
56--- src/modules/Unity/Application/application_manager.cpp 2014-09-22 17:38:38 +0000
57+++ src/modules/Unity/Application/application_manager.cpp 2014-09-29 10:34:35 +0000
58@@ -196,6 +196,7 @@
59 , m_desktopFileReaderFactory(desktopFileReaderFactory)
60 , m_procInfo(procInfo)
61 , m_suspended(false)
62+ , m_forceDashActive(false)
63 {
64 qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this;
65 setObjectName("qtmir::ApplicationManager");
66@@ -320,6 +321,35 @@
67 }
68 }
69
70+bool ApplicationManager::forceDashActive() const
71+{
72+ return m_forceDashActive;
73+}
74+
75+void ApplicationManager::setForceDashActive(bool forceDashActive)
76+{
77+ if (m_forceDashActive == forceDashActive) {
78+ return;
79+ }
80+
81+ m_forceDashActive = forceDashActive;
82+ Q_EMIT forceDashActiveChanged();
83+
84+ Application *dashApp = findApplication("unity8-dash");
85+ if (!dashApp) {
86+ qCWarning(QTMIR_APPLICATIONS) << "Dash doesn't seem to be running... Ignoring.";
87+ return;
88+ }
89+
90+ if (m_forceDashActive && dashApp->state() != Application::Running) {
91+ resumeApplication(dashApp);
92+ } else if (!m_forceDashActive && dashApp->state() == Application::Running
93+ && m_mainStageApplication != dashApp
94+ && m_sideStageApplication != dashApp) {
95+ suspendApplication(dashApp);
96+ }
97+}
98+
99 bool ApplicationManager::suspendApplication(Application *application)
100 {
101 if (application == nullptr)
102@@ -330,6 +360,10 @@
103 if (!m_lifecycleExceptions.filter(application->appId().section('_',0,0)).empty())
104 return false;
105
106+ if (m_forceDashActive && application->appId() == "unity8-dash") {
107+ return false;
108+ }
109+
110 if (application->state() == Application::Running)
111 application->setState(Application::Suspended);
112
113@@ -370,10 +404,14 @@
114
115 if (application->stage() == Application::MainStage) {
116 m_mainStageApplication = application;
117- resumeApplication(m_sideStageApplication); // in case unfocusCurrentApplication() was last called
118 } else {
119 m_sideStageApplication = application;
120- resumeApplication(m_mainStageApplication); // in case unfocusCurrentApplication() was last called
121+ }
122+
123+ if (!m_suspended) {
124+ resumeApplication(application); // in case unfocusCurrentApplication() was last called
125+ } else {
126+ suspendApplication(application); // Make sure we also have this one suspended if everything is suspended
127 }
128
129 m_focusedApplication = application;
130@@ -801,6 +839,9 @@
131 if (application && application->state() == Application::Starting) {
132 m_dbusWindowStack->WindowCreated(0, application->appId());
133 application->setState(Application::Running);
134+ if ((application != m_mainStageApplication && application != m_sideStageApplication) || m_suspended) {
135+ suspendApplication(application);
136+ }
137 }
138 }
139
140
141=== modified file 'src/modules/Unity/Application/application_manager.h'
142--- src/modules/Unity/Application/application_manager.h 2014-09-08 21:05:15 +0000
143+++ src/modules/Unity/Application/application_manager.h 2014-09-29 10:34:35 +0000
144@@ -91,6 +91,8 @@
145 QString focusedApplicationId() const override;
146 bool suspended() const override;
147 void setSuspended(bool suspended) override;
148+ bool forceDashActive() const override;
149+ void setForceDashActive(bool forceDashActive) override;
150 Q_INVOKABLE qtmir::Application* get(int index) const override;
151 Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override;
152 Q_INVOKABLE bool requestFocusApplication(const QString &appId) override;
153@@ -161,6 +163,7 @@
154 static ApplicationManager* the_application_manager;
155 QList<pid_t> m_hiddenPIDs;
156 bool m_suspended;
157+ bool m_forceDashActive;
158
159 friend class Application;
160 friend class DBusWindowStack;
161
162=== modified file 'src/modules/Unity/Application/taskcontroller.cpp'
163--- src/modules/Unity/Application/taskcontroller.cpp 2014-07-17 16:36:50 +0000
164+++ src/modules/Unity/Application/taskcontroller.cpp 2014-09-29 10:34:35 +0000
165@@ -109,10 +109,13 @@
166 return m_appController->findDesktopFileForAppId(appId);
167 }
168
169-bool TaskController::suspend(const QString& appId)
170+bool TaskController::suspend(const Application* app)
171 {
172- qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << appId;
173- pid_t pid = m_appController->primaryPidForAppId(appId);
174+ qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << app->appId();
175+ pid_t pid = m_appController->primaryPidForAppId(app->appId());
176+ if (pid == 0) {
177+ pid = app->pid();
178+ }
179 m_processController->oomController()->ensureProcessLikelyToBeKilled(pid);
180
181 if (pid) {
182@@ -125,10 +128,13 @@
183 }
184 }
185
186-bool TaskController::resume(const QString& appId)
187+bool TaskController::resume(const Application* app)
188 {
189- qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << appId;
190- pid_t pid = m_appController->primaryPidForAppId(appId);
191+ qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << app->appId();
192+ pid_t pid = m_appController->primaryPidForAppId(app->appId());
193+ if (pid == 0) {
194+ pid = app->pid();
195+ }
196
197 m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid);
198
199@@ -139,7 +145,7 @@
200 return m_processController->sigContinueProcessGroupForPid(pid);
201 return true;
202 } else {
203- qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - couldn't find PID to resume for appId=" << appId;
204+ qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - couldn't find PID to resume for appId=" << app->appId();
205 return false;
206 }
207 }
208
209=== modified file 'src/modules/Unity/Application/taskcontroller.h'
210--- src/modules/Unity/Application/taskcontroller.h 2014-07-17 16:36:50 +0000
211+++ src/modules/Unity/Application/taskcontroller.h 2014-09-29 10:34:35 +0000
212@@ -41,8 +41,8 @@
213 bool start(const QString &appId, const QStringList &args);
214 bool stop(const QString &appId);
215
216- bool suspend(const QString &appId);
217- bool resume(const QString &appId);
218+ bool suspend(const Application* app);
219+ bool resume(const Application* app);
220
221 bool appIdHasProcessId(const QString &appId, const quint64 pid) const;
222 QFileInfo findDesktopFileForAppId(const QString &appId) const;
223
224=== modified file 'tests/modules/ApplicationManager/application_manager_test.cpp'
225--- tests/modules/ApplicationManager/application_manager_test.cpp 2014-09-18 12:00:38 +0000
226+++ tests/modules/ApplicationManager/application_manager_test.cpp 2014-09-29 10:34:35 +0000
227@@ -393,6 +393,7 @@
228 applicationManager.authorizeSession(a_procId, authed);
229
230 onSessionStarting(first_session);
231+ applicationManager.focusApplication(an_app_id);
232 applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
233 onSessionStarting(second_session);
234
235@@ -441,6 +442,152 @@
236 EXPECT_EQ(true, the_app->focused());
237 }
238
239+TEST_F(ApplicationManagerTests,suspended_suspends_starting_app_when_it_gets_ready)
240+{
241+ using namespace ::testing;
242+ quint64 a_procId = 5921;
243+ const char an_app_id[] = "some_app";
244+ QByteArray a_cmd( "/usr/bin/app1 --desktop_file_hint=some_app");
245+ std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
246+
247+ ON_CALL(procInfo,command_line(_)).WillByDefault(Return(a_cmd));
248+
249+ ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
250+
251+ bool authed = true;
252+
253+ std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", a_procId);
254+ applicationManager.authorizeSession(a_procId, authed);
255+
256+ onSessionStarting(first_session);
257+
258+ Application * the_app = applicationManager.findApplication(an_app_id);
259+ applicationManager.focusApplication(an_app_id);
260+ EXPECT_EQ(Application::Starting, the_app->state());
261+
262+ applicationManager.setSuspended(true);
263+
264+ // Not suspending yet, as it's still starting
265+ EXPECT_EQ(Application::Starting, the_app->state());
266+
267+ // This signals the app is ready now
268+ applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
269+
270+ // And given that the AppManager is suspended now, this should go to suspended too
271+ EXPECT_EQ(Application::Suspended, the_app->state());
272+ EXPECT_EQ(false, the_app->focused());
273+
274+ applicationManager.setSuspended(false);
275+
276+ EXPECT_EQ(Application::Running, the_app->state());
277+ EXPECT_EQ(true, the_app->focused());
278+}
279+
280+TEST_F(ApplicationManagerTests,focus_change_suspends_starting_app_when_it_gets_ready)
281+{
282+ using namespace ::testing;
283+ quint64 first_procId = 5921;
284+ quint64 second_procId = 5922;
285+ std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
286+ QByteArray first_cmdLine( "/usr/bin/app1 --desktop_file_hint=app1");
287+ QByteArray second_cmdLine( "/usr/bin/app2--desktop_file_hint=app2");
288+
289+ EXPECT_CALL(procInfo,command_line(first_procId))
290+ .Times(1)
291+ .WillOnce(Return(first_cmdLine));
292+
293+ ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
294+
295+ EXPECT_CALL(procInfo,command_line(second_procId))
296+ .Times(1)
297+ .WillOnce(Return(second_cmdLine));
298+
299+ bool authed = true;
300+
301+ std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", first_procId);
302+ std::shared_ptr<mir::scene::Session> second_session = std::make_shared<MockSession>("oO", second_procId);
303+ applicationManager.authorizeSession(first_procId, authed);
304+ applicationManager.authorizeSession(second_procId, authed);
305+ onSessionStarting(first_session);
306+
307+ Application * app1 = applicationManager.findApplication("app1");
308+ applicationManager.focusApplication("app1");
309+
310+ // First app starting...
311+ EXPECT_EQ(Application::Starting, app1->state());
312+
313+ onSessionStarting(second_session);
314+ Application * app2 = applicationManager.findApplication("app2");
315+ applicationManager.focusApplication("app2");
316+
317+ // Second app starting...
318+ EXPECT_EQ(Application::Starting, app2->state());
319+
320+ // Make sure first one is still in starting state
321+ EXPECT_EQ(Application::Starting, app1->state());
322+
323+ // Signal app1 is ready now
324+ applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
325+
326+ // Make sure AppMan suspended it now that its ready
327+ EXPECT_EQ(Application::Suspended, app1->state());
328+}
329+
330+TEST_F(ApplicationManagerTests,forceDashActive_activates_dash_while_not_focused)
331+{
332+ using namespace ::testing;
333+ quint64 first_procId = 5921;
334+ quint64 second_procId = 5922;
335+ std::shared_ptr<mir::scene::Surface> aSurface(nullptr);
336+ QByteArray first_cmdLine( "/usr/bin/app1 --desktop_file_hint=unity8-dash");
337+ QByteArray second_cmdLine( "/usr/bin/app2--desktop_file_hint=app2");
338+
339+ EXPECT_CALL(procInfo,command_line(first_procId))
340+ .Times(1)
341+ .WillOnce(Return(first_cmdLine));
342+
343+ ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false));
344+
345+ EXPECT_CALL(procInfo,command_line(second_procId))
346+ .Times(1)
347+ .WillOnce(Return(second_cmdLine));
348+
349+ bool authed = true;
350+
351+ std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", first_procId);
352+ std::shared_ptr<mir::scene::Session> second_session = std::make_shared<MockSession>("oO", second_procId);
353+ applicationManager.authorizeSession(first_procId, authed);
354+ applicationManager.authorizeSession(second_procId, authed);
355+ onSessionStarting(first_session);
356+
357+ Application * dashApp = applicationManager.findApplication("unity8-dash");
358+ applicationManager.onSessionCreatedSurface(first_session.get(), aSurface);
359+ applicationManager.focusApplication("unity8-dash");
360+
361+ // Dash app should be ready now...
362+ EXPECT_EQ(Application::Running, dashApp->state());
363+
364+ // Launch second app
365+ onSessionStarting(second_session);
366+ applicationManager.onSessionCreatedSurface(second_session.get(), aSurface);
367+ applicationManager.focusApplication("app2");
368+ EXPECT_EQ(applicationManager.focusedApplicationId(), "app2");
369+
370+ // Make sure the dash is suspended
371+ EXPECT_EQ(dashApp->state(), Application::Suspended);
372+
373+ // Now set the dashactive flag
374+ applicationManager.setForceDashActive(true);
375+
376+ // And make sure the dash is woken up but not focused
377+ EXPECT_EQ(applicationManager.focusedApplicationId(), "app2");
378+ EXPECT_EQ(dashApp->state(), Application::Running);
379+
380+ // Unset the dashactive flag
381+ applicationManager.setForceDashActive(false);
382+ EXPECT_EQ(dashApp->state(), Application::Suspended);
383+}
384+
385 TEST_F(ApplicationManagerTests,requestFocusApplication)
386 {
387 using namespace ::testing;
388@@ -871,6 +1018,7 @@
389
390 applicationManager.startApplication(appId, ApplicationManager::NoFlag);
391 applicationManager.onProcessStarting(appId);
392+ applicationManager.focusApplication(appId);
393
394 std::shared_ptr<mir::scene::Session> session = std::make_shared<MockSession>("", procId);
395
396
397=== modified file 'tests/modules/TaskController/taskcontroller_test.cpp'
398--- tests/modules/TaskController/taskcontroller_test.cpp 2014-07-01 13:38:06 +0000
399+++ tests/modules/TaskController/taskcontroller_test.cpp 2014-09-29 10:34:35 +0000
400@@ -16,9 +16,12 @@
401 */
402
403 #include <Unity/Application/taskcontroller.h>
404+#include <Unity/Application/desktopfilereader.h>
405+#include <Unity/Application/application.h>
406
407 #include "mock_oom_controller.h"
408 #include "mock_process_controller.h"
409+#include "mock_desktop_file_reader.h"
410
411 #include <core/posix/fork.h>
412 #include <core/posix/linux/proc/process/oom_score_adj.h>
413@@ -141,11 +144,17 @@
414
415 EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(-1)).Times(1);
416
417- TaskController taskController(nullptr,
418+ auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr,
419 appControllerPtr,
420- processControllerPtr);
421-
422- taskController.suspend(appId);
423+ processControllerPtr));
424+
425+
426+ auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
427+ ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
428+ ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
429+ Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr);
430+ taskController->suspend(app);
431+ delete app;
432 }
433
434 TEST(TaskController, resumingAnApplicationAdjustsOomScoreForCorrectPid)
435@@ -173,11 +182,17 @@
436
437 EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(-1)).Times(1);
438
439- TaskController taskController(nullptr,
440+ auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr,
441 appControllerPtr,
442- processControllerPtr);
443-
444- taskController.resume(appId);
445+ processControllerPtr));
446+
447+
448+ auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo());
449+ ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true));
450+ ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId));
451+ Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr);
452+ taskController->resume(app);
453+ delete app;
454 }
455
456 TEST(TaskController, aStartedApplicationIsOomScoreAdjusted)

Subscribers

People subscribed via source and target branches