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

Proposed by Gerry Boland
Status: Superseded
Proposed branch: lp:~gerboland/unity-api/surfaceSizerCallback
Merge into: lp:unity-api
Diff against target: 365 lines (+73/-49)
12 files modified
CMakeLists.txt (+1/-1)
debian/changelog (+7/-0)
include/unity/shell/application/ApplicationInfoInterface.h (+0/-9)
include/unity/shell/application/ApplicationManagerInterface.h (+35/-14)
include/unity/shell/application/CMakeLists.txt (+3/-3)
test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt (+1/-1)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp (+0/-5)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h (+0/-2)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp (+15/-7)
test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h (+4/-2)
test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt (+1/-1)
test/qmltest/unity/shell/application/tst_Application.qml (+6/-4)
To merge this branch: bzr merge lp:~gerboland/unity-api/surfaceSizerCallback
Reviewer Review Type Date Requested Status
Michał Sawicz Needs Fixing
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+230270@code.launchpad.net

This proposal has been superseded by a proposal from 2014-08-21.

Commit message

AppMan: add surfaceAboutToBeCreatedCallback property to AppMan - allows QML shell override surface creation geometry

Description of the change

AppMan: add surfaceAboutToBeCreatedCallback property to AppMan - allows QML shell override surface creation geometry

 * Are there any related MPs required for this MP to build/function as expected? Please list.
https://code.launchpad.net/~gerboland/unity8/initialSurfaceGeometry/+merge/230490
https://code.launchpad.net/~gerboland/qtmir/initialSurfaceGeometry/+merge/230491
 * Did you perform an exploratory manual test run of your code change and any related functionality?
Y

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

Do not increment lib version, but header version

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

<Saviq> greyback, wonder, could this not ba Q_PROPERTY?
Maybe it could, in which case the API would be prettier. I'll see if it works

Revision history for this message
Michał Sawicz (saviq) :
review: Needs Fixing
Revision history for this message
Michał Sawicz (saviq) wrote :

Oh and document the signature of the callable please. Will it get info about fullscreen, for example?

I wonder if instead we should just pass availableGeometry, with Mir being responsible for policy, should we involve the shell like this?

review: Needs Information
158. By Gerry Boland

keep dch quiet

159. By Gerry Boland

Newer nicer API using properties (just one test failing)

160. By Gerry Boland

Implement a better mock and set a sensible default - fixes the test

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

> Oh and document the signature of the callable please. Will it get info about
> fullscreen, for example?
Sadly not, I need to add a feature request for Mir for that. IMO the surface type and other info that we get from a standard Mir surface would be good info to have, opposed to this limited subset.

> I wonder if instead we should just pass availableGeometry, with Mir being
> responsible for policy, should we involve the shell like this?
I dislike this idea, as effectively we'd need to educate Mir about the entire QML scene: which areas are off-limits for a non-fullscreen surfaces, what to do for surfaces of different types, stages, etc. Defining a vocabulary for that would be a nightmare IMO. And if Mir makes a decision that shell doesn't like, shell will immediately impose its will anyway - so where's the gain?

Policy I hope to define in Mir relate more to clients expectations, I want to ensure that client surfaces behave in a consistent way across mir server implementations. Shells should treat client surfaces in ways that they expect, that parent/child relationship is obeyed, focus handing is correct, input is delivered to the correct surface, siblings can attach to eachother/their parent and stay there, things like that.

161. By Gerry Boland

debump

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

Update Changelog to exhibit new api

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Michał Sawicz (saviq) wrote :

> > I wonder if instead we should just pass availableGeometry, with Mir being
> > responsible for policy, should we involve the shell like this?
> I dislike this idea, as effectively we'd need to educate Mir about the entire
> QML scene: which areas are off-limits for a non-fullscreen surfaces, what to
> do for surfaces of different types, stages, etc. Defining a vocabulary for
> that would be a nightmare IMO. And if Mir makes a decision that shell doesn't
> like, shell will immediately impose its will anyway - so where's the gain?

I'm thinking about, for example, initial placement based on previous runs and such. Maybe Mir could (optionally?) give up a preferred position and the shell would come back with the same or changed if not possible in current setup or something. Anyway, later. The gain? More logic shared between Mir shells.

