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

Proposed by Gerry Boland
Status: Superseded
Proposed branch: lp:~gerboland/unity-api/appManVersion2
Merge into: lp:~unity-team/unity-api/qtMirCompositor
Diff against target: 560 lines (+174/-135)
9 files modified
debian/changelog (+6/-0)
include/unity/shell/application/ApplicationInfoInterface.h (+28/-14)
include/unity/shell/application/ApplicationManagerInterface.h (+25/-50)
include/unity/shell/application/CMakeLists.txt (+1/-1)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp (+7/-6)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h (+14/-14)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp (+9/-19)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h (+19/-24)
test/qmltest/unity/shell/application/tst_Application.qml (+65/-7)
To merge this branch: bzr merge lp:~gerboland/unity-api/appManVersion2
Reviewer Review Type Date Requested Status
Michael Zanetti (community) Needs Fixing
Review via email: mp+217902@code.launchpad.net

This proposal has been superseded by a proposal from 2014-05-13.

Commit message

Revised ApplicationManager and ApplicationInfo APIs for QtMirCompositor project

Description of the change

Revised ApplicationManager and ApplicationInfo APIs for QtMirCompositor project

To post a comment you must log in.
133. By Gerry Boland

Revert last commit

134. By Gerry Boland

Bump version number of unity::shell::application api

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

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 :

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 :

> 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 :

> > 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 :

> > 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 :

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 :

> 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 :

ack. works for me

135. By Gerry Boland

Implement API adjustments suggested by mzanetti

136. By Gerry Boland

whitespace

137. By Gerry Boland

Add role for StagesSupported

138. By Gerry Boland

Update comment to reflect new API

139. By Gerry Boland

Oops forgot the test, but this breaks the compile

140. By Gerry Boland

QVariant does not know about QFlags by default, but as enum just an int anyway, cast it to keep QVariant happy

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

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
141. By Gerry Boland

Stages are flags now, set enum values so they can be ORed

142. By Gerry Boland

Add tests to verify state & stage enums

143. By Gerry Boland

Add test for flags operator |

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

I guess we should bump the package version too

review: Needs Fixing
144. By Gerry Boland

Bump debian version

145. By Gerry Boland

Resolve conflict

146. By Gerry Boland

Restore the Application screenshot API for now

147. By Gerry Boland

Merge trunk

148. By Gerry Boland

Update changelog

149. By Gerry Boland

changelog correction

150. By Gerry Boland

Merge trunk

151. By Gerry Boland

debian: package version 7.90

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

Subscribers

People subscribed via source and target branches

to all changes: