Merge lp:~mzanetti/unity8/fix_snap_decision_test into lp:unity8

Proposed by Michał Sawicz
Status: Superseded
Proposed branch: lp:~mzanetti/unity8/fix_snap_decision_test
Merge into: lp:unity8
Diff against target: 2962 lines (+1086/-824)
68 files modified
plugins/AccountsService/AccountsService.qmltypes (+2/-0)
plugins/Dash/Dash.qmltypes (+3/-0)
plugins/LightDM/LightDM.qmltypes (+1/-0)
plugins/Ubuntu/Payments/Payments.qmltypes (+1/-0)
plugins/Unity/DashCommunicator/DashCommunicator.qmltypes (+17/-4)
plugins/Unity/Indicators/CMakeLists.txt (+1/-0)
plugins/Unity/Indicators/Indicators.qmltypes (+10/-7)
plugins/Unity/Indicators/plugin.cpp (+8/-2)
plugins/Unity/Indicators/plugin.h (+1/-1)
plugins/Unity/Indicators/sharedunitymenumodel.cpp (+87/-0)
plugins/Unity/Indicators/sharedunitymenumodel.h (+66/-0)
plugins/Unity/Indicators/unitymenumodelcache.cpp (+28/-13)
plugins/Unity/Indicators/unitymenumodelcache.h (+15/-9)
plugins/Unity/Launcher/Launcher.qmltypes (+17/-12)
plugins/Unity/Session/Session.qmltypes (+10/-0)
plugins/Utils/Utils.qmltypes (+6/-0)
qml/Greeter/Clock.qml (+9/-9)
qml/Notifications/Notifications.qml (+1/-0)
qml/Panel/Indicators/CachedUnityMenuModel.qml (+0/-39)
qml/Panel/Indicators/IndicatorBase.qml (+2/-2)
qml/Shell.qml (+1/-1)
tests/mocks/AccountsService/AccountsService.qmltypes (+2/-0)
tests/mocks/LightDM/LightDM.qmltypes (+1/-0)
tests/mocks/QMenuModel/QMenuModel.qmltypes (+1/-1)
tests/mocks/QMenuModel/unitymenumodel.cpp (+1/-2)
tests/mocks/QMenuModel/unitymenumodel.h (+6/-2)
tests/mocks/Ubuntu/Payments/Payments.qmltypes (+2/-0)
tests/mocks/Ubuntu/Telephony/Telephony.qmltypes (+2/-1)
tests/mocks/Unity/Application/Application.qmltypes (+13/-0)
tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes (+2/-2)
tests/mocks/Unity/Indicators/CMakeLists.txt (+3/-10)
tests/mocks/Unity/Indicators/FakeMenuPage.qml (+0/-27)
tests/mocks/Unity/Indicators/Indicators.qmltypes (+41/-11)
tests/mocks/Unity/Indicators/IndicatorsModel.qml (+143/-35)
tests/mocks/Unity/Indicators/RootActionState.qml (+17/-9)
tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp (+60/-29)
tests/mocks/Unity/Indicators/fakeindicatorsmodel.h (+8/-2)
tests/mocks/Unity/Indicators/fakeplugin.cpp (+8/-4)
tests/mocks/Unity/Indicators/fakeunitymenumodelcache.cpp (+57/-0)
tests/mocks/Unity/Indicators/fakeunitymenumodelcache.h (+49/-0)
tests/mocks/Unity/Indicators/indicators_fake.qrc (+0/-14)
tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml (+0/-35)
tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml (+0/-35)
tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml (+0/-35)
tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml (+0/-35)
tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml (+0/-35)
tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml (+0/-23)
tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml (+0/-23)
tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml (+0/-23)
tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml (+0/-23)
tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml (+0/-23)
tests/mocks/Unity/Indicators/qmldir (+0/-1)
tests/mocks/Unity/Launcher/Launcher.qmltypes (+13/-0)
tests/mocks/Unity/Unity.qmltypes (+32/-0)
tests/plugins/Unity/Indicators/CMakeLists.txt (+1/-0)
tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp (+102/-0)
tests/qmltests/CMakeLists.txt (+7/-8)
tests/qmltests/Greeter/tst_Clock.qml (+57/-40)
tests/qmltests/Panel/Indicators/tst_CachedUnityMenuModel.qml (+0/-137)
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml (+21/-24)
tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml (+0/-8)
tests/qmltests/Panel/tst_IndicatorItem.qml (+1/-1)
tests/qmltests/Panel/tst_IndicatorRow.qml (+17/-19)
tests/qmltests/Panel/tst_Indicators.qml (+1/-0)
tests/qmltests/Panel/tst_MenuContent.qml (+0/-8)
tests/qmltests/tst_Shell.qml (+128/-40)
tests/qmltests/tst_ShellWithPin.qml (+2/-0)
tests/qmltests/tst_TabletShell.qml (+2/-0)
To merge this branch: bzr merge lp:~mzanetti/unity8/fix_snap_decision_test
Reviewer Review Type Date Requested Status
PS Jenkins bot (community) continuous-integration Needs Fixing
Michał Sawicz Approve
Josh Arenson Approve
Gerry Boland Pending
Michael Zanetti Pending
Review via email: mp+238238@code.launchpad.net

This proposal supersedes a proposal from 2014-10-07.

This proposal has been superseded by a proposal from 2014-10-15.

Commit message

Fix lp:1370240 by making stages interactive when a snap decision is dismissed.

Description of the change

 * Are there any related MPs required for this MP to build/function as expected? Please list.

no

 * Did you perform an exploratory manual test run of your code change and any related functionality?

yes

 * Did you make sure that your branch does not contain spurious tags?

yes

 * If you changed the packaging (debian), did you subscribe the ubuntu-unity team to this MP?

no

 * If you changed the UI, has there been a design review?

no

To post a comment you must log in.
Revision history for this message
Josh Arenson (josharenson) wrote : Posted in a previous version of this proposal

This should be covered by ApplicationWindow/test_forceActiveFocusFollowsInteractive

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Gerry Boland (gerboland) wrote : Posted in a previous version of this proposal

Testing this, it works fine!

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

fix looks great now. much better then the previous edition.

If possible, I think it would be worth adding a regression test for it still.

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote : Posted in a previous version of this proposal
review: Needs Fixing (continuous-integration)
Revision history for this message
Michael Zanetti (mzanetti) wrote : Posted in a previous version of this proposal

 6/17 Test #3: whitespace .......................***Failed 0.43 sec
/tmp/buildd/unity8-8.00+14.10.20141009.4bzr1322pkg0utopic1694/tests/qmltests/tst_Shell.qml: bad whitespace in multiple lines

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

I have reverted the actual fix and ran the test, it's still passing, so it doesn't really catch the bug.

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

I constantly get:

FAIL! : qmltestrunner::Shell::test_snapDecisionDismissalReturnsFocus() App didn't take active focus after snap notification was dismissed
   Actual (): false
   Expected (): true
   Loc: [/home/michal/dev/canonical/unity8/repo/tests/qmltests/tst_Shell.qml(249)]

review: Needs Fixing
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1324. By Michael Zanetti

merge trunk, update test to work with trunk

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Daniel d'Andrada (dandrader) wrote :

"""
+ mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
"""

Please do "tap(buttonAccept)" instead to better emulate what happens on the device.

Revision history for this message
Daniel d'Andrada (dandrader) wrote :

> """
> + mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
> """
>
> Please do "tap(buttonAccept)" instead to better emulate what happens on the
> device.

And no need to pass the position to tap() as it defaults to the center of the tapped item.

1325. By Michael Zanetti

revert back to activeFocus, make it a bit more robust

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

This still failed to me. It seems to click the accept button too early and the notification doesn't close.

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

and all the compare()s without tries feel a bit racy, too.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1326. By Michael Zanetti

cerry-pick fix over

1327. By Michael Zanetti

add more waitForRendering

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Josh Arenson (josharenson) wrote :

Verified the fix works, tests pass, and couldn't reproduce what @saviq saw in #584819
However, I feel https://bugs.launchpad.net/ubuntu/+source/unity8/+bug/1381292 might be related.

review: Approve
1328. By Michael Zanetti

wait for the notification to be expanded

1329. By Michael Zanetti

drop unneeded findChild

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

 * Did you perform an exploratory manual test run of the code change and any related functionality?
Y
 * Did CI run pass? If not, please explain why.
Other than ap, which is in bad condition...
 * Did you make sure that the branch does not contain spurious tags?
Y

review: Approve
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
1330. By Michael Zanetti

merge lp:~nick-dedekind/unity8/sharedunitymenumodel

1331. By Michael Zanetti