> Policy I hope to define in Mir relate more to clients expectations, I want to
> ensure that client surfaces behave in a consistent way across mir server
> implementations. Shells should treat client surfaces in ways that they expect,
> that parent/child relationship is obeyed, focus handing is correct, input is
> delivered to the correct surface, siblings can attach to eachother/their
> parent and stay there, things like that.

What you said above applies here just as well - shell, if not well behaved - can impose its own will.

163. By Gerry Boland

[debian] change to UNRELEASED series, to please CI train

Revision history for this message
Michał Sawicz (saviq) :
review: Needs Information
Revision history for this message
Gerry Boland (gerboland) wrote :

> I'm thinking about, for example, initial placement based on previous runs and
> such. Maybe Mir could (optionally?) give up a preferred position and the shell
> would come back with the same or changed if not possible in current setup or
> something. Anyway, later. The gain? More logic shared between Mir shells.

Yeah definitely, that's something Mir can give us, including saving the positions on close so it can inform us where it should re-open.

> > Policy I hope to define in Mir relate more to clients expectations, I want
> to
> > ensure that client surfaces behave in a consistent way across mir server
> > implementations. Shells should treat client surfaces in ways that they
> expect,
> > that parent/child relationship is obeyed, focus handing is correct, input is
> > delivered to the correct surface, siblings can attach to eachother/their
> > parent and stay there, things like that.
>
> What you said above applies here just as well - shell, if not well behaved -
> can impose its own will.

Sure. It's a line we have to walk carefully, but I think it's more important to try guarantee behaviour for clients. Mir can define that policy, and look after surface position/size save/restore, but I don't want to go down the road of trying to educate Mir of everything happening in the QML scene.

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

> I tried:
>
> Binding {
> target: ApplicationManager
> property: "surfaceAboutToBeCreatedCallback"
> value: function surfaceSizer(surface) { print("Hihi")
> surface.width = 400;
> if (surface.appId && surface.appId == "dialer-app") {
> surface.height = 300;
> }
> return surface;
> }
> }
>
> and got this error:
> file:///usr/share/unity8/Stages/PhoneStage.qml:125:12: Unable to assign a function to a property of any type other than var.

Hah! Interesting. Can't say I understand. If Binding.value is of type
other than var, how can it be flexible enough? Otherwise if
ApplicationManager.surfaceAboutToBeCreatedCallback is not var, how would
your original approach to assign instead of bind work in any case?

I'd say that's worth a QTBUG.

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

> > I tried:
> >
> > Binding {
> > target: ApplicationManager
> > property: "surfaceAboutToBeCreatedCallback"
> > value: function surfaceSizer(surface) { print("Hihi")
> > surface.width = 400;
> > if (surface.appId && surface.appId == "dialer-app") {
> > surface.height = 300;
> > }
> > return surface;
> > }
> > }
> >
> > and got this error:
> > file:///usr/share/unity8/Stages/PhoneStage.qml:125:12: Unable to assign a
> function to a property of any type other than var.
>
> Hah! Interesting. Can't say I understand. If Binding.value is of type
> other than var, how can it be flexible enough? Otherwise if
> ApplicationManager.surfaceAboutToBeCreatedCallback is not var, how would
> your original approach to assign instead of bind work in any case?
>
> I'd say that's worth a QTBUG.

My guess is that Binding does some naive type checking, and QJSValue is indeed not a QVariant. qtdeclarative5:/src/qml/qml/qmlproperty.cpp does confirm that idea: http://pastebin.ubuntu.com/8099923/ - I don't understand why exactly..

I don't create a binding with my original approach, it's a simple assignment. I would guess the only way around this error is to replace QJSValue with a QVariant. What say you?

Revision history for this message
Michał Sawicz (saviq) wrote :

> My guess is that Binding does some naive type checking, and QJSValue is indeed not a QVariant. qtdeclarative5:/src/qml/qml/qmlproperty.cpp does confirm that idea:http://pastebin.ubuntu.com/8099923/ - I don't understand why exactly..

Yeah.

> I don't create a binding with my original approach, it's a simple assignment. I would guess the only way around this error is to replace QJSValue with a QVariant. What say you?

Doesn't sound like that would help, since you'd still need to go through
a Binding and that would complain that function is not a var.

So it looks like assignment is the only way indeed. Worth a QTBUG IMO.
If you can assign something to a property, you should be able to bind to.

Revision history for this message
Michał Sawicz (saviq) wrote :

Please rebase on lp:~dandrader/unity-api/lifecycle, no need to bump versions over that one then.

review: Needs Fixing
164. By Gerry Boland

Undo application API version bump

165. By Gerry Boland

Merge lp:dandrader/unity-api/lifecycle and combine changelog entries to one

166. By Gerry Boland

Remove my changelog tweaks, train will do them

167. By Gerry Boland

Merge trunk

168. By Gerry Boland

Merge trunk

169. By Gerry Boland

Merge trunk

170. By Gerry Boland

Merge trunk & update changelog

171. By Gerry Boland

Merge trunk

172. By Gerry Boland

Add unity::shell::application::Globals

173. By Gerry Boland

Merge trunk

174. By Gerry Boland

Merge app-focus-state branch as prereq

175. By Gerry Boland

Document the Global class

176. By Gerry Boland

Revert 175

177. By Gerry Boland

Remove old Globals idea

178. By Gerry Boland

Merge trunk

179. By Gerry Boland

Merge trunk

180. By Gerry Boland

Remove bad merge atrifacts

Unmerged revisions

180. By Gerry Boland

Remove bad merge atrifacts

179. By Gerry Boland

Merge trunk

178. By Gerry Boland

Merge trunk

177. By Gerry Boland

Remove old Globals idea

176. By Gerry Boland

Revert 175

175. By Gerry Boland

Document the Global class

174. By Gerry Boland

Merge app-focus-state branch as prereq

173. By Gerry Boland

Merge trunk

172. By Gerry Boland

Add unity::shell::application::Globals

171. By Gerry Boland

