Merge lp:~gerboland/unity-api/appManVersion2 into lp:unity-api

Proposed by Gerry Boland
Status: Work in progress
Proposed branch: lp:~gerboland/unity-api/appManVersion2
Merge into: lp:unity-api
Diff against target: 527 lines (+187/-103)
9 files modified
debian/changelog (+6/-0)
include/unity/shell/application/ApplicationInfoInterface.h (+29/-6)
include/unity/shell/application/ApplicationManagerInterface.h (+31/-40)
include/unity/shell/application/CMakeLists.txt (+1/-1)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp (+7/-1)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h (+15/-13)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp (+14/-16)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h (+19/-23)
test/qmltest/unity/shell/application/tst_Application.qml (+65/-3)
To merge this branch: bzr merge lp:~gerboland/unity-api/appManVersion2
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+219403@code.launchpad.net

This proposal supersedes a proposal from 2014-05-01.

Commit message

Revised ApplicationManager and ApplicationInfo APIs to ease transition to the QtMirCompositor project

Description of the change

Revised ApplicationManager and ApplicationInfo APIs for QtMirCompositor project

 * Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~gerboland/unity-mir/appManV2-compat/+merge/219407
https://code.launchpad.net/~gerboland/unity8/appManV2-compat/+merge/219673
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Y
 * Did you make sure that your branch does not contain spurious tags?
Y
 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?
Y
 * If you changed the UI, has there been a design review?
N/A - no UI change

To post a comment you must log in.
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

Here's a couple of comments of things we should think of. Not necessarily disagreeing with them, just worth a though/discussion imo:

====

20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY supportedStagesChanged)

Do we assume that if an app claims support for both stages, all of its surfaces will support them? Probably yes.

====

31 + * Holds the current application focus state. True if a surface of this application is focused, false otherwise.

Really needed? what would we gain with this information? Wouldn't it make more sense to obtain it the other was round? For instance:

var focusedApp = SurfaceManager.appId(SurfaceManager.focusedSurfaceId)

====

78 + Q_INVOKABLE virtual bool suspend() = 0;
89 + Q_INVOKABLE virtual bool resume() = 0;

Where would you call this from? I'm not sure if we should expose this to unity but rather handle this stuff internally in the applicationmanager. We might add something like inhibitSuspension() at a later point if we want to give the user control over it.

Also it doesn't really match with the existing API, given that we have startApplication() and stopApplication() in ApplicationManager (not ApplicationInfo) such things should be at the same place. If we decide to expose this to the shell, I'm not opposed to have them in both places (ApplicationManager::suspendApplication(appId) and ApplicationInfo::suspend()).

====

301 void setFocused(bool focused);

What would this do?

review: Needs Information
Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

On 01.05.2014 15:11, Michael Zanetti wrote:
> ====
>
> 20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY supportedStagesChanged)
>
> Do we assume that if an app claims support for both stages, all of its surfaces will support them? Probably yes.

When thinking about stages, we're only considering single-surface apps.
So yes.

Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

> Here's a couple of comments of things we should think of. Not necessarily
> disagreeing with them, just worth a though/discussion imo:
Sure. I'm just making up stuff as I go along

> 20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY
> supportedStagesChanged)
> Do we assume that if an app claims support for both stages, all of its
> surfaces will support them? Probably yes.
Yes. This is property of an application. If it claims to support a stage, then its surface can be resized to suit that stage, and it can't stop that. One app can't have surfaces on both stage either. Note also that "stage" is a property shell will have to save when the app is closed, so user preference is retained.

> 31 + * Holds the current application focus state. True if a surface of
> this application is focused, false otherwise.
> Really needed? what would we gain with this information? Wouldn't it make more
> sense to obtain it the other was round? For instance:
I kept this as I thought it would make the job of the launcher easier. I can remove if you don't think it's worth it.

> 78 + Q_INVOKABLE virtual bool suspend() = 0;
> 89 + Q_INVOKABLE virtual bool resume() = 0;
>
> Where would you call this from? I'm not sure if we should expose this to unity
> but rather handle this stuff internally in the applicationmanager. We might
> add something like inhibitSuspension() at a later point if we want to give the
> user control over it.
>
> Also it doesn't really match with the existing API, given that we have
> startApplication() and stopApplication() in ApplicationManager (not
> ApplicationInfo) such things should be at the same place. If we decide to
> expose this to the shell, I'm not opposed to have them in both places
> (ApplicationManager::suspendApplication(appId) and
> ApplicationInfo::suspend()).

Not a bad point. I thought it a good idea to have shell decide when to suspend/resume apps, as only shell really knows what is visible or not, and shell implements the policy (on phone/tablet, all non-visible apps suspended, on desktop can be more flexible, maybe apps can opt-in to being suspended). I've been trying to make AppMan device independent, because I fear having some policy in AppMan, and some in shell, will end up with conflicts.

Another way this could be done by shell setting the surface visible flags, and if all an app's surfaces are hidden, it can be suspended. But then we tie rendering control to lifecycle control, which I don't like.

You're right, the API is not consistent. Will look more.

> ====
>
> 301 void setFocused(bool focused);
>
> What would this do?
That was in the Mock before. I dunno why it's there. I can remove

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

> > 31 + * Holds the current application focus state. True if a surface of
> > this application is focused, false otherwise.
> > Really needed? what would we gain with this information? Wouldn't it make
> more
> > sense to obtain it the other was round? For instance:
> I kept this as I thought it would make the job of the launcher easier. I can
> remove if you don't think it's worth it.

Right... Works for me. Thanks for caring about the Launcher :)

>
>
>
> > 78 + Q_INVOKABLE virtual bool suspend() = 0;
> > 89 + Q_INVOKABLE virtual bool resume() = 0;
> >
> > Where would you call this from? I'm not sure if we should expose this to
> unity
> > but rather handle this stuff internally in the applicationmanager. We might
> > add something like inhibitSuspension() at a later point if we want to give
> the
> > user control over it.
> >
> > Also it doesn't really match with the existing API, given that we have
> > startApplication() and stopApplication() in ApplicationManager (not
> > ApplicationInfo) such things should be at the same place. If we decide to
> > expose this to the shell, I'm not opposed to have them in both places
> > (ApplicationManager::suspendApplication(appId) and
> > ApplicationInfo::suspend()).
>
> Not a bad point. I thought it a good idea to have shell decide when to
> suspend/resume apps, as only shell really knows what is visible or not, and
> shell implements the policy (on phone/tablet, all non-visible apps suspended,
> on desktop can be more flexible, maybe apps can opt-in to being suspended).
> I've been trying to make AppMan device independent, because I fear having some
> policy in AppMan, and some in shell, will end up with conflicts.

You're right... Makes more sense in the shell. I was still thinking too much like the old approach. But now that focused is something that's only available in QML this obviously doesn't work the old way any more.

>
> Another way this could be done by shell setting the surface visible flags, and
> if all an app's surfaces are hidden, it can be suspended. But then we tie
> rendering control to lifecycle control, which I don't like.

Yeah... doesn't sound much better than the above.

>
> You're right, the API is not consistent. Will look more.

Jup... Again, I'm fine with having them in both. We need to keep startApplication() in AppMan which makes it natural to have stopApplication() there too, and with it suspend/resume. But I can see how it would be convenient to have that as an ApplicationInfo object's property in QML.

So I'd probably go for
ApplicationManager:
startApplication()
stopApplication()
suspendApplication()
resumeApplication()

and ApplicationInfo:
stop()
Q_PROPERTY(suspended)

We can even implement and test those in the abstract interface so there's little risk an implementation would get them out of sync.

Revision history for this message
kevin gunn (kgunn72) wrote : Posted in a previous version of this proposal

> > Here's a couple of comments of things we should think of. Not necessarily
> > disagreeing with them, just worth a though/discussion imo:
> Sure. I'm just making up stuff as I go along
>
>
> > 20 + Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY
> > supportedStagesChanged)
> > Do we assume that if an app claims support for both stages, all of its
> > surfaces will support them? Probably yes.
> Yes. This is property of an application. If it claims to support a stage, then
> its surface can be resized to suit that stage, and it can't stop that. One app
> can't have surfaces on both stage either. Note also that "stage" is a property
> shell will have to save when the app is closed, so user preference is
> retained.
>

So my comment/question might be irrelevant. But I could foresee that trusted sessions might create a case where an app could be open on mainstage but invoked for a second surface within the trust session on side stage (or vice versa). Would your assumptions/implementation preclude this ?

Revision history for this message
Michał Sawicz (saviq) wrote : Posted in a previous version of this proposal

On 01.05.2014 20:30, kevin gunn wrote:
> So my comment/question might be irrelevant. But I could foresee that trusted sessions might create a case where an app could be open on mainstage but invoked for a second surface within the trust session on side stage (or vice versa). Would your assumptions/implementation preclude this ?

The second surface will not be an app, it will be just a surface, from a
separate process, it will be part of the original "invoking" app.

So no, everything's good here.

Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

> Jup... Again, I'm fine with having them in both. We need to keep
> startApplication() in AppMan which makes it natural to have stopApplication()
> there too, and with it suspend/resume. But I can see how it would be
> convenient to have that as an ApplicationInfo object's property in QML.
>
> So I'd probably go for
> ApplicationManager:
> startApplication()
> stopApplication()
> suspendApplication()
> resumeApplication()

Ok, I can do those

> and ApplicationInfo:
> Q_PROPERTY(suspended)

This one I'm not so sure about. We already use 'state' to get the process state, so adding the "suspended" property duplicates info. I also dislike it as some apps are excluded from lifecycle, so shell setting myApp.suspended=true is just incorrect.

I prefer just using the first part of your proposal - with {suspend,resume}Application() returning bool, so that shell knows if asking an app to suspend was actually acted upon or not.

I don't think shell really needs to know if an app is lifecycle-exempt, but it would care if suspendApplication returns false. Main use-case I can think of is there's no need for shell to save a screenshot to disk for a lifecycle-exempt app's surface, as there's no way that app will be killed.

> stop()
I might leave this out for the time being, just for ease of implementation, if you don't mind.

Also maybe just putting the process control methods (start/stop/suspend/resume) in AppManager is enough for a start.

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

ack. works for me

Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

The stages and State enums are not tested. Can you please add a test that checks for all the values, but also that Stages are flags and can be used as such in QML?

===

Now that Stages are flags, we need to define their values explicitly in the enum definition. Now we have 0 and 1. ORing them loses information about 0.

===

Otherwise I think we're good now in terms of the API itself.

review: Needs Fixing
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

I guess we should bump the package version too

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

the changelog in unity-api changed by now and conflicts.

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

debian: package version 7.90

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

I've resumed work on this branch after a long delay

Main changes:
- I restored the "screenshot" taking methods and role in the AppManager model, as they are useful for generating the Dash App's lens application snapshot images
- Bumped debian package version to 7.90

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
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: Approve (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote :

+1

review: Approve

Unmerged revisions

151. By Gerry Boland

debian: package version 7.90

150. By Gerry Boland

Merge trunk

149. By Gerry Boland

changelog correction

148. By Gerry Boland

Update changelog

147. By Gerry Boland

Merge trunk

146. By Gerry Boland

Restore the Application screenshot API for now

145. By Gerry Boland

Resolve conflict

144. By Gerry Boland

Bump debian version

143. By Gerry Boland

Add test for flags operator |

142. By Gerry Boland

Add tests to verify state & stage enums

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/changelog'
2--- debian/changelog 2014-06-16 14:45:10 +0000
3+++ debian/changelog 2014-06-24 23:00:14 +0000
4@@ -1,3 +1,9 @@
5+unity-api (7.90) UNRELEASED; urgency=medium
6+
7+ * Version 3 of ApplicationManager and ApplicationInfo APIs, in preparation for QtCompositor
8+
9+ -- Gerry Boland <gerry.boland@canonical.com> Thu, 19 Jun 2014 12:46:15 +0100
10+
11 unity-api (7.82+14.10.20140616-0ubuntu1) utopic; urgency=medium
12
13 [ Albert Astals Cid ]
14
15=== modified file 'include/unity/shell/application/ApplicationInfoInterface.h'
16--- include/unity/shell/application/ApplicationInfoInterface.h 2013-12-11 11:04:11 +0000
17+++ include/unity/shell/application/ApplicationInfoInterface.h 2014-06-24 23:00:14 +0000
18@@ -45,6 +45,7 @@
19
20 Q_ENUMS(Stage)
21 Q_ENUMS(State)
22+ Q_FLAGS(Stages)
23
24 /**
25 * @brief The appId of the application.
26@@ -84,6 +85,13 @@
27 Q_PROPERTY(Stage stage READ stage NOTIFY stageChanged)
28
29 /**
30+ * @brief The stages the application supports.
31+ *
32+ * OR-combination of Stage enum values denoting the stages this application supports.
33+ */
34+ Q_PROPERTY(Stages supportedStages READ supportedStages NOTIFY supportedStagesChanged)
35+
36+ /**
37 * @brief The application's state.
38 *
39 * Holds the current application state.
40@@ -93,7 +101,7 @@
41 /**
42 * @brief The application's focus state.
43 *
44- * Holds the current application focus state. True if focused, false otherwise.
45+ * Holds the current application focus state. True if a surface of this application is focused, false otherwise.
46 */
47 Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)
48
49@@ -104,6 +112,7 @@
50 */
51 Q_PROPERTY(QUrl screenshot READ screenshot NOTIFY screenshotChanged)
52
53+
54 protected:
55 /// @cond
56 ApplicationInfoInterface(const QString &appId, QObject* parent = 0): QObject(parent) { Q_UNUSED(appId) }
57@@ -119,9 +128,10 @@
58 * applications.
59 */
60 enum Stage {
61- MainStage,
62- SideStage
63+ MainStage = 0x01,
64+ SideStage = 0x02,
65 };
66+ Q_DECLARE_FLAGS(Stages, Stage)
67
68 /**
69 * @brief An application's state.
70@@ -150,19 +160,30 @@
71 virtual QString comment() const = 0;
72 virtual QUrl icon() const = 0;
73 virtual Stage stage() const = 0;
74+ virtual Stages supportedStages() const = 0;
75 virtual State state() const = 0;
76 virtual bool focused() const = 0;
77 virtual QUrl screenshot() const = 0;
78 /// @endcond
79
80+ /**
81+ * @brief Set stage
82+ *
83+ * Applications may not support all stages, so this method only returns true if the stage is supported.
84+ * @returns true if stage supported so value set, false if not supported.
85+ */
86+ Q_INVOKABLE virtual bool setStage(const Stage) = 0;
87+
88+
89 Q_SIGNALS:
90 /// @cond
91 void nameChanged(const QString &name);
92 void commentChanged(const QString &comment);
93 void iconChanged(const QUrl &icon);
94- void stageChanged(Stage stage);
95- void stateChanged(State state);
96- void focusedChanged(bool focused);
97+ void stageChanged(const Stage stage);
98+ void supportedStagesChanged(const Stages stages);
99+ void stateChanged(const State state);
100+ void focusedChanged(const bool focused);
101 void screenshotChanged(const QUrl &screenshot);
102 /// @endcond
103 };
104@@ -171,4 +192,6 @@
105 } // namespace shell
106 } // namespace unity
107
108+Q_DECLARE_OPERATORS_FOR_FLAGS(unity::shell::application::ApplicationInfoInterface::Stages)
109+
110 #endif // UNITY_SHELL_APPLICATIONMANAGER_APPLICATIONINFOINTERFACE_H
111
112=== modified file 'include/unity/shell/application/ApplicationManagerInterface.h'
113--- include/unity/shell/application/ApplicationManagerInterface.h 2014-03-10 12:40:25 +0000
114+++ include/unity/shell/application/ApplicationManagerInterface.h 2014-06-24 23:00:14 +0000
115@@ -53,9 +53,7 @@
116 Q_PROPERTY(int count READ count NOTIFY countChanged)
117
118 /**
119- * @brief The currently focused application.
120- *
121- * Use focusApplication() and unfocusCurrentApplication() to modify this.
122+ * @brief The app ID of the currently focused application.
123 */
124 Q_PROPERTY(QString focusedApplicationId READ focusedApplicationId NOTIFY focusedApplicationIdChanged)
125
126@@ -75,6 +73,7 @@
127 m_roleNames.insert(RoleComment, "comment");
128 m_roleNames.insert(RoleIcon, "icon");
129 m_roleNames.insert(RoleStage, "stage");
130+ m_roleNames.insert(RoleSupportedStages, "supportedStages");
131 m_roleNames.insert(RoleState, "state");
132 m_roleNames.insert(RoleFocused, "focused");
133 m_roleNames.insert(RoleScreenshot, "screenshot");
134@@ -98,6 +97,7 @@
135 RoleComment,
136 RoleIcon,
137 RoleStage,
138+ RoleSupportedStages,
139 RoleState,
140 RoleFocused,
141 RoleScreenshot,
142@@ -142,40 +142,14 @@
143 Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const = 0;
144
145 /**
146- * @brief Request to focus a given application
147- *
148- * This will request the shell to focus the given application.
149- *
150- * @param appId The appId of the app to be focused.
151- * @returns True if the request will processed, false if it was discarded (i.e. the given appid could not be found)
152- */
153- Q_INVOKABLE virtual bool requestFocusApplication(const QString &appId) = 0;
154-
155- /**
156- * @brief Focus the given application.
157- *
158- * This will immediately focus the given application. Usually you should not use this
159- * but instead call requestFocusApplication() in order to allow the shell to prepare
160- * for the upcoming animation or even block the focus request (e.g. focus stealing prevention)
161- *
162- * @param appId The application to be focused.
163- * @returns True if appId found and application focused, else false.
164- */
165- Q_INVOKABLE virtual bool focusApplication(const QString &appId) = 0;
166-
167- /**
168- * @brief Unfocus the currently focused application.
169- */
170- Q_INVOKABLE virtual void unfocusCurrentApplication() = 0;
171-
172- /**
173 * @brief Start an application.
174 *
175 * @param appId The appId for the application to be spawned.
176 * @param arguments Any arguments to be passed to the process.
177 * @returns The created application item if start successful, else null.
178 */
179- Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments) = 0;
180+ Q_INVOKABLE virtual unity::shell::application::ApplicationInfoInterface
181+ *startApplication(const QString &appId, const QStringList &arguments) = 0;
182
183 /**
184 * @brief Stops an application.
185@@ -193,24 +167,41 @@
186 * you can request the ApplicationManager to update it now.
187 *
188 * @param appId The application for which the screenshot should be updated.
189- * @returns True if the screenshot update operation was scheduled successfully, false otherwise (i.e. the given appId could not be found)
190+ * @returns True if the screenshot update operation was scheduled successfully, false otherwise (i.e. the given
191+ * appId could not be found)
192 */
193 Q_INVOKABLE virtual bool updateScreenshot(const QString &appId) = 0;
194
195+ /**
196+ * @brief Request the application suspends
197+ *
198+ * If application supports lifecycling and is in a running state, calling this method notifies the
199+ * app of pending suspension and a few seconds later suspends the app, updating the "state" property
200+ * to "Suspended". Method is non-blocking.
201+ * @param appId The application to be stopped.
202+ * @returns True if app is running and supports lifecycle suspension, false otherwise.
203+ */
204+ Q_INVOKABLE virtual bool suspendApplication(const QString &appId) = 0;
205+
206+ /**
207+ * @brief Request the application resumes from suspends
208+ *
209+ * If application supports lifecycling and is in a suspended state, calling this method resumes it
210+ * updating the "state" property to "Running". If application was stopped, it will be relaunched and
211+ * will restore its internal state - the state property set to "Running" only when app ready. Method
212+ * is non-blocking.
213+ * @param appId The application to be stopped.
214+ * @returns true if app is lifecycle suspended, false otherwise.
215+ */
216+ Q_INVOKABLE virtual bool resumeApplication(const QString &appId) = 0;
217+
218+
219 Q_SIGNALS:
220 /// @cond
221 void countChanged();
222 /// @endcond
223
224 /**
225- * @brief Will be emitted right before the focused application changes.
226- *
227- * This can be used to prepare for an upcoming focus change. For example starting
228- * an animation.
229- */
230- void focusRequested(const QString &appId);
231-
232- /**
233 * @brief Will be emitted whenever the focused application changes.
234 */
235 void focusedApplicationIdChanged();
236
237=== modified file 'include/unity/shell/application/CMakeLists.txt'
238--- include/unity/shell/application/CMakeLists.txt 2014-03-04 10:50:44 +0000
239+++ include/unity/shell/application/CMakeLists.txt 2014-06-24 23:00:14 +0000
240@@ -7,7 +7,7 @@
241
242 set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
243
244-set(VERSION 2)
245+set(VERSION 3)
246 set(PKGCONFIG_NAME "unity-shell-appliction")
247 set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")
248 set(PKGCONFIG_REQUIRES "Qt5Core")
249
250=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp'
251--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2013-12-11 11:28:22 +0000
252+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2014-06-24 23:00:14 +0000
253@@ -64,13 +64,19 @@
254 return m_stage;
255 }
256
257-void MockApplicationInfo::setStage(ApplicationInfoInterface::Stage stage)
258+bool MockApplicationInfo::setStage(ApplicationInfoInterface::Stage stage)
259 {
260 if (m_stage != stage)
261 {
262 m_stage = stage;
263 Q_EMIT stageChanged(m_stage);
264 }
265+ return true;
266+}
267+
268+ApplicationInfoInterface::Stages MockApplicationInfo::supportedStages() const
269+{
270+ return ApplicationInfoInterface::MainStage | ApplicationInfoInterface::SideStage;
271 }
272
273 ApplicationInfoInterface::State MockApplicationInfo::state() const
274
275=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h'
276--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2013-12-11 11:28:22 +0000
277+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2014-06-24 23:00:14 +0000
278@@ -32,19 +32,21 @@
279 public:
280 MockApplicationInfo(const QString &appId, const QString& name, const QString& comment, const QUrl& icon, QObject* parent = 0);
281
282- QString appId() const;
283- QString name() const;
284- QString comment() const;
285- QUrl icon() const;
286- QUrl screenshot() const;
287-
288- ApplicationInfoInterface::Stage stage() const;
289- void setStage(ApplicationInfoInterface::Stage stage);
290-
291- ApplicationInfoInterface::State state() const;
292- void setState(ApplicationInfoInterface::State state);
293-
294- bool focused() const;
295+ QString appId() const override;
296+ QString name() const override;
297+ QString comment() const override;
298+ QUrl icon() const override;
299+ QUrl screenshot() const override;
300+
301+ ApplicationInfoInterface::Stage stage() const override;
302+ bool setStage(const ApplicationInfoInterface::Stage stage) override;
303+
304+ ApplicationInfoInterface::Stages supportedStages() const override;
305+
306+ ApplicationInfoInterface::State state() const override;
307+ void setState(const ApplicationInfoInterface::State state);
308+
309+ bool focused() const override;
310 void setFocused(bool focused);
311
312 private:
313
314=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp'
315--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2014-05-23 08:35:43 +0000
316+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2014-06-24 23:00:14 +0000
317@@ -62,6 +62,8 @@
318 return item->icon();
319 case RoleStage:
320 return item->stage();
321+ case RoleSupportedStages:
322+ return static_cast<int>(item->supportedStages());
323 case RoleState:
324 return item->state();
325 case RoleFocused:
326@@ -110,22 +112,6 @@
327 Q_UNUSED(suspended)
328 }
329
330-bool MockApplicationManager::requestFocusApplication(const QString &appId)
331-{
332- Q_UNUSED(appId)
333- return true;
334-}
335-
336-bool MockApplicationManager::focusApplication(const QString &appId)
337-{
338- Q_UNUSED(appId)
339- return true;
340-}
341-
342-void MockApplicationManager::unfocusCurrentApplication()
343-{
344-}
345-
346 unity::shell::application::ApplicationInfoInterface *MockApplicationManager::startApplication(const QString &appId, const QStringList &arguments)
347 {
348 Q_UNUSED(arguments)
349@@ -144,3 +130,15 @@
350 Q_UNUSED(appId)
351 return true;
352 }
353+
354+bool MockApplicationManager::suspendApplication(const QString &appId)
355+{
356+ Q_UNUSED(appId)
357+ return true;
358+}
359+
360+bool MockApplicationManager::resumeApplication(const QString &appId)
361+{
362+ Q_UNUSED(appId)
363+ return true;
364+}
365
366=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h'
367--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2014-03-10 12:34:16 +0000
368+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2014-06-24 23:00:14 +0000
369@@ -34,31 +34,27 @@
370 MockApplicationManager(QObject* parent = 0);
371 ~MockApplicationManager();
372
373- int rowCount(const QModelIndex& parent) const;
374-
375- QVariant data(const QModelIndex& index, int role) const;
376-
377- QString focusedApplicationId() const;
378-
379- bool suspended() const;
380- void setSuspended(bool suspended);
381-
382- Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;
383-
384- Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;
385-
386- Q_INVOKABLE bool requestFocusApplication(const QString &appId);
387-
388- Q_INVOKABLE bool focusApplication(const QString &appId);
389-
390- Q_INVOKABLE void unfocusCurrentApplication();
391-
392- Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *startApplication(const QString &appId, const QStringList &arguments);
393-
394- Q_INVOKABLE bool stopApplication(const QString &appId);
395+ int rowCount(const QModelIndex& parent) const override;
396+
397+ QVariant data(const QModelIndex& index, int role) const override;
398+
399+ QString focusedApplicationId() const override;
400+
401+ bool suspended() const override;
402+ void setSuspended(bool suspended) override;
403+
404+ Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const override;
405+
406+ Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const override;
407+
408+ Q_INVOKABLE unity::shell::application::ApplicationInfoInterface
409+ *startApplication(const QString &appId, const QStringList &arguments) override;
410+
411+ Q_INVOKABLE bool stopApplication(const QString &appId) override;
412+ Q_INVOKABLE bool suspendApplication(const QString &appId) override;
413+ Q_INVOKABLE bool resumeApplication(const QString &appId) override;
414
415 Q_INVOKABLE bool updateScreenshot(const QString &appId);
416-
417 private:
418 QList<MockApplicationInfo*> m_list;
419 };
420
421=== modified file 'test/qmltest/unity/shell/application/tst_Application.qml'
422--- test/qmltest/unity/shell/application/tst_Application.qml 2014-03-10 12:34:16 +0000
423+++ test/qmltest/unity/shell/application/tst_Application.qml 2014-06-24 23:00:14 +0000
424@@ -67,6 +67,7 @@
425 { enum: "RoleComment" },
426 { enum: "RoleIcon" },
427 { enum: "RoleStage" },
428+ { enum: "RoleSupportedStages"},
429 { enum: "RoleState" },
430 { enum: "RoleFocused" },
431 { enum: "RoleScreenshot" },
432@@ -87,6 +88,7 @@
433 { tag: "ApplicationManager.roles[comment]", role: "comment", type: "string" },
434 { tag: "ApplicationManager.roles[icon]", role: "icon", type: "object" },
435 { tag: "ApplicationManager.roles[stage]", role: "stage", type: "number" },
436+ { tag: "ApplicationManager.roles[supportedStages]", role: "supportedStages", type: "number" },
437 { tag: "ApplicationManager.roles[state]", role: "state", type: "number" },
438 { tag: "ApplicationManager.roles[focused]", role: "focused", type: "boolean" },
439 { tag: "ApplicationManager.roles[screenshot]", role: "screenshot", type: "object" },
440@@ -108,11 +110,10 @@
441 return [
442 { tag: "ApplicationManager.methods[get]", method: "get" },
443 { tag: "ApplicationManager.methods[findApplication]", method: "findApplication" },
444- { tag: "ApplicationManager.methods[requestFocusApplication]", method: "requestFocusApplication" },
445- { tag: "ApplicationManager.methods[focusApplication]", method: "focusApplication" },
446- { tag: "ApplicationManager.methods[unfocusCurrentApplication]", method: "unfocusCurrentApplication" },
447 { tag: "ApplicationManager.methods[startApplication]", method: "startApplication" },
448 { tag: "ApplicationManager.methods[stopApplication]", method: "stopApplication" },
449+ { tag: "ApplicationManager.methods[suspendApplication]", method: "suspendApplication" },
450+ { tag: "ApplicationManager.methods[resumeApplication]", method: "resumeApplication" },
451 { tag: "ApplicationManager.methods[updateScreenshot]", method: "updateScreenshot" },
452 ];
453 }
454@@ -144,6 +145,7 @@
455 { tag: "ApplicationInfo.properties[comment]", property: "comment", type: "string" },
456 { tag: "ApplicationInfo.properties[icon]", property: "icon", type: "object" },
457 { tag: "ApplicationInfo.properties[stage]", property: "stage", type: "number" },
458+ { tag: "ApplicationInfo.properties[supportedStages]", property: "supportedStages", type: "number" },
459 { tag: "ApplicationInfo.properties[state]", property: "state", type: "number" },
460 { tag: "ApplicationInfo.properties[focused]", property: "focused", type: "boolean" },
461 { tag: "ApplicationInfo.properties[screenshot]", property: "screenshot", type: "object" },
462@@ -161,5 +163,65 @@
463
464 verifyData(data)
465 }
466+
467+ function test_item_methods_data() {
468+ return [
469+ { tag: "ApplicationInfo.methods[setStage]", method: "setStage" },
470+ ];
471+ }
472+
473+ function test_item_methods(data) {
474+ name = "ApplicationInfo";
475+ try {
476+ object = ApplicationManager.get(0)
477+ } catch(err) {
478+ object = undefined;
479+ print(err)
480+ }
481+ verifyData(data);
482+ }
483+
484+ function test_item_stage_flags_data() {
485+ return [
486+ { enum: "MainStage" },
487+ { enum: "SideStage" },
488+ ];
489+ }
490+
491+ function test_item_stage_flags(data) {
492+ name = "Application";
493+ try {
494+ object = ApplicationInfo
495+ } catch(err) {
496+ object = undefined;
497+ print(err)
498+ }
499+ verifyData(data);
500+ }
501+
502+ function test_item_stage_flags_operator() {
503+ // check that flags operator functional
504+ verify(ApplicationInfo.MainStage | ApplicationInfo.SideStage, 0x003)
505+ }
506+
507+ function test_item_state_enum_data() {
508+ return [
509+ { enum: "Starting" },
510+ { enum: "Running" },
511+ { enum: "Suspended" },
512+ { enum: "Stopped" },
513+ ];
514+ }
515+
516+ function test_item_state_enum(data) {
517+ name = "Application";
518+ try {
519+ object = ApplicationInfo
520+ } catch(err) {
521+ object = undefined;
522+ print(err)
523+ }
524+ verifyData(data);
525+ }
526 }
527 }

Subscribers

People subscribed via source and target branches

to all changes: