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
=== modified file 'plugins/AccountsService/AccountsService.qmltypes'
--- plugins/AccountsService/AccountsService.qmltypes 2014-09-01 12:18:53 +0000
+++ plugins/AccountsService/AccountsService.qmltypes 2014-10-15 19:48:28 +0000
@@ -23,6 +23,8 @@
23 }23 }
24 Property { name: "user"; type: "string" }24 Property { name: "user"; type: "string" }
25 Property { name: "demoEdges"; type: "bool" }25 Property { name: "demoEdges"; type: "bool" }
26 Property { name: "enableLauncherWhileLocked"; type: "bool"; isReadonly: true }
27 Property { name: "enableIndicatorsWhileLocked"; type: "bool"; isReadonly: true }
26 Property { name: "backgroundFile"; type: "string"; isReadonly: true }28 Property { name: "backgroundFile"; type: "string"; isReadonly: true }
27 Property { name: "statsWelcomeScreen"; type: "bool"; isReadonly: true }29 Property { name: "statsWelcomeScreen"; type: "bool"; isReadonly: true }
28 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }30 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
2931
=== modified file 'plugins/Dash/Dash.qmltypes'
--- plugins/Dash/Dash.qmltypes 2014-08-14 01:28:06 +0000
+++ plugins/Dash/Dash.qmltypes 2014-10-15 19:48:28 +0000
@@ -40,9 +40,12 @@
40 Property { name: "forceNoClip"; type: "bool" }40 Property { name: "forceNoClip"; type: "bool" }
41 Property { name: "stickyHeaderHeight"; type: "int"; isReadonly: true }41 Property { name: "stickyHeaderHeight"; type: "int"; isReadonly: true }
42 Property { name: "headerItemShownHeight"; type: "double"; isReadonly: true }42 Property { name: "headerItemShownHeight"; type: "double"; isReadonly: true }
43 Property { name: "cacheBuffer"; type: "double" }
43 Signal { name: "headerChanged" }44 Signal { name: "headerChanged" }
44 Method { name: "positionAtBeginning" }45 Method { name: "positionAtBeginning" }
45 Method { name: "showHeader" }46 Method { name: "showHeader" }
47 Method { name: "firstCreatedIndex"; type: "int" }
48 Method { name: "createdItemCount"; type: "int" }
46 Method {49 Method {
47 name: "item"50 name: "item"
48 type: "QQuickItem*"51 type: "QQuickItem*"
4952
=== modified file 'plugins/LightDM/LightDM.qmltypes'
--- plugins/LightDM/LightDM.qmltypes 2014-09-01 12:18:53 +0000
+++ plugins/LightDM/LightDM.qmltypes 2014-10-15 19:48:28 +0000
@@ -37,6 +37,7 @@
37 Signal { name: "isActiveChanged" }37 Signal { name: "isActiveChanged" }
38 Signal { name: "isAuthenticatedChanged" }38 Signal { name: "isAuthenticatedChanged" }
39 Signal { name: "showGreeter" }39 Signal { name: "showGreeter" }
40 Signal { name: "hideGreeter" }
40 Signal {41 Signal {
41 name: "requestAuthenticationUser"42 name: "requestAuthenticationUser"
42 Parameter { name: "user"; type: "string" }43 Parameter { name: "user"; type: "string" }
4344
=== modified file 'plugins/Ubuntu/Payments/Payments.qmltypes'
--- plugins/Ubuntu/Payments/Payments.qmltypes 2014-06-27 20:53:24 +0000
+++ plugins/Ubuntu/Payments/Payments.qmltypes 2014-10-15 19:48:28 +0000
@@ -37,6 +37,7 @@
37 Parameter { name: "error"; type: "string" }37 Parameter { name: "error"; type: "string" }
38 }38 }
39 Signal { name: "purchaseCompleted" }39 Signal { name: "purchaseCompleted" }
40 Signal { name: "purchaseCancelled" }
40 Method { name: "start" }41 Method { name: "start" }
41 }42 }
42}43}
4344
=== modified file 'plugins/Unity/DashCommunicator/DashCommunicator.qmltypes'
--- plugins/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-08-14 13:33:28 +0000
+++ plugins/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-10-15 19:48:28 +0000
@@ -9,14 +9,14 @@
9Module {9Module {
10 Component {10 Component {
11 name: "DashCommunicator"11 name: "DashCommunicator"
12 prototype: "QObject"12 prototype: "QThread"
13 exports: ["Unity.DashCommunicator/DashCommunicator 0.1"]13 exports: ["Unity.DashCommunicator/DashCommunicator 0.1"]
14 exportMetaObjectRevisions: [0]14 exportMetaObjectRevisions: [0]
15 Method {15 Method {
16 name: "setCurrentScope"16 name: "setCurrentScope"
17 Parameter { name: "scopeId"; type: "string" }17 Parameter { name: "scopeId"; type: "string" }
18 Parameter { name: "animate"; type: "bool" }18 Parameter { name: "animate"; type: "bool" }
19 Parameter { name: "reset"; type: "bool" }19 Parameter { name: "isSwipe"; type: "bool" }
20 }20 }
21 }21 }
22 Component {22 Component {
@@ -28,7 +28,20 @@
28 name: "setCurrentScopeRequested"28 name: "setCurrentScopeRequested"
29 Parameter { name: "scopeId"; type: "string" }29 Parameter { name: "scopeId"; type: "string" }
30 Parameter { name: "animate"; type: "bool" }30 Parameter { name: "animate"; type: "bool" }
31 Parameter { name: "reset"; type: "bool" }31 Parameter { name: "isSwipe"; type: "bool" }
32 }32 }
33 }
34 Component {
35 name: "QThread"
36 prototype: "QObject"
37 Signal { name: "started" }
38 Signal { name: "finished" }
39 Method {
40 name: "start"
41 Parameter { type: "Priority" }
42 }
43 Method { name: "start" }
44 Method { name: "terminate" }
45 Method { name: "quit" }
33 }46 }
34}47}
3548
=== modified file 'plugins/Unity/Indicators/CMakeLists.txt'
--- plugins/Unity/Indicators/CMakeLists.txt 2014-07-30 16:00:55 +0000
+++ plugins/Unity/Indicators/CMakeLists.txt 2014-10-15 19:48:28 +0000
@@ -24,6 +24,7 @@
24 modelprinter.cpp24 modelprinter.cpp
25 plugin.cpp25 plugin.cpp
26 rootactionstate.cpp26 rootactionstate.cpp
27 sharedunitymenumodel.cpp
27 unitymenumodelcache.cpp28 unitymenumodelcache.cpp
28 unitymenumodelstack.cpp29 unitymenumodelstack.cpp
29 visibleindicatorsmodel.cpp30 visibleindicatorsmodel.cpp
3031
=== modified file 'plugins/Unity/Indicators/Indicators.qmltypes'
--- plugins/Unity/Indicators/Indicators.qmltypes 2014-09-01 12:18:53 +0000
+++ plugins/Unity/Indicators/Indicators.qmltypes 2014-10-15 19:48:28 +0000
@@ -210,6 +210,16 @@
210 Signal { name: "indexChanged" }210 Signal { name: "indexChanged" }
211 }211 }
212 Component {212 Component {
213 name: "SharedUnityMenuModel"
214 prototype: "QObject"
215 exports: ["Unity.Indicators/SharedUnityMenuModel 0.1"]
216 exportMetaObjectRevisions: [0]
217 Property { name: "busName"; type: "QByteArray" }
218 Property { name: "menuObjectPath"; type: "QByteArray" }
219 Property { name: "actions"; type: "QVariantMap" }
220 Property { name: "model"; type: "UnityMenuModel"; isReadonly: true; isPointer: true }
221 }
222 Component {
213 name: "UnityMenuModelCache"223 name: "UnityMenuModelCache"
214 prototype: "QObject"224 prototype: "QObject"
215 exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]225 exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]
@@ -217,13 +227,6 @@
217 isSingleton: true227 isSingleton: true
218 exportMetaObjectRevisions: [0]228 exportMetaObjectRevisions: [0]
219 Method {229 Method {
220 name: "model"
221 type: "UnityMenuModel*"
222 Parameter { name: "bus"; type: "QByteArray" }
223 Parameter { name: "path"; type: "QByteArray" }
224 Parameter { name: "actions"; type: "QVariantMap" }
225 }
226 Method {
227 name: "contains"230 name: "contains"
228 type: "bool"231 type: "bool"
229 Parameter { name: "path"; type: "QByteArray" }232 Parameter { name: "path"; type: "QByteArray" }
230233
=== modified file 'plugins/Unity/Indicators/plugin.cpp'
--- plugins/Unity/Indicators/plugin.cpp 2014-07-30 16:00:55 +0000
+++ plugins/Unity/Indicators/plugin.cpp 2014-10-15 19:48:28 +0000
@@ -30,18 +30,23 @@
30#include "menucontentactivator.h"30#include "menucontentactivator.h"
31#include "modelprinter.h"31#include "modelprinter.h"
32#include "rootactionstate.h"32#include "rootactionstate.h"
33#include "sharedunitymenumodel.h"
33#include "unitymenumodelcache.h"34#include "unitymenumodelcache.h"
34#include "unitymenumodelstack.h"35#include "unitymenumodelstack.h"
35#include "visibleindicatorsmodel.h"36#include "visibleindicatorsmodel.h"
3637
38#include <unitymenumodel.h>
39
37static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {40static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
38 Q_UNUSED(engine);41 Q_UNUSED(engine);
39 Q_UNUSED(scriptEngine);42 Q_UNUSED(scriptEngine);
40 return new UnityMenuModelCache;43 return UnityMenuModelCache::singleton();
41}44}
4245
43void Indicators2Plugin::registerTypes(const char *uri)46void IndicatorsPlugin::registerTypes(const char *uri)
44{47{
48 qRegisterMetaType<UnityMenuModel*>("UnityMenuModel*");
49
45 qmlRegisterType<IndicatorsManager>(uri, 0, 1, "IndicatorsManager");50 qmlRegisterType<IndicatorsManager>(uri, 0, 1, "IndicatorsManager");
46 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");51 qmlRegisterType<IndicatorsModel>(uri, 0, 1, "IndicatorsModel");
47 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");52 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
@@ -49,6 +54,7 @@
49 qmlRegisterType<RootActionState>(uri, 0, 1, "RootActionState");54 qmlRegisterType<RootActionState>(uri, 0, 1, "RootActionState");
50 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");55 qmlRegisterType<ModelPrinter>(uri, 0, 1, "ModelPrinter");
51 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");56 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
57 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
5258
53 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);59 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
5460
5561
=== modified file 'plugins/Unity/Indicators/plugin.h'
--- plugins/Unity/Indicators/plugin.h 2013-08-14 09:07:45 +0000
+++ plugins/Unity/Indicators/plugin.h 2014-10-15 19:48:28 +0000
@@ -22,7 +22,7 @@
2222
23#include <QtQml/QQmlExtensionPlugin>23#include <QtQml/QQmlExtensionPlugin>
2424
25class Indicators2Plugin : public QQmlExtensionPlugin25class IndicatorsPlugin : public QQmlExtensionPlugin
26{26{
27 Q_OBJECT27 Q_OBJECT
28 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")28 Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface")
2929
=== added file 'plugins/Unity/Indicators/sharedunitymenumodel.cpp'
--- plugins/Unity/Indicators/sharedunitymenumodel.cpp 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/sharedunitymenumodel.cpp 2014-10-15 19:48:28 +0000
@@ -0,0 +1,87 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "sharedunitymenumodel.h"
19#include "unitymenumodelcache.h"
20
21SharedUnityMenuModel::SharedUnityMenuModel(QObject* parent)
22 : QObject(parent)
23{
24}
25
26QByteArray SharedUnityMenuModel::busName() const
27{
28 return m_busName;
29}
30
31void SharedUnityMenuModel::setBusName(const QByteArray& busName)
32{
33 if (m_busName != busName) {
34 m_busName = busName;
35 Q_EMIT busNameChanged();
36 initialize();
37 }
38}
39
40QByteArray SharedUnityMenuModel::menuObjectPath() const
41{
42 return m_menuObjectPath;
43}
44
45void SharedUnityMenuModel::setMenuObjectPath(const QByteArray& menuObjectPath)
46{
47 if (m_menuObjectPath != menuObjectPath) {
48 m_menuObjectPath = menuObjectPath;
49 Q_EMIT menuObjectPathChanged();
50 initialize();
51 }
52}
53
54QVariantMap SharedUnityMenuModel::actions() const
55{
56 return m_actions;
57}
58
59void SharedUnityMenuModel::setActions(const QVariantMap& actions)
60{
61 if (m_actions != actions) {
62 m_actions = actions;
63 Q_EMIT actionsChanged();
64 initialize();
65 }
66}
67
68UnityMenuModel* SharedUnityMenuModel::model() const
69{
70 return m_model ? m_model.data() : nullptr;
71}
72
73void SharedUnityMenuModel::initialize()
74{
75 if (m_busName.isEmpty() || m_menuObjectPath.isEmpty() || m_actions.isEmpty()) {
76 if (!m_model.isNull()) {
77 m_model.clear();
78 Q_EMIT modelChanged();
79 }
80 } else {
81 QSharedPointer<UnityMenuModel> model = UnityMenuModelCache::singleton()->model(m_busName, m_menuObjectPath, m_actions);
82 if (model != m_model) {
83 m_model = model;
84 Q_EMIT modelChanged();
85 }
86 }
87}
088
=== added file 'plugins/Unity/Indicators/sharedunitymenumodel.h'
--- plugins/Unity/Indicators/sharedunitymenumodel.h 1970-01-01 00:00:00 +0000
+++ plugins/Unity/Indicators/sharedunitymenumodel.h 2014-10-15 19:48:28 +0000
@@ -0,0 +1,66 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#ifndef SHAREDUNITYMENUMODEL_H
19#define SHAREDUNITYMENUMODEL_H
20
21#include "unityindicatorsglobal.h"
22
23#include <QObject>
24#include <QSharedPointer>
25#include <QVariantMap>
26
27class UnityMenuModel;
28
29class UNITYINDICATORS_EXPORT SharedUnityMenuModel : public QObject
30{
31 Q_OBJECT
32 Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)
33 Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)
34 Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)
35 Q_PROPERTY(UnityMenuModel* model READ model NOTIFY modelChanged)
36
37public:
38 SharedUnityMenuModel(QObject* parent = nullptr);
39
40 QByteArray busName() const;
41 void setBusName(const QByteArray&);
42
43 QByteArray menuObjectPath() const;
44 void setMenuObjectPath(const QByteArray&);
45
46 QVariantMap actions() const;
47 void setActions(const QVariantMap&);
48
49 UnityMenuModel* model() const;
50
51Q_SIGNALS:
52 void busNameChanged();
53 void menuObjectPathChanged();
54 void actionsChanged();
55 void modelChanged();
56
57private:
58 void initialize();
59
60 QByteArray m_busName;
61 QByteArray m_menuObjectPath;
62 QVariantMap m_actions;
63 QSharedPointer<UnityMenuModel> m_model;
64};
65
66#endif // SHAREDUNITYMENUMODEL_H
067
=== modified file 'plugins/Unity/Indicators/unitymenumodelcache.cpp'
--- plugins/Unity/Indicators/unitymenumodelcache.cpp 2014-08-20 09:16:28 +0000
+++ plugins/Unity/Indicators/unitymenumodelcache.cpp 2014-10-15 19:48:28 +0000
@@ -20,30 +20,45 @@
20#include "unitymenumodelcache.h"20#include "unitymenumodelcache.h"
21#include <unitymenumodel.h>21#include <unitymenumodel.h>
2222
23#include <QQmlEngine>
24
25QPointer<UnityMenuModelCache> UnityMenuModelCache::theCache = nullptr;
26
27UnityMenuModelCache* UnityMenuModelCache::singleton()
28{
29 if (theCache.isNull()) {
30 theCache = new UnityMenuModelCache();
31 }
32 return theCache.data();
33}
34
23UnityMenuModelCache::UnityMenuModelCache(QObject* parent)35UnityMenuModelCache::UnityMenuModelCache(QObject* parent)
24 : QObject(parent)36 : QObject(parent)
25{37{
26}38}
2739
28UnityMenuModelCache::~UnityMenuModelCache()40QSharedPointer<UnityMenuModel> UnityMenuModelCache::model(const QByteArray& bus,
29{41 const QByteArray& path,
30}42 const QVariantMap& actions)
31
32UnityMenuModel* UnityMenuModelCache::model(const QByteArray& bus,
33 const QByteArray& path,
34 const QVariantMap& actions)
35{43{
36 if (m_registry.contains(path))44 if (m_registry.contains(path))
37 return m_registry[path];45 return m_registry[path];
3846
39 UnityMenuModel* menuModel = new UnityMenuModel;47 UnityMenuModel* model = new UnityMenuModel;
40 connect(menuModel, &QObject::destroyed, this, [menuModel, this](QObject*) {48 QQmlEngine::setObjectOwnership(model, QQmlEngine::CppOwnership);
41 QList<QByteArray> keys = m_registry.keys(menuModel);49
42 Q_FOREACH(const QByteArray& key, keys) {50 QSharedPointer<UnityMenuModel> menuModel(model);
43 m_registry.remove(key);51 connect(model, &QObject::destroyed, this, [this] {
52 QMutableHashIterator<QByteArray, QWeakPointer<UnityMenuModel>> iter(m_registry);
53 while(iter.hasNext()) {
54 auto keyVal = iter.next();
55 if (keyVal.value().isNull()) {
56 iter.remove();
57 break;
58 }
44 }59 }
45 });60 });
46 m_registry[path] = menuModel;61 m_registry[path] = menuModel.toWeakRef();
4762
48 menuModel->setBusName(bus);63 menuModel->setBusName(bus);
49 menuModel->setMenuObjectPath(path);64 menuModel->setMenuObjectPath(path);
5065
=== modified file 'plugins/Unity/Indicators/unitymenumodelcache.h'
--- plugins/Unity/Indicators/unitymenumodelcache.h 2014-08-26 08:14:44 +0000
+++ plugins/Unity/Indicators/unitymenumodelcache.h 2014-10-15 19:48:28 +0000
@@ -24,6 +24,8 @@
2424
25#include <QObject>25#include <QObject>
26#include <QHash>26#include <QHash>
27#include <QPointer>
28#include <QWeakPointer>
2729
28class UnityMenuModel;30class UnityMenuModel;
2931
@@ -32,15 +34,19 @@
32 Q_OBJECT34 Q_OBJECT
33public:35public:
34 UnityMenuModelCache(QObject*parent=nullptr);36 UnityMenuModelCache(QObject*parent=nullptr);
35 ~UnityMenuModelCache();37
3638 static UnityMenuModelCache* singleton();
37 Q_INVOKABLE UnityMenuModel* model(const QByteArray& bus,39
38 const QByteArray& path,40 virtual QSharedPointer<UnityMenuModel> model(const QByteArray& bus,
39 const QVariantMap& actions);41 const QByteArray& path,
40 Q_INVOKABLE bool contains(const QByteArray& path);42 const QVariantMap& actions);
4143
42private:44 // for tests use
43 QHash<QByteArray, UnityMenuModel*> m_registry;45 Q_INVOKABLE virtual bool contains(const QByteArray& path);
46
47protected:
48 QHash<QByteArray, QWeakPointer<UnityMenuModel>> m_registry;
49 static QPointer<UnityMenuModelCache> theCache;
44};50};
4551
46#endif // UNITYMENUMODELCACHE_H52#endif // UNITYMENUMODELCACHE_H
4753
=== modified file 'plugins/Unity/Launcher/Launcher.qmltypes'
--- plugins/Unity/Launcher/Launcher.qmltypes 2014-06-26 07:47:57 +0000
+++ plugins/Unity/Launcher/Launcher.qmltypes 2014-10-15 19:48:28 +0000
@@ -13,14 +13,6 @@
13 exports: ["Unity.Launcher/LauncherItem 0.1"]13 exports: ["Unity.Launcher/LauncherItem 0.1"]
14 isCreatable: false14 isCreatable: false
15 exportMetaObjectRevisions: [0]15 exportMetaObjectRevisions: [0]
16 Signal {
17 name: "favoriteChanged"
18 Parameter { name: "favorite"; type: "bool" }
19 }
20 Signal {
21 name: "runningChanged"
22 Parameter { name: "running"; type: "bool" }
23 }
24 }16 }
25 Component {17 Component {
26 name: "LauncherModel"18 name: "LauncherModel"
@@ -30,6 +22,10 @@
30 isSingleton: true22 isSingleton: true
31 exportMetaObjectRevisions: [0]23 exportMetaObjectRevisions: [0]
32 Method {24 Method {
25 name: "requestRemove"
26 Parameter { name: "appId"; type: "string" }
27 }
28 Method {
33 name: "get"29 name: "get"
34 type: "unity::shell::launcher::LauncherItemInterface*"30 type: "unity::shell::launcher::LauncherItemInterface*"
35 Parameter { name: "index"; type: "int" }31 Parameter { name: "index"; type: "int" }
@@ -49,10 +45,6 @@
49 Parameter { name: "appId"; type: "string" }45 Parameter { name: "appId"; type: "string" }
50 }46 }
51 Method {47 Method {
52 name: "requestRemove"
53 Parameter { name: "appId"; type: "string" }
54 }
55 Method {
56 name: "quickListActionInvoked"48 name: "quickListActionInvoked"
57 Parameter { name: "appId"; type: "string" }49 Parameter { name: "appId"; type: "string" }
58 Parameter { name: "actionIndex"; type: "int" }50 Parameter { name: "actionIndex"; type: "int" }
@@ -88,6 +80,7 @@
88 Property { name: "recent"; type: "bool"; isReadonly: true }80 Property { name: "recent"; type: "bool"; isReadonly: true }
89 Property { name: "progress"; type: "int"; isReadonly: true }81 Property { name: "progress"; type: "int"; isReadonly: true }
90 Property { name: "count"; type: "int"; isReadonly: true }82 Property { name: "count"; type: "int"; isReadonly: true }
83 Property { name: "countVisible"; type: "bool"; isReadonly: true }
91 Property { name: "focused"; type: "bool"; isReadonly: true }84 Property { name: "focused"; type: "bool"; isReadonly: true }
92 Property {85 Property {
93 name: "quickList"86 name: "quickList"
@@ -96,6 +89,14 @@
96 isPointer: true89 isPointer: true
97 }90 }
98 Signal {91 Signal {
92 name: "nameChanged"
93 Parameter { name: "name"; type: "string" }
94 }
95 Signal {
96 name: "iconChanged"
97 Parameter { name: "icon"; type: "string" }
98 }
99 Signal {
99 name: "pinnedChanged"100 name: "pinnedChanged"
100 Parameter { name: "pinned"; type: "bool" }101 Parameter { name: "pinned"; type: "bool" }
101 }102 }
@@ -116,6 +117,10 @@
116 Parameter { name: "count"; type: "int" }117 Parameter { name: "count"; type: "int" }
117 }118 }
118 Signal {119 Signal {
120 name: "countVisibleChanged"
121 Parameter { name: "countVisible"; type: "bool" }
122 }
123 Signal {
119 name: "focusedChanged"124 name: "focusedChanged"
120 Parameter { name: "focused"; type: "bool" }125 Parameter { name: "focused"; type: "bool" }
121 }126 }
122127
=== modified file 'plugins/Unity/Session/Session.qmltypes'
--- plugins/Unity/Session/Session.qmltypes 2014-08-14 01:28:06 +0000
+++ plugins/Unity/Session/Session.qmltypes 2014-10-15 19:48:28 +0000
@@ -34,4 +34,14 @@
34 Method { name: "RequestReboot" }34 Method { name: "RequestReboot" }
35 Method { name: "RequestShutdown" }35 Method { name: "RequestShutdown" }
36 }36 }
37 Component {
38 name: "OrientationLock"
39 prototype: "QObject"
40 exports: ["Unity.Session/OrientationLock 0.1"]
41 isCreatable: false
42 isSingleton: true
43 exportMetaObjectRevisions: [0]
44 Property { name: "enabled"; type: "bool"; isReadonly: true }
45 Property { name: "savedOrientation"; type: "Qt::ScreenOrientation" }
46 }
37}47}
3848
=== modified file 'plugins/Utils/Utils.qmltypes'
--- plugins/Utils/Utils.qmltypes 2014-08-14 01:28:06 +0000
+++ plugins/Utils/Utils.qmltypes 2014-10-15 19:48:28 +0000
@@ -107,6 +107,12 @@
107 }107 }
108 }108 }
109 Component {109 Component {
110 name: "RelativeTimeFormatter"
111 prototype: "TimeFormatter"
112 exports: ["Utils/RelativeTimeFormatter 0.1"]
113 exportMetaObjectRevisions: [0]
114 }
115 Component {
110 name: "TimeFormatter"116 name: "TimeFormatter"
111 prototype: "QObject"117 prototype: "QObject"
112 exports: ["Utils/GDateTimeFormatter 0.1", "Utils/TimeFormatter 0.1"]118 exports: ["Utils/GDateTimeFormatter 0.1", "Utils/TimeFormatter 0.1"]
113119
=== modified file 'qml/Greeter/Clock.qml'
--- qml/Greeter/Clock.qml 2014-08-20 08:39:09 +0000
+++ qml/Greeter/Clock.qml 2014-10-15 19:48:28 +0000
@@ -34,21 +34,21 @@
34 }34 }
35 }35 }
3636
37 CachedUnityMenuModel {37 Indicators.SharedUnityMenuModel {
38 id: timeModel38 id: timeModel
39 objectName: "timeModel"39 objectName: "timeModel"
4040
41 busName: "com.canonical.indicator.datetime"41 busName: "com.canonical.indicator.datetime"
42 actionsObjectPath: "/com/canonical/indicator/datetime"42 actions: { "indicator": "/com/canonical/indicator/datetime" }
43 menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : ""43 menuObjectPath: clock.visible ? "/com/canonical/indicator/datetime/phone" : ""
44 }
4445
45 Indicators.RootActionState {46 Indicators.RootActionState {
46 menu: timeModel.model47 menu: timeModel.model
47 onUpdated: {48 onUpdated: {
48 if (timeLabel.text != rightLabel) {49 if (timeLabel.text != rightLabel) {
49 timeLabel.text = rightLabel;50 if (rightLabel != "") timeLabel.text = rightLabel;
50 clock.currentDate = new Date();51 clock.currentDate = new Date();
51 }
52 }52 }
53 }53 }
54 }54 }
5555
=== modified file 'qml/Notifications/Notifications.qml'
--- qml/Notifications/Notifications.qml 2014-09-09 09:34:28 +0000
+++ qml/Notifications/Notifications.qml 2014-10-15 19:48:28 +0000
@@ -32,6 +32,7 @@
3232
33 SortFilterProxyModel {33 SortFilterProxyModel {
34 id: snapDecisionProxyModel34 id: snapDecisionProxyModel
35 objectName: "snapDecisionProxyModel"
3536
36 model: notificationList.model37 model: notificationList.model
37 filterRole: UnityNotifications.ModelInterface != undefined ? UnityNotifications.ModelInterface.RoleType : 038 filterRole: UnityNotifications.ModelInterface != undefined ? UnityNotifications.ModelInterface.RoleType : 0
3839
=== removed file 'qml/Panel/Indicators/CachedUnityMenuModel.qml'
--- qml/Panel/Indicators/CachedUnityMenuModel.qml 2014-08-20 08:39:09 +0000
+++ qml/Panel/Indicators/CachedUnityMenuModel.qml 1970-01-01 00:00:00 +0000
@@ -1,39 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Nick Dedekind <nick.dedekind@canonical.com>
18 */
19
20import QtQuick 2.0
21import QMenuModel 0.1
22import Unity.Indicators 0.1 as Indicators
23
24// Make sure we don't duplicate models.
25Item {
26 id: cachedModel
27 property string busName
28 property string actionsObjectPath
29 property string menuObjectPath
30 readonly property bool ready: busName!=="" && actionsObjectPath!=="" && menuObjectPath!==""
31
32 property var model: {
33 if (!ready) return null;
34
35 return Indicators.UnityMenuModelCache.model(cachedModel.busName,
36 cachedModel.menuObjectPath,
37 { "indicator": cachedModel.actionsObjectPath });
38 }
39}
400
=== modified file 'qml/Panel/Indicators/IndicatorBase.qml'
--- qml/Panel/Indicators/IndicatorBase.qml 2014-09-29 10:24:58 +0000
+++ qml/Panel/Indicators/IndicatorBase.qml 2014-10-15 19:48:28 +0000
@@ -37,10 +37,10 @@
37 property alias menuModel: cachedModel.model37 property alias menuModel: cachedModel.model
38 property alias rootActionState: rootAction38 property alias rootActionState: rootAction
3939
40 CachedUnityMenuModel {40 SharedUnityMenuModel {
41 id: cachedModel41 id: cachedModel
42 busName: indicatorItem.busName42 busName: indicatorItem.busName
43 actionsObjectPath: indicatorItem.actionsObjectPath43 actions: { "indicator": indicatorItem.actionsObjectPath }
44 menuObjectPath: indicatorItem.deviceMenuObjectPath44 menuObjectPath: indicatorItem.deviceMenuObjectPath
45 }45 }
4646
4747
=== modified file 'qml/Shell.qml'
--- qml/Shell.qml 2014-10-13 15:41:29 +0000
+++ qml/Shell.qml 2014-10-15 19:48:28 +0000
@@ -248,7 +248,7 @@
248 Binding {248 Binding {
249 target: applicationsDisplayLoader.item249 target: applicationsDisplayLoader.item
250 property: "interactive"250 property: "interactive"
251 value: edgeDemo.stagesEnabled && !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0251 value: edgeDemo.stagesEnabled && !greeter.shown && !lockscreen.shown && panel.indicators.fullyClosed && launcher.progress == 0 && !notifications.useModal
252 }252 }
253 Binding {253 Binding {
254 target: applicationsDisplayLoader.item254 target: applicationsDisplayLoader.item
255255
=== modified file 'tests/mocks/AccountsService/AccountsService.qmltypes'
--- tests/mocks/AccountsService/AccountsService.qmltypes 2014-09-01 12:18:53 +0000
+++ tests/mocks/AccountsService/AccountsService.qmltypes 2014-10-15 19:48:28 +0000
@@ -23,6 +23,8 @@
23 }23 }
24 Property { name: "user"; type: "string" }24 Property { name: "user"; type: "string" }
25 Property { name: "demoEdges"; type: "bool" }25 Property { name: "demoEdges"; type: "bool" }
26 Property { name: "enableLauncherWhileLocked"; type: "bool" }
27 Property { name: "enableIndicatorsWhileLocked"; type: "bool" }
26 Property { name: "backgroundFile"; type: "string" }28 Property { name: "backgroundFile"; type: "string" }
27 Property { name: "statsWelcomeScreen"; type: "bool" }29 Property { name: "statsWelcomeScreen"; type: "bool" }
28 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }30 Property { name: "passwordDisplayHint"; type: "PasswordDisplayHint"; isReadonly: true }
2931
=== modified file 'tests/mocks/LightDM/LightDM.qmltypes'
--- tests/mocks/LightDM/LightDM.qmltypes 2014-09-01 12:18:53 +0000
+++ tests/mocks/LightDM/LightDM.qmltypes 2014-10-15 19:48:28 +0000
@@ -37,6 +37,7 @@
37 Signal { name: "isActiveChanged" }37 Signal { name: "isActiveChanged" }
38 Signal { name: "isAuthenticatedChanged" }38 Signal { name: "isAuthenticatedChanged" }
39 Signal { name: "showGreeter" }39 Signal { name: "showGreeter" }
40 Signal { name: "hideGreeter" }
40 Signal {41 Signal {
41 name: "requestAuthenticationUser"42 name: "requestAuthenticationUser"
42 Parameter { name: "user"; type: "string" }43 Parameter { name: "user"; type: "string" }
4344
=== modified file 'tests/mocks/QMenuModel/QMenuModel.qmltypes'
--- tests/mocks/QMenuModel/QMenuModel.qmltypes 2014-08-14 01:28:06 +0000
+++ tests/mocks/QMenuModel/QMenuModel.qmltypes 2014-10-15 19:48:28 +0000
@@ -18,12 +18,12 @@
18 prototype: "QAbstractListModel"18 prototype: "QAbstractListModel"
19 exports: ["QMenuModel/UnityMenuModel 0.1"]19 exports: ["QMenuModel/UnityMenuModel 0.1"]
20 exportMetaObjectRevisions: [0]20 exportMetaObjectRevisions: [0]
21 Property { name: "modelData"; type: "QVariant" }
22 Property { name: "busName"; type: "QByteArray" }21 Property { name: "busName"; type: "QByteArray" }
23 Property { name: "actions"; type: "QVariantMap" }22 Property { name: "actions"; type: "QVariantMap" }
24 Property { name: "menuObjectPath"; type: "QByteArray" }23 Property { name: "menuObjectPath"; type: "QByteArray" }
25 Property { name: "actionStateParser"; type: "ActionStateParser"; isPointer: true }24 Property { name: "actionStateParser"; type: "ActionStateParser"; isPointer: true }
26 Property { name: "nameOwner"; type: "string"; isReadonly: true }25 Property { name: "nameOwner"; type: "string"; isReadonly: true }
26 Property { name: "modelData"; type: "QVariant" }
27 Method {27 Method {
28 name: "insertRow"28 name: "insertRow"
29 Parameter { name: "row"; type: "int" }29 Parameter { name: "row"; type: "int" }
3030
=== modified file 'tests/mocks/QMenuModel/unitymenumodel.cpp'
--- tests/mocks/QMenuModel/unitymenumodel.cpp 2014-08-26 08:14:44 +0000
+++ tests/mocks/QMenuModel/unitymenumodel.cpp 2014-10-15 19:48:28 +0000
@@ -50,13 +50,12 @@
50{50{
51 beginResetModel();51 beginResetModel();
5252
53 m_modelData.clear();
54 m_modelData = data.toList();53 m_modelData = data.toList();
54 Q_EMIT modelDataChanged();
5555
56 endResetModel();56 endResetModel();
57}57}
5858
59
60void UnityMenuModel::insertRow(int row, const QVariant& data)59void UnityMenuModel::insertRow(int row, const QVariant& data)
61{60{
62 row = qMin(row, rowCount());61 row = qMin(row, rowCount());
6362
=== modified file 'tests/mocks/QMenuModel/unitymenumodel.h'
--- tests/mocks/QMenuModel/unitymenumodel.h 2014-08-26 08:14:44 +0000
+++ tests/mocks/QMenuModel/unitymenumodel.h 2014-10-15 19:48:28 +0000
@@ -27,13 +27,15 @@
27class Q_DECL_EXPORT UnityMenuModel : public QAbstractListModel27class Q_DECL_EXPORT UnityMenuModel : public QAbstractListModel
28{28{
29 Q_OBJECT29 Q_OBJECT
30 Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
31 Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)30 Q_PROPERTY(QByteArray busName READ busName WRITE setBusName NOTIFY busNameChanged)
32 Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)31 Q_PROPERTY(QVariantMap actions READ actions WRITE setActions NOTIFY actionsChanged)
33 Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)32 Q_PROPERTY(QByteArray menuObjectPath READ menuObjectPath WRITE setMenuObjectPath NOTIFY menuObjectPathChanged)
34 Q_PROPERTY(ActionStateParser* actionStateParser READ actionStateParser WRITE setActionStateParser NOTIFY actionStateParserChanged)33 Q_PROPERTY(ActionStateParser* actionStateParser READ actionStateParser WRITE setActionStateParser NOTIFY actionStateParserChanged)
35 Q_PROPERTY(QString nameOwner READ nameOwner NOTIFY nameOwnerChanged)34 Q_PROPERTY(QString nameOwner READ nameOwner NOTIFY nameOwnerChanged)
3635
36 // internal mock properties
37 Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
38
37public:39public:
38 UnityMenuModel(QObject *parent = nullptr);40 UnityMenuModel(QObject *parent = nullptr);
39 virtual ~UnityMenuModel();41 virtual ~UnityMenuModel();
@@ -81,8 +83,10 @@
81 void actionsChanged();83 void actionsChanged();
82 void menuObjectPathChanged();84 void menuObjectPathChanged();
83 void actionStateParserChanged();85 void actionStateParserChanged();
86 void nameOwnerChanged();
87
88 // Internal mock usage
84 void modelDataChanged();89 void modelDataChanged();
85 void nameOwnerChanged();
8690
87private:91private:
88 QVariantMap rowData(int row) const;92 QVariantMap rowData(int row) const;
8993
=== modified file 'tests/mocks/Ubuntu/Payments/Payments.qmltypes'
--- tests/mocks/Ubuntu/Payments/Payments.qmltypes 2014-06-27 20:53:24 +0000
+++ tests/mocks/Ubuntu/Payments/Payments.qmltypes 2014-10-15 19:48:28 +0000
@@ -37,6 +37,8 @@
37 Parameter { name: "error"; type: "string" }37 Parameter { name: "error"; type: "string" }
38 }38 }
39 Signal { name: "purchaseCompleted" }39 Signal { name: "purchaseCompleted" }
40 Signal { name: "purchaseCancelled" }
40 Method { name: "start" }41 Method { name: "start" }
42 Method { name: "process" }
41 }43 }
42}44}
4345
=== modified file 'tests/mocks/Ubuntu/Telephony/Telephony.qmltypes'
--- tests/mocks/Ubuntu/Telephony/Telephony.qmltypes 2014-08-14 13:33:28 +0000
+++ tests/mocks/Ubuntu/Telephony/Telephony.qmltypes 2014-10-15 19:48:28 +0000
@@ -22,7 +22,8 @@
22 exportMetaObjectRevisions: [0]22 exportMetaObjectRevisions: [0]
23 Property { name: "phoneNumber"; type: "string" }23 Property { name: "phoneNumber"; type: "string" }
24 Property { name: "isConference"; type: "bool" }24 Property { name: "isConference"; type: "bool" }
25 Property { name: "elapsedTime"; type: "int"; isReadonly: true }25 Property { name: "elapsedTime"; type: "int" }
26 Property { name: "elapsedTimerRunning"; type: "bool" }
26 }27 }
27 Component {28 Component {
28 name: "MockCallManager"29 name: "MockCallManager"
2930
=== modified file 'tests/mocks/Unity/Application/Application.qmltypes'
--- tests/mocks/Unity/Application/Application.qmltypes 2014-09-01 12:24:06 +0000
+++ tests/mocks/Unity/Application/Application.qmltypes 2014-10-15 19:48:28 +0000
@@ -238,6 +238,7 @@
238 Property { name: "state"; type: "State"; isReadonly: true }238 Property { name: "state"; type: "State"; isReadonly: true }
239 Property { name: "name"; type: "string"; isReadonly: true }239 Property { name: "name"; type: "string"; isReadonly: true }
240 Property { name: "live"; type: "bool"; isReadonly: true }240 Property { name: "live"; type: "bool"; isReadonly: true }
241 Property { name: "orientation"; type: "Qt::ScreenOrientation" }
241 Signal {242 Signal {
242 name: "typeChanged"243 name: "typeChanged"
243 Parameter { type: "Type" }244 Parameter { type: "Type" }
@@ -268,10 +269,15 @@
268 exportMetaObjectRevisions: [0]269 exportMetaObjectRevisions: [0]
269 Property { name: "name"; type: "string"; isReadonly: true }270 Property { name: "name"; type: "string"; isReadonly: true }
270 Property { name: "surface"; type: "MirSurfaceItem"; isReadonly: true; isPointer: true }271 Property { name: "surface"; type: "MirSurfaceItem"; isReadonly: true; isPointer: true }
272 Property { name: "application"; type: "ApplicationInfo"; isReadonly: true; isPointer: true }
271 Property { name: "parentSession"; type: "Session"; isReadonly: true; isPointer: true }273 Property { name: "parentSession"; type: "Session"; isReadonly: true; isPointer: true }
272 Property { name: "childSessions"; type: "SessionModel"; isReadonly: true; isPointer: true }274 Property { name: "childSessions"; type: "SessionModel"; isReadonly: true; isPointer: true }
273 Property { name: "live"; type: "bool"; isReadonly: true }275 Property { name: "live"; type: "bool"; isReadonly: true }
274 Signal {276 Signal {
277 name: "applicationChanged"
278 Parameter { type: "ApplicationInfo"; isPointer: true }
279 }
280 Signal {
275 name: "surfaceChanged"281 name: "surfaceChanged"
276 Parameter { type: "MirSurfaceItem"; isPointer: true }282 Parameter { type: "MirSurfaceItem"; isPointer: true }
277 }283 }
@@ -368,6 +374,12 @@
368 Property { name: "stage"; type: "Stage"; isReadonly: true }374 Property { name: "stage"; type: "Stage"; isReadonly: true }
369 Property { name: "state"; type: "State"; isReadonly: true }375 Property { name: "state"; type: "State"; isReadonly: true }
370 Property { name: "focused"; type: "bool"; isReadonly: true }376 Property { name: "focused"; type: "bool"; isReadonly: true }
377 Property { name: "splashTitle"; type: "string"; isReadonly: true }
378 Property { name: "splashImage"; type: "QUrl"; isReadonly: true }
379 Property { name: "splashShowHeader"; type: "bool"; isReadonly: true }
380 Property { name: "splashColor"; type: "QColor"; isReadonly: true }
381 Property { name: "splashColorHeader"; type: "QColor"; isReadonly: true }
382 Property { name: "splashColorFooter"; type: "QColor"; isReadonly: true }
371 Signal {383 Signal {
372 name: "nameChanged"384 name: "nameChanged"
373 Parameter { name: "name"; type: "string" }385 Parameter { name: "name"; type: "string" }
@@ -414,6 +426,7 @@
414 Property { name: "count"; type: "int"; isReadonly: true }426 Property { name: "count"; type: "int"; isReadonly: true }
415 Property { name: "focusedApplicationId"; type: "string"; isReadonly: true }427 Property { name: "focusedApplicationId"; type: "string"; isReadonly: true }
416 Property { name: "suspended"; type: "bool" }428 Property { name: "suspended"; type: "bool" }
429 Property { name: "forceDashActive"; type: "bool" }
417 Signal {430 Signal {
418 name: "focusRequested"431 name: "focusRequested"
419 Parameter { name: "appId"; type: "string" }432 Parameter { name: "appId"; type: "string" }
420433
=== modified file 'tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes'
--- tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-08-14 13:33:28 +0000
+++ tests/mocks/Unity/DashCommunicator/DashCommunicator.qmltypes 2014-10-15 19:48:28 +0000
@@ -34,13 +34,13 @@
34 name: "setCurrentScopeRequested"34 name: "setCurrentScopeRequested"
35 Parameter { name: "scopeId"; type: "string" }35 Parameter { name: "scopeId"; type: "string" }
36 Parameter { name: "animate"; type: "bool" }36 Parameter { name: "animate"; type: "bool" }
37 Parameter { name: "reset"; type: "bool" }37 Parameter { name: "isSwipe"; type: "bool" }
38 }38 }
39 Method {39 Method {
40 name: "mockSetCurrentScope"40 name: "mockSetCurrentScope"
41 Parameter { name: "scopeId"; type: "string" }41 Parameter { name: "scopeId"; type: "string" }
42 Parameter { name: "animate"; type: "bool" }42 Parameter { name: "animate"; type: "bool" }
43 Parameter { name: "reset"; type: "bool" }43 Parameter { name: "isSwipe"; type: "bool" }
44 }44 }
45 }45 }
46}46}
4747
=== modified file 'tests/mocks/Unity/Indicators/CMakeLists.txt'
--- tests/mocks/Unity/Indicators/CMakeLists.txt 2014-08-20 08:39:09 +0000
+++ tests/mocks/Unity/Indicators/CMakeLists.txt 2014-10-15 19:48:28 +0000
@@ -12,24 +12,17 @@
1212
13set(IndicatorsFakeQml_SOURCES13set(IndicatorsFakeQml_SOURCES
14 fakeplugin.cpp14 fakeplugin.cpp
15 fakeindicatorsmodel.cpp
16 fakeunitymenumodelcache.cpp
15 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/indicators.h17 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/indicators.h
16 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp18 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/menucontentactivator.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/sharedunitymenumodel.cpp
17 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelcache.cpp20 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelcache.cpp
18 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp21 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/unitymenumodelstack.cpp
19 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp22 ${CMAKE_SOURCE_DIR}/plugins/Unity/Indicators/visibleindicatorsmodel.cpp
20 fakeindicatorsmodel.cpp
21)
22
23set(IndicatorsFakeQml_RESOURCES
24 indicators_fake.qrc
25)
26
27qt5_add_resources(IndicatorsFakeQml_RESOURCES_RCC
28 ${IndicatorsFakeQml_RESOURCES}
29)23)
3024
31add_library(IndicatorsFakeQml SHARED25add_library(IndicatorsFakeQml SHARED
32 ${IndicatorsFakeQml_RESOURCES_RCC}
33 ${IndicatorsFakeQml_SOURCES}26 ${IndicatorsFakeQml_SOURCES}
34)27)
35add_definitions(-DUNITYINDICATORS_LIBRARY)28add_definitions(-DUNITYINDICATORS_LIBRARY)
3629
=== removed file 'tests/mocks/Unity/Indicators/FakeMenuPage.qml'
--- tests/mocks/Unity/Indicators/FakeMenuPage.qml 2014-09-09 15:10:52 +0000
+++ tests/mocks/Unity/Indicators/FakeMenuPage.qml 1970-01-01 00:00:00 +0000
@@ -1,27 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19Flickable {
20 objectName: "fakeMenuPlugin"
21 // Make it compatible with the PluginItem interface
22 function reset() {
23 if (shell != undefined && shell.indicator_status != undefined) {
24 shell.indicator_status[objectName].reset++;
25 }
26 }
27}
280
=== modified file 'tests/mocks/Unity/Indicators/Indicators.qmltypes'
--- tests/mocks/Unity/Indicators/Indicators.qmltypes 2014-09-01 12:18:53 +0000
+++ tests/mocks/Unity/Indicators/Indicators.qmltypes 2014-10-15 19:48:28 +0000
@@ -29,6 +29,7 @@
29 exports: ["Unity.Indicators/FakeIndicatorsModel 0.1"]29 exports: ["Unity.Indicators/FakeIndicatorsModel 0.1"]
30 exportMetaObjectRevisions: [0]30 exportMetaObjectRevisions: [0]
31 Property { name: "count"; type: "int"; isReadonly: true }31 Property { name: "count"; type: "int"; isReadonly: true }
32 Property { name: "modelData"; type: "QVariant" }
32 Method {33 Method {
33 name: "load"34 name: "load"
34 Parameter { name: "profile"; type: "string" }35 Parameter { name: "profile"; type: "string" }
@@ -39,6 +40,15 @@
39 Parameter { name: "row"; type: "QVariantMap" }40 Parameter { name: "row"; type: "QVariantMap" }
40 }41 }
41 Method {42 Method {
43 name: "insert"
44 Parameter { name: "row"; type: "int" }
45 Parameter { name: "data"; type: "QVariantMap" }
46 }
47 Method {
48 name: "remove"
49 Parameter { name: "row"; type: "int" }
50 }
51 Method {
42 name: "data"52 name: "data"
43 type: "QVariant"53 type: "QVariant"
44 Parameter { name: "row"; type: "int" }54 Parameter { name: "row"; type: "int" }
@@ -46,6 +56,27 @@
46 }56 }
47 }57 }
48 Component {58 Component {
59 name: "FakeUnityMenuModelCache"
60 prototype: "UnityMenuModelCache"
61 exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]
62 isCreatable: false
63 isSingleton: true
64 exportMetaObjectRevisions: [0]
65 Method {
66 name: "setCachedModelData"
67 Parameter { name: "bus"; type: "QByteArray" }
68 Parameter { name: "path"; type: "QByteArray" }
69 Parameter { name: "actions"; type: "QVariantMap" }
70 Parameter { name: "data"; type: "QVariant" }
71 }
72 Method {
73 name: "setCachedModelData"
74 Parameter { name: "bus"; type: "QByteArray" }
75 Parameter { name: "path"; type: "QByteArray" }
76 Parameter { name: "actions"; type: "QVariantMap" }
77 }
78 }
79 Component {
49 name: "FlatMenuProxyModelRole"80 name: "FlatMenuProxyModelRole"
50 prototype: "QObject"81 prototype: "QObject"
51 exports: ["Unity.Indicators/FlatMenuProxyModelRole 0.1"]82 exports: ["Unity.Indicators/FlatMenuProxyModelRole 0.1"]
@@ -160,19 +191,18 @@
160 }191 }
161 Component { name: "QIdentityProxyModel"; prototype: "QAbstractProxyModel" }192 Component { name: "QIdentityProxyModel"; prototype: "QAbstractProxyModel" }
162 Component {193 Component {
194 name: "SharedUnityMenuModel"
195 prototype: "QObject"
196 exports: ["Unity.Indicators/SharedUnityMenuModel 0.1"]
197 exportMetaObjectRevisions: [0]
198 Property { name: "busName"; type: "QByteArray" }
199 Property { name: "menuObjectPath"; type: "QByteArray" }
200 Property { name: "actions"; type: "QVariantMap" }
201 Property { name: "model"; type: "UnityMenuModel"; isReadonly: true; isPointer: true }
202 }
203 Component {
163 name: "UnityMenuModelCache"204 name: "UnityMenuModelCache"
164 prototype: "QObject"205 prototype: "QObject"
165 exports: ["Unity.Indicators/UnityMenuModelCache 0.1"]
166 isCreatable: false
167 isSingleton: true
168 exportMetaObjectRevisions: [0]
169 Method {
170 name: "model"
171 type: "UnityMenuModel*"
172 Parameter { name: "bus"; type: "QByteArray" }
173 Parameter { name: "path"; type: "QByteArray" }
174 Parameter { name: "actions"; type: "QVariantMap" }
175 }
176 Method {206 Method {
177 name: "contains"207 name: "contains"
178 type: "bool"208 type: "bool"
179209
=== modified file 'tests/mocks/Unity/Indicators/IndicatorsModel.qml'
--- tests/mocks/Unity/Indicators/IndicatorsModel.qml 2014-03-03 11:55:00 +0000
+++ tests/mocks/Unity/Indicators/IndicatorsModel.qml 2014-10-15 19:48:28 +0000
@@ -18,43 +18,151 @@
18import Unity.Indicators 0.1 as Indicators18import Unity.Indicators 0.1 as Indicators
1919
20Indicators.FakeIndicatorsModel {20Indicators.FakeIndicatorsModel {
21 id: root
22
23 Component.onCompleted: {
24 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake1",
25 "/com/canonical/indicators/fake1",
26 "/com/canonical/indicators/fake1",
27 getUnityMenuModelData("fake-indicator-bluetooth",
28 "Bluetooth (F)",
29 "",
30 [ "image://theme/bluetooth-active" ]));
31 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake2",
32 "/com/canonical/indicators/fake2",
33 "/com/canonical/indicators/fake2",
34 getUnityMenuModelData("fake-indicator-network",
35 "Network (F)",
36 "",
37 [ "image://theme/simcard-error", "image://theme/wifi-high" ]));
38 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake3",
39 "/com/canonical/indicators/fake3",
40 "/com/canonical/indicators/fake3",
41 getUnityMenuModelData("fake-indicator-sound",
42 "Messages (F)",
43 "",
44 [ "image://theme/messages-new" ]));
45 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake4",
46 "/com/canonical/indicators/fake4",
47 "/com/canonical/indicators/fake4",
48 getUnityMenuModelData("fake-indicator-power",
49 "Sound (F)",
50 "",
51 [ "image://theme/audio-volume-high" ]));
52 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicators.fake5",
53 "/com/canonical/indicators/fake5",
54 "/com/canonical/indicators/fake5",
55 getUnityMenuModelData("fake-indicator-power",
56 "Battery (F)",
57 "",
58 [ "image://theme/battery-020" ]));
59 }
60
61 function getUnityMenuModelData(identifier, title, label, icons) {
62 var root = [{
63 "rowData": { // 1
64 "label": "",
65 "sensitive": true,
66 "isSeparator": false,
67 "icon": "",
68 "type": "com.canonical.indicator.root",
69 "ext": {},
70 "action": "",
71 "actionState": {
72 "title": title,
73 "label": label,
74 "icons": icons
75 },
76 "isCheck": false,
77 "isRadio": false,
78 "isToggled": false,
79 },
80 "submenu": []
81 }];
82
83 var submenus = [];
84 for (var i = 0; i < 8; i++) {
85 var submenu = {
86 "rowData": { // 1.1
87 "label": identifier,
88 "sensitive": true,
89 "isSeparator": false,
90 "icon": "",
91 "type": undefined,
92 "ext": {},
93 "action": "",
94 "actionState": {},
95 "isCheck": false,
96 "isRadio": false,
97 "isToggled": false,
98 }};
99 submenus.push(submenu);
100 }
101 root[0]["submenu"] = submenus;
102
103 return root;
104 }
105
106 property var originalModelData: [
107 {
108 "identifier": "indicator-fake1",
109 "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
110 "pageSource": "Indicators/DefaultIndicatorPage.qml",
111 "indicatorProperties": {
112 "enabled": true,
113 "busName": "com.canonical.indicators.fake1",
114 "menuObjectPath": "/com/canonical/indicators/fake1",
115 "actionsObjectPath": "/com/canonical/indicators/fake1"
116 }
117 },
118 {
119 "identifier": "indicator-fake2",
120 "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
121 "pageSource": "Indicators/DefaultIndicatorPage.qml",
122 "indicatorProperties": {
123 "enabled": true,
124 "busName": "com.canonical.indicators.fake2",
125 "menuObjectPath": "/com/canonical/indicators/fake2",
126 "actionsObjectPath": "/com/canonical/indicators/fake2"
127 }
128 },
129 {
130 "identifier": "indicator-fake3",
131 "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
132 "pageSource": "Indicators/DefaultIndicatorPage.qml",
133 "indicatorProperties": {
134 "enabled": true,
135 "busName": "com.canonical.indicators.fake3",
136 "menuObjectPath": "/com/canonical/indicators/fake3",
137 "actionsObjectPath": "/com/canonical/indicators/fake3"
138 }
139 },
140 {
141 "identifier": "indicator-fake4",
142 "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
143 "pageSource": "Indicators/DefaultIndicatorPage.qml",
144 "indicatorProperties": {
145 "enabled": true,
146 "busName": "com.canonical.indicators.fake4",
147 "menuObjectPath": "/com/canonical/indicators/fake4",
148 "actionsObjectPath": "/com/canonical/indicators/fake4"
149 }
150 },
151 {
152 "identifier": "indicator-fake5",
153 "widgetSource": "Indicators/DefaultIndicatorWidget.qml",
154 "pageSource": "Indicators/DefaultIndicatorPage.qml",
155 "indicatorProperties": {
156 "enabled": true,
157 "busName": "com.canonical.indicators.fake5",
158 "menuObjectPath": "/com/canonical/indicators/fake5",
159 "actionsObjectPath": "/com/canonical/indicators/fake5"
160 }
161 }
162 ]
21163
22 function load(profile) {164 function load(profile) {
23 unload();165 unload();
24166 root.modelData = originalModelData;
25 append({ "identifier": "indicator-fake1",
26 "position": 0,
27 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget1.qml",
28 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page1.qml",
29 "indicatorProperties": { enabled: true }
30 });
31
32 append({ "identifier": "indicator-fake2",
33 "position": 1,
34 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget2.qml",
35 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page2.qml",
36 "indicatorProperties": { enabled: true }
37 });
38
39 append({ "identifier": "indicator-fake3",
40 "position": 2,
41 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget3.qml",
42 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page3.qml",
43 "indicatorProperties": { enabled: true }
44 });
45
46 append({ "identifier": "indicator-fake4",
47 "position": 3,
48 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget4.qml",
49 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page4.qml",
50 "indicatorProperties": { enabled: true }
51 });
52
53 append({ "identifier": "indicator-fake5",
54 "position": 4,
55 "widgetSource": "qrc:/tests/indciators/qml/fake_menu_widget5.qml",
56 "pageSource": "qrc:/tests/indciators/qml/fake_menu_page5.qml",
57 "indicatorProperties": { enabled: true }
58 });
59 }167 }
60}168}
61169
=== modified file 'tests/mocks/Unity/Indicators/RootActionState.qml'
--- tests/mocks/Unity/Indicators/RootActionState.qml 2013-10-28 18:19:15 +0000
+++ tests/mocks/Unity/Indicators/RootActionState.qml 2014-10-15 19:48:28 +0000
@@ -19,15 +19,23 @@
1919
20import QtQuick 2.020import QtQuick 2.0
2121
22QtObject {22Item {
23 property var menu23 property var menu: null
24 property bool valid: false24 property bool valid: cachedState !== undefined
25 property string title25 property string title: cachedState && cachedState.hasOwnProperty("title") ? cachedState["title"] : ""
26 property string leftLabel26 property string leftLabel: cachedState && cachedState.hasOwnProperty("pre-label") ? cachedState["pre-label"] : ""
27 property string rightLabel27 property string rightLabel: cachedState && cachedState.hasOwnProperty("label") ? cachedState["label"] : ""
28 property var icons28 property var icons: cachedState && cachedState.hasOwnProperty("icons") ? cachedState["icons"] : []
29 property string accessibleName29 property string accessibleName: cachedState && cachedState.hasOwnProperty("accessible-desc") ? cachedState["accessible-desc"] : ""
30 property bool visible: true30 visible: cachedState && cachedState.hasOwnProperty("visible") ? cachedState["visible"] : true
31
32 property var cachedState: menu ? menu.get(0, "actionState") : undefined
33 Connections {
34 target: menu
35 onModelDataChanged: {
36 cachedState = menu.get(0, "actionState");
37 }
38 }
3139
32 signal updated40 signal updated
3341
3442
=== modified file 'tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp'
--- tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp 2014-07-01 09:49:24 +0000
+++ tests/mocks/Unity/Indicators/fakeindicatorsmodel.cpp 2014-10-15 19:48:28 +0000
@@ -31,7 +31,6 @@
31/*! \internal */31/*! \internal */
32FakeIndicatorsModel::~FakeIndicatorsModel()32FakeIndicatorsModel::~FakeIndicatorsModel()
33{33{
34 qDeleteAll(m_indicators);
35}34}
3635
37int FakeIndicatorsModel::count() const36int FakeIndicatorsModel::count() const
@@ -47,29 +46,61 @@
47{46{
48 beginResetModel();47 beginResetModel();
4948
50 qDeleteAll(m_indicators);49 m_modelData.clear();
51 m_indicators.clear();50 Q_EMIT modelDataChanged();
5251
53 endResetModel();52 endResetModel();
54}53}
5554
5655
57void FakeIndicatorsModel::append(const QVariantMap& row)56void FakeIndicatorsModel::append(const QVariantMap& data)
58{57{
59 Indicator* new_row = new QHash<int, QVariant>();58 QList<QVariant> allData = m_modelData.toList();
60 for (auto iter = row.begin(); iter != row.end(); ++iter )59 beginInsertRows(QModelIndex(), allData.count(), allData.count());
61 {60
62 int key = roleNames().key(iter.key().toUtf8(), -1);61 allData.append(data);
63 if (key != -1) {62 m_modelData = allData;
64 new_row->insert(key, iter.value());63 Q_EMIT modelDataChanged();
65 }64
66 }65 endInsertRows();
6766}
68 beginInsertRows(QModelIndex(), m_indicators.count(), m_indicators.count());67
6968void FakeIndicatorsModel::insert(int row, const QVariantMap& data)
70 m_indicators.append(new_row);69{
7170 QList<QVariant> allData = m_modelData.toList();
72 endInsertRows();71 row = qMax(0, qMin(row, allData.count()));
72
73 beginInsertRows(QModelIndex(), row, row);
74
75 allData.insert(row, data);
76 m_modelData = allData;
77 Q_EMIT modelDataChanged();
78
79 endInsertRows();
80}
81
82void FakeIndicatorsModel::remove(int row)
83{
84 QList<QVariant> allData = m_modelData.toList();
85 row = qMax(0, qMin(row, allData.count()));
86
87 beginRemoveRows(QModelIndex(), row, row);
88
89 allData.removeAt(row);
90 m_modelData = allData;
91 Q_EMIT modelDataChanged();
92
93 endRemoveRows();
94}
95
96void FakeIndicatorsModel::setModelData(const QVariant& modelData)
97{
98 beginResetModel();
99
100 m_modelData = modelData;
101 Q_EMIT modelDataChanged();
102
103 endResetModel();
73}104}
74105
75QHash<int, QByteArray> FakeIndicatorsModel::roleNames() const106QHash<int, QByteArray> FakeIndicatorsModel::roleNames() const
@@ -91,18 +122,18 @@
91 return 1;122 return 1;
92}123}
93124
94Q_INVOKABLE QVariant FakeIndicatorsModel::data(int row, int role) const125QVariant FakeIndicatorsModel::data(int row, int role) const
95{126{
96 return data(index(row, 0), role);127 return data(index(row, 0), role);
97}128}
98129
99QVariant FakeIndicatorsModel::data(const QModelIndex &index, int role) const130QVariant FakeIndicatorsModel::data(const QModelIndex &index, int role) const
100{131{
101 if (!index.isValid() || index.row() >= m_indicators.size())132 QList<QVariant> dataList = m_modelData.toList();
133 if (!index.isValid() || index.row() >= dataList.size())
102 return QVariant();134 return QVariant();
103135
104 Indicator* indicator = m_indicators[index.row()];136 return dataList[index.row()].toMap()[roleNames()[role]];
105 return indicator->value(role, QVariant());
106}137}
107138
108QModelIndex FakeIndicatorsModel::parent(const QModelIndex&) const139QModelIndex FakeIndicatorsModel::parent(const QModelIndex&) const
@@ -112,5 +143,5 @@
112143
113int FakeIndicatorsModel::rowCount(const QModelIndex&) const144int FakeIndicatorsModel::rowCount(const QModelIndex&) const
114{145{
115 return m_indicators.count();146 return m_modelData.toList().count();
116}147}
117148
=== modified file 'tests/mocks/Unity/Indicators/fakeindicatorsmodel.h'
--- tests/mocks/Unity/Indicators/fakeindicatorsmodel.h 2014-03-03 12:01:09 +0000
+++ tests/mocks/Unity/Indicators/fakeindicatorsmodel.h 2014-10-15 19:48:28 +0000
@@ -27,6 +27,7 @@
27 Q_OBJECT27 Q_OBJECT
28 Q_ENUMS(Roles)28 Q_ENUMS(Roles)
29 Q_PROPERTY(int count READ count NOTIFY countChanged)29 Q_PROPERTY(int count READ count NOTIFY countChanged)
30 Q_PROPERTY(QVariant modelData READ modelData WRITE setModelData NOTIFY modelDataChanged)
30public:31public:
3132
32 FakeIndicatorsModel(QObject *parent=0);33 FakeIndicatorsModel(QObject *parent=0);
@@ -36,9 +37,14 @@
36 Q_INVOKABLE void unload();37 Q_INVOKABLE void unload();
3738
38 Q_INVOKABLE void append(const QVariantMap& row);39 Q_INVOKABLE void append(const QVariantMap& row);
40 Q_INVOKABLE void insert(int row, const QVariantMap& data);
41 Q_INVOKABLE void remove(int row);
3942
40 Q_INVOKABLE QVariant data(int row, int role) const;43 Q_INVOKABLE QVariant data(int row, int role) const;
4144
45 void setModelData(const QVariant& data);
46 QVariant modelData() const { return m_modelData; }
47
42 /* QAbstractItemModel */48 /* QAbstractItemModel */
43 QHash<int, QByteArray> roleNames() const;49 QHash<int, QByteArray> roleNames() const;
44 int columnCount(const QModelIndex &parent = QModelIndex()) const;50 int columnCount(const QModelIndex &parent = QModelIndex()) const;
@@ -48,12 +54,12 @@
4854
49Q_SIGNALS:55Q_SIGNALS:
50 void countChanged();56 void countChanged();
57 void modelDataChanged();
5158
52private:59private:
53 int count() const;60 int count() const;
5461
55 typedef QHash<int, QVariant> Indicator;62 QVariant m_modelData;
56 QList<Indicator*> m_indicators;
57};63};
5864
59#endif // FAKE_INDICATORSMODEL_H65#endif // FAKE_INDICATORSMODEL_H
6066
=== modified file 'tests/mocks/Unity/Indicators/fakeplugin.cpp'
--- tests/mocks/Unity/Indicators/fakeplugin.cpp 2014-08-20 08:39:09 +0000
+++ tests/mocks/Unity/Indicators/fakeplugin.cpp 2014-10-15 19:48:28 +0000
@@ -26,19 +26,22 @@
26#include "fakeindicatorsmodel.h"26#include "fakeindicatorsmodel.h"
27#include "indicators.h"27#include "indicators.h"
28#include "menucontentactivator.h"28#include "menucontentactivator.h"
29#include "unitymenumodelcache.h"29#include "sharedunitymenumodel.h"
30#include "fakeunitymenumodelcache.h"
30#include "unitymenumodelstack.h"31#include "unitymenumodelstack.h"
31#include "visibleindicatorsmodel.h"32#include "visibleindicatorsmodel.h"
3233
34#include <unitymenumodel.h>
35
33static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {36static QObject* menuModelCacheSingleton(QQmlEngine* engine, QJSEngine* scriptEngine) {
34 Q_UNUSED(engine);37 Q_UNUSED(engine);
35 Q_UNUSED(scriptEngine);38 Q_UNUSED(scriptEngine);
36 return new UnityMenuModelCache;39 return FakeUnityMenuModelCache::singleton();
37}40}
3841
39void IndicatorsFakePlugin::registerTypes(const char * uri)42void IndicatorsFakePlugin::registerTypes(const char * uri)
40{43{
41 Q_INIT_RESOURCE(indicators_fake);44 qRegisterMetaType<UnityMenuModel*>("UnityMenuModel*");
4245
43 // internal46 // internal
44 qmlRegisterType<FakeIndicatorsModel>(uri, 0, 1, "FakeIndicatorsModel");47 qmlRegisterType<FakeIndicatorsModel>(uri, 0, 1, "FakeIndicatorsModel");
@@ -47,8 +50,9 @@
47 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");50 qmlRegisterType<MenuContentActivator>(uri, 0, 1, "MenuContentActivator");
48 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");51 qmlRegisterType<UnityMenuModelStack>(uri, 0, 1, "UnityMenuModelStack");
49 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");52 qmlRegisterType<VisibleIndicatorsModel>(uri, 0, 1, "VisibleIndicatorsModel");
53 qmlRegisterType<SharedUnityMenuModel>(uri, 0, 1, "SharedUnityMenuModel");
5054
51 qmlRegisterSingletonType<UnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);55 qmlRegisterSingletonType<FakeUnityMenuModelCache>(uri, 0, 1, "UnityMenuModelCache", menuModelCacheSingleton);
5256
53 // external uncreatables57 // external uncreatables
54 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");58 qmlRegisterUncreatableType<MenuContentState>(uri, 0, 1, "MenuContentState", "Can't create MenuContentState class");
5559
=== added file 'tests/mocks/Unity/Indicators/fakeunitymenumodelcache.cpp'
--- tests/mocks/Unity/Indicators/fakeunitymenumodelcache.cpp 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Indicators/fakeunitymenumodelcache.cpp 2014-10-15 19:48:28 +0000
@@ -0,0 +1,57 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#include "fakeunitymenumodelcache.h"
18#include <unitymenumodel.h>
19
20QPointer<FakeUnityMenuModelCache> FakeUnityMenuModelCache::theFakeCache = nullptr;
21
22FakeUnityMenuModelCache* FakeUnityMenuModelCache::singleton()
23{
24 if (theFakeCache.isNull()) {
25 theFakeCache = new FakeUnityMenuModelCache();
26 }
27 return theFakeCache.data();
28}
29
30FakeUnityMenuModelCache::FakeUnityMenuModelCache(QObject* parent)
31 : UnityMenuModelCache(parent)
32{
33}
34
35QSharedPointer<UnityMenuModel> FakeUnityMenuModelCache::model(const QByteArray& bus,
36 const QByteArray& path,
37 const QVariantMap& actions)
38{
39 return UnityMenuModelCache::singleton()->model(bus, path, actions);
40}
41
42bool FakeUnityMenuModelCache::contains(const QByteArray& path)
43{
44 return UnityMenuModelCache::singleton()->contains(path);
45}
46
47void FakeUnityMenuModelCache::setCachedModelData(const QByteArray& bus,
48 const QByteArray& path,
49 const QVariantMap& actions,
50 const QVariant& data)
51{
52 // keep a ref forever!
53 if (!m_models.contains(path)) {
54 m_models[path] = model(bus, path, actions);
55 }
56 m_models[path]->setModelData(data);
57}
058
=== added file 'tests/mocks/Unity/Indicators/fakeunitymenumodelcache.h'
--- tests/mocks/Unity/Indicators/fakeunitymenumodelcache.h 1970-01-01 00:00:00 +0000
+++ tests/mocks/Unity/Indicators/fakeunitymenumodelcache.h 2014-10-15 19:48:28 +0000
@@ -0,0 +1,49 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17#ifndef FAKEUNITYMENUMODELCACHE_H
18#define FAKEUNITYMENUMODELCACHE_H
19
20#include "unitymenumodelcache.h"
21
22#include <QVariantMap>
23
24class FakeUnityMenuModelCache : public UnityMenuModelCache
25{
26 Q_OBJECT
27public:
28 FakeUnityMenuModelCache(QObject* parent = nullptr);
29
30 static FakeUnityMenuModelCache* singleton();
31
32 QSharedPointer<UnityMenuModel> model(const QByteArray& bus,
33 const QByteArray& path,
34 const QVariantMap& actions) override;
35 bool contains(const QByteArray& path) override;
36
37
38
39 Q_INVOKABLE void setCachedModelData(const QByteArray& bus,
40 const QByteArray& path,
41 const QVariantMap& actions,
42 const QVariant& data = QVariant());
43
44private:
45 static QPointer<FakeUnityMenuModelCache> theFakeCache;
46 QHash<QByteArray, QSharedPointer<UnityMenuModel>> m_models;
47};
48
49#endif // FAKEUNITYMENUMODELCACHE_H
050
=== removed file 'tests/mocks/Unity/Indicators/indicators_fake.qrc'
--- tests/mocks/Unity/Indicators/indicators_fake.qrc 2013-06-17 09:02:14 +0000
+++ tests/mocks/Unity/Indicators/indicators_fake.qrc 1970-01-01 00:00:00 +0000
@@ -1,14 +0,0 @@
1<RCC>
2 <qresource prefix="/tests/indciators">
3 <file>qml/fake_menu_widget1.qml</file>
4 <file>qml/fake_menu_widget2.qml</file>
5 <file>qml/fake_menu_widget3.qml</file>
6 <file>qml/fake_menu_widget4.qml</file>
7 <file>qml/fake_menu_widget5.qml</file>
8 <file>qml/fake_menu_page1.qml</file>
9 <file>qml/fake_menu_page2.qml</file>
10 <file>qml/fake_menu_page3.qml</file>
11 <file>qml/fake_menu_page4.qml</file>
12 <file>qml/fake_menu_page5.qml</file>
13 </qresource>
14</RCC>
150
=== removed directory 'tests/mocks/Unity/Indicators/qml'
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml 2014-01-14 16:44:35 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_page1.qml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Unity.Indicators 0.1 as Indicators
19
20Indicators.FakeMenuPage {
21 id: menu_plugin1
22
23 Rectangle {
24 id: contents
25 color: "red"
26
27 height: 150
28 width: 150
29
30 anchors {
31 horizontalCenter: parent.horizontalCenter
32 verticalCenter: parent.verticalCenter
33 }
34 }
35}
360
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml 2014-01-14 16:44:35 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_page2.qml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Unity.Indicators 0.1 as Indicators
19
20Indicators.FakeMenuPage {
21 id: menu_plugin2
22
23 Rectangle {
24 id: contents
25 color: "blue"
26
27 height: 150
28 width: 150
29
30 anchors {
31 horizontalCenter: parent.horizontalCenter
32 verticalCenter: parent.verticalCenter
33 }
34 }
35}
360
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml 2014-01-14 16:44:35 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_page3.qml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Unity.Indicators 0.1 as Indicators
19
20Indicators.FakeMenuPage {
21 id: menu_plugin3
22
23 Rectangle {
24 id: contents
25 color: "yellow"
26
27 height: 150
28 width: 150
29
30 anchors {
31 horizontalCenter: parent.horizontalCenter
32 verticalCenter: parent.verticalCenter
33 }
34 }
35}
360
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml 2014-01-14 16:44:35 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_page4.qml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Unity.Indicators 0.1 as Indicators
19
20Indicators.FakeMenuPage {
21 id: menu_plugin4
22
23 Rectangle {
24 id: contents
25 color: "green"
26
27 height: 150
28 width: 150
29
30 anchors {
31 horizontalCenter: parent.horizontalCenter
32 verticalCenter: parent.verticalCenter
33 }
34 }
35}
360
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml 2014-01-14 16:44:35 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_page5.qml 1970-01-01 00:00:00 +0000
@@ -1,35 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import Unity.Indicators 0.1 as Indicators
19
20Indicators.FakeMenuPage {
21 id: menu_plugin5
22
23 Rectangle {
24 id: contents
25 color: "orange"
26
27 height: 150
28 width: 150
29
30 anchors {
31 horizontalCenter: parent.horizontalCenter
32 verticalCenter: parent.verticalCenter
33 }
34 }
35}
360
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml 2013-06-17 09:02:14 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget1.qml 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19Rectangle {
20 width: 40
21 height: 40
22 color : "red"
23}
240
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml 2014-01-13 16:25:32 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget2.qml 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19Rectangle {
20 width: 40
21 height: 40
22 color : "blue"
23}
240
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml 2014-01-13 16:25:32 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget3.qml 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19Rectangle {
20 width: 40
21 height: 40
22 color : "yellow"
23}
240
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml 2013-06-17 09:02:14 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget4.qml 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19Rectangle {
20 width: 40
21 height: 40
22 color : "green"
23}
240
=== removed file 'tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml'
--- tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml 2013-06-17 09:02:14 +0000
+++ tests/mocks/Unity/Indicators/qml/fake_menu_widget5.qml 1970-01-01 00:00:00 +0000
@@ -1,23 +0,0 @@
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18
19Rectangle {
20 width: 40
21 height: 40
22 color : "orange"
23}
240
=== modified file 'tests/mocks/Unity/Indicators/qmldir'
--- tests/mocks/Unity/Indicators/qmldir 2014-08-20 08:39:09 +0000
+++ tests/mocks/Unity/Indicators/qmldir 2014-10-15 19:48:28 +0000
@@ -3,5 +3,4 @@
3typeinfo Indicators.qmltypes3typeinfo Indicators.qmltypes
44
5IndicatorsModel 0.1 IndicatorsModel.qml5IndicatorsModel 0.1 IndicatorsModel.qml
6FakeMenuPage 0.1 FakeMenuPage.qml
7RootActionState 0.1 RootActionState.qml6RootActionState 0.1 RootActionState.qml
87
=== modified file 'tests/mocks/Unity/Launcher/Launcher.qmltypes'
--- tests/mocks/Unity/Launcher/Launcher.qmltypes 2014-06-26 07:47:57 +0000
+++ tests/mocks/Unity/Launcher/Launcher.qmltypes 2014-10-15 19:48:28 +0000
@@ -85,6 +85,7 @@
85 Property { name: "recent"; type: "bool"; isReadonly: true }85 Property { name: "recent"; type: "bool"; isReadonly: true }
86 Property { name: "progress"; type: "int"; isReadonly: true }86 Property { name: "progress"; type: "int"; isReadonly: true }
87 Property { name: "count"; type: "int"; isReadonly: true }87 Property { name: "count"; type: "int"; isReadonly: true }
88 Property { name: "countVisible"; type: "bool"; isReadonly: true }
88 Property { name: "focused"; type: "bool"; isReadonly: true }89 Property { name: "focused"; type: "bool"; isReadonly: true }
89 Property {90 Property {
90 name: "quickList"91 name: "quickList"
@@ -93,6 +94,14 @@
93 isPointer: true94 isPointer: true
94 }95 }
95 Signal {96 Signal {
97 name: "nameChanged"
98 Parameter { name: "name"; type: "string" }
99 }
100 Signal {
101 name: "iconChanged"
102 Parameter { name: "icon"; type: "string" }
103 }
104 Signal {
96 name: "pinnedChanged"105 name: "pinnedChanged"
97 Parameter { name: "pinned"; type: "bool" }106 Parameter { name: "pinned"; type: "bool" }
98 }107 }
@@ -113,6 +122,10 @@
113 Parameter { name: "count"; type: "int" }122 Parameter { name: "count"; type: "int" }
114 }123 }
115 Signal {124 Signal {
125 name: "countVisibleChanged"
126 Parameter { name: "countVisible"; type: "bool" }
127 }
128 Signal {
116 name: "focusedChanged"129 name: "focusedChanged"
117 Parameter { name: "focused"; type: "bool" }130 Parameter { name: "focused"; type: "bool" }
118 }131 }
119132
=== modified file 'tests/mocks/Unity/Unity.qmltypes'
--- tests/mocks/Unity/Unity.qmltypes 2014-09-01 12:18:53 +0000
+++ tests/mocks/Unity/Unity.qmltypes 2014-10-15 19:48:28 +0000
@@ -30,6 +30,25 @@
30 Parameter { name: "row"; type: "int" }30 Parameter { name: "row"; type: "int" }
31 Parameter { name: "role"; type: "int" }31 Parameter { name: "role"; type: "int" }
32 }32 }
33 Method {
34 name: "setCount"
35 Parameter { name: "count"; type: "int" }
36 }
37 Method {
38 name: "resultModel"
39 type: "ResultsModel*"
40 Parameter { name: "row"; type: "int" }
41 }
42 Method {
43 name: "setLayout"
44 Parameter { name: "row"; type: "int" }
45 Parameter { name: "layout"; type: "string" }
46 }
47 Method {
48 name: "setHeaderLink"
49 Parameter { name: "row"; type: "int" }
50 Parameter { name: "headerLink"; type: "string" }
51 }
33 }52 }
34 Component {53 Component {
35 name: "PreviewModel"54 name: "PreviewModel"
@@ -66,6 +85,10 @@
66 exports: ["Unity/FakeResultsModel 0.2", "Unity/ResultsModel 0.2"]85 exports: ["Unity/FakeResultsModel 0.2", "Unity/ResultsModel 0.2"]
67 isCreatable: false86 isCreatable: false
68 exportMetaObjectRevisions: [0, 0]87 exportMetaObjectRevisions: [0, 0]
88 Method {
89 name: "setResultCount"
90 Parameter { name: "result_count"; type: "int" }
91 }
69 }92 }
70 Component {93 Component {
71 name: "Scope"94 name: "Scope"
@@ -76,6 +99,15 @@
76 name: "performQuery"99 name: "performQuery"
77 Parameter { name: "query"; type: "string" }100 Parameter { name: "query"; type: "string" }
78 }101 }
102 Signal { name: "refreshed" }
103 Method {
104 name: "setId"
105 Parameter { name: "id"; type: "string" }
106 }
107 Method {
108 name: "setName"
109 Parameter { name: "name"; type: "string" }
110 }
79 Method {111 Method {
80 name: "setSearchInProgress"112 name: "setSearchInProgress"
81 Parameter { name: "inProg"; type: "bool" }113 Parameter { name: "inProg"; type: "bool" }
82114
=== modified file 'tests/plugins/Unity/Indicators/CMakeLists.txt'
--- tests/plugins/Unity/Indicators/CMakeLists.txt 2013-12-10 14:22:43 +0000
+++ tests/plugins/Unity/Indicators/CMakeLists.txt 2014-10-15 19:48:28 +0000
@@ -40,3 +40,4 @@
40indicator_test(menucontentactivatortest ADDITIONAL_CPPS ${INDICATORS_DIR}/menucontentactivator.cpp)40indicator_test(menucontentactivatortest ADDITIONAL_CPPS ${INDICATORS_DIR}/menucontentactivator.cpp)
41indicator_test(unitymenumodelstacktest ADDITIONAL_CPPS ${TEST_DIR}/mocks/QMenuModel/unitymenumodel.cpp ${INDICATORS_DIR}/unitymenumodelstack.cpp)41indicator_test(unitymenumodelstacktest ADDITIONAL_CPPS ${TEST_DIR}/mocks/QMenuModel/unitymenumodel.cpp ${INDICATORS_DIR}/unitymenumodelstack.cpp)
42indicator_test(rootactionstatetest ADDITIONAL_LIBS IndicatorsQml)42indicator_test(rootactionstatetest ADDITIONAL_LIBS IndicatorsQml)
43indicator_test(sharedunitymenumodeltest ADDITIONAL_LIBS IndicatorsQml)
4344
=== added file 'tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp'
--- tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp 1970-01-01 00:00:00 +0000
+++ tests/plugins/Unity/Indicators/sharedunitymenumodeltest.cpp 2014-10-15 19:48:28 +0000
@@ -0,0 +1,102 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 */
17
18#include "sharedunitymenumodel.h"
19#include "unitymenumodelcache.h"
20
21#include <QtTest>
22#include <unitymenumodel.h>
23
24class SharedUnityMenuModelTest : public QObject
25{
26 Q_OBJECT
27
28 SharedUnityMenuModel* createFullModel(const QByteArray& testId)
29 {
30 SharedUnityMenuModel* model = new SharedUnityMenuModel;
31 model->setBusName("com.canonical." + testId);
32 model->setMenuObjectPath("/com/canonical/" + testId);
33 QVariantMap actions;
34 actions["test"] = QString("/com/canonical/%1/actions").arg(QString(testId));
35 model->setActions(actions);
36
37 return model;
38 }
39
40private Q_SLOTS:
41
42 void testCreateModel()
43 {
44 QSharedPointer<SharedUnityMenuModel> model(createFullModel("test1"));
45 QVERIFY(model->model() != nullptr);
46 }
47
48 void testDifferentDataCreatesDifferentModels()
49 {
50 QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
51 QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test2"));
52
53 QVERIFY(model1->model() != model2->model());
54 }
55
56 void testSameDataCreatesSameModels()
57 {
58 QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
59 QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test1"));
60
61 QCOMPARE(model1->model(), model2->model());
62 }
63
64 void testSharedOwnership()
65 {
66 QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
67 QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test1"));
68
69 QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), true);
70 model1.clear();
71 QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), true);
72 model2.clear();
73 QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), false);
74 }
75
76 // Tests that changing cached model data does not change the model path of others
77 void testLP1328646()
78 {
79 QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
80 QSharedPointer<SharedUnityMenuModel> model2(createFullModel("test1"));
81
82 model2->setMenuObjectPath("/com/canonical/LP1328646");
83
84 QVERIFY(model1->model() != model2->model());
85 QCOMPARE(model1->model()->menuObjectPath(), QByteArray("/com/canonical/test1"));
86 QCOMPARE(model2->model()->menuObjectPath(), QByteArray("/com/canonical/LP1328646"));
87 }
88
89 // Tests that the cache is recreated if deleted.
90 void testDeletedCache()
91 {
92 QSharedPointer<SharedUnityMenuModel> model1(createFullModel("test1"));
93
94 QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), true);
95 delete UnityMenuModelCache::singleton();
96 QCOMPARE(UnityMenuModelCache::singleton()->contains("/com/canonical/test1"), false);
97 }
98
99};
100
101QTEST_GUILESS_MAIN(SharedUnityMenuModelTest)
102#include "sharedunitymenumodeltest.moc"
0103
=== modified file 'tests/qmltests/CMakeLists.txt'
--- tests/qmltests/CMakeLists.txt 2014-10-01 13:22:00 +0000
+++ tests/qmltests/CMakeLists.txt 2014-10-15 19:48:28 +0000
@@ -19,9 +19,9 @@
19set(qmltest_DEFAULT_NO_ADD_TEST TRUE)19set(qmltest_DEFAULT_NO_ADD_TEST TRUE)
20set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C")20set(qmltest_DEFAULT_PROPERTIES ENVIRONMENT "LC_ALL=C")
2121
22add_qml_test(. Shell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single")22add_qml_test(. Shell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
23add_qml_test(. ShellWithPin ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single-pin")23add_qml_test(. ShellWithPin ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/single-pin:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
24add_qml_test(. TabletShell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full")24add_qml_test(. TabletShell ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/LightDM/full:${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
25add_qml_test(Components Background)25add_qml_test(Components Background)
26add_qml_test(Components Carousel)26add_qml_test(Components Carousel)
27add_qml_test(Components DraggingArea)27add_qml_test(Components DraggingArea)
@@ -72,14 +72,13 @@
72add_qml_test(Notifications Notifications)72add_qml_test(Notifications Notifications)
73add_qml_test(Notifications VisualSnapDecisionsQueue)73add_qml_test(Notifications VisualSnapDecisionsQueue)
74add_qml_test(Panel ActiveCallHint)74add_qml_test(Panel ActiveCallHint)
75add_qml_test(Panel IndicatorRow)75add_qml_test(Panel IndicatorRow ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
76add_qml_test(Panel Indicators)76add_qml_test(Panel Indicators ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
77add_qml_test(Panel MenuContent)77add_qml_test(Panel MenuContent ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
78add_qml_test(Panel Panel)78add_qml_test(Panel Panel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
79add_qml_test(Panel SearchIndicator)79add_qml_test(Panel SearchIndicator)
80add_qml_test(Panel/Indicators DefaultIndicatorWidget ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")80add_qml_test(Panel/Indicators DefaultIndicatorWidget ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
81add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")81add_qml_test(Panel/Indicators DefaultIndicatorPage ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
82add_qml_test(Panel/Indicators CachedUnityMenuModel ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}/tests/mocks/QMenuModel")
83# These MenuItemFactory tests need the test/mocks/ to come before plugins/82# These MenuItemFactory tests need the test/mocks/ to come before plugins/
84add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})83add_qml_test(Panel/Indicators MenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
85add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})84add_qml_test(Panel/Indicators MessageMenuItemFactory IMPORT_PATHS ${CMAKE_BINARY_DIR}/tests/mocks ${qmltest_DEFAULT_IMPORT_PATHS})
8685
=== modified file 'tests/qmltests/Greeter/tst_Clock.qml'
--- tests/qmltests/Greeter/tst_Clock.qml 2014-05-01 14:25:18 +0000
+++ tests/qmltests/Greeter/tst_Clock.qml 2014-10-15 19:48:28 +0000
@@ -19,7 +19,7 @@
19import ".."19import ".."
20import "../../../qml/Greeter"20import "../../../qml/Greeter"
21import Ubuntu.Components 0.121import Ubuntu.Components 0.1
22import QMenuModel 0.122import Unity.Indicators 0.1 as Indicators
23import Unity.Test 0.1 as UT23import Unity.Test 0.1 as UT
2424
25Rectangle {25Rectangle {
@@ -36,56 +36,73 @@
36 }36 }
37 }37 }
3838
39 UnityMenuModel {39 function updateDatetimeModelTime(label) {
40 id: menuModel40 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicator.datetime",
41 modelData: [{41 "/com/canonical/indicator/datetime/phone",
42 "rowData": {42 "/com/canonical/indicator/datetime",
43 "actionState": { "label": Qt.formatTime(new Date("October 13, 1975 11:13:00")) }43 [{
44 }44 "rowData": {
45 }]45 "actionState": { "label": label }
46 }
47 }]);
46 }48 }
4749
48 UT.UnityTestCase {50 UT.UnityTestCase {
49 name: "Clock"51 name: "Clock"
52 when: windowShown
5053
51 function init() {54 function init() {
52 var cachedModel = findChild(clock, "timeModel");55 updateDatetimeModelTime(Qt.formatTime(new Date("October 13, 1975 12:14:00")));
53 verify(cachedModel !== undefined);56 clock.visible = true;
54 cachedModel.model = menuModel;57 }
55 }58
5659 // Test that the date portion of the clock updates with custom value.
57 function test_customDate() {60 // Time portion is controlled by indicators
58 var dateObj = new Date("October 13, 1975 11:13:00")61 function test_updateDate() {
59 var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)62 var dateLabel = findChild(clock, "dateLabel");
60 var timeString = Qt.formatTime(dateObj)63 var timeLabel = findChild(clock, "timeLabel");
6164
62 clock.currentDate = dateObj65 var timeString = Qt.formatTime(new Date("October 13, 1975 12:14:00"));
63 var dateLabel = findChild(clock, "dateLabel")66
64 compare(dateLabel.text, dateString, "Not the expected date")67 // initial date.
65 var timeLabel = findChild(clock, "timeLabel")68 var dateObj = new Date("October 13, 1975 11:13:00");
66 compare(timeLabel.text, timeString, "Not the expected time")69 var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate);
67 }70 clock.currentDate = dateObj;
6871
69 function test_dateUpdate() {72 compare(dateLabel.text, dateString, "Not the expected date");
70 var dateObj = new Date("October 13, 1975 11:13:00")73 compare(timeLabel.text, timeString, "Time should come from indicators");
71 var dateString = Qt.formatDate(dateObj, Qt.DefaultLocaleLongDate)74
72 var timeString = Qt.formatTime(dateObj)75 // update date.
7376 var dateObj2 = new Date("October 14, 1976 13:15:00");
77 var dateString2 = Qt.formatDate(dateObj2, Qt.DefaultLocaleLongDate);
78 clock.currentDate = dateObj2;
79
80 compare(dateLabel.text, dateString2, "Not the expected date");
81 compare(timeLabel.text,timeString, "Time should come from indicators");
82 }
83
84 // Test that the date portion of the clock updates with custom value.
85 // Time portion is controlled by indicators
86 function test_updateTime() {
87 var timeLabel = findChild(clock, "timeLabel");
88
89 var timeString1 = Qt.formatTime(new Date("October 13, 1975 11:15:00"));
90 var timeString2 = Qt.formatTime(new Date("October 14, 1976 12:16:00"));
91
92 updateDatetimeModelTime(timeString1);
93 compare(timeLabel.text, timeString1, "Time should come from indicators");
94
95 updateDatetimeModelTime(timeString2);
96 compare(timeLabel.text, timeString2, "Time should come from indicators");
97 }
98
99 function test_indicatorDisconnect() {
74 clock.visible = false100 clock.visible = false
75 var timeModel = findInvisibleChild(clock, "timeModel")101 var timeModel = findInvisibleChild(clock, "timeModel")
76
77 compare(timeModel.menuObjectPath, "", "Clock shouldn't be connected to Indicators when not visible.")102 compare(timeModel.menuObjectPath, "", "Clock shouldn't be connected to Indicators when not visible.")
78103
79 clock.currentDate = dateObj
80
81 var dateLabel = findChild(clock, "dateLabel")
82 compare(dateLabel.text, dateString, "Not the expected date")
83 var timeLabel = findChild(clock, "timeLabel")
84 compare(timeLabel.text, timeString, "Not the expected time")
85
86 clock.visible = true104 clock.visible = true
87105 verify(timeModel.menuObjectPath !== "", "Should be connected to Indicators.")
88 verify(timeModel.menuObjectPath != "", "Should be connected to Indicators.")
89 }106 }
90 }107 }
91}108}
92109
=== removed file 'tests/qmltests/Panel/Indicators/tst_CachedUnityMenuModel.qml'
--- tests/qmltests/Panel/Indicators/tst_CachedUnityMenuModel.qml 2014-08-20 09:16:28 +0000
+++ tests/qmltests/Panel/Indicators/tst_CachedUnityMenuModel.qml 1970-01-01 00:00:00 +0000
@@ -1,137 +0,0 @@
1/*
2 * Copyright 2014 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
17import QtQuick 2.0
18import QtTest 1.0
19import Unity.Test 0.1 as UT
20import QMenuModel 0.1
21import Unity.Indicators 0.1 as Indicators
22import "../../../../qml/Panel/Indicators"
23
24Item {
25 id: root
26 width: units.gu(40)
27 height: units.gu(70)
28
29 Component {
30 id: model
31 CachedUnityMenuModel {}
32 }
33
34 UT.UnityTestCase {
35 name: "CachedUnityMenuModel"
36 when: windowShown
37
38 function cleanup() {
39 doGC();
40 }
41
42 function doGC() {
43 // need to put some wait cycles here to get gc going properly.
44 wait(10);
45 gc();
46 wait(10);
47 }
48
49 function test_createDifferent() {
50 var cachedObject = model.createObject(null,
51 {
52 "busName": "com.canonical.test1",
53 "menuObjectPath": "/com/canonical/test1",
54 "actionsObjectPath": "/com/canonical/test1"
55 });
56
57 var cachedObject2 = model.createObject(null,
58 {
59 "busName": "com.canonical.test2",
60 "menuObjectPath": "/com/canonical/test2",
61 "actionsObjectPath": "/com/canonical/test2"
62 });
63
64 verify(cachedObject.model !== cachedObject2.model);
65 }
66
67 function test_createSame() {
68 var cachedObject = model.createObject(null,
69 {
70 "busName": "com.canonical.test3",
71 "menuObjectPath": "/com/canonical/test3",
72 "actionsObjectPath": "/com/canonical/test3"
73 });
74
75 var cachedObject2 = model.createObject(null,
76 {
77 "busName": "com.canonical.test3",
78 "menuObjectPath": "/com/canonical/test3",
79 "actionsObjectPath": "/com/canonical/test3"
80 });
81
82 verify(cachedObject.model === cachedObject2.model);
83 }
84
85 // Tests that changing cached model data does not change the model path of others
86 function test_lp1328646() {
87 var cachedObject = model.createObject(null,
88 {
89 "busName": "com.canonical.test4",
90 "menuObjectPath": "/com/canonical/test4",
91 "actionsObjectPath": "/com/canonical/test4"
92 });
93
94 var cachedObject2 = model.createObject(null,
95 {
96 "busName": "com.canonical.test4",
97 "menuObjectPath": "/com/canonical/test4",
98 "actionsObjectPath": "/com/canonical/test4"
99 });
100
101 cachedObject.menuObjectPath = "/com/canonical/test5";
102 compare(cachedObject.model.menuObjectPath, "/com/canonical/test5");
103 compare(cachedObject2.model.menuObjectPath, "/com/canonical/test4");
104
105 verify(cachedObject.model !== cachedObject2.model);
106 }
107
108 function createAndDestroy(test) {
109 var cachedObject = model.createObject(null,
110 {
111 "busName": "com.canonical."+test,
112 "menuObjectPath": "/com/canonical/"+test,
113 "actionsObjectPath": "/com/canonical/"+test
114 });
115 var cachedObject2 = model.createObject(null,
116 {
117 "busName": "com.canonical."+test,
118 "menuObjectPath": "/com/canonical/"+test,
119 "actionsObjectPath": "/com/canonical/"+test
120 });
121 cachedObject.destroy();
122 return cachedObject2;
123 }
124
125 function test_destroyAllDeletesModel() {
126 createAndDestroy("test6");
127 doGC();
128 compare(Indicators.UnityMenuModelCache.contains("/com/canonical/test6"), false);
129 }
130
131 function test_destroyPartialKeepsModel() {
132 var model = createAndDestroy("test7");
133 doGC();
134 compare(Indicators.UnityMenuModelCache.contains("/com/canonical/test7"), true);
135 }
136 }
137}
1380
=== modified file 'tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml'
--- tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml 2014-09-29 10:24:58 +0000
+++ tests/qmltests/Panel/Indicators/tst_DefaultIndicatorPage.qml 2014-10-15 19:48:28 +0000
@@ -17,7 +17,7 @@
17import QtQuick 2.017import QtQuick 2.0
18import QtTest 1.018import QtTest 1.0
19import Unity.Test 0.1 as UT19import Unity.Test 0.1 as UT
20import QMenuModel 0.120import Unity.Indicators 0.1 as Indicators
21import "../../../../qml/Panel/Indicators"21import "../../../../qml/Panel/Indicators"
2222
23Item {23Item {
@@ -25,18 +25,14 @@
25 width: units.gu(40)25 width: units.gu(40)
26 height: units.gu(70)26 height: units.gu(70)
2727
28 DefaultIndicatorPage {28 DefaultIndicatorPage {
29 id: page29 id: page
30
31 anchors.fill: parent30 anchors.fill: parent
3231
33 menuModel: UnityMenuModel {}
34 busName: "test"
35 actionsObjectPath: "test"
36 menuObjectPath: "test"
37
38 identifier: "test-indicator"32 identifier: "test-indicator"
39 rootMenuType: "com.canonical.indicator.root"33 busName: "com.caninical.indicator.test"
34 actionsObjectPath: "/com/canonical/indicator/test"
35 menuObjectPath: "/com/canonical/indicator/test"
40 }36 }
4137
42 property var fullMenuData: [{38 property var fullMenuData: [{
@@ -113,29 +109,30 @@
113 "submenu": []109 "submenu": []
114 }]; // end row 1110 }]; // end row 1
115111
112 function initializeMenuData(data) {
113 Indicators.UnityMenuModelCache.setCachedModelData("com.canonical.indicator.test",
114 "/com/canonical/indicator/test",
115 "/com/canonical/indicator/test",
116 data);
117 }
118
116 UT.UnityTestCase {119 UT.UnityTestCase {
117 name: "DefaultIndicatorPage"120 name: "DefaultIndicatorPage"
118121
119 function init() {122 function init() {
120 var mainMenu = findChild(page, "mainMenu");123 initializeMenuData([]);
121 page.menuModel.modelData = [];
122 verify(mainMenu.model !== null);
123 }124 }
124125
125 function test_reloadData() {126 function test_reloadData() {
126 var mainMenu = findChild(page, "mainMenu");127 var mainMenu = findChild(page, "mainMenu");
127128
128 page.menuModel.modelData = [];129 tryCompare(mainMenu, "count", 0);
129 tryCompare(mainMenu, "count", 0);130
130131 initializeMenuData(fullMenuData);
131 page.menuModel.modelData = fullMenuData;132 tryCompare(mainMenu, "count", 3);
132 tryCompare(mainMenu, "count", 3);133
133134 initializeMenuData([]);
134 page.menuModel.modelData = [];135 tryCompare(mainMenu, "count", 0);
135 tryCompare(mainMenu, "count", 0);
136
137 page.menuModel.modelData = fullMenuData;
138 tryCompare(mainMenu, "count", 3);
139 }136 }
140137
141 function test_traverse_rootMenuType_data() {138 function test_traverse_rootMenuType_data() {
@@ -147,7 +144,7 @@
147144
148 function test_traverse_rootMenuType(data) {145 function test_traverse_rootMenuType(data) {
149 page.rootMenuType = data.rootMenuType;146 page.rootMenuType = data.rootMenuType;
150 page.menuModel.modelData = fullMenuData;147 initializeMenuData(fullMenuData);
151148
152 var mainMenu = findChild(page, "mainMenu");149 var mainMenu = findChild(page, "mainMenu");
153 tryCompare(mainMenu, "count", data.expectedCount);150 tryCompare(mainMenu, "count", data.expectedCount);
154151
=== modified file 'tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml'
--- tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml 2014-07-03 13:46:51 +0000
+++ tests/qmltests/Panel/Indicators/tst_DefaultIndicatorWidget.qml 2014-10-15 19:48:28 +0000
@@ -33,7 +33,6 @@
33 top: parent.top33 top: parent.top
34 }34 }
3535
36 menuModel: UnityMenuModel {}
37 busName: "test"36 busName: "test"
38 actionsObjectPath: "test"37 actionsObjectPath: "test"
39 deviceMenuObjectPath: "test"38 deviceMenuObjectPath: "test"
@@ -48,13 +47,6 @@
48 name: "DefaultIndicatorWidget"47 name: "DefaultIndicatorWidget"
49 when: windowShown48 when: windowShown
5049
51 function init() {
52 widget.rootActionState.icons = [];
53 widget.rootActionState.leftLabel = "";
54 widget.rootActionState.rightLabel = "";
55 waitForRendering(widget)
56 }
57
58 // FIXME: add tests50 // FIXME: add tests
59 }51 }
60}52}
6153
=== modified file 'tests/qmltests/Panel/tst_IndicatorItem.qml'
--- tests/qmltests/Panel/tst_IndicatorItem.qml 2014-01-07 14:29:23 +0000
+++ tests/qmltests/Panel/tst_IndicatorItem.qml 2014-10-15 19:48:28 +0000
@@ -43,7 +43,7 @@
4343
44 function test_empty() {44 function test_empty() {
45 compare(indicatorItem.indicatorVisible, false, "IndicatorItem should not be visible.");45 compare(indicatorItem.indicatorVisible, false, "IndicatorItem should not be visible.");
46 indicatorItem.widgetSource = "qrc:/tests/indciators/qml/fake_menu_widget1.qml";46 indicatorItem.widgetSource = "../../../qml/Panel/Indicators/DefaultIndicatorWidget.qml";
47 tryCompare(indicatorItem, "indicatorVisible", true);47 tryCompare(indicatorItem, "indicatorVisible", true);
48 }48 }
49 }49 }
5050
=== modified file 'tests/qmltests/Panel/tst_IndicatorRow.qml'
--- tests/qmltests/Panel/tst_IndicatorRow.qml 2014-03-03 11:55:00 +0000
+++ tests/qmltests/Panel/tst_IndicatorRow.qml 2014-10-15 19:48:28 +0000
@@ -30,15 +30,6 @@
30 width: units.gu(40)30 width: units.gu(40)
31 height: units.gu(60)31 height: units.gu(60)
3232
33 function init_test()
34 {
35 indicatorModel.load("test1");
36
37 indicatorRow.state = "initial";
38 indicatorRow.setCurrentItemIndex(-1);
39 indicatorRow.unitProgress = 0.0;
40 }
41
42 PanelBackground {33 PanelBackground {
43 anchors.fill: indicatorRow34 anchors.fill: indicatorRow
44 }35 }
@@ -63,20 +54,33 @@
63 name: "IndicatorRow"54 name: "IndicatorRow"
64 when: windowShown55 when: windowShown
6556
57 function init() {
58 indicatorModel.load("test1");
59
60 indicatorRow.state = "initial";
61 indicatorRow.setCurrentItemIndex(-1);
62 indicatorRow.unitProgress = 0.0;
63 }
64
66 function get_indicator_item(index) {65 function get_indicator_item(index) {
67 return findChild(indicatorRow.row, "item" + index);66 return findChild(indicatorRow.row, "item" + index);
68 }67 }
6968
70 function test_set_current_item() {69 function test_set_current_item() {
71 init_test();
72 indicatorRow.setCurrentItemIndex(0);70 indicatorRow.setCurrentItemIndex(0);
73 compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake1", "Incorrect item at position 0");71 compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier),
72 "indicator-fake1",
73 "Incorrect item at position 0");
7474
75 indicatorRow.setCurrentItemIndex(1);75 indicatorRow.setCurrentItemIndex(1);
76 compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake2", "Incorrect item at position 1");76 compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier),
77 "indicator-fake2",
78 "Incorrect item at position 1");
7779
78 indicatorRow.setCurrentItemIndex(2);80 indicatorRow.setCurrentItemIndex(2);
79 compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier), "indicator-fake3", "Incorrect item at position 2");81 compare(indicatorRow.indicatorsModel.data(indicatorRow.currentItemIndex, Indicators.IndicatorsModelRole.Identifier),
82 "indicator-fake3",
83 "Incorrect item at position 2");
80 }84 }
8185
82 function test_highlight_data() {86 function test_highlight_data() {
@@ -93,8 +97,6 @@
93 }97 }
9498
95 function test_highlight(data) {99 function test_highlight(data) {
96 init_test();
97
98 indicatorRow.unitProgress = data.progress;100 indicatorRow.unitProgress = data.progress;
99 indicatorRow.setCurrentItemIndex(data.index);101 indicatorRow.setCurrentItemIndex(data.index);
100102
@@ -119,8 +121,6 @@
119 }121 }
120122
121 function test_opacity(data) {123 function test_opacity(data) {
122 init_test();
123
124 indicatorRow.unitProgress = data.progress;124 indicatorRow.unitProgress = data.progress;
125 indicatorRow.setCurrentItemIndex(data.index);125 indicatorRow.setCurrentItemIndex(data.index);
126126
@@ -145,8 +145,6 @@
145 }145 }
146146
147 function test_dimmed(data) {147 function test_dimmed(data) {
148 init_test();
149
150 indicatorRow.unitProgress = data.progress;148 indicatorRow.unitProgress = data.progress;
151 indicatorRow.setCurrentItemIndex(data.index);149 indicatorRow.setCurrentItemIndex(data.index);
152150
153151
=== modified file 'tests/qmltests/Panel/tst_Indicators.qml'
--- tests/qmltests/Panel/tst_Indicators.qml 2014-07-30 16:01:09 +0000
+++ tests/qmltests/Panel/tst_Indicators.qml 2014-10-15 19:48:28 +0000
@@ -158,6 +158,7 @@
158 function init_invisible_indicator(identifier) {158 function init_invisible_indicator(identifier) {
159 tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);159 tryCompareFunction(function() { return findChild(indicators, identifier+"-delegate") !== undefined }, true);
160 var item = findChild(indicators, identifier+"-delegate");160 var item = findChild(indicators, identifier+"-delegate");
161 verify(item !== null);
161162
162 item.enabled = false;163 item.enabled = false;
163 }164 }
164165
=== modified file 'tests/qmltests/Panel/tst_MenuContent.qml'
--- tests/qmltests/Panel/tst_MenuContent.qml 2014-09-09 15:10:52 +0000
+++ tests/qmltests/Panel/tst_MenuContent.qml 2014-10-15 19:48:28 +0000
@@ -26,14 +26,6 @@
26 width: units.gu(40)26 width: units.gu(40)
27 height: units.gu(70)27 height: units.gu(70)
2828
29 property var indicator_status: {
30 'indicator-fake1-page': { 'started': false, 'reset': 0 },
31 'indicator-fake2-page': { 'started': false, 'reset': 0 },
32 'indicator-fake3-page': { 'started': false, 'reset': 0 },
33 'indicator-fake4-page': { 'started': false, 'reset': 0 },
34 'indicator-fake5-page': { 'started': false, 'reset': 0 }
35 }
36
37 // Dummy objects29 // Dummy objects
38 Item { id: greeter }30 Item { id: greeter }
39 Item { id: handle }31 Item { id: handle }
4032
=== modified file 'tests/qmltests/tst_Shell.qml'
--- tests/qmltests/tst_Shell.qml 2014-10-13 15:42:40 +0000
+++ tests/qmltests/tst_Shell.qml 2014-10-15 19:48:28 +0000
@@ -25,14 +25,16 @@
25import Ubuntu.Telephony 0.1 as Telephony25import Ubuntu.Telephony 0.1 as Telephony
26import Unity.Application 0.126import Unity.Application 0.1
27import Unity.Connectivity 0.127import Unity.Connectivity 0.1
28import Unity.Notifications 1.0
28import Unity.Test 0.1 as UT29import Unity.Test 0.1 as UT
29import Powerd 0.130import Powerd 0.1
3031
31import "../../qml"32import "../../qml"
3233
33Row {34Item {
34 id: root35 id: root
35 spacing: 036 width: units.gu(60)
37 height: units.gu(71)
3638
37 QtObject {39 QtObject {
38 id: applicationArguments40 id: applicationArguments
@@ -50,47 +52,43 @@
50 }52 }
51 }53 }
5254
53 Loader {55 Row {
54 id: shellLoader56 anchors.fill: parent
5557 Loader {
56 // Copied from Shell.qml58 id: shellLoader
57 property bool tablet: false59
58 width: tablet ? units.gu(160)60 property bool itemDestroyed: false
59 : applicationArguments.hasGeometry() ? applicationArguments.width()61 sourceComponent: Component {
60 : units.gu(40)62 property string indicatorProfile: "phone"
61 height: tablet ? units.gu(100)63
62 : applicationArguments.hasGeometry() ? applicationArguments.height()64 Shell {
63 : units.gu(71)65 Component.onDestruction: {
6466 shellLoader.itemDestroyed = true;
65 property bool itemDestroyed: false67 }
66 sourceComponent: Component {
67 Shell {
68 Component.onDestruction: {
69 shellLoader.itemDestroyed = true;
70 }68 }
71 }69 }
72 }70 }
73 }71
7472 Rectangle {
75 Rectangle {73 color: "white"
76 color: "white"74 width: units.gu(30)
77 width: units.gu(30)75 height: shellLoader.height
78 height: shellLoader.height76
7977 Column {
80 Column {78 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }
81 anchors { left: parent.left; right: parent.right; top: parent.top; margins: units.gu(1) }79 spacing: units.gu(1)
82 spacing: units.gu(1)80 Row {
83 Row {81 anchors { left: parent.left; right: parent.right }
84 anchors { left: parent.left; right: parent.right }82 Button {
85 Button {83 text: "Show Greeter"
86 text: "Show Greeter"84 onClicked: {
87 onClicked: {85 if (shellLoader.status !== Loader.Ready)
88 if (shellLoader.status !== Loader.Ready)86 return;
89 return;87
9088 var greeter = testCase.findChild(shellLoader.item, "greeter");
91 var greeter = testCase.findChild(shellLoader.item, "greeter");89 if (!greeter.shown) {
92 if (!greeter.shown) {90 greeter.show();
93 greeter.show();91 }
94 }92 }
95 }93 }
96 }94 }
@@ -98,6 +96,31 @@
98 }96 }
99 }97 }
10098
99 Component {
100 id: mockNotification
101
102 QtObject {
103 function invokeAction(actionId) {
104 mockNotificationsModel.actionInvoked(actionId)
105 }
106 }
107 }
108 ListModel {
109 id: mockNotificationsModel
110
111 signal actionInvoked(string actionId)
112
113 function getRaw(id) {
114 return mockNotification.createObject(mockNotificationsModel)
115 }
116
117 onActionInvoked: {
118 if(actionId == "ok_id") {
119 mockNotificationsModel.clear()
120 }
121 }
122 }
123
101 SignalSpy {124 SignalSpy {
102 id: launcherShowDashHomeSpy125 id: launcherShowDashHomeSpy
103 signalName: "showDashHome"126 signalName: "showDashHome"
@@ -119,6 +142,12 @@
119 signalName: "unlockingAllModems"142 signalName: "unlockingAllModems"
120 }143 }
121144
145 SignalSpy {
146 id: notificationActionSpy
147 target: mockNotificationsModel
148 signalName: "actionInvoked"
149 }
150
122 Telephony.CallEntry {151 Telephony.CallEntry {
123 id: phoneCall152 id: phoneCall
124 phoneNumber: "+447812221111"153 phoneNumber: "+447812221111"
@@ -178,6 +207,65 @@
178 compare(ApplicationManager.count, 1)207 compare(ApplicationManager.count, 1)
179 }208 }
180209
210 function test_snapDecisionDismissalReturnsFocus() {
211 var notifications = findChild(shell, "notificationList");
212 var app = ApplicationManager.startApplication("camera-app");
213 var stage = findChild(shell, "stage")
214 // Open an application and focus
215 waitUntilApplicationWindowIsFullyVisible(app);
216 ApplicationManager.focusApplication(app);
217 tryCompare(app.session.surface, "activeFocus", true);
218
219 notifications.model = mockNotificationsModel;
220
221 // FIXME: Hack: SortFilterProxyModelQML doesn't work with QML ListModels which we use
222 // for mocking here (RoleType can't be found in the QML model). As we only need to show
223 // one SnapDecision lets just disable the filtering and make appear any notification as a
224 // SnapDecision.
225 var snapDecisionProxyModel = findInvisibleChild(shell, "snapDecisionProxyModel");
226 snapDecisionProxyModel.filterRegExp = RegExp("");
227
228 // Pop-up a notification
229 addSnapDecisionNotification();
230 waitForRendering(shell);
231
232 // Make sure the notification really opened
233 var notification = findChild(notifications, "notification" + (mockNotificationsModel.count - 1));
234 verify(notification !== undefined && notification != null, "notification wasn't found");
235 tryCompare(notification, "height", notification.implicitHeight)
236 waitForRendering(notification);
237
238 // Make sure activeFocus went away from the app window
239 tryCompare(app.session.surface, "activeFocus", false);
240 tryCompare(stage, "interactive", false);
241
242 // Clicking the button should dismiss the notification and return focus
243 var buttonAccept = findChild(notification, "notify_button0");
244 mouseClick(buttonAccept, buttonAccept.width / 2, buttonAccept.height / 2);
245
246 // Make sure we're back to normal
247 tryCompare(app.session.surface, "activeFocus", true);
248 compare(stage.interactive, true, "Stages not interactive again after modal notification has closed");
249 }
250
251 function addSnapDecisionNotification() {
252 var n = {
253 type: Notification.SnapDecision,
254 hints: {"x-canonical-private-affirmative-tint": "true"},
255 summary: "Tom Ato",
256 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.",
257 icon: "../graphics/avatars/funky.png",
258 secondaryIcon: "../graphics/applicationIcons/facebook.png",
259 actions: [{ id: "ok_id", label: "Ok"},
260 { id: "cancel_id", label: "Cancel"},
261 { id: "notreally_id", label: "Not really"},
262 { id: "noway_id", label: "messages:No way"},
263 { id: "nada_id", label: "messages:Nada"}]
264 }
265
266 mockNotificationsModel.append(n)
267 }
268
181 function test_leftEdgeDrag_data() {269 function test_leftEdgeDrag_data() {
182 return [270 return [
183 {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true},271 {tag: "without launcher", revealLauncher: false, swipeLength: units.gu(27), appHides: true, focusedApp: "dialer-app", launcherHides: true},
184272
=== modified file 'tests/qmltests/tst_ShellWithPin.qml'
--- tests/qmltests/tst_ShellWithPin.qml 2014-10-13 15:42:15 +0000
+++ tests/qmltests/tst_ShellWithPin.qml 2014-10-15 19:48:28 +0000
@@ -61,6 +61,8 @@
61 property bool itemDestroyed: false61 property bool itemDestroyed: false
62 sourceComponent: Component {62 sourceComponent: Component {
63 Shell {63 Shell {
64 property string indicatorProfile: "phone"
65
64 Component.onDestruction: {66 Component.onDestruction: {
65 shellLoader.itemDestroyed = true67 shellLoader.itemDestroyed = true
66 }68 }
6769
=== modified file 'tests/qmltests/tst_TabletShell.qml'
--- tests/qmltests/tst_TabletShell.qml 2014-10-09 13:05:21 +0000
+++ tests/qmltests/tst_TabletShell.qml 2014-10-15 19:48:28 +0000
@@ -57,6 +57,8 @@
57 property bool itemDestroyed: false57 property bool itemDestroyed: false
58 sourceComponent: Component {58 sourceComponent: Component {
59 Shell {59 Shell {
60 property string indicatorProfile: "phone"
61
60 Component.onDestruction: {62 Component.onDestruction: {
61 shellLoader.itemDestroyed = true63 shellLoader.itemDestroyed = true
62 }64 }

Subscribers

People subscribed via source and target branches