Merge trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt 2014-07-18 15:46:22 +0000
+++ CMakeLists.txt 2014-08-21 10:07:55 +0000
@@ -133,7 +133,7 @@
133# API version133# API version
134set(UNITY_API_MAJOR 0)134set(UNITY_API_MAJOR 0)
135set(UNITY_API_MINOR 1)135set(UNITY_API_MINOR 1)
136set(UNITY_API_MICRO 4)136set(UNITY_API_MICRO 5)
137set(UNITY_API_VERSION "${UNITY_API_MAJOR}.${UNITY_API_MINOR}.${UNITY_API_MICRO}")137set(UNITY_API_VERSION "${UNITY_API_MAJOR}.${UNITY_API_MINOR}.${UNITY_API_MICRO}")
138138
139# API library139# API library
140140
=== modified file 'debian/changelog'
--- debian/changelog 2014-08-06 19:32:56 +0000
+++ debian/changelog 2014-08-21 10:07:55 +0000
@@ -1,3 +1,10 @@
1unity-api (7.89-0ubuntu1) UNRELEASED; urgency=medium
2
3 * AppMan: add surfaceAboutToBeCreatedCallback property to AppMan - allows QML shell override surface creation geometry
4 * ApplicationInfo - add updateScreenshot() and discardScreenshot()
5
6 -- Daniel d'Andrada <daniel.dandrada@canonical.com> Fri, 08 Aug 2014 06:05:53 -0300
7
1unity-api (7.88+14.10.20140806-0ubuntu1) utopic; urgency=medium8unity-api (7.88+14.10.20140806-0ubuntu1) utopic; urgency=medium
29
3 [ Michal Hruby ]10 [ Michal Hruby ]
411
=== modified file 'include/unity/shell/application/ApplicationInfoInterface.h'
--- include/unity/shell/application/ApplicationInfoInterface.h 2013-12-11 11:04:11 +0000
+++ include/unity/shell/application/ApplicationInfoInterface.h 2014-08-21 10:07:55 +0000
@@ -97,13 +97,6 @@
97 */97 */
98 Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)98 Q_PROPERTY(bool focused READ focused NOTIFY focusedChanged)
9999
100 /**
101 * @brief The URL of the app's screenshot to be used with the image provider.
102 *
103 * Holds the URL for the app's screenshot. This URL will change whenever the screenshot updates.
104 */
105 Q_PROPERTY(QUrl screenshot READ screenshot NOTIFY screenshotChanged)
106
107protected:100protected:
108 /// @cond101 /// @cond
109 ApplicationInfoInterface(const QString &appId, QObject* parent = 0): QObject(parent) { Q_UNUSED(appId) }102 ApplicationInfoInterface(const QString &appId, QObject* parent = 0): QObject(parent) { Q_UNUSED(appId) }
@@ -152,7 +145,6 @@
152 virtual Stage stage() const = 0;145 virtual Stage stage() const = 0;
153 virtual State state() const = 0;146 virtual State state() const = 0;
154 virtual bool focused() const = 0;147 virtual bool focused() const = 0;
155 virtual QUrl screenshot() const = 0;
156 /// @endcond148 /// @endcond
157149
158Q_SIGNALS:150Q_SIGNALS:
@@ -163,7 +155,6 @@
163 void stageChanged(Stage stage);155 void stageChanged(Stage stage);
164 void stateChanged(State state);156 void stateChanged(State state);
165 void focusedChanged(bool focused);157 void focusedChanged(bool focused);
166 void screenshotChanged(const QUrl &screenshot);
167 /// @endcond158 /// @endcond
168};159};
169160
170161
=== modified file 'include/unity/shell/application/ApplicationManagerInterface.h'
--- include/unity/shell/application/ApplicationManagerInterface.h 2014-03-10 12:40:25 +0000
+++ include/unity/shell/application/ApplicationManagerInterface.h 2014-08-21 10:07:55 +0000
@@ -24,6 +24,7 @@
2424
25#include <QtCore/QObject>25#include <QtCore/QObject>
26#include <QtCore/QAbstractListModel>26#include <QtCore/QAbstractListModel>
27#include <QtQml/QJSValue>
2728
28namespace unity29namespace unity
29{30{
@@ -66,6 +67,36 @@
66 */67 */
67 Q_PROPERTY(bool suspended READ suspended WRITE setSuspended NOTIFY suspendedChanged)68 Q_PROPERTY(bool suspended READ suspended WRITE setSuspended NOTIFY suspendedChanged)
6869
70 /**
71 * @brief Register a Javascript function as a callback for when an application is asking to create a new surface
72 *
73 * Registers a Javascript callback function which ApplicationManager will call when an application is asking
74 * Mir to create a new surface. The function is passed a 'surface' object with properties width, height and
75 * appId. The shell can implement this function to return different width & height to override the geometry
76 * requested by the client.
77 *
78 * Example QML:
79 *
80 * function surfaceSizer(surface) {
81 * surface.width = 400;
82 * if (surface.appId && surface.appId == "dialer-app") {
83 * surface.height = 300;
84 * }
85 * return surface;
86 * }
87 *
88 * Component.onCompleted {
89 * ApplicationManager.surfaceAboutToBeCreatedCallback = surfaceSizer;
90 * }
91 * Component.onDestruction {
92 * ApplicationManager.surfaceAboutToBeCreatedCallback = null;
93 * }
94 *
95 * Warning: the function must live in the QML context thread!
96 */
97 Q_PROPERTY(QJSValue surfaceAboutToBeCreatedCallback READ surfaceAboutToBeCreatedCallback
98 WRITE setSurfaceAboutToBeCreatedCallback NOTIFY surfaceAboutToBeCreatedCallbackChanged)
99
69protected:100protected:
70 /// @cond101 /// @cond
71 ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)102 ApplicationManagerInterface(QObject* parent = 0): QAbstractListModel(parent)
@@ -77,7 +108,6 @@
77 m_roleNames.insert(RoleStage, "stage");108 m_roleNames.insert(RoleStage, "stage");
78 m_roleNames.insert(RoleState, "state");109 m_roleNames.insert(RoleState, "state");
79 m_roleNames.insert(RoleFocused, "focused");110 m_roleNames.insert(RoleFocused, "focused");
80 m_roleNames.insert(RoleScreenshot, "screenshot");
81111
82 connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(countChanged()));112 connect(this, SIGNAL(rowsInserted(QModelIndex, int, int)), SIGNAL(countChanged()));
83 connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(countChanged()));113 connect(this, SIGNAL(rowsRemoved(QModelIndex, int, int)), SIGNAL(countChanged()));
@@ -100,7 +130,6 @@
100 RoleStage,130 RoleStage,
101 RoleState,131 RoleState,
102 RoleFocused,132 RoleFocused,
103 RoleScreenshot,
104 };133 };
105134
106 /// @cond135 /// @cond
@@ -119,6 +148,9 @@
119148
120 virtual bool suspended() const = 0;149 virtual bool suspended() const = 0;
121 virtual void setSuspended(bool suspended) = 0;150 virtual void setSuspended(bool suspended) = 0;
151
152 virtual QJSValue surfaceAboutToBeCreatedCallback() const = 0;
153 virtual void setSurfaceAboutToBeCreatedCallback(const QJSValue &callback) = 0;
122 /// @endcond154 /// @endcond
123155
124 /**156 /**
@@ -185,21 +217,10 @@
185 */217 */
186 Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;218 Q_INVOKABLE virtual bool stopApplication(const QString &appId) = 0;
187219
188 /**
189 * @brief Update the screenshot for an application.
190 *
191 * NOTE: Normally the ApplicationManager will update screenshots unfocusing or focusing apps,
192 * However, in cases where you need to show the screenshot while the application is still focused,
193 * you can request the ApplicationManager to update it now.
194 *
195 * @param appId The application for which the screenshot should be updated.
196 * @returns True if the screenshot update operation was scheduled successfully, false otherwise (i.e. the given appId could not be found)
197 */
198 Q_INVOKABLE virtual bool updateScreenshot(const QString &appId) = 0;
199
200Q_SIGNALS:220Q_SIGNALS:
201 /// @cond221 /// @cond
202 void countChanged();222 void countChanged();
223 void surfaceAboutToBeCreatedCallbackChanged();
203 /// @endcond224 /// @endcond
204225
205 /**226 /**
206227
=== modified file 'include/unity/shell/application/CMakeLists.txt'
--- include/unity/shell/application/CMakeLists.txt 2014-03-04 10:50:44 +0000
+++ include/unity/shell/application/CMakeLists.txt 2014-08-21 10:07:55 +0000
@@ -7,10 +7,10 @@
77
8set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)8set(UNITY_API_LIB_HDRS ${UNITY_API_LIB_HDRS} ${headers} ${internal_headers} PARENT_SCOPE)
99
10set(VERSION 2)10set(VERSION 3)
11set(PKGCONFIG_NAME "unity-shell-appliction")11set(PKGCONFIG_NAME "unity-shell-application")
12set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")12set(PKGCONFIG_DESCRIPTION "Unity shell Application APIs")
13set(PKGCONFIG_REQUIRES "Qt5Core")13set(PKGCONFIG_REQUIRES "Qt5Core Qt5Qml")
14set(PKGCONFIG_FILE unity-shell-application.pc)14set(PKGCONFIG_FILE unity-shell-application.pc)
1515
16configure_file(${CMAKE_SOURCE_DIR}/data/unity-shell-api.pc.in16configure_file(${CMAKE_SOURCE_DIR}/data/unity-shell-api.pc.in
1717
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt'
--- test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt 2013-08-29 12:54:56 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/CMakeLists.txt 2014-08-21 10:07:55 +0000
@@ -19,7 +19,7 @@
1919
20add_library(ApplicationMocks SHARED ${ApplicationMocks_SOURCES})20add_library(ApplicationMocks SHARED ${ApplicationMocks_SOURCES})
2121
22qt5_use_modules(ApplicationMocks Core)22qt5_use_modules(ApplicationMocks Core Qml)
2323
24set(TestApplicationPlugin_SOURCES24set(TestApplicationPlugin_SOURCES
25 TestApplicationPlugin.cpp25 TestApplicationPlugin.cpp
2626
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2013-12-11 11:28:22 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.cpp 2014-08-21 10:07:55 +0000
@@ -54,11 +54,6 @@
54 return m_icon;54 return m_icon;
55}55}
5656
57QUrl MockApplicationInfo::screenshot() const
58{
59 return m_screenshot;
60}
61
62ApplicationInfoInterface::Stage MockApplicationInfo::stage() const57ApplicationInfoInterface::Stage MockApplicationInfo::stage() const
63{58{
64 return m_stage;59 return m_stage;
6560
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2013-12-11 11:28:22 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationInfo.h 2014-08-21 10:07:55 +0000
@@ -36,7 +36,6 @@
36 QString name() const;36 QString name() const;
37 QString comment() const;37 QString comment() const;
38 QUrl icon() const;38 QUrl icon() const;
39 QUrl screenshot() const;
4039
41 ApplicationInfoInterface::Stage stage() const;40 ApplicationInfoInterface::Stage stage() const;
42 void setStage(ApplicationInfoInterface::Stage stage);41 void setStage(ApplicationInfoInterface::Stage stage);
@@ -52,7 +51,6 @@
52 QString m_name;51 QString m_name;
53 QString m_comment;52 QString m_comment;
54 QUrl m_icon;53 QUrl m_icon;
55 QUrl m_screenshot;
56 ApplicationInfoInterface::Stage m_stage;54 ApplicationInfoInterface::Stage m_stage;
57 ApplicationInfoInterface::State m_state;55 ApplicationInfoInterface::State m_state;
58 bool m_focused;56 bool m_focused;
5957
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2014-05-23 08:35:43 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.cpp 2014-08-21 10:07:55 +0000
@@ -22,7 +22,9 @@
2222
23using namespace unity::shell::application;23using namespace unity::shell::application;
2424
25MockApplicationManager::MockApplicationManager(QObject* parent): ApplicationManagerInterface(parent)25MockApplicationManager::MockApplicationManager(QObject* parent)
26 : ApplicationManagerInterface(parent)
27 , m_surfaceAboutToBeCreatedCallback(QJSValue::UndefinedValue)
26{28{
27 MockApplicationInfo *item = new MockApplicationInfo("phone-app", "Phone App", "Telephony application", QUrl("/usr/share/pixmaps/some/icon.png"), this);29 MockApplicationInfo *item = new MockApplicationInfo("phone-app", "Phone App", "Telephony application", QUrl("/usr/share/pixmaps/some/icon.png"), this);
28 m_list.append(item);30 m_list.append(item);
@@ -66,8 +68,6 @@
66 return item->state();68 return item->state();
67 case RoleFocused:69 case RoleFocused:
68 return item->focused();70 return item->focused();
69 case RoleScreenshot:
70 return item->screenshot();
71 }71 }
7272
73 return QVariant();73 return QVariant();
@@ -139,8 +139,16 @@
139 return true;139 return true;
140}140}
141141
142bool MockApplicationManager::updateScreenshot(const QString &appId)142QJSValue MockApplicationManager::surfaceAboutToBeCreatedCallback() const
143{143{
144 Q_UNUSED(appId)144 return m_surfaceAboutToBeCreatedCallback;
145 return true;145}
146
147void MockApplicationManager::setSurfaceAboutToBeCreatedCallback(const QJSValue &callback)
148{
149 if (m_surfaceAboutToBeCreatedCallback.equals(callback))
150 return;
151
152 m_surfaceAboutToBeCreatedCallback = callback;
153 Q_EMIT surfaceAboutToBeCreatedCallbackChanged();
146}154}
147155
=== modified file 'test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h'
--- test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2014-03-10 12:34:16 +0000
+++ test/qmltest/mocks/plugins/Unity/Application/Mocks/MockApplicationManager.h 2014-08-21 10:07:55 +0000
@@ -43,6 +43,9 @@
43 bool suspended() const;43 bool suspended() const;
44 void setSuspended(bool suspended);44 void setSuspended(bool suspended);
4545
46 QJSValue surfaceAboutToBeCreatedCallback() const;
47 void setSurfaceAboutToBeCreatedCallback(const QJSValue &callback);
48
46 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;49 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *get(const int index) const;
4750
48 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;51 Q_INVOKABLE unity::shell::application::ApplicationInfoInterface *findApplication(const QString &appId) const;
@@ -57,10 +60,9 @@
5760
58 Q_INVOKABLE bool stopApplication(const QString &appId);61 Q_INVOKABLE bool stopApplication(const QString &appId);
5962
60 Q_INVOKABLE bool updateScreenshot(const QString &appId);
61
62private:63private:
63 QList<MockApplicationInfo*> m_list;64 QList<MockApplicationInfo*> m_list;
65 QJSValue m_surfaceAboutToBeCreatedCallback;
64};66};
6567
66#endif // MOCKAPPLICATIONMANAGER_H68#endif // MOCKAPPLICATIONMANAGER_H
6769
=== modified file 'test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt'
--- test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2013-09-11 15:28:22 +0000
+++ test/qmltest/mocks/plugins/Unity/Launcher/CMakeLists.txt 2014-08-21 10:07:55 +0000
@@ -27,7 +27,7 @@
2727
28add_library(LauncherMocks SHARED ${LauncherMocks_SOURCES})28add_library(LauncherMocks SHARED ${LauncherMocks_SOURCES})
2929
30qt5_use_modules(LauncherMocks Core)30qt5_use_modules(LauncherMocks Core Qml)
3131
32set(TestLauncherPlugin_SOURCES32set(TestLauncherPlugin_SOURCES
33 TestLauncherPlugin.cpp33 TestLauncherPlugin.cpp
3434
=== modified file 'test/qmltest/unity/shell/application/tst_Application.qml'
--- test/qmltest/unity/shell/application/tst_Application.qml 2014-03-10 12:34:16 +0000
+++ test/qmltest/unity/shell/application/tst_Application.qml 2014-08-21 10:07:55 +0000
@@ -59,6 +59,11 @@
59 }59 }
60 }60 }
6161
62 function initTestCase() {
63 function surfaceSizer(surface) { return surface; }
64 ApplicationManager.surfaceAboutToBeCreatedCallback = surfaceSizer;
65 }
66
62 /* make sure all the required roles are exposed on ApplicationManager */67 /* make sure all the required roles are exposed on ApplicationManager */
63 function test_model_roles_enum_data() {68 function test_model_roles_enum_data() {
64 return [69 return [
@@ -69,7 +74,6 @@
69 { enum: "RoleStage" },74 { enum: "RoleStage" },
70 { enum: "RoleState" },75 { enum: "RoleState" },
71 { enum: "RoleFocused" },76 { enum: "RoleFocused" },
72 { enum: "RoleScreenshot" },
73 ];77 ];
74 }78 }
7579
@@ -89,7 +93,6 @@
89 { tag: "ApplicationManager.roles[stage]", role: "stage", type: "number" },93 { tag: "ApplicationManager.roles[stage]", role: "stage", type: "number" },
90 { tag: "ApplicationManager.roles[state]", role: "state", type: "number" },94 { tag: "ApplicationManager.roles[state]", role: "state", type: "number" },
91 { tag: "ApplicationManager.roles[focused]", role: "focused", type: "boolean" },95 { tag: "ApplicationManager.roles[focused]", role: "focused", type: "boolean" },
92 { tag: "ApplicationManager.roles[screenshot]", role: "screenshot", type: "object" },
93 ];96 ];
94 }97 }
9598
@@ -113,7 +116,6 @@
113 { tag: "ApplicationManager.methods[unfocusCurrentApplication]", method: "unfocusCurrentApplication" },116 { tag: "ApplicationManager.methods[unfocusCurrentApplication]", method: "unfocusCurrentApplication" },
114 { tag: "ApplicationManager.methods[startApplication]", method: "startApplication" },117 { tag: "ApplicationManager.methods[startApplication]", method: "startApplication" },
115 { tag: "ApplicationManager.methods[stopApplication]", method: "stopApplication" },118 { tag: "ApplicationManager.methods[stopApplication]", method: "stopApplication" },
116 { tag: "ApplicationManager.methods[updateScreenshot]", method: "updateScreenshot" },
117 ];119 ];
118 }120 }
119121
@@ -128,6 +130,7 @@
128 { tag: "ApplicationManager.count", property: "count", type: "number" },130 { tag: "ApplicationManager.count", property: "count", type: "number" },
129 { tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" },131 { tag: "ApplicationManager.focusedApplicationId", property: "focusedApplicationId", type: "string" },
130 { tag: "ApplicationManager.suspended", property: "suspended", type: "boolean" },132 { tag: "ApplicationManager.suspended", property: "suspended", type: "boolean" },
133 { tag: "ApplicationManager.surfaceAboutToBeCreatedCallback", property: "surfaceAboutToBeCreatedCallback", type: "function" },
131 ];134 ];
132 }135 }
133136
@@ -146,7 +149,6 @@
146 { tag: "ApplicationInfo.properties[stage]", property: "stage", type: "number" },149 { tag: "ApplicationInfo.properties[stage]", property: "stage", type: "number" },
147 { tag: "ApplicationInfo.properties[state]", property: "state", type: "number" },150 { tag: "ApplicationInfo.properties[state]", property: "state", type: "number" },
148 { tag: "ApplicationInfo.properties[focused]", property: "focused", type: "boolean" },151 { tag: "ApplicationInfo.properties[focused]", property: "focused", type: "boolean" },
149 { tag: "ApplicationInfo.properties[screenshot]", property: "screenshot", type: "object" },
150 ];152 ];
151 }153 }
152154

Subscribers

People subscribed via source and target branches

to all changes: