Merge lp:~unity-team/qtmir/fix-some-lifecycle-bugs into lp:qtmir
- fix-some-lifecycle-bugs
- Merge into trunk
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 |
Related 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:/
https:/
* 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
Michael Zanetti (mzanetti) : | # |
PS Jenkins bot (ps-jenkins) wrote : | # |
Gerry Boland (gerboland) wrote : | # |
+bool TaskController:
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?
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.
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:/
https:/
please associate them with this MR.
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.
Michael Zanetti (mzanetti) wrote : | # |
> +bool TaskController:
> 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
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... ApplicationMana
> I think this MR fixes these bugs too:
> https:/
> https:/
> please associate them with this MR.
done.
PS Jenkins bot (ps-jenkins) wrote : | # |
PASSED: Continuous integration, rev:248
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
All good, thanks!
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:252
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Gerry Boland (gerboland) wrote : | # |
https:/
this was superceded by a branch which merged, it can be removed from the prereq list
Gerry Boland (gerboland) wrote : | # |
+ qWarning() << "Dash doesn't seem to be running... Ignoring.";
By your own edict, needs fixing :)
+ && m_sideStageAppl
possible?? I hope not
+ if (m_dashActive && application-
+ 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
- 253. By Michael Zanetti
-
merge/update
- 254. By Michael Zanetti
-
dashActive -> forceDashActive
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:253
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:254
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
- 255. By Michael Zanetti
-
add a test for forceDashActive
Michael Zanetti (mzanetti) wrote : | # |
> + qWarning() << "Dash doesn't seem to be running... Ignoring.";
> By your own edict, needs fixing :)
>
fixed
> + && m_sideStageAppl
> possible?? I hope not
not atm, but yeah, should be according to design.
>
> + if (m_dashActive && application-
> + 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
PS Jenkins bot (ps-jenkins) wrote : | # |
FAILED: Continuous integration, rev:255
http://
Executed test runs:
FAILURE: http://
FAILURE: http://
Click here to trigger a rebuild:
http://
Albert Astals Cid (aacid) wrote : | # |
Looks good codewise, need to test.
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
Preview Diff
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 | 19 | libubuntu-app-launch2-dev, | 19 | libubuntu-app-launch2-dev, |
6 | 20 | libubuntu-application-api-dev (>= 2.1.0), | 20 | libubuntu-application-api-dev (>= 2.1.0), |
7 | 21 | libudev-dev, | 21 | libudev-dev, |
9 | 22 | libunity-api-dev (>= 7.91), | 22 | libunity-api-dev (>= 7.92), |
10 | 23 | liburl-dispatcher1-dev, | 23 | liburl-dispatcher1-dev, |
11 | 24 | libxkbcommon-dev, | 24 | libxkbcommon-dev, |
12 | 25 | libxrender-dev, | 25 | libxrender-dev, |
13 | 26 | 26 | ||
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 | 325 | void Application::onSessionSuspended() | 325 | void Application::onSessionSuspended() |
19 | 326 | { | 326 | { |
20 | 327 | qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionSuspended - appId=" << appId(); | 327 | qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionSuspended - appId=" << appId(); |
22 | 328 | m_taskController->suspend(longAppId()); | 328 | m_taskController->suspend(this); |
23 | 329 | } | 329 | } |
24 | 330 | 330 | ||
25 | 331 | void Application::onSessionResumed() | 331 | void Application::onSessionResumed() |
26 | 332 | { | 332 | { |
27 | 333 | qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionResumed - appId=" << appId(); | 333 | qCDebug(QTMIR_APPLICATIONS) << "Application::onSessionResumed - appId=" << appId(); |
29 | 334 | m_taskController->resume(longAppId()); | 334 | m_taskController->resume(this); |
30 | 335 | } | 335 | } |
31 | 336 | 336 | ||
32 | 337 | void Application::respawn() | 337 | void Application::respawn() |
33 | 338 | 338 | ||
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 | 105 | Stages supportedStages() const; | 105 | Stages supportedStages() const; |
39 | 106 | SupportedOrientations supportedOrientations() const; | 106 | SupportedOrientations supportedOrientations() const; |
40 | 107 | 107 | ||
42 | 108 | bool containsProcess(pid_t pid) const; | 108 | pid_t pid() const; |
43 | 109 | 109 | ||
44 | 110 | Q_SIGNALS: | 110 | Q_SIGNALS: |
45 | 111 | void fullscreenChanged(bool fullscreen); | 111 | void fullscreenChanged(bool fullscreen); |
46 | @@ -120,7 +120,6 @@ | |||
47 | 120 | 120 | ||
48 | 121 | private: | 121 | private: |
49 | 122 | QString longAppId() const; | 122 | QString longAppId() const; |
50 | 123 | pid_t pid() const; | ||
51 | 124 | void setPid(pid_t pid); | 123 | void setPid(pid_t pid); |
52 | 125 | void setArguments(const QStringList arguments); | 124 | void setArguments(const QStringList arguments); |
53 | 126 | void setFocused(bool focus); | 125 | void setFocused(bool focus); |
54 | 127 | 126 | ||
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 | 196 | , m_desktopFileReaderFactory(desktopFileReaderFactory) | 196 | , m_desktopFileReaderFactory(desktopFileReaderFactory) |
60 | 197 | , m_procInfo(procInfo) | 197 | , m_procInfo(procInfo) |
61 | 198 | , m_suspended(false) | 198 | , m_suspended(false) |
62 | 199 | , m_forceDashActive(false) | ||
63 | 199 | { | 200 | { |
64 | 200 | qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this; | 201 | qCDebug(QTMIR_APPLICATIONS) << "ApplicationManager::ApplicationManager (this=%p)" << this; |
65 | 201 | setObjectName("qtmir::ApplicationManager"); | 202 | setObjectName("qtmir::ApplicationManager"); |
66 | @@ -320,6 +321,35 @@ | |||
67 | 320 | } | 321 | } |
68 | 321 | } | 322 | } |
69 | 322 | 323 | ||
70 | 324 | bool ApplicationManager::forceDashActive() const | ||
71 | 325 | { | ||
72 | 326 | return m_forceDashActive; | ||
73 | 327 | } | ||
74 | 328 | |||
75 | 329 | void ApplicationManager::setForceDashActive(bool forceDashActive) | ||
76 | 330 | { | ||
77 | 331 | if (m_forceDashActive == forceDashActive) { | ||
78 | 332 | return; | ||
79 | 333 | } | ||
80 | 334 | |||
81 | 335 | m_forceDashActive = forceDashActive; | ||
82 | 336 | Q_EMIT forceDashActiveChanged(); | ||
83 | 337 | |||
84 | 338 | Application *dashApp = findApplication("unity8-dash"); | ||
85 | 339 | if (!dashApp) { | ||
86 | 340 | qCWarning(QTMIR_APPLICATIONS) << "Dash doesn't seem to be running... Ignoring."; | ||
87 | 341 | return; | ||
88 | 342 | } | ||
89 | 343 | |||
90 | 344 | if (m_forceDashActive && dashApp->state() != Application::Running) { | ||
91 | 345 | resumeApplication(dashApp); | ||
92 | 346 | } else if (!m_forceDashActive && dashApp->state() == Application::Running | ||
93 | 347 | && m_mainStageApplication != dashApp | ||
94 | 348 | && m_sideStageApplication != dashApp) { | ||
95 | 349 | suspendApplication(dashApp); | ||
96 | 350 | } | ||
97 | 351 | } | ||
98 | 352 | |||
99 | 323 | bool ApplicationManager::suspendApplication(Application *application) | 353 | bool ApplicationManager::suspendApplication(Application *application) |
100 | 324 | { | 354 | { |
101 | 325 | if (application == nullptr) | 355 | if (application == nullptr) |
102 | @@ -330,6 +360,10 @@ | |||
103 | 330 | if (!m_lifecycleExceptions.filter(application->appId().section('_',0,0)).empty()) | 360 | if (!m_lifecycleExceptions.filter(application->appId().section('_',0,0)).empty()) |
104 | 331 | return false; | 361 | return false; |
105 | 332 | 362 | ||
106 | 363 | if (m_forceDashActive && application->appId() == "unity8-dash") { | ||
107 | 364 | return false; | ||
108 | 365 | } | ||
109 | 366 | |||
110 | 333 | if (application->state() == Application::Running) | 367 | if (application->state() == Application::Running) |
111 | 334 | application->setState(Application::Suspended); | 368 | application->setState(Application::Suspended); |
112 | 335 | 369 | ||
113 | @@ -370,10 +404,14 @@ | |||
114 | 370 | 404 | ||
115 | 371 | if (application->stage() == Application::MainStage) { | 405 | if (application->stage() == Application::MainStage) { |
116 | 372 | m_mainStageApplication = application; | 406 | m_mainStageApplication = application; |
117 | 373 | resumeApplication(m_sideStageApplication); // in case unfocusCurrentApplication() was last called | ||
118 | 374 | } else { | 407 | } else { |
119 | 375 | m_sideStageApplication = application; | 408 | m_sideStageApplication = application; |
121 | 376 | resumeApplication(m_mainStageApplication); // in case unfocusCurrentApplication() was last called | 409 | } |
122 | 410 | |||
123 | 411 | if (!m_suspended) { | ||
124 | 412 | resumeApplication(application); // in case unfocusCurrentApplication() was last called | ||
125 | 413 | } else { | ||
126 | 414 | suspendApplication(application); // Make sure we also have this one suspended if everything is suspended | ||
127 | 377 | } | 415 | } |
128 | 378 | 416 | ||
129 | 379 | m_focusedApplication = application; | 417 | m_focusedApplication = application; |
130 | @@ -801,6 +839,9 @@ | |||
131 | 801 | if (application && application->state() == Application::Starting) { | 839 | if (application && application->state() == Application::Starting) { |
132 | 802 | m_dbusWindowStack->WindowCreated(0, application->appId()); | 840 | m_dbusWindowStack->WindowCreated(0, application->appId()); |
133 | 803 | application->setState(Application::Running); | 841 | application->setState(Application::Running); |
134 | 842 | if ((application != m_mainStageApplication && application != m_sideStageApplication) || m_suspended) { | ||
135 | 843 | suspendApplication(application); | ||
136 | 844 | } | ||
137 | 804 | } | 845 | } |
138 | 805 | } | 846 | } |
139 | 806 | 847 | ||
140 | 807 | 848 | ||
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 | 91 | QString focusedApplicationId() const override; | 91 | QString focusedApplicationId() const override; |
146 | 92 | bool suspended() const override; | 92 | bool suspended() const override; |
147 | 93 | void setSuspended(bool suspended) override; | 93 | void setSuspended(bool suspended) override; |
148 | 94 | bool forceDashActive() const override; | ||
149 | 95 | void setForceDashActive(bool forceDashActive) override; | ||
150 | 94 | Q_INVOKABLE qtmir::Application* get(int index) const override; | 96 | Q_INVOKABLE qtmir::Application* get(int index) const override; |
151 | 95 | Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override; | 97 | Q_INVOKABLE qtmir::Application* findApplication(const QString &appId) const override; |
152 | 96 | Q_INVOKABLE bool requestFocusApplication(const QString &appId) override; | 98 | Q_INVOKABLE bool requestFocusApplication(const QString &appId) override; |
153 | @@ -161,6 +163,7 @@ | |||
154 | 161 | static ApplicationManager* the_application_manager; | 163 | static ApplicationManager* the_application_manager; |
155 | 162 | QList<pid_t> m_hiddenPIDs; | 164 | QList<pid_t> m_hiddenPIDs; |
156 | 163 | bool m_suspended; | 165 | bool m_suspended; |
157 | 166 | bool m_forceDashActive; | ||
158 | 164 | 167 | ||
159 | 165 | friend class Application; | 168 | friend class Application; |
160 | 166 | friend class DBusWindowStack; | 169 | friend class DBusWindowStack; |
161 | 167 | 170 | ||
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 | 109 | return m_appController->findDesktopFileForAppId(appId); | 109 | return m_appController->findDesktopFileForAppId(appId); |
167 | 110 | } | 110 | } |
168 | 111 | 111 | ||
170 | 112 | bool TaskController::suspend(const QString& appId) | 112 | bool TaskController::suspend(const Application* app) |
171 | 113 | { | 113 | { |
174 | 114 | qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << appId; | 114 | qCDebug(QTMIR_APPLICATIONS) << "TaskController::suspend - appId=" << app->appId(); |
175 | 115 | pid_t pid = m_appController->primaryPidForAppId(appId); | 115 | pid_t pid = m_appController->primaryPidForAppId(app->appId()); |
176 | 116 | if (pid == 0) { | ||
177 | 117 | pid = app->pid(); | ||
178 | 118 | } | ||
179 | 116 | m_processController->oomController()->ensureProcessLikelyToBeKilled(pid); | 119 | m_processController->oomController()->ensureProcessLikelyToBeKilled(pid); |
180 | 117 | 120 | ||
181 | 118 | if (pid) { | 121 | if (pid) { |
182 | @@ -125,10 +128,13 @@ | |||
183 | 125 | } | 128 | } |
184 | 126 | } | 129 | } |
185 | 127 | 130 | ||
187 | 128 | bool TaskController::resume(const QString& appId) | 131 | bool TaskController::resume(const Application* app) |
188 | 129 | { | 132 | { |
191 | 130 | qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << appId; | 133 | qCDebug(QTMIR_APPLICATIONS) << "TaskController::resume - appId=" << app->appId(); |
192 | 131 | pid_t pid = m_appController->primaryPidForAppId(appId); | 134 | pid_t pid = m_appController->primaryPidForAppId(app->appId()); |
193 | 135 | if (pid == 0) { | ||
194 | 136 | pid = app->pid(); | ||
195 | 137 | } | ||
196 | 132 | 138 | ||
197 | 133 | m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid); | 139 | m_processController->oomController()->ensureProcessUnlikelyToBeKilled(pid); |
198 | 134 | 140 | ||
199 | @@ -139,7 +145,7 @@ | |||
200 | 139 | return m_processController->sigContinueProcessGroupForPid(pid); | 145 | return m_processController->sigContinueProcessGroupForPid(pid); |
201 | 140 | return true; | 146 | return true; |
202 | 141 | } else { | 147 | } else { |
204 | 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(); |
205 | 143 | return false; | 149 | return false; |
206 | 144 | } | 150 | } |
207 | 145 | } | 151 | } |
208 | 146 | 152 | ||
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 | 41 | bool start(const QString &appId, const QStringList &args); | 41 | bool start(const QString &appId, const QStringList &args); |
214 | 42 | bool stop(const QString &appId); | 42 | bool stop(const QString &appId); |
215 | 43 | 43 | ||
218 | 44 | bool suspend(const QString &appId); | 44 | bool suspend(const Application* app); |
219 | 45 | bool resume(const QString &appId); | 45 | bool resume(const Application* app); |
220 | 46 | 46 | ||
221 | 47 | bool appIdHasProcessId(const QString &appId, const quint64 pid) const; | 47 | bool appIdHasProcessId(const QString &appId, const quint64 pid) const; |
222 | 48 | QFileInfo findDesktopFileForAppId(const QString &appId) const; | 48 | QFileInfo findDesktopFileForAppId(const QString &appId) const; |
223 | 49 | 49 | ||
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 | 393 | applicationManager.authorizeSession(a_procId, authed); | 393 | applicationManager.authorizeSession(a_procId, authed); |
229 | 394 | 394 | ||
230 | 395 | onSessionStarting(first_session); | 395 | onSessionStarting(first_session); |
231 | 396 | applicationManager.focusApplication(an_app_id); | ||
232 | 396 | applicationManager.onSessionCreatedSurface(first_session.get(), aSurface); | 397 | applicationManager.onSessionCreatedSurface(first_session.get(), aSurface); |
233 | 397 | onSessionStarting(second_session); | 398 | onSessionStarting(second_session); |
234 | 398 | 399 | ||
235 | @@ -441,6 +442,152 @@ | |||
236 | 441 | EXPECT_EQ(true, the_app->focused()); | 442 | EXPECT_EQ(true, the_app->focused()); |
237 | 442 | } | 443 | } |
238 | 443 | 444 | ||
239 | 445 | TEST_F(ApplicationManagerTests,suspended_suspends_starting_app_when_it_gets_ready) | ||
240 | 446 | { | ||
241 | 447 | using namespace ::testing; | ||
242 | 448 | quint64 a_procId = 5921; | ||
243 | 449 | const char an_app_id[] = "some_app"; | ||
244 | 450 | QByteArray a_cmd( "/usr/bin/app1 --desktop_file_hint=some_app"); | ||
245 | 451 | std::shared_ptr<mir::scene::Surface> aSurface(nullptr); | ||
246 | 452 | |||
247 | 453 | ON_CALL(procInfo,command_line(_)).WillByDefault(Return(a_cmd)); | ||
248 | 454 | |||
249 | 455 | ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false)); | ||
250 | 456 | |||
251 | 457 | bool authed = true; | ||
252 | 458 | |||
253 | 459 | std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", a_procId); | ||
254 | 460 | applicationManager.authorizeSession(a_procId, authed); | ||
255 | 461 | |||
256 | 462 | onSessionStarting(first_session); | ||
257 | 463 | |||
258 | 464 | Application * the_app = applicationManager.findApplication(an_app_id); | ||
259 | 465 | applicationManager.focusApplication(an_app_id); | ||
260 | 466 | EXPECT_EQ(Application::Starting, the_app->state()); | ||
261 | 467 | |||
262 | 468 | applicationManager.setSuspended(true); | ||
263 | 469 | |||
264 | 470 | // Not suspending yet, as it's still starting | ||
265 | 471 | EXPECT_EQ(Application::Starting, the_app->state()); | ||
266 | 472 | |||
267 | 473 | // This signals the app is ready now | ||
268 | 474 | applicationManager.onSessionCreatedSurface(first_session.get(), aSurface); | ||
269 | 475 | |||
270 | 476 | // And given that the AppManager is suspended now, this should go to suspended too | ||
271 | 477 | EXPECT_EQ(Application::Suspended, the_app->state()); | ||
272 | 478 | EXPECT_EQ(false, the_app->focused()); | ||
273 | 479 | |||
274 | 480 | applicationManager.setSuspended(false); | ||
275 | 481 | |||
276 | 482 | EXPECT_EQ(Application::Running, the_app->state()); | ||
277 | 483 | EXPECT_EQ(true, the_app->focused()); | ||
278 | 484 | } | ||
279 | 485 | |||
280 | 486 | TEST_F(ApplicationManagerTests,focus_change_suspends_starting_app_when_it_gets_ready) | ||
281 | 487 | { | ||
282 | 488 | using namespace ::testing; | ||
283 | 489 | quint64 first_procId = 5921; | ||
284 | 490 | quint64 second_procId = 5922; | ||
285 | 491 | std::shared_ptr<mir::scene::Surface> aSurface(nullptr); | ||
286 | 492 | QByteArray first_cmdLine( "/usr/bin/app1 --desktop_file_hint=app1"); | ||
287 | 493 | QByteArray second_cmdLine( "/usr/bin/app2--desktop_file_hint=app2"); | ||
288 | 494 | |||
289 | 495 | EXPECT_CALL(procInfo,command_line(first_procId)) | ||
290 | 496 | .Times(1) | ||
291 | 497 | .WillOnce(Return(first_cmdLine)); | ||
292 | 498 | |||
293 | 499 | ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false)); | ||
294 | 500 | |||
295 | 501 | EXPECT_CALL(procInfo,command_line(second_procId)) | ||
296 | 502 | .Times(1) | ||
297 | 503 | .WillOnce(Return(second_cmdLine)); | ||
298 | 504 | |||
299 | 505 | bool authed = true; | ||
300 | 506 | |||
301 | 507 | std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", first_procId); | ||
302 | 508 | std::shared_ptr<mir::scene::Session> second_session = std::make_shared<MockSession>("oO", second_procId); | ||
303 | 509 | applicationManager.authorizeSession(first_procId, authed); | ||
304 | 510 | applicationManager.authorizeSession(second_procId, authed); | ||
305 | 511 | onSessionStarting(first_session); | ||
306 | 512 | |||
307 | 513 | Application * app1 = applicationManager.findApplication("app1"); | ||
308 | 514 | applicationManager.focusApplication("app1"); | ||
309 | 515 | |||
310 | 516 | // First app starting... | ||
311 | 517 | EXPECT_EQ(Application::Starting, app1->state()); | ||
312 | 518 | |||
313 | 519 | onSessionStarting(second_session); | ||
314 | 520 | Application * app2 = applicationManager.findApplication("app2"); | ||
315 | 521 | applicationManager.focusApplication("app2"); | ||
316 | 522 | |||
317 | 523 | // Second app starting... | ||
318 | 524 | EXPECT_EQ(Application::Starting, app2->state()); | ||
319 | 525 | |||
320 | 526 | // Make sure first one is still in starting state | ||
321 | 527 | EXPECT_EQ(Application::Starting, app1->state()); | ||
322 | 528 | |||
323 | 529 | // Signal app1 is ready now | ||
324 | 530 | applicationManager.onSessionCreatedSurface(first_session.get(), aSurface); | ||
325 | 531 | |||
326 | 532 | // Make sure AppMan suspended it now that its ready | ||
327 | 533 | EXPECT_EQ(Application::Suspended, app1->state()); | ||
328 | 534 | } | ||
329 | 535 | |||
330 | 536 | TEST_F(ApplicationManagerTests,forceDashActive_activates_dash_while_not_focused) | ||
331 | 537 | { | ||
332 | 538 | using namespace ::testing; | ||
333 | 539 | quint64 first_procId = 5921; | ||
334 | 540 | quint64 second_procId = 5922; | ||
335 | 541 | std::shared_ptr<mir::scene::Surface> aSurface(nullptr); | ||
336 | 542 | QByteArray first_cmdLine( "/usr/bin/app1 --desktop_file_hint=unity8-dash"); | ||
337 | 543 | QByteArray second_cmdLine( "/usr/bin/app2--desktop_file_hint=app2"); | ||
338 | 544 | |||
339 | 545 | EXPECT_CALL(procInfo,command_line(first_procId)) | ||
340 | 546 | .Times(1) | ||
341 | 547 | .WillOnce(Return(first_cmdLine)); | ||
342 | 548 | |||
343 | 549 | ON_CALL(appController,appIdHasProcessId(_,_)).WillByDefault(Return(false)); | ||
344 | 550 | |||
345 | 551 | EXPECT_CALL(procInfo,command_line(second_procId)) | ||
346 | 552 | .Times(1) | ||
347 | 553 | .WillOnce(Return(second_cmdLine)); | ||
348 | 554 | |||
349 | 555 | bool authed = true; | ||
350 | 556 | |||
351 | 557 | std::shared_ptr<mir::scene::Session> first_session = std::make_shared<MockSession>("Oo", first_procId); | ||
352 | 558 | std::shared_ptr<mir::scene::Session> second_session = std::make_shared<MockSession>("oO", second_procId); | ||
353 | 559 | applicationManager.authorizeSession(first_procId, authed); | ||
354 | 560 | applicationManager.authorizeSession(second_procId, authed); | ||
355 | 561 | onSessionStarting(first_session); | ||
356 | 562 | |||
357 | 563 | Application * dashApp = applicationManager.findApplication("unity8-dash"); | ||
358 | 564 | applicationManager.onSessionCreatedSurface(first_session.get(), aSurface); | ||
359 | 565 | applicationManager.focusApplication("unity8-dash"); | ||
360 | 566 | |||
361 | 567 | // Dash app should be ready now... | ||
362 | 568 | EXPECT_EQ(Application::Running, dashApp->state()); | ||
363 | 569 | |||
364 | 570 | // Launch second app | ||
365 | 571 | onSessionStarting(second_session); | ||
366 | 572 | applicationManager.onSessionCreatedSurface(second_session.get(), aSurface); | ||
367 | 573 | applicationManager.focusApplication("app2"); | ||
368 | 574 | EXPECT_EQ(applicationManager.focusedApplicationId(), "app2"); | ||
369 | 575 | |||
370 | 576 | // Make sure the dash is suspended | ||
371 | 577 | EXPECT_EQ(dashApp->state(), Application::Suspended); | ||
372 | 578 | |||
373 | 579 | // Now set the dashactive flag | ||
374 | 580 | applicationManager.setForceDashActive(true); | ||
375 | 581 | |||
376 | 582 | // And make sure the dash is woken up but not focused | ||
377 | 583 | EXPECT_EQ(applicationManager.focusedApplicationId(), "app2"); | ||
378 | 584 | EXPECT_EQ(dashApp->state(), Application::Running); | ||
379 | 585 | |||
380 | 586 | // Unset the dashactive flag | ||
381 | 587 | applicationManager.setForceDashActive(false); | ||
382 | 588 | EXPECT_EQ(dashApp->state(), Application::Suspended); | ||
383 | 589 | } | ||
384 | 590 | |||
385 | 444 | TEST_F(ApplicationManagerTests,requestFocusApplication) | 591 | TEST_F(ApplicationManagerTests,requestFocusApplication) |
386 | 445 | { | 592 | { |
387 | 446 | using namespace ::testing; | 593 | using namespace ::testing; |
388 | @@ -871,6 +1018,7 @@ | |||
389 | 871 | 1018 | ||
390 | 872 | applicationManager.startApplication(appId, ApplicationManager::NoFlag); | 1019 | applicationManager.startApplication(appId, ApplicationManager::NoFlag); |
391 | 873 | applicationManager.onProcessStarting(appId); | 1020 | applicationManager.onProcessStarting(appId); |
392 | 1021 | applicationManager.focusApplication(appId); | ||
393 | 874 | 1022 | ||
394 | 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); |
395 | 876 | 1024 | ||
396 | 877 | 1025 | ||
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 | 16 | */ | 16 | */ |
402 | 17 | 17 | ||
403 | 18 | #include <Unity/Application/taskcontroller.h> | 18 | #include <Unity/Application/taskcontroller.h> |
404 | 19 | #include <Unity/Application/desktopfilereader.h> | ||
405 | 20 | #include <Unity/Application/application.h> | ||
406 | 19 | 21 | ||
407 | 20 | #include "mock_oom_controller.h" | 22 | #include "mock_oom_controller.h" |
408 | 21 | #include "mock_process_controller.h" | 23 | #include "mock_process_controller.h" |
409 | 24 | #include "mock_desktop_file_reader.h" | ||
410 | 22 | 25 | ||
411 | 23 | #include <core/posix/fork.h> | 26 | #include <core/posix/fork.h> |
412 | 24 | #include <core/posix/linux/proc/process/oom_score_adj.h> | 27 | #include <core/posix/linux/proc/process/oom_score_adj.h> |
413 | @@ -141,11 +144,17 @@ | |||
414 | 141 | 144 | ||
415 | 142 | EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(-1)).Times(1); | 145 | EXPECT_CALL(oomController, ensureProcessLikelyToBeKilled(-1)).Times(1); |
416 | 143 | 146 | ||
418 | 144 | TaskController taskController(nullptr, | 147 | auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr, |
419 | 145 | appControllerPtr, | 148 | appControllerPtr, |
423 | 146 | processControllerPtr); | 149 | processControllerPtr)); |
424 | 147 | 150 | ||
425 | 148 | taskController.suspend(appId); | 151 | |
426 | 152 | auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); | ||
427 | 153 | ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); | ||
428 | 154 | ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); | ||
429 | 155 | Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr); | ||
430 | 156 | taskController->suspend(app); | ||
431 | 157 | delete app; | ||
432 | 149 | } | 158 | } |
433 | 150 | 159 | ||
434 | 151 | TEST(TaskController, resumingAnApplicationAdjustsOomScoreForCorrectPid) | 160 | TEST(TaskController, resumingAnApplicationAdjustsOomScoreForCorrectPid) |
435 | @@ -173,11 +182,17 @@ | |||
436 | 173 | 182 | ||
437 | 174 | EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(-1)).Times(1); | 183 | EXPECT_CALL(oomController, ensureProcessUnlikelyToBeKilled(-1)).Times(1); |
438 | 175 | 184 | ||
440 | 176 | TaskController taskController(nullptr, | 185 | auto taskController = QSharedPointer<TaskController>(new TaskController(nullptr, |
441 | 177 | appControllerPtr, | 186 | appControllerPtr, |
445 | 178 | processControllerPtr); | 187 | processControllerPtr)); |
446 | 179 | 188 | ||
447 | 180 | taskController.resume(appId); | 189 | |
448 | 190 | auto mockDesktopFileReader = new NiceMock<MockDesktopFileReader>(appId, QFileInfo()); | ||
449 | 191 | ON_CALL(*mockDesktopFileReader, loaded()).WillByDefault(Return(true)); | ||
450 | 192 | ON_CALL(*mockDesktopFileReader, appId()).WillByDefault(Return(appId)); | ||
451 | 193 | Application *app = new Application(taskController, mockDesktopFileReader, Application::Running, QStringList(), nullptr); | ||
452 | 194 | taskController->resume(app); | ||
453 | 195 | delete app; | ||
454 | 181 | } | 196 | } |
455 | 182 | 197 | ||
456 | 183 | TEST(TaskController, aStartedApplicationIsOomScoreAdjusted) | 198 | TEST(TaskController, aStartedApplicationIsOomScoreAdjusted) |
PASSED: Continuous integration, rev:247 jenkins. qa.ubuntu. com/job/ qtmir-ci/ 66/ jenkins. qa.ubuntu. com/job/ qtmir-utopic- amd64-ci/ 66 jenkins. qa.ubuntu. com/job/ qtmir-utopic- armhf-ci/ 66
http://
Executed test runs:
SUCCESS: http://
SUCCESS: http://
Click here to trigger a rebuild: s-jenkins. ubuntu- ci:8080/ job/qtmir- ci/66/rebuild
http://