fix bad merge

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'plugins/AccountsService/AccountsService.qmltypes'
2--- plugins/AccountsService/AccountsService.qmltypes 2014-09-01 12:18:53 +0000
3+++ plugins/AccountsService/AccountsService.qmltypes 2014-10-15 19:48:28 +0000
4@@ -23,6 +23,8 @@
5 }
6 Property { name: "user"; type: "string" }
7 Property { name: "demoEdges"; type: "bool" }
8+ Property { name: "enableLauncherWhileLocked"; type: "bool"; isReadonly: true }
9+ Property { name: "enableIndicatorsWhileLocked"; type: "bool"; isReadonly: true }
10 Property { name: "backgroundFile"; type: "string"; isReadonly: true }
11 Property { name: "statsWelcomeScreen"; type: "bool"; isReadonly: true }
12 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
13
14=== modified file 'plugins/Dash/Dash.qmltypes'
15--- plugins/Dash/Dash.qmltypes 2014-08-14 01:28:06 +0000
16+++ plugins/Dash/Dash.qmltypes 2014-10-15 19:48:28 +0000
17@@ -40,9 +40,12 @@
18 Property { name: "forceNoClip"; type: "bool" }
19 Property { name: "stickyHeaderHeight"; type: "int"; isReadonly: true }
20 Property { name: "headerItemShownHeight"; type: "double"; isReadonly: true }
21+ Property { name: "cacheBuffer"; type: "double" }
22 Signal { name: "headerChanged" }
23 Method { name: "positionAtBeginning" }
24 Method { name: "showHeader" }
25+ Method { name: "firstCreatedIndex"; type: "int" }
26+ Method { name: "createdItemCount"; type: "int" }
27 Method {
28 name: "item"
29 type: "QQuickItem*"
30
31=== modified file 'plugins/LightDM/LightDM.qmltypes'
32--- plugins/LightDM/LightDM.qmltypes 2014-09-01 12:18:53 +0000
33+++ plugins/LightDM/LightDM.qmltypes 2014-10-15 19:48:28 +0000
34@@ -37,6 +37,7 @@
35 Signal { name: "isActiveChanged" }
36 Signal { name: "isAuthenticatedChanged" }
37 Signal { name: "showGreeter" }
38+ Signal { name: "hideGreeter" }
39 Signal {
40 name: "requestAuthenticationUser"
41 Parameter { name: "user"; type: "string" }
42
43=== modified file 'plugins/Ubuntu/Payments/Payments.qmltypes'
44--- plugins/Ubuntu/Payments/Payments.qmltypes 2014-06-27 20:53:24 +0000
45+++ plugins/Ubuntu/Payments/Payments.qmltypes 2014-10-15 19:48:28 +0000
46@@ -37,6 +37,7 @@
47 Parameter { name: "error"; type: "string" }
48 }
49 Signal { name: "purchaseCompleted" }
50+ Signal { name: "purchaseCancelled" }
51 Method { name: "start" }
52 }
53 }
54
55=== modified file 'plugins/Unity/DashCommunicator/DashCommunicator.qmltypes'
56--- plugins/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-08-14 13:33:28 +0000
57+++ plugins/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-10-15 19:48:28 +0000
58@@ -9,14 +9,14 @@
59 Module {
60 Component {
61 name: "DashCommunicator"
62- prototype: "QObject"
63+ prototype: "QThread"
64 exports: ["Unity.DashCommunicator/DashCommunicator 0.1"]
65 exportMetaObjectRevisions: [0]
66 Method {
67 name: "setCurrentScope"
68 Parameter { name: "scopeId"; type: "string" }
69 Parameter { name: "animate"; type: "bool" }
70- Parameter { name: "reset"; type: "bool" }
71+ Parameter { name: "isSwipe"; type: "bool" }
72 }
73 }
74 Component {
75@@ -28,7 +28,20 @@
76 name: "setCurrentScopeRequested"
77 Parameter { name: "scopeId"; type: "string" }
78 Parameter { name: "animate"; type: "bool" }
79- Parameter { name: "reset"; type: "bool" }
80- }
81+ Parameter { name: "isSwipe"; type: "bool" }
82+ }
83+ }
84+ Component {
85+ name: "QThread"
86+ prototype: "QObject"
87+ Signal { name: "started" }
88+ Signal { name: "finished" }
89+ Method {
90+ name: "start"
91+ Parameter { type: "Priority" }
92+ }
93+ Method { name: "start" }
94+ Method { name: "terminate" }
95+ Method { name: "quit" }
96 }
97 }
98
99=== modified file 'plugins/Unity/Indicators/CMakeLists.txt'
100--- plugins/Unity/Indicators/CMakeLists.txt 2014-07-30 16:00:55 +0000
101+++ plugins/Unity/Indicators/CMakeLists.txt 2014-10-15 19:48:28 +0000
102@@ -24,6 +24,7 @@
103 modelprinter.cpp
104 plugin.cpp
105 rootactionstate.cpp
106+ sharedunitymenumodel.cpp
107 unitymenumodelcache.cpp
108 unitymenumodelstack.cpp
109 visibleindicatorsmodel.cpp
110
111=== modified file 'plugins/Unity/Indicators/Indicators.qmltypes'
112--- plugins/Unity/Indicators/Indicators.qmltypes 2014-09-01 12:18:53 +0000
113+++ plugins/Unity/Indicators/Indicators.qmltypes 2014-10-15 19:48:28 +0000
114@@ -210,6 +210,16 @@
115 Signal { name: "indexChanged" }
116 }
117 Component {
118+ name: "SharedUnityMenuModel"
119+ prototype: "QObject"
120+ exports: ["Unity.Indicators/SharedUnityMenuModel 0.1"]
121+ exportMetaObjectRevisions: [0]
122+ Property { name: "busName"; type: "QByteArray" }
123+ Property { name: "menuObjectPath"; type: "QByteArray" }
124+ Property { name: "actions"; type: "QVariantMap" }
125+ Property { name: "model"; type: "UnityMenuModel"; isReadonly: true; isPointer: true }
126+ }
127+ Component {
128 name: "UnityMenuModelCache"
129 prototype: "QObject"
130 exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]
131@@ -217,13 +227,6 @@
132 isSingleton: true
133 exportMetaObjectRevisions: [0]
134 Method {
135- name: "model"
136- type: "UnityMenuModel*"
137- Parameter { name: "bus"; type: "QByteArray" }
138- Parameter { name: "path"; type: "QByteArray" }
139- Parameter { name: "actions"; type: "QVariantMap" }
140- }
141- Method {
142 name: "contains"
143 type: "bool"
144 Parameter { name: "path"; type: "QByteArray" }
145
146=== modified file 'plugins/Unity/Indicators/plugin.cpp'
147--- plugins/Unity/Indicators/plugin.cpp 2014-07-30 16:00:55 +0000
148+++ plugins/Unity/Indicators/plugin.cpp 2014-10-15 19:48:28 +0000
149@@ -30,18 +30,23 @@
150 #include "menucontentactivator.h"
151 #include "modelprinter.h"
152 #include "rootactionstate.h"
153+#include "sharedunitymenumodel.h"
154 #include "unitymenumodelcache.h"
155 #include "unitymenumodelstack.h"
156 #include "visibleindicatorsmodel.h"
157
158+#include <unitymenumodel.h>
159+
160 static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
161 Q_UNUSED(engine);
162 Q_UNUSED(scriptEngine);
163- return new UnityMenuModelCache;
164+ return UnityMenuModelCache::singleton();
165 }
166
167-void Indicators2Plugin::registerTypes(const char *uri)
168+void IndicatorsPlugin::registerTypes(const char *uri)
169 {
170+ qRegisterMetaType<UnityMenuModel*>("UnityMenuModel*");
171+
172 qmlRegisterType<IndicatorsManager>(uri, 0, 1, "IndicatorsManager");
173 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");
174 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
175@@ -49,6 +54,7 @@
176 qmlRegisterType<RootActionState>(uri, 0, 1, "RootActionState");
177 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
178 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
179+ qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
180
181 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
182
183
184=== modified file 'plugins/Unity/Indicators/plugin.h'
185--- plugins/Unity/Indicators/plugin.h 2013-08-14 09:07:45 +0000
186+++ plugins/Unity/Indicators/plugin.h 2014-10-15 19:48:28 +0000
187@@ -22,7 +22,7 @@
188
189 #include <QtQml/QQmlExtensionPlugin>
190
191-class Indicators2Plugin : public QQmlExtensionPlugin
192+class IndicatorsPlugin : public QQmlExtensionPlugin
193 {
194 Q_OBJECT
195 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
196
197=== added file 'plugins/Unity/Indicators/sharedunitymenumodel.cpp'
198--- plugins/Unity/Indicators/sharedunitymenumodel.cpp 1970-01-01 00:00:00 +0000
199+++ plugins/Unity/Indicators/sharedunitymenumodel.cpp 2014-10-15 19:48:28 +0000
200@@ -0,0 +1,87 @@
201+/*
202+ * Copyright 2014 Canonical Ltd.
203+ *
204+ * This program is free software; you can redistribute it and/or modify
205+ * it under the terms of the GNU Lesser General Public License as published by
206+ * the Free Software Foundation; version 3.
207+ *
208+ * This program is distributed in the hope that it will be useful,
209+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
210+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
211+ * GNU Lesser General Public License for more details.
212+ *
213+ * You should have received a copy of the GNU Lesser General Public License
214+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
215+ *
216+ */
217+
218+#include "sharedunitymenumodel.h"
219+#include "unitymenumodelcache.h"
220+
221+SharedUnityMenuModel::SharedUnityMenuModel(QObject* parent)
222+ : QObject(parent)
223+{
224+}
225+
226+QByteArray SharedUnityMenuModel::busName() const
227+{
228+ return m_busName;
229+}
230+
231+void SharedUnityMenuModel::setBusName(const QByteArray& busName)
232+{
233+ if (m_busName != busName) {
234+ m_busName = busName;
235+ Q_EMIT busNameChanged();
236+ initialize();
237+ }
238+}
239+
240+QByteArray SharedUnityMenuModel::menuObjectPath() const
241+{
242+ return m_menuObjectPath;
243+}
244+
245+void SharedUnityMenuModel::setMenuObjectPath(const QByteArray& menuObjectPath)
246+{
247+ if (m_menuObjectPath != menuObjectPath) {
248+ m_menuObjectPath = menuObjectPath;
249+ Q_EMIT menuObjectPathChanged();
250+ initialize();
251+ }
252+}
253+
254+QVariantMap SharedUnityMenuModel::actions() const
255+{
256+ return m_actions;
257+}
258+
259+void SharedUnityMenuModel::setActions(const QVariantMap& actions)
260+{
261+ if (m_actions != actions) {
262+ m_actions = actions;
263+ Q_EMIT actionsChanged();
264+ initialize();
265+ }
266+}
267+
268+UnityMenuModel* SharedUnityMenuModel::model() const
269+{
270+ return m_model ? m_model.data() : nullptr;
271+}
272+
273+void SharedUnityMenuModel::initialize()
274+{
275+ if (m_busName.isEmpty() || m_menuObjectPath.isEmpty() || m_actions.isEmpty()) {
276+ if (!m_model.isNull()) {
277+ m_model.clear();
278+ Q_EMIT modelChanged();
279+ }
280+ } else {
281+ QSharedPointer<UnityMenuModel> model = UnityMenuModelCache::singleton()->model(m_busName, m_menuObjectPath, m_actions);
282+ if (model != m_model) {
283+ m_model = model;
284+ Q_EMIT modelChanged();
285+ }
286+ }
287+}
288
289=== added file 'plugins/Unity/Indicators/sharedunitymenumodel.h'
290--- plugins/Unity/Indicators/sharedunitymenumodel.h 1970-01-01 00:00:00 +0000
291+++ plugins/Unity/Indicators/sharedunitymenumodel.h 2014-10-15 19:48:28 +0000
292@@ -0,0 +1,66 @@
293+/*
294+ * Copyright 2014 Canonical Ltd.
295+ *
296+ * This program is free software; you can redistribute it and/or modify
297+ * it under the terms of the GNU Lesser General Public License as published by
298+ * the Free Software Foundation; version 3.
299+ *
300+ * This program is distributed in the hope that it will be useful,
301+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
302+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
303+ * GNU Lesser General Public License for more details.
304+ *
305+ * You should have received a copy of the GNU Lesser General Public License
306+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
307+ *
308+ */
309+
310+#ifndef SHAREDUNITYMENUMODEL_H
311+#define SHAREDUNITYMENUMODEL_H
312+
313+#include "unityindicatorsglobal.h"
314+
315+#include <QObject>
316+#include <QSharedPointer>
317+#include <QVariantMap>
318+
319+class UnityMenuModel;
320+
321+class UNITYINDICATORS_EXPORT SharedUnityMenuModel : public QObject
322+{
323+ Q_OBJECT
324+ Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)
325+ Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)
326+ Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)
327+ Q_PROPERTY(UnityMenuModel* model READ model NOTIFY modelChanged)
328+
329+public:
330+ SharedUnityMenuModel(QObject* parent = nullptr);
331+
332+ QByteArray busName() const;
333+ void setBusName(const QByteArray&);
334+
335+ QByteArray menuObjectPath() const;
336+ void setMenuObjectPath(const QByteArray&);
337+
338+ QVariantMap actions() const;
339+ void setActions(const QVariantMap&);
340+
341+ UnityMenuModel* model() const;
342+
343+Q_SIGNALS:
344+ void busNameChanged();
345+ void menuObjectPathChanged();
346+ void actionsChanged();
347+ void modelChanged();
348+
349+private:
350+ void initialize();
351+
352+ QByteArray m_busName;
353+ QByteArray m_menuObjectPath;
354+ QVariantMap m_actions;
355+ QSharedPointer<UnityMenuModel> m_model;
356+};
357+
358+#endif // SHAREDUNITYMENUMODEL_H
359
360=== modified file 'plugins/Unity/Indicators/unitymenumodelcache.cpp'
361--- plugins/Unity/Indicators/unitymenumodelcache.cpp 2014-08-20 09:16:28 +0000
362+++ plugins/Unity/Indicators/unitymenumodelcache.cpp 2014-10-15 19:48:28 +0000
363@@ -20,30 +20,45 @@
364 #include "unitymenumodelcache.h"
365 #include <unitymenumodel.h>
366
367+#include <QQmlEngine>
368+
369+QPointer<UnityMenuModelCache> UnityMenuModelCache::theCache = nullptr;
370+
371+UnityMenuModelCache* UnityMenuModelCache::singleton()
372+{
373+ if (theCache.isNull()) {
374+ theCache = new UnityMenuModelCache();
375+ }
376+ return theCache.data();
377+}
378+
379 UnityMenuModelCache::UnityMenuModelCache(QObject* parent)
380 : QObject(parent)
381 {
382 }
383
384-UnityMenuModelCache::~UnityMenuModelCache()
385-{
386-}
387-
388-UnityMenuModel* UnityMenuModelCache::model(const QByteArray& bus,
389- const QByteArray& path,
390- const QVariantMap& actions)
391+QSharedPointer<UnityMenuModel> UnityMenuModelCache::model(const QByteArray& bus,
392+ const QByteArray& path,
393+ const QVariantMap& actions)
394 {
395 if (m_registry.contains(path))
396 return m_registry[path];
397
398- UnityMenuModel* menuModel = new UnityMenuModel;
399- connect(menuModel, &QObject::destroyed, this, [menuModel, this](QObject*) {
400- QList<QByteArray> keys = m_registry.keys(menuModel);
401- Q_FOREACH(const QByteArray& key, keys) {
402- m_registry.remove(key);
403+ UnityMenuModel* model = new UnityMenuModel;
404+ QQmlEngine::setObjectOwnership(model, QQmlEngine::CppOwnership);
405+
406+ QSharedPointer<UnityMenuModel> menuModel(model);
407+ connect(model, &QObject::destroyed, this, [this] {
408+ QMutableHashIterator<QByteArray, QWeakPointer<UnityMenuModel>> iter(m_registry);
409+ while(iter.hasNext()) {
410+ auto keyVal = iter.next();
411+ if (keyVal.value().isNull()) {
412+ iter.remove();
413+ break;
414+ }
415 }
416 });
417- m_registry[path] = menuModel;
418+ m_registry[path] = menuModel.toWeakRef();
419
420 menuModel->setBusName(bus);
421 menuModel->setMenuObjectPath(path);
422
423=== modified file 'plugins/Unity/Indicators/unitymenumodelcache.h'
424--- plugins/Unity/Indicators/unitymenumodelcache.h 2014-08-26 08:14:44 +0000
425+++ plugins/Unity/Indicators/unitymenumodelcache.h 2014-10-15 19:48:28 +0000
426@@ -24,6 +24,8 @@
427
428 #include <QObject>
429 #include <QHash>
430+#include <QPointer>
431+#include <QWeakPointer>
432
433 class UnityMenuModel;
434
435@@ -32,15 +34,19 @@
436 Q_OBJECT
437 public:
438 UnityMenuModelCache(QObject*parent=nullptr);
439- ~UnityMenuModelCache();
440-
441- Q_INVOKABLE UnityMenuModel* model(const QByteArray& bus,
442- const QByteArray& path,
443- const QVariantMap& actions);
444- Q_INVOKABLE bool contains(const QByteArray& path);
445-
446-private:
447- QHash<QByteArray, UnityMenuModel*> m_registry;
448+
449+ static UnityMenuModelCache* singleton();
450+
451+ virtual QSharedPointer<UnityMenuModel> model(const QByteArray& bus,
452+ const QByteArray& path,
453+ const QVariantMap& actions);
454+
455+ // for tests use
456+ Q_INVOKABLE virtual bool contains(const QByteArray& path);
457+
458+protected:
459+ QHash<QByteArray, QWeakPointer<UnityMenuModel>> m_registry;
460+ static QPointer<UnityMenuModelCache> theCache;
461 };
462
463 #endif // UNITYMENUMODELCACHE_H
464
465=== modified file 'plugins/Unity/Launcher/Launcher.qmltypes'
466--- plugins/Unity/Launcher/Launcher.qmltypes 2014-06-26 07:47:57 +0000
467+++ plugins/Unity/Launcher/Launcher.qmltypes 2014-10-15 19:48:28 +0000
468@@ -13,14 +13,6 @@
469 exports: ["Unity.Launcher/LauncherItem 0.1"]
470 isCreatable: false
471 exportMetaObjectRevisions: [0]
472- Signal {
473- name: "favoriteChanged"
474- Parameter { name: "favorite"; type: "bool" }
475- }
476- Signal {
477- name: "runningChanged"
478- Parameter { name: "running"; type: "bool" }
479- }
480 }
481 Component {
482 name: "LauncherModel"
483@@ -30,6 +22,10 @@
484 isSingleton: true
485 exportMetaObjectRevisions: [0]
486 Method {
487+ name: "requestRemove"
488+ Parameter { name: "appId"; type: "string" }
489+ }
490+ Method {
491 name: "get"
492 type: "unity::shell::launcher::LauncherItemInterface*"
493 Parameter { name: "index"; type: "int" }
494@@ -49,10 +45,6 @@
495 Parameter { name: "appId"; type: "string" }
496 }
497 Method {
498- name: "requestRemove"
499- Parameter { name: "appId"; type: "string" }
500- }
501- Method {
502 name: "quickListActionInvoked"
503 Parameter { name: "appId"; type: "string" }
504 Parameter { name: "actionIndex"; type: "int" }
505@@ -88,6 +80,7 @@
506 Property { name: "recent"; type: "bool"; isReadonly: true }
507 Property { name: "progress"; type: "int"; isReadonly: true }
508 Property { name: "count"; type: "int"; isReadonly: true }
509+ Property { name: "countVisible"; type: "bool"; isReadonly: true }
510 Property { name: "focused"; type: "bool"; isReadonly: true }
511 Property {
512 name: "quickList"
513@@ -96,6 +89,14 @@
514 isPointer: true
515 }
516 Signal {
517+ name: "nameChanged"
518+ Parameter { name: "name"; type: "string" }
519+ }
520+ Signal {
521+ name: "iconChanged"
522+ Parameter { name: "icon"; type: "string" }
523+ }
524+ Signal {
525 name: "pinnedChanged"
526 Parameter { name: "pinned"; type: "bool" }
527 }
528@@ -116,6 +117,10 @@
529 Parameter { name: "count"; type: "int" }
530 }
531 Signal {
532+ name: "countVisibleChanged"
533+ Parameter { name: "countVisible"; type: "bool" }
534+ }
535+ Signal {
536 name: "focusedChanged"
537 Parameter { name: "focused"; type: "bool" }
538 }
539
540=== modified file 'plugins/Unity/Session/Session.qmltypes'
541--- plugins/Unity/Session/Session.qmltypes 2014-08-14 01:28:06 +0000
542+++ plugins/Unity/Session/Session.qmltypes 2014-10-15 19:48:28 +0000
543@@ -34,4 +34,14 @@
544 Method { name: "RequestReboot" }
545 Method { name: "RequestShutdown" }
546 }
547+ Component {
548+ name: "OrientationLock"
549+ prototype: "QObject"
550+ exports: ["Unity.Session/OrientationLock 0.1"]
551+ isCreatable: false
552+ isSingleton: true
553+ exportMetaObjectRevisions: [0]
554+ Property { name: "enabled"; type: "bool"; isReadonly: true }
555+ Property { name: "savedOrientation"; type: "Qt::ScreenOrientation" }
556+ }
557 }
558
559=== modified file 'plugins/Utils/Utils.qmltypes'
560--- plugins/Utils/Utils.qmltypes 2014-08-14 01:28:06 +0000
561+++ plugins/Utils/Utils.qmltypes 2014-10-15 19:48:28 +0000
562@@ -107,6 +107,12 @@
563 }
564 }
565 Component {
566+ name: "RelativeTimeFormatter"
567+ prototype: "TimeFormatter"
568+ exports: ["Utils/RelativeTimeFormatter 0.1"]
569+ exportMetaObjectRevisions: [0]
570+ }
571+ Component {
572 name: "TimeFormatter"
573 prototype: "QObject"
574 exports: ["Utils/GDateTimeFormatter 0.1", "Utils/TimeFormatter 0.1"]
575
576=== modified file 'qml/Greeter/Clock.qml'
577--- qml/Greeter/Clock.qml 2014-08-20 08:39:09 +0000
578+++ qml/Greeter/Clock.qml 2014-10-15 19:48:28 +0000
579@@ -34,21 +34,21 @@
580 }
581 }
582
583- CachedUnityMenuModel {
584+ Indicators.SharedUnityMenuModel {
585 id: timeModel
586 objectName: "timeModel"
587
588 busName: "com.canonical.indicator.datetime"
589- actionsObjectPath: "/com/canonical/indicator/datetime"
590+ actions: { "indicator": "/com/canonical/indicator/datetime" }
591 menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : ""
592+ }
593
594- Indicators.RootActionState {
595- menu: timeModel.model
596- onUpdated: {
597- if (timeLabel.text != rightLabel) {
598- timeLabel.text = rightLabel;
599- clock.currentDate = new Date();
600- }
601+ Indicators.RootActionState {
602+ menu: timeModel.model
603+ onUpdated: {
604+ if (timeLabel.text != rightLabel) {
605+ if (rightLabel != "") timeLabel.text = rightLabel;
606+ clock.currentDate = new Date();
607 }
608 }
609 }
610
611=== modified file 'qml/Notifications/Notifications.qml'
612--- qml/Notifications/Notifications.qml 2014-09-09 09:34:28 +0000
613+++ qml/Notifications/Notifications.qml 2014-10-15 19:48:28 +0000
614@@ -32,6 +32,7 @@
615
616 SortFilterProxyModel {
617 id: snapDecisionProxyModel
618+ objectName: "snapDecisionProxyModel"
619
620 model: notificationList.model
621 filterRole: UnityNotifications.ModelInterface != undefined ? UnityNotifications.ModelInterface.RoleType : 0
622
623=== removed file 'qml/Panel/Indicators/CachedUnityMenuModel.qml'
624--- qml/Panel/Indicators/CachedUnityMenuModel.qml 2014-08-20 08:39:09 +0000
625+++ qml/Panel/Indicators/CachedUnityMenuModel.qml 1970-01-01 00:00:00 +0000
626@@ -1,39 +0,0 @@
627-/*
628- * Copyright 2013 Canonical Ltd.
629- *
630- * This program is free software; you can redistribute it and/or modify
631- * it under the terms of the GNU Lesser General Public License as published by
632- * the Free Software Foundation; version 3.
633- *
634- * This program is distributed in the hope that it will be useful,
635- * but WITHOUT ANY WARRANTY; without even the implied warranty of
636- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
637- * GNU Lesser General Public License for more details.
638- *
639- * You should have received a copy of the GNU Lesser General Public License
640- * along with this program. If not, see <http://www.gnu.org/licenses/>.
641- *
642- * Authors:
643- * Nick Dedekind <nick.dedekind@canonical.com>
644- */
645-
646-import QtQuick 2.0
647-import QMenuModel 0.1
648-import Unity.Indicators 0.1 as Indicators
649-
650-// Make sure we don't duplicate models.
651-Item {
652- id: cachedModel
653- property string busName
654- property string actionsObjectPath
655- property string menuObjectPath
656- readonly property bool ready: busName!=="" && actionsObjectPath!=="" && menuObjectPath!==""
657-
658- property var model: {
659- if (!ready) return null;
660-
661- return Indicators.UnityMenuModelCache.model(cachedModel.busName,
662- cachedModel.menuObjectPath,
663- { "indicator": cachedModel.actionsObjectPath });
664- }
665-}
666
667=== modified file 'qml/Panel/Indicators/IndicatorBase.qml'
668--- qml/Panel/Indicators/IndicatorBase.qml 2014-09-29 10:24:58 +0000
669+++ qml/Panel/Indicators/IndicatorBase.qml 2014-10-15 19:48:28 +0000
670@@ -37,10 +37,10 @@
671 property alias menuModel: cachedModel.model
672 property alias rootActionState: rootAction
673
674- CachedUnityMenuModel {
675+ SharedUnityMenuModel {
676 id: cachedModel
677 busName: indicatorItem.busName
678- actionsObjectPath: indicatorItem.actionsObjectPath
679+ actions: { "indicator": indicatorItem.actionsObjectPath }
680 menuObjectPath: indicatorItem.deviceMenuObjectPath
681 }
682
683
684=== modified file 'qml/Shell.qml'
685--- qml/Shell.qml 2014-10-13 15:41:29 +0000
686+++ qml/Shell.qml 2014-10-15 19:48:28 +0000
687@@ -248,7 +248,7 @@
688 Binding {
689 target: applicationsDisplayLoader.item
690 property: "interactive"
691- value: edgeDemo.stagesEnabled && !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0
692+ value: edgeDemo.stagesEnabled && !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0 && !notifications.useModal
693 }
694 Binding {
695 target: applicationsDisplayLoader.item
696
697=== modified file 'tests/mocks/AccountsService/AccountsService.qmltypes'
698--- tests/mocks/AccountsService/AccountsService.qmltypes 2014-09-01 12:18:53 +0000
699+++ tests/mocks/AccountsService/AccountsService.qmltypes 2014-10-15 19:48:28 +0000
700@@ -23,6 +23,8 @@
701 }
702 Property { name: "user"; type: "string" }
703 Property { name: "demoEdges"; type: "bool" }
704+ Property { name: "enableLauncherWhileLocked"; type: "bool" }
705+ Property { name: "enableIndicatorsWhileLocked"; type: "bool" }
706 Property { name: "backgroundFile"; type: "string" }
707 Property { name: "statsWelcomeScreen"; type: "bool" }
708 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
709
710=== modified file 'tests/mocks/LightDM/LightDM.qmltypes'
711--- tests/mocks/LightDM/LightDM.qmltypes 2014-09-01 12:18:53 +0000
712+++ tests/mocks/LightDM/LightDM.qmltypes 2014-10-15 19:48:28 +0000
713@@ -37,6 +37,7 @@
714 Signal { name: "isActiveChanged" }
715 Signal { name: "isAuthenticatedChanged" }
716 Signal { name: "showGreeter" }
717+ Signal { name: "hideGreeter" }
718 Signal {
719 name: "requestAuthenticationUser"
720 Parameter { name: "user"; type: "string" }
721
722=== modified file 'tests/mocks/QMenuModel/QMenuModel.qmltypes'
723--- tests/mocks/QMenuModel/QMenuModel.qmltypes 2014-08-14 01:28:06 +0000
724+++ tests/mocks/QMenuModel/QMenuModel.qmltypes 2014-10-15 19:48:28 +0000
725@@ -18,12 +18,12 @@
726 prototype: "QAbstractListModel"
727 exports: ["QMenuModel/UnityMenuModel 0.1"]
728 exportMetaObjectRevisions: [0]
729- Property { name: "modelData"; type: "QVariant" }
730 Property { name: "busName"; type: "QByteArray" }
731 Property { name: "actions"; type: "QVariantMap" }
732 Property { name: "menuObjectPath"; type: "QByteArray" }
733 Property { name: "actionStateParser"; type: "ActionStateParser"; isPointer: true }
734 Property { name: "nameOwner"; type: "string"; isReadonly: true }
735+ Property { name: "modelData"; type: "QVariant" }
736 Method {
737 name: "insertRow"
738 Parameter { name: "row"; type: "int" }
739
740=== modified file 'tests/mocks/QMenuModel/unitymenumodel.cpp'
741--- tests/mocks/QMenuModel/unitymenumodel.cpp 2014-08-26 08:14:44 +0000
742+++ tests/mocks/QMenuModel/unitymenumodel.cpp 2014-10-15 19:48:28 +0000
743@@ -50,13 +50,12 @@
744 {
745 beginResetModel();
746
747- m_modelData.clear();
748 m_modelData = data.toList();
749+ Q_EMIT modelDataChanged();
750
751 endResetModel();
752 }
753
754-
755 void UnityMenuModel::insertRow(int row, const QVariant& data)
756 {
757 row = qMin(row, rowCount());
758
759=== modified file 'tests/mocks/QMenuModel/unitymenumodel.h'
760--- tests/mocks/QMenuModel/unitymenumodel.h 2014-08-26 08:14:44 +0000
761+++ tests/mocks/QMenuModel/unitymenumodel.h 2014-10-15 19:48:28 +0000
762@@ -27,13 +27,15 @@
763 class Q_DECL_EXPORT UnityMenuModel : public QAbstractListModel
764 {
765 Q_OBJECT
766- Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
767 Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)
768 Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)
769 Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)
770 Q_PROPERTY(ActionStateParser* actionStateParser READ actionStateParser WRITE setActionStateParser NOTIFY actionStateParserChanged)
771 Q_PROPERTY(QString nameOwner READ nameOwner NOTIFY nameOwnerChanged)
772
773+ // internal mock properties
774+ Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
775+
776 public:
777 UnityMenuModel(QObject *parent = nullptr);
778 virtual ~UnityMenuModel();
779@@ -81,8 +83,10 @@
780 void actionsChanged();
781 void menuObjectPathChanged();
782 void actionStateParserChanged();
783+ void nameOwnerChanged();
784+
785+ // Internal mock usage
786 void modelDataChanged();
787- void nameOwnerChanged();
788
789 private:
790 QVariantMap rowData(int row) const;
791
792=== modified file 'tests/mocks/Ubuntu/Payments/Payments.qmltypes'
793--- tests/mocks/Ubuntu/Payments/Payments.qmltypes 2014-06-27 20:53:24 +0000
794+++ tests/mocks/Ubuntu/Payments/Payments.qmltypes 2014-10-15 19:48:28 +0000
795@@ -37,6 +37,8 @@
796 Parameter { name: "error"; type: "string" }
797 }
798 Signal { name: "purchaseCompleted" }
799+ Signal { name: "purchaseCancelled" }
800 Method { name: "start" }
801+ Method { name: "process" }
802 }
803 }
804
805=== modified file 'tests/mocks/Ubuntu/Telephony/Telephony.qmltypes'
806--- tests/mocks/Ubuntu/Telephony/Telephony.qmltypes 2014-08-14 13:33:28 +0000
807+++ tests/mocks/Ubuntu/Telephony/Telephony.qmltypes 2014-10-15 19:48:28 +0000
808@@ -22,7 +22,8 @@
809 exportMetaObjectRevisions: [0]
810 Property { name: "phoneNumber"; type: "string" }
811 Property { name: "isConference"; type: "bool" }
812- Property { name: "elapsedTime"; type: "int"; isReadonly: true }
813+ Property { name: "elapsedTime"; type: "int" }
814+ Property { name: "elapsedTimerRunning"; type: "bool" }
815 }
816 Component {
817 name: "MockCallManager"
818
819=== modified file 'tests/mocks/Unity/Application/Application.qmltypes'
820--- tests/mocks/Unity/Application/Application.qmltypes 2014-09-01 12:24:06 +0000
821+++ tests/mocks/Unity/Application/Application.qmltypes 2014-10-15 19:48:28 +0000
822@@ -238,6 +238,7 @@
823 Property { name: "state"; type: "State"; isReadonly: true }
824 Property { name: "name"; type: "string"; isReadonly: true }
825 Property { name: "live"; type: "bool"; isReadonly: true }
826+ Property { name: "orientation"; type: "Qt::ScreenOrientation" }
827 Signal {
828 name: "typeChanged"
829 Parameter { type: "Type" }
830@@ -268,10 +269,15 @@
831 exportMetaObjectRevisions: [0]
832 Property { name: "name"; type: "string"; isReadonly: true }
833 Property { name: "surface"; type: "MirSurfaceItem"; isReadonly: true; isPointer: true }
834+ Property { name: "application"; type: "ApplicationInfo"; isReadonly: true; isPointer: true }
835 Property { name: "parentSession"; type: "Session"; isReadonly: true; isPointer: true }
836 Property { name: "childSessions"; type: "SessionModel"; isReadonly: true; isPointer: true }
837 Property { name: "live"; type: "bool"; isReadonly: true }
838 Signal {
839+ name: "applicationChanged"
840+ Parameter { type: "ApplicationInfo"; isPointer: true }
841+ }
842+ Signal {
843 name: "surfaceChanged"
844 Parameter { type: "MirSurfaceItem"; isPointer: true }
845 }
846@@ -368,6 +374,12 @@
847 Property { name: "stage"; type: "Stage"; isReadonly: true }
848 Property { name: "state"; type: "State"; isReadonly: true }
849 Property { name: "focused"; type: "bool"; isReadonly: true }
850+ Property { name: "splashTitle"; type: "string"; isReadonly: true }
851+ Property { name: "splashImage"; type: "QUrl"; isReadonly: true }
852+ Property { name: "splashShowHeader"; type: "bool"; isReadonly: true }
853+ Property { name: "splashColor"; type: "QColor"; isReadonly: true }
854+ Property { name: "splashColorHeader"; type: "QColor"; isReadonly: true }
855+ Property { name: "splashColorFooter"; type: "QColor"; isReadonly: true }
856 Signal {
857 name: "nameChanged"
858 Parameter { name: "name"; type: "string" }
859@@ -414,6 +426,7 @@
860 Property { name: "count"; type: "int"; isReadonly: true }
861 Property { name: "focusedApplicationId"; type: "string"; isReadonly: true }
862 Property { name: "suspended"; type: "bool" }
863+ Property { name: "forceDashActive"; type: "bool" }
864 Signal {
865 name: "focusRequested"
866 Parameter { name: "appId"; type: "string" }
867
868=== modified file 'tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes'
869--- tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-08-14 13:33:28 +0000
870+++ tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-10-15 19:48:28 +0000
871@@ -34,13 +34,13 @@
872 name: "setCurrentScopeRequested"
873 Parameter { name: "scopeId"; type: "string" }
874 Parameter { name: "animate"; type: "bool" }
875- Parameter { name: "reset"; type: "bool" }
876+ Parameter { name: "isSwipe"; type: "bool" }
877 }
878 Method {
879 name: "mockSetCurrentScope"
880 Parameter { name: "scopeId"; type: "string" }
881 Parameter { name: "animate"; type: "bool" }
882- Parameter { name: "reset"; type: "bool" }
883+ Parameter { name: "isSwipe"; type: "bool" }
884 }
885 }
886 }
887
888=== modified file 'tests/mocks/Unity/Indicators/CMakeLists.txt'
889--- tests/mocks/Unity/Indicators/CMakeLists.txt 2014-08-20 08:39:09 +0000
890+++ tests/mocks/Unity/Indicators/CMakeLists.txt 2014-10-15 19:48:28 +0000
891@@ -12,24 +12,17 @@
892
893 set(IndicatorsFakeQml_SOURCES
894 fakeplugin.cpp
895+ fakeindicatorsmodel.cpp
896+ fakeunitymenumodelcache.cpp
897 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/indicators.h
898 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
899+ ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/sharedunitymenumodel.cpp
900 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelcache.cpp
901 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
902 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
903- fakeindicatorsmodel.cpp
904-)
905-
906-set(IndicatorsFakeQml_RESOURCES
907- indicators_fake.qrc
908-)
909-
910-qt5_add_resources(IndicatorsFakeQml_RESOURCES_RCC
911- ${IndicatorsFakeQml_RESOURCES}
912 )
913
914 add_library(IndicatorsFakeQml SHARED
915- ${IndicatorsFakeQml_RESOURCES_RCC}
916 ${IndicatorsFakeQml_SOURCES}
917 )
918 add_definitions(-DUNITYINDICATORS_LIBRARY)
919
920=== removed file 'tests/mocks/Unity/Indicators/FakeMenuPage.qml'
921--- tests/mocks/Unity/Indicators/FakeMenuPage.qml 2014-09-09 15:10:52 +0000
922+++ tests/mocks/Unity/Indicators/FakeMenuPage.qml 1970-01-01 00:00:00 +0000
923@@ -1,27 +0,0 @@
924-/*
925- * Copyright 2013 Canonical Ltd.
926- *
927- * This program is free software; you can redistribute it and/or modify
928- * it under the terms of the GNU General Public License as published by
929- * the Free Software Foundation; version 3.
930- *
931- * This program is distributed in the hope that it will be useful,
932- * but WITHOUT ANY WARRANTY; without even the implied warranty of
933- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
934- * GNU General Public License for more details.
935- *
936- * You should have received a copy of the GNU General Public License
937- * along with this program. If not, see <http://www.gnu.org/licenses/>.
938- */
939-
940-import QtQuick 2.0
941-
942-Flickable {
943- objectName: "fakeMenuPlugin"
944- // Make it compatible with the PluginItem interface
945- function reset() {
946- if (shell != undefined && shell.indicator_status != undefined) {
947- shell.indicator_status[objectName].reset++;
948- }
949- }
950-}
951
952=== modified file 'tests/mocks/Unity/Indicators/Indicators.qmltypes'
953--- tests/mocks/Unity/Indicators/Indicators.qmltypes 2014-09-01 12:18:53 +0000
954+++ tests/mocks/Unity/Indicators/Indicators.qmltypes 2014-10-15 19:48:28 +0000
955@@ -29,6 +29,7 @@
956 exports: ["Unity.Indicators/FakeIndicatorsModel 0.1"]
957 exportMetaObjectRevisions: [0]
958 Property { name: "count"; type: "int"; isReadonly: true }
959+ Property { name: "modelData"; type: "QVariant" }
960 Method {
961 name: "load"
962 Parameter { name: "profile"; type: "string" }
963@@ -39,6 +40,15 @@
964 Parameter { name: "row"; type: "QVariantMap" }
965 }
966 Method {
967+ name: "insert"
968+ Parameter { name: "row"; type: "int" }
969+ Parameter { name: "data"; type: "QVariantMap" }
970+ }
971+ Method {
972+ name: "remove"
973+ Parameter { name: "row"; type: "int" }
974+ }
975+ Method {
976 name: "data"
977 type: "QVariant"
978 Parameter { name: "row"; type: "int" }
979@@ -46,6 +56,27 @@
980 }
981 }
982 Component {
983+ name: "FakeUnityMenuModelCache"
984+ prototype: "UnityMenuModelCache"
985+ exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]
986+ isCreatable: false
987+ isSingleton: true
988+ exportMetaObjectRevisions: [0]
989+ Method {
990+ name: "setCachedModelData"
991+ Parameter { name: "bus"; type: "QByteArray" }
992+ Parameter { name: "path"; type: "QByteArray" }
993+ Parameter { name: "actions"; type: "QVariantMap" }
994+ Parameter { name: "data"; type: "QVariant" }
995+ }
996+ Method {
997+ name: "setCachedModelData"
998+ Parameter { name: "bus"; type: "QByteArray" }
999+ Parameter { name: "path"; type: "QByteArray" }
1000+ Parameter { name: "actions"; type: "QVariantMap" }
1001+ }
1002+ }
1003+ Component {
1004 name: "FlatMenuProxyModelRole"
1005 prototype: "QObject"
1006 exports: ["Unity.Indicators/FlatMenuProxyModelRole 0.1"]
1007@@ -160,19 +191,18 @@
1008 }
1009 Component { name: "QIdentityProxyModel"; prototype: "QAbstractProxyModel" }
1010 Component {
1011+ name: "SharedUnityMenuModel"
1012+ prototype: "QObject"
1013+ exports: ["Unity.Indicators/SharedUnityMenuModel 0.1"]
1014+ exportMetaObjectRevisions: [0]
1015+ Property { name: "busName"; type: "QByteArray" }
1016+ Property { name: "menuObjectPath"; type: "QByteArray" }
1017+ Property { name: "actions"; type: "QVariantMap" }
1018+ Property { name: "model"; type: "UnityMenuModel"; isReadonly: true; isPointer: true }
1019+ }
1020+ Component {
1021 name: "UnityMenuModelCache"
1022 prototype: "QObject"
1023- exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]
1024- isCreatable: false
1025- isSingleton: true
1026- exportMetaObjectRevisions: [0]
1027- Method {
1028- name: "model"
1029- type: "UnityMenuModel*"
1030- Parameter { name: "bus"; type: "QByteArray" }
1031- Parameter { name: "path"; type: "QByteArray" }
1032- Parameter { name: "actions"; type: "QVariantMap" }
1033- }
1034 Method {
1035 name: "contains"
1036 type: "bool"
1037
1038=== modified file 'tests/mocks/Unity/Indicators/IndicatorsModel.qml'
1039--- tests/mocks/Unity/Indicators/IndicatorsModel.qml 2014-03-03 11:55:00 +0000
1040+++ tests/mocks/Unity/Indicators/IndicatorsModel.qml 2014-10-15 19:48:28 +0000
1041@@ -18,43 +18,151 @@
1042 import Unity.Indicators 0.1 as Indicators
1043
1044 Indicators.FakeIndicatorsModel {
1045+ id: root
1046+
1047+ Component.onCompleted: {
1048+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake1",
1049+ "/com/canonical/indicators/fake1",
1050+ "/com/canonical/indicators/fake1",
1051+ getUnityMenuModelData("fake-indicator-bluetooth",
1052+ "Bluetooth (F)",
1053+ "",
1054+ [ "image://theme/bluetooth-active" ]));
1055+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake2",
1056+ "/com/canonical/indicators/fake2",
1057+ "/com/canonical/indicators/fake2",
1058+ getUnityMenuModelData("fake-indicator-network",
1059+ "Network (F)",
1060+ "",
1061+ [ "image://theme/simcard-error", "image://theme/wifi-high" ]));
1062+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake3",
1063+ "/com/canonical/indicators/fake3",
1064+ "/com/canonical/indicators/fake3",
1065+ getUnityMenuModelData("fake-indicator-sound",
1066+ "Messages (F)",
1067+ "",
1068+ [ "image://theme/messages-new" ]));
1069+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake4",
1070+ "/com/canonical/indicators/fake4",
1071+ "/com/canonical/indicators/fake4",
1072+ getUnityMenuModelData("fake-indicator-power",
1073+ "Sound (F)",
1074+ "",
1075+ [ "image://theme/audio-volume-high" ]));
1076+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake5",
1077+ "/com/canonical/indicators/fake5",
1078+ "/com/canonical/indicators/fake5",
1079+ getUnityMenuModelData("fake-indicator-power",
1080+ "Battery (F)",
1081+ "",
1082+ [ "image://theme/battery-020" ]));
1083+ }
1084+
1085+ function getUnityMenuModelData(identifier, title, label, icons) {
1086+ var root = [{
1087+ "rowData": { // 1
1088+ "label": "",
1089+ "sensitive": true,
1090+ "isSeparator": false,
1091+ "icon": "",
1092+ "type": "com.canonical.indicator.root",
1093+ "ext": {},
1094+ "action": "",
1095+ "actionState": {
1096+ "title": title,
1097+ "label": label,
1098+ "icons": icons
1099+ },
1100+ "isCheck": false,
1101+ "isRadio": false,
1102+ "isToggled": false,
1103+ },
1104+ "submenu": []
1105+ }];
1106+
1107+ var submenus = [];
1108+ for (var i = 0; i < 8; i++) {
1109+ var submenu = {
1110+ "rowData": { // 1.1
1111+ "label": identifier,
1112+ "sensitive": true,
1113+ "isSeparator": false,
1114+ "icon": "",
1115+ "type": undefined,
1116+ "ext": {},
1117+ "action": "",
1118+ "actionState": {},
1119+ "isCheck": false,
1120+ "isRadio": false,
1121+ "isToggled": false,
1122+ }};
1123+ submenus.push(submenu);
1124+ }
1125+ root[0]["submenu"] = submenus;
1126+
1127+ return root;
1128+ }
1129+
1130+ property var originalModelData: [
1131+ {
1132+ "identifier": "indicator-fake1",
1133+ "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
1134+ "pageSource": "Indicators/DefaultIndicatorPage.qml",
1135+ "indicatorProperties": {
1136+ "enabled": true,
1137+ "busName": "com.canonical.indicators.fake1",
1138+ "menuObjectPath": "/com/canonical/indicators/fake1",
1139+ "actionsObjectPath": "/com/canonical/indicators/fake1"
1140+ }
1141+ },
1142+ {
1143+ "identifier": "indicator-fake2",
1144+ "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
1145+ "pageSource": "Indicators/DefaultIndicatorPage.qml",
1146+ "indicatorProperties": {
1147+ "enabled": true,
1148+ "busName": "com.canonical.indicators.fake2",
1149+ "menuObjectPath": "/com/canonical/indicators/fake2",
1150+ "actionsObjectPath": "/com/canonical/indicators/fake2"
1151+ }
1152+ },
1153+ {
1154+ "identifier": "indicator-fake3",
1155+ "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
1156+ "pageSource": "Indicators/DefaultIndicatorPage.qml",
1157+ "indicatorProperties": {
1158+ "enabled": true,
1159+ "busName": "com.canonical.indicators.fake3",
1160+ "menuObjectPath": "/com/canonical/indicators/fake3",
1161+ "actionsObjectPath": "/com/canonical/indicators/fake3"
1162+ }
1163+ },
1164+ {
1165+ "identifier": "indicator-fake4",
1166+ "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
1167+ "pageSource": "Indicators/DefaultIndicatorPage.qml",
1168+ "indicatorProperties": {
1169+ "enabled": true,
1170+ "busName": "com.canonical.indicators.fake4",
1171+ "menuObjectPath": "/com/canonical/indicators/fake4",
1172+ "actionsObjectPath": "/com/canonical/indicators/fake4"
1173+ }
1174+ },
1175+ {
1176+ "identifier": "indicator-fake5",
1177+ "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
1178+ "pageSource": "Indicators/DefaultIndicatorPage.qml",
1179+ "indicatorProperties": {
1180+ "enabled": true,
1181+ "busName": "com.canonical.indicators.fake5",
1182+ "menuObjectPath": "/com/canonical/indicators/fake5",
1183+ "actionsObjectPath": "/com/canonical/indicators/fake5"
1184+ }
1185+ }
1186+ ]
1187
1188 function load(profile) {
1189 unload();
1190-
1191- append({ "identifier": "indicator-fake1",
1192- "position": 0,
1193- "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
1194- "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
1195- "indicatorProperties": { enabled: true }
1196- });
1197-
1198- append({ "identifier": "indicator-fake2",
1199- "position": 1,
1200- "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
1201- "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
1202- "indicatorProperties": { enabled: true }
1203- });
1204-
1205- append({ "identifier": "indicator-fake3",
1206- "position": 2,
1207- "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
1208- "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
1209- "indicatorProperties": { enabled: true }
1210- });
1211-
1212- append({ "identifier": "indicator-fake4",
1213- "position": 3,
1214- "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
1215- "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
1216- "indicatorProperties": { enabled: true }
1217- });
1218-
1219- append({ "identifier": "indicator-fake5",
1220- "position": 4,
1221- "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
1222- "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
1223- "indicatorProperties": { enabled: true }
1224- });
1225+ root.modelData = originalModelData;
1226 }
1227 }
1228
1229=== modified file 'tests/mocks/Unity/Indicators/RootActionState.qml'
1230--- tests/mocks/Unity/Indicators/RootActionState.qml 2013-10-28 18:19:15 +0000
1231+++ tests/mocks/Unity/Indicators/RootActionState.qml 2014-10-15 19:48:28 +0000
1232@@ -19,15 +19,23 @@
1233
1234 import QtQuick 2.0
1235
1236-QtObject {
1237- property var menu
1238- property bool valid: false
1239- property string title
1240- property string leftLabel
1241- property string rightLabel
1242- property var icons
1243- property string accessibleName
1244- property bool visible: true
1245+Item {
1246+ property var menu: null
1247+ property bool valid: cachedState !== undefined
1248+ property string title: cachedState && cachedState.hasOwnProperty("title") ? cachedState["title"] : ""
1249+ property string leftLabel: cachedState && cachedState.hasOwnProperty("pre-label") ? cachedState["pre-label"] : ""
1250+ property string rightLabel: cachedState && cachedState.hasOwnProperty("label") ? cachedState["label"] : ""
1251+ property var icons: cachedState && cachedState.hasOwnProperty("icons") ? cachedState["icons"] : []
1252+ property string accessibleName: cachedState && cachedState.hasOwnProperty("accessible-desc") ? cachedState["accessible-desc"] : ""
1253+ visible: cachedState && cachedState.hasOwnProperty("visible") ? cachedState["visible"] : true
1254+
1255+ property var cachedState: menu ? menu.get(0, "actionState") : undefined
1256+ Connections {
1257+ target: menu
1258+ onModelDataChanged: {
1259+ cachedState = menu.get(0, "actionState");
1260+ }
1261+ }
1262
1263 signal updated
1264
1265
1266=== modified file 'tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp'
1267--- tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp 2014-07-01 09:49:24 +0000
1268+++ tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp 2014-10-15 19:48:28 +0000
1269@@ -31,7 +31,6 @@
1270 /*! \internal */
1271 FakeIndicatorsModel::~FakeIndicatorsModel()
1272 {
1273- qDeleteAll(m_indicators);
1274 }
1275
1276 int FakeIndicatorsModel::count() const
1277@@ -47,29 +46,61 @@
1278 {
1279 beginResetModel();
1280
1281- qDeleteAll(m_indicators);
1282- m_indicators.clear();
1283-
1284- endResetModel();
1285-}
1286-
1287-
1288-void FakeIndicatorsModel::append(const QVariantMap& row)
1289-{
1290- Indicator* new_row = new QHash<int, QVariant>();
1291- for (auto iter = row.begin(); iter != row.end(); ++iter )
1292- {
1293- int key = roleNames().key(iter.key().toUtf8(), -1);
1294- if (key != -1) {
1295- new_row->insert(key, iter.value());
1296- }
1297- }
1298-
1299- beginInsertRows(QModelIndex(), m_indicators.count(), m_indicators.count());
1300-
1301- m_indicators.append(new_row);
1302-
1303- endInsertRows();
1304+ m_modelData.clear();
1305+ Q_EMIT modelDataChanged();
1306+
1307+ endResetModel();
1308+}
1309+
1310+
1311+void FakeIndicatorsModel::append(const QVariantMap& data)
1312+{
1313+ QList<QVariant> allData = m_modelData.toList();
1314+ beginInsertRows(QModelIndex(), allData.count(), allData.count());
1315+
1316+ allData.append(data);
1317+ m_modelData = allData;
1318+ Q_EMIT modelDataChanged();
1319+
1320+ endInsertRows();
1321+}
1322+
1323+void FakeIndicatorsModel::insert(int row, const QVariantMap& data)
1324+{
1325+ QList<QVariant> allData = m_modelData.toList();
1326+ row = qMax(0, qMin(row, allData.count()));
1327+
1328+ beginInsertRows(QModelIndex(), row, row);
1329+
1330+ allData.insert(row, data);
1331+ m_modelData = allData;
1332+ Q_EMIT modelDataChanged();
1333+
1334+ endInsertRows();
1335+}
1336+
1337+void FakeIndicatorsModel::remove(int row)
1338+{
1339+ QList<QVariant> allData = m_modelData.toList();
1340+ row = qMax(0, qMin(row, allData.count()));
1341+
1342+ beginRemoveRows(QModelIndex(), row, row);
1343+
1344+ allData.removeAt(row);
1345+ m_modelData = allData;
1346+ Q_EMIT modelDataChanged();
1347+
1348+ endRemoveRows();
1349+}
1350+
1351+void FakeIndicatorsModel::setModelData(const QVariant& modelData)
1352+{
1353+ beginResetModel();
1354+
1355+ m_modelData = modelData;
1356+ Q_EMIT modelDataChanged();
1357+
1358+ endResetModel();
1359 }
1360
1361 QHash<int, QByteArray> FakeIndicatorsModel::roleNames() const
1362@@ -91,18 +122,18 @@
1363 return 1;
1364 }
1365
1366-Q_INVOKABLE QVariant FakeIndicatorsModel::data(int row, int role) const
1367+QVariant FakeIndicatorsModel::data(int row, int role) const
1368 {
1369 return data(index(row, 0), role);
1370 }
1371
1372 QVariant FakeIndicatorsModel::data(const QModelIndex &index, int role) const
1373 {
1374- if (!index.isValid() || index.row() >= m_indicators.size())
1375+ QList<QVariant> dataList = m_modelData.toList();
1376+ if (!index.isValid() || index.row() >= dataList.size())
1377 return QVariant();
1378
1379- Indicator* indicator = m_indicators[index.row()];
1380- return indicator->value(role, QVariant());
1381+ return dataList[index.row()].toMap()[roleNames()[role]];
1382 }
1383
1384 QModelIndex FakeIndicatorsModel::parent(const QModelIndex&) const
1385@@ -112,5 +143,5 @@
1386
1387 int FakeIndicatorsModel::rowCount(const QModelIndex&) const
1388 {
1389- return m_indicators.count();
1390+ return m_modelData.toList().count();
1391 }
1392
1393=== modified file 'tests/mocks/Unity/Indicators/fakeindicatorsmodel.h'
1394--- tests/mocks/Unity/Indicators/fakeindicatorsmodel.h 2014-03-03 12:01:09 +0000
1395+++ tests/mocks/Unity/Indicators/fakeindicatorsmodel.h 2014-10-15 19:48:28 +0000
1396@@ -27,6 +27,7 @@
1397 Q_OBJECT
1398 Q_ENUMS(Roles)
1399 Q_PROPERTY(int count READ count NOTIFY countChanged)
1400+ Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
1401 public:
1402
1403 FakeIndicatorsModel(QObject *parent=0);
1404@@ -36,9 +37,14 @@
1405 Q_INVOKABLE void unload();
1406
1407 Q_INVOKABLE void append(const QVariantMap& row);
1408+ Q_INVOKABLE void insert(int row, const QVariantMap& data);
1409+ Q_INVOKABLE void remove(int row);
1410
1411 Q_INVOKABLE QVariant data(int row, int role) const;
1412
1413+ void setModelData(const QVariant& data);
1414+ QVariant modelData() const { return m_modelData; }
1415+
1416 /* QAbstractItemModel */
1417 QHash<int, QByteArray> roleNames() const;
1418 int columnCount(const QModelIndex &parent = QModelIndex()) const;
1419@@ -48,12 +54,12 @@
1420
1421 Q_SIGNALS:
1422 void countChanged();
1423+ void modelDataChanged();
1424
1425 private:
1426 int count() const;
1427
1428- typedef QHash<int, QVariant> Indicator;
1429- QList<Indicator*> m_indicators;
1430+ QVariant m_modelData;
1431 };
1432
1433 #endif // FAKE_INDICATORSMODEL_H
1434
1435=== modified file 'tests/mocks/Unity/Indicators/fakeplugin.cpp'
1436--- tests/mocks/Unity/Indicators/fakeplugin.cpp 2014-08-20 08:39:09 +0000
1437+++ tests/mocks/Unity/Indicators/fakeplugin.cpp 2014-10-15 19:48:28 +0000
1438@@ -26,19 +26,22 @@
1439 #include "fakeindicatorsmodel.h"
1440 #include "indicators.h"
1441 #include "menucontentactivator.h"
1442-#include "unitymenumodelcache.h"
1443+#include "sharedunitymenumodel.h"
1444+#include "fakeunitymenumodelcache.h"
1445 #include "unitymenumodelstack.h"
1446 #include "visibleindicatorsmodel.h"
1447
1448+#include <unitymenumodel.h>
1449+
1450 static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
1451 Q_UNUSED(engine);
1452 Q_UNUSED(scriptEngine);
1453- return new UnityMenuModelCache;
1454+ return FakeUnityMenuModelCache::singleton();
1455 }
1456
1457 void IndicatorsFakePlugin::registerTypes(const char * uri)
1458 {
1459- Q_INIT_RESOURCE(indicators_fake);
1460+ qRegisterMetaType<UnityMenuModel*>("UnityMenuModel*");
1461
1462 // internal
1463 qmlRegisterType<FakeIndicatorsModel>(uri, 0, 1, "FakeIndicatorsModel");
1464@@ -47,8 +50,9 @@
1465 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
1466 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
1467 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
1468+ qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
1469
1470- qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
1471+ qmlRegisterSingletonType<FakeUnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
1472
1473 // external uncreatables
1474 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");
1475
1476=== added file 'tests/mocks/Unity/Indicators/fakeunitymenumodelcache.cpp'
1477--- tests/mocks/Unity/Indicators/fakeunitymenumodelcache.cpp 1970-01-01 00:00:00 +0000
1478+++ tests/mocks/Unity/Indicators/fakeunitymenumodelcache.cpp 2014-10-15 19:48:28 +0000
1479@@ -0,0 +1,57 @@
1480+/*
1481+ * Copyright 2014 Canonical Ltd.
1482+ *
1483+ * This program is free software; you can redistribute it and/or modify
1484+ * it under the terms of the GNU Lesser General Public License as published by
1485+ * the Free Software Foundation; version 3.
1486+ *
1487+ * This program is distributed in the hope that it will be useful,
1488+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1489+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1490+ * GNU Lesser General Public License for more details.
1491+ *
1492+ * You should have received a copy of the GNU Lesser General Public License
1493+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1494+ */
1495+
1496+#include "fakeunitymenumodelcache.h"
1497+#include <unitymenumodel.h>
1498+
1499+QPointer<FakeUnityMenuModelCache> FakeUnityMenuModelCache::theFakeCache = nullptr;
1500+
1501+FakeUnityMenuModelCache* FakeUnityMenuModelCache::singleton()
1502+{
1503+ if (theFakeCache.isNull()) {
1504+ theFakeCache = new FakeUnityMenuModelCache();
1505+ }
1506+ return theFakeCache.data();
1507+}
1508+
1509+FakeUnityMenuModelCache::FakeUnityMenuModelCache(QObject* parent)
1510+ : UnityMenuModelCache(parent)
1511+{
1512+}
1513+
1514+QSharedPointer<UnityMenuModel> FakeUnityMenuModelCache::model(const QByteArray& bus,
1515+ const QByteArray& path,
1516+ const QVariantMap& actions)
1517+{
1518+ return UnityMenuModelCache::singleton()->model(bus, path, actions);
1519+}
1520+
1521+bool FakeUnityMenuModelCache::contains(const QByteArray& path)
1522+{
1523+ return UnityMenuModelCache::singleton()->contains(path);
1524+}
1525+
1526+void FakeUnityMenuModelCache::setCachedModelData(const QByteArray& bus,
1527+ const QByteArray& path,
1528+ const QVariantMap& actions,
1529+ const QVariant& data)
1530+{
1531+ // keep a ref forever!
1532+ if (!m_models.contains(path)) {
1533+ m_models[path] = model(bus, path, actions);
1534+ }
1535+ m_models[path]->setModelData(data);
1536+}
1537
1538=== added file 'tests/mocks/Unity/Indicators/fakeunitymenumodelcache.h'
1539--- tests/mocks/Unity/Indicators/fakeunitymenumodelcache.h 1970-01-01 00:00:00 +0000
1540+++ tests/mocks/Unity/Indicators/fakeunitymenumodelcache.h 2014-10-15 19:48:28 +0000
1541@@ -0,0 +1,49 @@
1542+/*
1543+ * Copyright 2014 Canonical Ltd.
1544+ *
1545+ * This program is free software; you can redistribute it and/or modify
1546+ * it under the terms of the GNU Lesser General Public License as published by
1547+ * the Free Software Foundation; version 3.
1548+ *
1549+ * This program is distributed in the hope that it will be useful,
1550+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
1551+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1552+ * GNU Lesser General Public License for more details.
1553+ *
1554+ * You should have received a copy of the GNU Lesser General Public License
1555+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
1556+ */
1557+
1558+#ifndef FAKEUNITYMENUMODELCACHE_H
1559+#define FAKEUNITYMENUMODELCACHE_H
1560+
1561+#include "unitymenumodelcache.h"
1562+
1563+#include <QVariantMap>
1564+
1565+class FakeUnityMenuModelCache : public UnityMenuModelCache
1566+{
1567+ Q_OBJECT
1568+public:
1569+ FakeUnityMenuModelCache(QObject* parent = nullptr);
1570+
1571+ static FakeUnityMenuModelCache* singleton();
1572+
1573+ QSharedPointer<UnityMenuModel> model(const QByteArray& bus,
1574+ const QByteArray& path,
1575+ const QVariantMap& actions) override;
1576+ bool contains(const QByteArray& path) override;
1577+
1578+
1579+
1580+ Q_INVOKABLE void setCachedModelData(const QByteArray& bus,
1581+ const QByteArray& path,
1582+ const QVariantMap& actions,
1583+ const QVariant& data = QVariant());
1584+
1585+private:
1586+ static QPointer<FakeUnityMenuModelCache> theFakeCache;
1587+ QHash<QByteArray, QSharedPointer<UnityMenuModel>> m_models;
1588+};
1589+
1590+#endif // FAKEUNITYMENUMODELCACHE_H
1591
1592=== removed file 'tests/mocks/Unity/Indicators/indicators_fake.qrc'
1593--- tests/mocks/Unity/Indicators/indicators_fake.qrc 2013-06-17 09:02:14 +0000
1594+++ tests/mocks/Unity/Indicators/indicators_fake.qrc 1970-01-01 00:00:00 +0000
1595@@ -1,14 +0,0 @@
1596-<RCC>
1597- <qresource prefix="/tests/indciators">
1598- <file>qml/fake_menu_widget1.qml</file>
1599- <file>qml/fake_menu_widget2.qml</file>
1600- <file>qml/fake_menu_widget3.qml</file>
1601- <file>qml/fake_menu_widget4.qml</file>
1602- <file>qml/fake_menu_widget5.qml</file>
1603- <file>qml/fake_menu_page1.qml</file>
1604- <file>qml/fake_menu_page2.qml</file>
1605- <file>qml/fake_menu_page3.qml</file>
1606- <file>qml/fake_menu_page4.qml</file>
1607- <file>qml/fake_menu_page5.qml</file>
1608- </qresource>
1609-</RCC>
1610
1611=== removed directory 'tests/mocks/Unity/Indicators/qml'
1612=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml'
1613--- tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml 2014-01-14 16:44:35 +0000
1614+++ tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml 1970-01-01 00:00:00 +0000
1615@@ -1,35 +0,0 @@
1616-/*
1617- * Copyright 2013 Canonical Ltd.
1618- *
1619- * This program is free software; you can redistribute it and/or modify
1620- * it under the terms of the GNU General Public License as published by
1621- * the Free Software Foundation; version 3.
1622- *
1623- * This program is distributed in the hope that it will be useful,
1624- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1625- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1626- * GNU General Public License for more details.
1627- *
1628- * You should have received a copy of the GNU General Public License
1629- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1630- */
1631-
1632-import QtQuick 2.0
1633-import Unity.Indicators 0.1 as Indicators
1634-
1635-Indicators.FakeMenuPage {
1636- id: menu_plugin1
1637-
1638- Rectangle {
1639- id: contents
1640- color: "red"
1641-
1642- height: 150
1643- width: 150
1644-
1645- anchors {
1646- horizontalCenter: parent.horizontalCenter
1647- verticalCenter: parent.verticalCenter
1648- }
1649- }
1650-}
1651
1652=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml'
1653--- tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml 2014-01-14 16:44:35 +0000
1654+++ tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml 1970-01-01 00:00:00 +0000
1655@@ -1,35 +0,0 @@
1656-/*
1657- * Copyright 2013 Canonical Ltd.
1658- *
1659- * This program is free software; you can redistribute it and/or modify
1660- * it under the terms of the GNU General Public License as published by
1661- * the Free Software Foundation; version 3.
1662- *
1663- * This program is distributed in the hope that it will be useful,
1664- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1665- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1666- * GNU General Public License for more details.
1667- *
1668- * You should have received a copy of the GNU General Public License
1669- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1670- */
1671-
1672-import QtQuick 2.0
1673-import Unity.Indicators 0.1 as Indicators
1674-
1675-Indicators.FakeMenuPage {
1676- id: menu_plugin2
1677-
1678- Rectangle {
1679- id: contents
1680- color: "blue"
1681-
1682- height: 150
1683- width: 150
1684-
1685- anchors {
1686- horizontalCenter: parent.horizontalCenter
1687- verticalCenter: parent.verticalCenter
1688- }
1689- }
1690-}
1691
1692=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml'
1693--- tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml 2014-01-14 16:44:35 +0000
1694+++ tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml 1970-01-01 00:00:00 +0000
1695@@ -1,35 +0,0 @@
1696-/*
1697- * Copyright 2013 Canonical Ltd.
1698- *
1699- * This program is free software; you can redistribute it and/or modify
1700- * it under the terms of the GNU General Public License as published by
1701- * the Free Software Foundation; version 3.
1702- *
1703- * This program is distributed in the hope that it will be useful,
1704- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1705- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1706- * GNU General Public License for more details.
1707- *
1708- * You should have received a copy of the GNU General Public License
1709- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1710- */
1711-
1712-import QtQuick 2.0
1713-import Unity.Indicators 0.1 as Indicators
1714-
1715-Indicators.FakeMenuPage {
1716- id: menu_plugin3
1717-
1718- Rectangle {
1719- id: contents
1720- color: "yellow"
1721-
1722- height: 150
1723- width: 150
1724-
1725- anchors {
1726- horizontalCenter: parent.horizontalCenter
1727- verticalCenter: parent.verticalCenter
1728- }
1729- }
1730-}
1731
1732=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml'
1733--- tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml 2014-01-14 16:44:35 +0000
1734+++ tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml 1970-01-01 00:00:00 +0000
1735@@ -1,35 +0,0 @@
1736-/*
1737- * Copyright 2013 Canonical Ltd.
1738- *
1739- * This program is free software; you can redistribute it and/or modify
1740- * it under the terms of the GNU General Public License as published by
1741- * the Free Software Foundation; version 3.
1742- *
1743- * This program is distributed in the hope that it will be useful,
1744- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1745- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1746- * GNU General Public License for more details.
1747- *
1748- * You should have received a copy of the GNU General Public License
1749- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1750- */
1751-
1752-import QtQuick 2.0
1753-import Unity.Indicators 0.1 as Indicators
1754-
1755-Indicators.FakeMenuPage {
1756- id: menu_plugin4
1757-
1758- Rectangle {
1759- id: contents
1760- color: "green"
1761-
1762- height: 150
1763- width: 150
1764-
1765- anchors {
1766- horizontalCenter: parent.horizontalCenter
1767- verticalCenter: parent.verticalCenter
1768- }
1769- }
1770-}
1771
1772=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml'
1773--- tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml 2014-01-14 16:44:35 +0000
1774+++ tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml 1970-01-01 00:00:00 +0000
1775@@ -1,35 +0,0 @@
1776-/*
1777- * Copyright 2013 Canonical Ltd.
1778- *
1779- * This program is free software; you can redistribute it and/or modify
1780- * it under the terms of the GNU General Public License as published by
1781- * the Free Software Foundation; version 3.
1782- *
1783- * This program is distributed in the hope that it will be useful,
1784- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1785- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1786- * GNU General Public License for more details.
1787- *
1788- * You should have received a copy of the GNU General Public License
1789- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1790- */
1791-
1792-import QtQuick 2.0
1793-import Unity.Indicators 0.1 as Indicators
1794-
1795-Indicators.FakeMenuPage {
1796- id: menu_plugin5
1797-
1798- Rectangle {
1799- id: contents
1800- color: "orange"
1801-
1802- height: 150
1803- width: 150
1804-
1805- anchors {
1806- horizontalCenter: parent.horizontalCenter
1807- verticalCenter: parent.verticalCenter
1808- }
1809- }
1810-}
1811
1812=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml'
1813--- tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml 2013-06-17 09:02:14 +0000
1814+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml 1970-01-01 00:00:00 +0000
1815@@ -1,23 +0,0 @@
1816-/*
1817- * Copyright 2013 Canonical Ltd.
1818- *
1819- * This program is free software; you can redistribute it and/or modify
1820- * it under the terms of the GNU General Public License as published by
1821- * the Free Software Foundation; version 3.
1822- *
1823- * This program is distributed in the hope that it will be useful,
1824- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1825- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1826- * GNU General Public License for more details.
1827- *
1828- * You should have received a copy of the GNU General Public License
1829- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1830- */
1831-
1832-import QtQuick 2.0
1833-
1834-Rectangle {
1835- width: 40
1836- height: 40
1837- color : "red"
1838-}
1839
1840=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml'
1841--- tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml 2014-01-13 16:25:32 +0000
1842+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml 1970-01-01 00:00:00 +0000
1843@@ -1,23 +0,0 @@
1844-/*
1845- * Copyright 2013 Canonical Ltd.
1846- *
1847- * This program is free software; you can redistribute it and/or modify
1848- * it under the terms of the GNU General Public License as published by
1849- * the Free Software Foundation; version 3.
1850- *
1851- * This program is distributed in the hope that it will be useful,
1852- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1853- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1854- * GNU General Public License for more details.
1855- *
1856- * You should have received a copy of the GNU General Public License
1857- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1858- */
1859-
1860-import QtQuick 2.0
1861-
1862-Rectangle {
1863- width: 40
1864- height: 40
1865- color : "blue"
1866-}
1867
1868=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml'
1869--- tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml 2014-01-13 16:25:32 +0000
1870+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml 1970-01-01 00:00:00 +0000
1871@@ -1,23 +0,0 @@
1872-/*
1873- * Copyright 2013 Canonical Ltd.
1874- *
1875- * This program is free software; you can redistribute it and/or modify
1876- * it under the terms of the GNU General Public License as published by
1877- * the Free Software Foundation; version 3.
1878- *
1879- * This program is distributed in the hope that it will be useful,
1880- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1881- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1882- * GNU General Public License for more details.
1883- *
1884- * You should have received a copy of the GNU General Public License
1885- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1886- */
1887-
1888-import QtQuick 2.0
1889-
1890-Rectangle {
1891- width: 40
1892- height: 40
1893- color : "yellow"
1894-}
1895
1896=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml'
1897--- tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml 2013-06-17 09:02:14 +0000
1898+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml 1970-01-01 00:00:00 +0000
1899@@ -1,23 +0,0 @@
1900-/*
1901- * Copyright 2013 Canonical Ltd.
1902- *
1903- * This program is free software; you can redistribute it and/or modify
1904- * it under the terms of the GNU General Public License as published by
1905- * the Free Software Foundation; version 3.
1906- *
1907- * This program is distributed in the hope that it will be useful,
1908- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1909- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1910- * GNU General Public License for more details.
1911- *
1912- * You should have received a copy of the GNU General Public License
1913- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1914- */
1915-
1916-import QtQuick 2.0
1917-
1918-Rectangle {
1919- width: 40
1920- height: 40
1921- color : "green"
1922-}
1923
1924=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml'
1925--- tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml 2013-06-17 09:02:14 +0000
1926+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml 1970-01-01 00:00:00 +0000
1927@@ -1,23 +0,0 @@
1928-/*
1929- * Copyright 2013 Canonical Ltd.
1930- *
1931- * This program is free software; you can redistribute it and/or modify
1932- * it under the terms of the GNU General Public License as published by
1933- * the Free Software Foundation; version 3.
1934- *
1935- * This program is distributed in the hope that it will be useful,
1936- * but WITHOUT ANY WARRANTY; without even the implied warranty of
1937- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1938- * GNU General Public License for more details.
1939- *
1940- * You should have received a copy of the GNU General Public License
1941- * along with this program. If not, see <http://www.gnu.org/licenses/>.
1942- */
1943-
1944-import QtQuick 2.0
1945-
1946-Rectangle {
1947- width: 40
1948- height: 40
1949- color : "orange"
1950-}
1951
1952=== modified file 'tests/mocks/Unity/Indicators/qmldir'
1953--- tests/mocks/Unity/Indicators/qmldir 2014-08-20 08:39:09 +0000
1954+++ tests/mocks/Unity/Indicators/qmldir 2014-10-15 19:48:28 +0000
1955@@ -3,5 +3,4 @@
1956 typeinfo Indicators.qmltypes
1957
1958 IndicatorsModel 0.1 IndicatorsModel.qml
1959-FakeMenuPage 0.1 FakeMenuPage.qml
1960 RootActionState 0.1 RootActionState.qml
1961
1962=== modified file 'tests/mocks/Unity/Launcher/Launcher.qmltypes'
1963--- tests/mocks/Unity/Launcher/Launcher.qmltypes 2014-06-26 07:47:57 +0000
1964+++ tests/mocks/Unity/Launcher/Launcher.qmltypes 2014-10-15 19:48:28 +0000
1965@@ -85,6 +85,7 @@
1966 Property { name: "recent"; type: "bool"; isReadonly: true }
1967 Property { name: "progress"; type: "int"; isReadonly: true }
1968 Property { name: "count"; type: "int"; isReadonly: true }
1969+ Property { name: "countVisible"; type: "bool"; isReadonly: true }
1970 Property { name: "focused"; type: "bool"; isReadonly: true }
1971 Property {
1972 name: "quickList"
1973@@ -93,6 +94,14 @@
1974 isPointer: true
1975 }
1976 Signal {
1977+ name: "nameChanged"
1978+ Parameter { name: "name"; type: "string" }
1979+ }
1980+ Signal {
1981+ name: "iconChanged"
1982+ Parameter { name: "icon"; type: "string" }
1983+ }
1984+ Signal {
1985 name: "pinnedChanged"
1986 Parameter { name: "pinned"; type: "bool" }
1987 }
1988@@ -113,6 +122,10 @@
1989 Parameter { name: "count"; type: "int" }
1990 }
1991 Signal {
1992+ name: "countVisibleChanged"
1993+ Parameter { name: "countVisible"; type: "bool" }
1994+ }
1995+ Signal {
1996 name: "focusedChanged"
1997 Parameter { name: "focused"; type: "bool" }
1998 }
1999
2000=== modified file 'tests/mocks/Unity/Unity.qmltypes'
2001--- tests/mocks/Unity/Unity.qmltypes 2014-09-01 12:18:53 +0000
2002+++ tests/mocks/Unity/Unity.qmltypes 2014-10-15 19:48:28 +0000
2003@@ -30,6 +30,25 @@
2004 Parameter { name: "row"; type: "int" }
2005 Parameter { name: "role"; type: "int" }
2006 }
2007+ Method {
2008+ name: "setCount"
2009+ Parameter { name: "count"; type: "int" }
2010+ }
2011+ Method {
2012+ name: "resultModel"
2013+ type: "ResultsModel*"
2014+ Parameter { name: "row"; type: "int" }
2015+ }
2016+ Method {
2017+ name: "setLayout"
2018+ Parameter { name: "row"; type: "int" }
2019+ Parameter { name: "layout"; type: "string" }
2020+ }
2021+ Method {
2022+ name: "setHeaderLink"
2023+ Parameter { name: "row"; type: "int" }
2024+ Parameter { name: "headerLink"; type: "string" }
2025+ }
2026 }
2027 Component {
2028 name: "PreviewModel"
2029@@ -66,6 +85,10 @@
2030 exports: ["Unity/FakeResultsModel 0.2", "Unity/ResultsModel 0.2"]
2031 isCreatable: false
2032 exportMetaObjectRevisions: [0, 0]
2033+ Method {
2034+ name: "setResultCount"
2035+ Parameter { name: "result_count"; type: "int" }
2036+ }
2037 }
2038 Component {
2039 name: "Scope"
2040@@ -76,6 +99,15 @@
2041 name: "performQuery"
2042 Parameter { name: "query"; type: "string" }
2043 }
2044+ Signal { name: "refreshed" }
2045+ Method {
2046+ name: "setId"
2047+ Parameter { name: "id"; type: "string" }
2048+ }
2049+ Method {
2050+ name: "setName"
2051+ Parameter { name: "name"; type: "string" }
2052+ }
2053 Method {
2054 name: "setSearchInProgress"
2055 Parameter { name: "inProg"; type: "bool" }
2056
2057=== modified file 'tests/plugins/Unity/Indicators/CMakeLists.txt'
2058--- tests/plugins/Unity/Indicators/CMakeLists.txt 2013-12-10 14:22:43 +0000
2059+++ tests/plugins/Unity/Indicators/CMakeLists.txt 2014-10-15 19:48:28 +0000
2060@@ -40,3 +40,4 @@
2061 indicator_test(menucontentactivatortest ADDITIONAL_CPPS ${INDICATORS_DIR}/menucontentactivator.cpp)
2062 indicator_test(unitymenumodelstacktest ADDITIONAL_CPPS ${TEST_DIR}/mocks/QMenuModel/unitymenumodel.cpp ${INDICATORS_DIR}/unitymenumodelstack.cpp)
2063 indicator_test(rootactionstatetest ADDITIONAL_LIBS IndicatorsQml)
2064+indicator_test(sharedunitymenumodeltest ADDITIONAL_LIBS IndicatorsQml)
2065
2066=== added file 'tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp'
2067--- tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp 1970-01-01 00:00:00 +0000
2068+++ tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp 2014-10-15 19:48:28 +0000
2069@@ -0,0 +1,102 @@
2070+/*
2071+ * Copyright 2014 Canonical Ltd.
2072+ *
2073+ * This program is free software; you can redistribute it and/or modify
2074+ * it under the terms of the GNU Lesser General Public License as published by
2075+ * the Free Software Foundation; version 3.
2076+ *
2077+ * This program is distributed in the hope that it will be useful,
2078+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
2079+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2080+ * GNU Lesser General Public License for more details.
2081+ *
2082+ * You should have received a copy of the GNU Lesser General Public License
2083+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
2084+ *
2085+ */
2086+
2087+#include "sharedunitymenumodel.h"
2088+#include "unitymenumodelcache.h"
2089+
2090+#include <QtTest>
2091+#include <unitymenumodel.h>
2092+
2093+class SharedUnityMenuModelTest : public QObject
2094+{
2095+ Q_OBJECT
2096+
2097+ SharedUnityMenuModel* createFullModel(const QByteArray& testId)
2098+ {
2099+ SharedUnityMenuModel* model = new SharedUnityMenuModel;
2100+ model->setBusName("com.canonical." + testId);
2101+ model->setMenuObjectPath("/com/canonical/" + testId);
2102+ QVariantMap actions;
2103+ actions["test"] = QString("/com/canonical/%1/actions").arg(QString(testId));
2104+ model->setActions(actions);
2105+
2106+ return model;
2107+ }
2108+
2109+private Q_SLOTS:
2110+
2111+ void testCreateModel()
2112+ {
2113+ QSharedPointer<SharedUnityMenuModel> model(createFullModel("test1"));
2114+ QVERIFY(model->model() != nullptr);
2115+ }
2116+
2117+ void testDifferentDataCreatesDifferentModels()
2118+ {
2119+ QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
2120+ QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test2"));
2121+
2122+ QVERIFY(model1->model() != model2->model());
2123+ }
2124+
2125+ void testSameDataCreatesSameModels()
2126+ {
2127+ QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
2128+ QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test1"));
2129+
2130+ QCOMPARE(model1->model(), model2->model());
2131+ }
2132+
2133+ void testSharedOwnership()
2134+ {
2135+ QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
2136+ QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test1"));
2137+
2138+ QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), true);
2139+ model1.clear();
2140+ QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), true);
2141+ model2.clear();
2142+ QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), false);
2143+ }
2144+
2145+ // Tests that changing cached model data does not change the model path of others
2146+ void testLP1328646()
2147+ {
2148+ QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
2149+ QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test1"));
2150+
2151+ model2->setMenuObjectPath("/com/canonical/LP1328646");
2152+
2153+ QVERIFY(model1->model() != model2->model());
2154+ QCOMPARE(model1->model()->menuObjectPath(), QByteArray("/com/canonical/test1"));
2155+ QCOMPARE(model2->model()->menuObjectPath(), QByteArray("/com/canonical/LP1328646"));
2156+ }
2157+
2158+ // Tests that the cache is recreated if deleted.
2159+ void testDeletedCache()
2160+ {
2161+ QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
2162+
2163+ QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), true);
2164+ delete UnityMenuModelCache::singleton();
2165+ QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), false);
2166+ }
2167+
2168+};
2169+
2170+QTEST_GUILESS_MAIN(SharedUnityMenuModelTest)
2171+#include "sharedunitymenumodeltest.moc"
2172
2173=== modified file 'tests/qmltests/CMakeLists.txt'
2174--- tests/qmltests/CMakeLists.txt 2014-10-01 13:22:00 +0000
2175+++ tests/qmltests/CMakeLists.txt 2014-10-15 19:48:28 +0000
2176@@ -19,9 +19,9 @@
2177 set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
2178 set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C")
2179
2180-add_qml_test(. Shell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")
2181-add_qml_test(. ShellWithPin ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single-pin")
2182-add_qml_test(. TabletShell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")
2183+add_qml_test(. Shell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2184+add_qml_test(. ShellWithPin ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single-pin:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2185+add_qml_test(. TabletShell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2186 add_qml_test(Components Background)
2187 add_qml_test(Components Carousel)
2188 add_qml_test(Components DraggingArea)
2189@@ -72,14 +72,13 @@
2190 add_qml_test(Notifications Notifications)
2191 add_qml_test(Notifications VisualSnapDecisionsQueue)
2192 add_qml_test(Panel ActiveCallHint)
2193-add_qml_test(Panel IndicatorRow)
2194-add_qml_test(Panel Indicators)
2195-add_qml_test(Panel MenuContent)
2196-add_qml_test(Panel Panel)
2197+add_qml_test(Panel IndicatorRow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2198+add_qml_test(Panel Indicators ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2199+add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2200+add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2201 add_qml_test(Panel SearchIndicator)
2202 add_qml_test(Panel/Indicators DefaultIndicatorWidget ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2203 add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2204-add_qml_test(Panel/Indicators CachedUnityMenuModel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
2205 # These MenuItemFactory tests need the test/mocks/ to come before plugins/
2206 add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
2207 add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
2208
2209=== modified file 'tests/qmltests/Greeter/tst_Clock.qml'
2210--- tests/qmltests/Greeter/tst_Clock.qml 2014-05-01 14:25:18 +0000
2211+++ tests/qmltests/Greeter/tst_Clock.qml 2014-10-15 19:48:28 +0000
2212@@ -19,7 +19,7 @@
2213 import ".."
2214 import "../../../qml/Greeter"
2215 import Ubuntu.Components 0.1
2216-import QMenuModel 0.1
2217+import Unity.Indicators 0.1 as Indicators
2218 import Unity.Test 0.1 as UT
2219
2220 Rectangle {
2221@@ -36,56 +36,73 @@
2222 }
2223 }
2224
2225- UnityMenuModel {
2226- id: menuModel
2227- modelData: [{
2228- "rowData": {
2229- "actionState": { "label": Qt.formatTime(new Date("October 13, 1975 11:13:00")) }
2230- }
2231- }]
2232+ function updateDatetimeModelTime(label) {
2233+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicator.datetime",
2234+ "/com/canonical/indicator/datetime/phone",
2235+ "/com/canonical/indicator/datetime",
2236+ [{
2237+ "rowData": {
2238+ "actionState": { "label": label }
2239+ }
2240+ }]);
2241 }
2242
2243 UT.UnityTestCase {
2244 name: "Clock"
2245+ when: windowShown
2246
2247 function init() {
2248- var cachedModel = findChild(clock, "timeModel");
2249- verify(cachedModel !== undefined);
2250- cachedModel.model = menuModel;
2251- }
2252-
2253- function test_customDate() {
2254- var dateObj = new Date("October 13, 1975 11:13:00")
2255- var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
2256- var timeString = Qt.formatTime(dateObj)
2257-
2258- clock.currentDate = dateObj
2259- var dateLabel = findChild(clock, "dateLabel")
2260- compare(dateLabel.text, dateString, "Not the expected date")
2261- var timeLabel = findChild(clock, "timeLabel")
2262- compare(timeLabel.text, timeString, "Not the expected time")
2263- }
2264-
2265- function test_dateUpdate() {
2266- var dateObj = new Date("October 13, 1975 11:13:00")
2267- var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)
2268- var timeString = Qt.formatTime(dateObj)
2269-
2270+ updateDatetimeModelTime(Qt.formatTime(new Date("October 13, 1975 12:14:00")));
2271+ clock.visible = true;
2272+ }
2273+
2274+ // Test that the date portion of the clock updates with custom value.
2275+ // Time portion is controlled by indicators
2276+ function test_updateDate() {
2277+ var dateLabel = findChild(clock, "dateLabel");
2278+ var timeLabel = findChild(clock, "timeLabel");
2279+
2280+ var timeString = Qt.formatTime(new Date("October 13, 1975 12:14:00"));
2281+
2282+ // initial date.
2283+ var dateObj = new Date("October 13, 1975 11:13:00");
2284+ var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate);
2285+ clock.currentDate = dateObj;
2286+
2287+ compare(dateLabel.text, dateString, "Not the expected date");
2288+ compare(timeLabel.text, timeString, "Time should come from indicators");
2289+
2290+ // update date.
2291+ var dateObj2 = new Date("October 14, 1976 13:15:00");
2292+ var dateString2 = Qt.formatDate(dateObj2, Qt.DefaultLocaleLongDate);
2293+ clock.currentDate = dateObj2;
2294+
2295+ compare(dateLabel.text, dateString2, "Not the expected date");
2296+ compare(timeLabel.text,timeString, "Time should come from indicators");
2297+ }
2298+
2299+ // Test that the date portion of the clock updates with custom value.
2300+ // Time portion is controlled by indicators
2301+ function test_updateTime() {
2302+ var timeLabel = findChild(clock, "timeLabel");
2303+
2304+ var timeString1 = Qt.formatTime(new Date("October 13, 1975 11:15:00"));
2305+ var timeString2 = Qt.formatTime(new Date("October 14, 1976 12:16:00"));
2306+
2307+ updateDatetimeModelTime(timeString1);
2308+ compare(timeLabel.text, timeString1, "Time should come from indicators");
2309+
2310+ updateDatetimeModelTime(timeString2);
2311+ compare(timeLabel.text, timeString2, "Time should come from indicators");
2312+ }
2313+
2314+ function test_indicatorDisconnect() {
2315 clock.visible = false
2316 var timeModel = findInvisibleChild(clock, "timeModel")
2317-
2318 compare(timeModel.menuObjectPath, "", "Clock shouldn't be connected to Indicators when not visible.")
2319
2320- clock.currentDate = dateObj
2321-
2322- var dateLabel = findChild(clock, "dateLabel")
2323- compare(dateLabel.text, dateString, "Not the expected date")
2324- var timeLabel = findChild(clock, "timeLabel")
2325- compare(timeLabel.text, timeString, "Not the expected time")
2326-
2327 clock.visible = true
2328-
2329- verify(timeModel.menuObjectPath != "", "Should be connected to Indicators.")
2330+ verify(timeModel.menuObjectPath !== "", "Should be connected to Indicators.")
2331 }
2332 }
2333 }
2334
2335=== removed file 'tests/qmltests/Panel/Indicators/tst_CachedUnityMenuModel.qml'
2336--- tests/qmltests/Panel/Indicators/tst_CachedUnityMenuModel.qml 2014-08-20 09:16:28 +0000
2337+++ tests/qmltests/Panel/Indicators/tst_CachedUnityMenuModel.qml 1970-01-01 00:00:00 +0000
2338@@ -1,137 +0,0 @@
2339-/*
2340- * Copyright 2014 Canonical Ltd.
2341- *
2342- * This program is free software; you can redistribute it and/or modify
2343- * it under the terms of the GNU General Public License as published by
2344- * the Free Software Foundation; version 3.
2345- *
2346- * This program is distributed in the hope that it will be useful,
2347- * but WITHOUT ANY WARRANTY; without even the implied warranty of
2348- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2349- * GNU General Public License for more details.
2350- *
2351- * You should have received a copy of the GNU General Public License
2352- * along with this program. If not, see <http://www.gnu.org/licenses/>.
2353- */
2354-
2355-import QtQuick 2.0
2356-import QtTest 1.0
2357-import Unity.Test 0.1 as UT
2358-import QMenuModel 0.1
2359-import Unity.Indicators 0.1 as Indicators
2360-import "../../../../qml/Panel/Indicators"
2361-
2362-Item {
2363- id: root
2364- width: units.gu(40)
2365- height: units.gu(70)
2366-
2367- Component {
2368- id: model
2369- CachedUnityMenuModel {}
2370- }
2371-
2372- UT.UnityTestCase {
2373- name: "CachedUnityMenuModel"
2374- when: windowShown
2375-
2376- function cleanup() {
2377- doGC();
2378- }
2379-
2380- function doGC() {
2381- // need to put some wait cycles here to get gc going properly.
2382- wait(10);
2383- gc();
2384- wait(10);
2385- }
2386-
2387- function test_createDifferent() {
2388- var cachedObject = model.createObject(null,
2389- {
2390- "busName": "com.canonical.test1",
2391- "menuObjectPath": "/com/canonical/test1",
2392- "actionsObjectPath": "/com/canonical/test1"
2393- });
2394-
2395- var cachedObject2 = model.createObject(null,
2396- {
2397- "busName": "com.canonical.test2",
2398- "menuObjectPath": "/com/canonical/test2",
2399- "actionsObjectPath": "/com/canonical/test2"
2400- });
2401-
2402- verify(cachedObject.model !== cachedObject2.model);
2403- }
2404-
2405- function test_createSame() {
2406- var cachedObject = model.createObject(null,
2407- {
2408- "busName": "com.canonical.test3",
2409- "menuObjectPath": "/com/canonical/test3",
2410- "actionsObjectPath": "/com/canonical/test3"
2411- });
2412-
2413- var cachedObject2 = model.createObject(null,
2414- {
2415- "busName": "com.canonical.test3",
2416- "menuObjectPath": "/com/canonical/test3",
2417- "actionsObjectPath": "/com/canonical/test3"
2418- });
2419-
2420- verify(cachedObject.model === cachedObject2.model);
2421- }
2422-
2423- // Tests that changing cached model data does not change the model path of others
2424- function test_lp1328646() {
2425- var cachedObject = model.createObject(null,
2426- {
2427- "busName": "com.canonical.test4",
2428- "menuObjectPath": "/com/canonical/test4",
2429- "actionsObjectPath": "/com/canonical/test4"
2430- });
2431-
2432- var cachedObject2 = model.createObject(null,
2433- {
2434- "busName": "com.canonical.test4",
2435- "menuObjectPath": "/com/canonical/test4",
2436- "actionsObjectPath": "/com/canonical/test4"
2437- });
2438-
2439- cachedObject.menuObjectPath = "/com/canonical/test5";
2440- compare(cachedObject.model.menuObjectPath, "/com/canonical/test5");
2441- compare(cachedObject2.model.menuObjectPath, "/com/canonical/test4");
2442-
2443- verify(cachedObject.model !== cachedObject2.model);
2444- }
2445-
2446- function createAndDestroy(test) {
2447- var cachedObject = model.createObject(null,
2448- {
2449- "busName": "com.canonical."+test,
2450- "menuObjectPath": "/com/canonical/"+test,
2451- "actionsObjectPath": "/com/canonical/"+test
2452- });
2453- var cachedObject2 = model.createObject(null,
2454- {
2455- "busName": "com.canonical."+test,
2456- "menuObjectPath": "/com/canonical/"+test,
2457- "actionsObjectPath": "/com/canonical/"+test
2458- });
2459- cachedObject.destroy();
2460- return cachedObject2;
2461- }
2462-
2463- function test_destroyAllDeletesModel() {
2464- createAndDestroy("test6");
2465- doGC();
2466- compare(Indicators.UnityMenuModelCache.contains("/com/canonical/test6"), false);
2467- }
2468-
2469- function test_destroyPartialKeepsModel() {
2470- var model = createAndDestroy("test7");
2471- doGC();
2472- compare(Indicators.UnityMenuModelCache.contains("/com/canonical/test7"), true);
2473- }
2474- }
2475-}
2476
2477=== modified file 'tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml'
2478--- tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml 2014-09-29 10:24:58 +0000
2479+++ tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml 2014-10-15 19:48:28 +0000
2480@@ -17,7 +17,7 @@
2481 import QtQuick 2.0
2482 import QtTest 1.0
2483 import Unity.Test 0.1 as UT
2484-import QMenuModel 0.1
2485+import Unity.Indicators 0.1 as Indicators
2486 import "../../../../qml/Panel/Indicators"
2487
2488 Item {
2489@@ -25,18 +25,14 @@
2490 width: units.gu(40)
2491 height: units.gu(70)
2492
2493- DefaultIndicatorPage {
2494+ DefaultIndicatorPage {
2495 id: page
2496-
2497 anchors.fill: parent
2498
2499- menuModel: UnityMenuModel {}
2500- busName: "test"
2501- actionsObjectPath: "test"
2502- menuObjectPath: "test"
2503-
2504 identifier: "test-indicator"
2505- rootMenuType: "com.canonical.indicator.root"
2506+ busName: "com.caninical.indicator.test"
2507+ actionsObjectPath: "/com/canonical/indicator/test"
2508+ menuObjectPath: "/com/canonical/indicator/test"
2509 }
2510
2511 property var fullMenuData: [{
2512@@ -113,29 +109,30 @@
2513 "submenu": []
2514 }]; // end row 1
2515
2516+ function initializeMenuData(data) {
2517+ Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicator.test",
2518+ "/com/canonical/indicator/test",
2519+ "/com/canonical/indicator/test",
2520+ data);
2521+ }
2522+
2523 UT.UnityTestCase {
2524 name: "DefaultIndicatorPage"
2525
2526 function init() {
2527- var mainMenu = findChild(page, "mainMenu");
2528- page.menuModel.modelData = [];
2529- verify(mainMenu.model !== null);
2530+ initializeMenuData([]);
2531 }
2532
2533 function test_reloadData() {
2534 var mainMenu = findChild(page, "mainMenu");
2535
2536- page.menuModel.modelData = [];
2537- tryCompare(mainMenu, "count", 0);
2538-
2539- page.menuModel.modelData = fullMenuData;
2540- tryCompare(mainMenu, "count", 3);
2541-
2542- page.menuModel.modelData = [];
2543- tryCompare(mainMenu, "count", 0);
2544-
2545- page.menuModel.modelData = fullMenuData;
2546- tryCompare(mainMenu, "count", 3);
2547+ tryCompare(mainMenu, "count", 0);
2548+
2549+ initializeMenuData(fullMenuData);
2550+ tryCompare(mainMenu, "count", 3);
2551+
2552+ initializeMenuData([]);
2553+ tryCompare(mainMenu, "count", 0);
2554 }
2555
2556 function test_traverse_rootMenuType_data() {
2557@@ -147,7 +144,7 @@
2558
2559 function test_traverse_rootMenuType(data) {
2560 page.rootMenuType = data.rootMenuType;
2561- page.menuModel.modelData = fullMenuData;
2562+ initializeMenuData(fullMenuData);
2563
2564 var mainMenu = findChild(page, "mainMenu");
2565 tryCompare(mainMenu, "count", data.expectedCount);
2566
2567=== modified file 'tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml'
2568--- tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml 2014-07-03 13:46:51 +0000
2569+++ tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml 2014-10-15 19:48:28 +0000
2570@@ -33,7 +33,6 @@
2571 top: parent.top
2572 }
2573
2574- menuModel: UnityMenuModel {}
2575 busName: "test"
2576 actionsObjectPath: "test"
2577 deviceMenuObjectPath: "test"
2578@@ -48,13 +47,6 @@
2579 name: "DefaultIndicatorWidget"
2580 when: windowShown
2581
2582- function init() {
2583- widget.rootActionState.icons = [];
2584- widget.rootActionState.leftLabel = "";
2585- widget.rootActionState.rightLabel = "";
2586- waitForRendering(widget)
2587- }
2588-
2589 // FIXME: add tests
2590 }
2591 }
2592
2593=== modified file 'tests/qmltests/Panel/tst_IndicatorItem.qml'
2594--- tests/qmltests/Panel/tst_IndicatorItem.qml 2014-01-07 14:29:23 +0000
2595+++ tests/qmltests/Panel/tst_IndicatorItem.qml 2014-10-15 19:48:28 +0000
2596@@ -43,7 +43,7 @@
2597
2598 function test_empty() {
2599 compare(indicatorItem.indicatorVisible, false, "IndicatorItem should not be visible.");
2600- indicatorItem.widgetSource = "qrc:/tests/indciators/qml/fake_menu_widget1.qml";
2601+ indicatorItem.widgetSource = "../../../qml/Panel/Indicators/DefaultIndicatorWidget.qml";
2602 tryCompare(indicatorItem, "indicatorVisible", true);
2603 }
2604 }
2605
2606=== modified file 'tests/qmltests/Panel/tst_IndicatorRow.qml'
2607--- tests/qmltests/Panel/tst_IndicatorRow.qml 2014-03-03 11:55:00 +0000
2608+++ tests/qmltests/Panel/tst_IndicatorRow.qml 2014-10-15 19:48:28 +0000
2609@@ -30,15 +30,6 @@
2610 width: units.gu(40)
2611 height: units.gu(60)
2612
2613- function init_test()
2614- {
2615- indicatorModel.load("test1");
2616-
2617- indicatorRow.state = "initial";
2618- indicatorRow.setCurrentItemIndex(-1);
2619- indicatorRow.unitProgress = 0.0;
2620- }
2621-
2622 PanelBackground {
2623 anchors.fill: indicatorRow
2624 }
2625@@ -63,20 +54,33 @@
2626 name: "IndicatorRow"
2627 when: windowShown
2628
2629+ function init() {
2630+ indicatorModel.load("test1");
2631+
2632+ indicatorRow.state = "initial";
2633+ indicatorRow.setCurrentItemIndex(-1);
2634+ indicatorRow.unitProgress = 0.0;
2635+ }
2636+
2637 function get_indicator_item(index) {
2638 return findChild(indicatorRow.row, "item" + index);
2639 }
2640
2641 function test_set_current_item() {
2642- init_test();
2643 indicatorRow.setCurrentItemIndex(0);
2644- compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake1", "Incorrect item at position 0");
2645+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier),
2646+ "indicator-fake1",
2647+ "Incorrect item at position 0");
2648
2649 indicatorRow.setCurrentItemIndex(1);
2650- compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake2", "Incorrect item at position 1");
2651+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier),
2652+ "indicator-fake2",
2653+ "Incorrect item at position 1");
2654
2655 indicatorRow.setCurrentItemIndex(2);
2656- compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake3", "Incorrect item at position 2");
2657+ compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier),
2658+ "indicator-fake3",
2659+ "Incorrect item at position 2");
2660 }
2661
2662 function test_highlight_data() {
2663@@ -93,8 +97,6 @@
2664 }
2665
2666 function test_highlight(data) {
2667- init_test();
2668-
2669 indicatorRow.unitProgress = data.progress;
2670 indicatorRow.setCurrentItemIndex(data.index);
2671
2672@@ -119,8 +121,6 @@
2673 }
2674
2675 function test_opacity(data) {
2676- init_test();
2677-
2678 indicatorRow.unitProgress = data.progress;
2679 indicatorRow.setCurrentItemIndex(data.index);
2680
2681@@ -145,8 +145,6 @@
2682 }
2683
2684 function test_dimmed(data) {
2685- init_test();
2686-
2687 indicatorRow.unitProgress = data.progress;
2688 indicatorRow.setCurrentItemIndex(data.index);
2689
2690
2691=== modified file 'tests/qmltests/Panel/tst_Indicators.qml'
2692--- tests/qmltests/Panel/tst_Indicators.qml 2014-07-30 16:01:09 +0000
2693+++ tests/qmltests/Panel/tst_Indicators.qml 2014-10-15 19:48:28 +0000
2694@@ -158,6 +158,7 @@
2695 function init_invisible_indicator(identifier) {
2696 tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);
2697 var item = findChild(indicators, identifier+"-delegate");
2698+ verify(item !== null);
2699
2700 item.enabled = false;
2701 }
2702
2703=== modified file 'tests/qmltests/Panel/tst_MenuContent.qml'
2704--- tests/qmltests/Panel/tst_MenuContent.qml 2014-09-09 15:10:52 +0000
2705+++ tests/qmltests/Panel/tst_MenuContent.qml 2014-10-15 19:48:28 +0000
2706@@ -26,14 +26,6 @@
2707 width: units.gu(40)
2708 height: units.gu(70)
2709
2710- property var indicator_status: {
2711- 'indicator-fake1-page': { 'started': false, 'reset': 0 },
2712- 'indicator-fake2-page': { 'started': false, 'reset': 0 },
2713- 'indicator-fake3-page': { 'started': false, 'reset': 0 },
2714- 'indicator-fake4-page': { 'started': false, 'reset': 0 },
2715- 'indicator-fake5-page': { 'started': false, 'reset': 0 }
2716- }
2717-
2718 // Dummy objects
2719 Item { id: greeter }
2720 Item { id: handle }
2721
2722=== modified file 'tests/qmltests/tst_Shell.qml'
2723--- tests/qmltests/tst_Shell.qml 2014-10-13 15:42:40 +0000
2724+++ tests/qmltests/tst_Shell.qml 2014-10-15 19:48:28 +0000
2725@@ -25,14 +25,16 @@
2726 import Ubuntu.Telephony 0.1 as Telephony
2727 import Unity.Application 0.1
2728 import Unity.Connectivity 0.1
2729+import Unity.Notifications 1.0
2730 import Unity.Test 0.1 as UT
2731 import Powerd 0.1
2732
2733 import "../../qml"
2734
2735-Row {
2736+Item {
2737 id: root
2738- spacing: 0
2739+ width: units.gu(60)
2740+ height: units.gu(71)
2741
2742 QtObject {
2743 id: applicationArguments
2744@@ -50,47 +52,43 @@
2745 }
2746 }
2747
2748- Loader {
2749- id: shellLoader
2750-
2751- // Copied from Shell.qml
2752- property bool tablet: false
2753- width: tablet ? units.gu(160)
2754- : applicationArguments.hasGeometry() ? applicationArguments.width()
2755- : units.gu(40)
2756- height: tablet ? units.gu(100)
2757- : applicationArguments.hasGeometry() ? applicationArguments.height()
2758- : units.gu(71)
2759-
2760- property bool itemDestroyed: false
2761- sourceComponent: Component {
2762- Shell {
2763- Component.onDestruction: {
2764- shellLoader.itemDestroyed = true;
2765+ Row {
2766+ anchors.fill: parent
2767+ Loader {
2768+ id: shellLoader
2769+
2770+ property bool itemDestroyed: false
2771+ sourceComponent: Component {
2772+ property string indicatorProfile: "phone"
2773+
2774+ Shell {
2775+ Component.onDestruction: {
2776+ shellLoader.itemDestroyed = true;
2777+ }
2778 }
2779 }
2780 }
2781- }
2782-
2783- Rectangle {
2784- color: "white"
2785- width: units.gu(30)
2786- height: shellLoader.height
2787-
2788- Column {
2789- anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
2790- spacing: units.gu(1)
2791- Row {
2792- anchors { left: parent.left; right: parent.right }
2793- Button {
2794- text: "Show Greeter"
2795- onClicked: {
2796- if (shellLoader.status !== Loader.Ready)
2797- return;
2798-
2799- var greeter = testCase.findChild(shellLoader.item, "greeter");
2800- if (!greeter.shown) {
2801- greeter.show();
2802+
2803+ Rectangle {
2804+ color: "white"
2805+ width: units.gu(30)
2806+ height: shellLoader.height
2807+
2808+ Column {
2809+ anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
2810+ spacing: units.gu(1)
2811+ Row {
2812+ anchors { left: parent.left; right: parent.right }
2813+ Button {
2814+ text: "Show Greeter"
2815+ onClicked: {
2816+ if (shellLoader.status !== Loader.Ready)
2817+ return;
2818+
2819+ var greeter = testCase.findChild(shellLoader.item, "greeter");
2820+ if (!greeter.shown) {
2821+ greeter.show();
2822+ }
2823 }
2824 }
2825 }
2826@@ -98,6 +96,31 @@
2827 }
2828 }
2829
2830+ Component {
2831+ id: mockNotification
2832+
2833+ QtObject {
2834+ function invokeAction(actionId) {
2835+ mockNotificationsModel.actionInvoked(actionId)
2836+ }
2837+ }
2838+ }
2839+ ListModel {
2840+ id: mockNotificationsModel
2841+
2842+ signal actionInvoked(string actionId)
2843+
2844+ function getRaw(id) {
2845+ return mockNotification.createObject(mockNotificationsModel)
2846+ }
2847+
2848+ onActionInvoked: {
2849+ if(actionId == "ok_id") {
2850+ mockNotificationsModel.clear()
2851+ }
2852+ }
2853+ }
2854+
2855 SignalSpy {
2856 id: launcherShowDashHomeSpy
2857 signalName: "showDashHome"
2858@@ -119,6 +142,12 @@
2859 signalName: "unlockingAllModems"
2860 }
2861
2862+ SignalSpy {
2863+ id: notificationActionSpy
2864+ target: mockNotificationsModel
2865+ signalName: "actionInvoked"
2866+ }
2867+
2868 Telephony.CallEntry {
2869 id: phoneCall
2870 phoneNumber: "+447812221111"
2871@@ -178,6 +207,65 @@
2872 compare(ApplicationManager.count, 1)
2873 }
2874
2875+ function test_snapDecisionDismissalReturnsFocus() {
2876+ var notifications = findChild(shell, "notificationList");
2877+ var app = ApplicationManager.startApplication("camera-app");
2878+ var stage = findChild(shell, "stage")
2879+ // Open an application and focus
2880+ waitUntilApplicationWindowIsFullyVisible(app);
2881+ ApplicationManager.focusApplication(app);
2882+ tryCompare(app.session.surface, "activeFocus", true);
2883+
2884+ notifications.model = mockNotificationsModel;
2885+
2886+ // FIXME: Hack: SortFilterProxyModelQML doesn't work with QML ListModels which we use
2887+ // for mocking here (RoleType can't be found in the QML model). As we only need to show
2888+ // one SnapDecision lets just disable the filtering and make appear any notification as a
2889+ // SnapDecision.
2890+ var snapDecisionProxyModel = findInvisibleChild(shell, "snapDecisionProxyModel");
2891+ snapDecisionProxyModel.filterRegExp = RegExp("");
2892+
2893+ // Pop-up a notification
2894+ addSnapDecisionNotification();
2895+ waitForRendering(shell);
2896+
2897+ // Make sure the notification really opened
2898+ var notification = findChild(notifications, "notification" + (mockNotificationsModel.count - 1));
2899+ verify(notification !== undefined && notification != null, "notification wasn't found");
2900+ tryCompare(notification, "height", notification.implicitHeight)
2901+ waitForRendering(notification);
2902+
2903+ // Make sure activeFocus went away from the app window
2904+ tryCompare(app.session.surface, "activeFocus", false);
2905+ tryCompare(stage, "interactive", false);
2906+
2907+ // Clicking the button should dismiss the notification and return focus
2908+ var buttonAccept = findChild(notification, "notify_button0");
2909+ mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
2910+
2911+ // Make sure we're back to normal
2912+ tryCompare(app.session.surface, "activeFocus", true);
2913+ compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
2914+ }
2915+
2916+ function addSnapDecisionNotification() {
2917+ var n = {
2918+ type: Notification.SnapDecision,
2919+ hints: {"x-canonical-private-affirmative-tint": "true"},
2920+ summary: "Tom Ato",
2921+ body: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.",
2922+ icon: "../graphics/avatars/funky.png",
2923+ secondaryIcon: "../graphics/applicationIcons/facebook.png",
2924+ actions: [{ id: "ok_id", label: "Ok"},
2925+ { id: "cancel_id", label: "Cancel"},
2926+ { id: "notreally_id", label: "Not really"},
2927+ { id: "noway_id", label: "messages:No way"},
2928+ { id: "nada_id", label: "messages:Nada"}]
2929+ }
2930+
2931+ mockNotificationsModel.append(n)
2932+ }
2933+
2934 function test_leftEdgeDrag_data() {
2935 return [
2936 {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true},
2937
2938=== modified file 'tests/qmltests/tst_ShellWithPin.qml'
2939--- tests/qmltests/tst_ShellWithPin.qml 2014-10-13 15:42:15 +0000
2940+++ tests/qmltests/tst_ShellWithPin.qml 2014-10-15 19:48:28 +0000
2941@@ -61,6 +61,8 @@
2942 property bool itemDestroyed: false
2943 sourceComponent: Component {
2944 Shell {
2945+ property string indicatorProfile: "phone"
2946+
2947 Component.onDestruction: {
2948 shellLoader.itemDestroyed = true
2949 }
2950
2951=== modified file 'tests/qmltests/tst_TabletShell.qml'
2952--- tests/qmltests/tst_TabletShell.qml 2014-10-09 13:05:21 +0000
2953+++ tests/qmltests/tst_TabletShell.qml 2014-10-15 19:48:28 +0000
2954@@ -57,6 +57,8 @@
2955 property bool itemDestroyed: false
2956 sourceComponent: Component {
2957 Shell {
2958+ property string indicatorProfile: "phone"
2959+
2960 Component.onDestruction: {
2961 shellLoader.itemDestroyed = true
2962 }

Subscribers

People subscribed via source and target branches