2
* Copyright 2014 Canonical Ltd.
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.
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.
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/>.
19
import Unity.Test 0.1 as UT
21
import Unity.Indicators 0.1 as Indicators
22
import "../../../../qml/Panel/Indicators"
31
CachedUnityMenuModel {}
35
name: "CachedUnityMenuModel"
43
// need to put some wait cycles here to get gc going properly.
49
function test_createDifferent() {
50
var cachedObject = model.createObject(null,
52
"busName": "com.canonical.test1",
53
"menuObjectPath": "/com/canonical/test1",
54
"actionsObjectPath": "/com/canonical/test1"
57
var cachedObject2 = model.createObject(null,
59
"busName": "com.canonical.test2",
60
"menuObjectPath": "/com/canonical/test2",
61
"actionsObjectPath": "/com/canonical/test2"
64
verify(cachedObject.model !== cachedObject2.model);
67
function test_createSame() {
68
var cachedObject = model.createObject(null,
70
"busName": "com.canonical.test3",
71
"menuObjectPath": "/com/canonical/test3",
72
"actionsObjectPath": "/com/canonical/test3"
75
var cachedObject2 = model.createObject(null,
77
"busName": "com.canonical.test3",
78
"menuObjectPath": "/com/canonical/test3",
79
"actionsObjectPath": "/com/canonical/test3"
82
verify(cachedObject.model === cachedObject2.model);
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,
89
"busName": "com.canonical.test4",
90
"menuObjectPath": "/com/canonical/test4",
91
"actionsObjectPath": "/com/canonical/test4"
94
var cachedObject2 = model.createObject(null,
96
"busName": "com.canonical.test4",
97
"menuObjectPath": "/com/canonical/test4",
98
"actionsObjectPath": "/com/canonical/test4"
101
cachedObject.menuObjectPath = "/com/canonical/test5";
102
compare(cachedObject.model.menuObjectPath, "/com/canonical/test5");
103
compare(cachedObject2.model.menuObjectPath, "/com/canonical/test4");
105
verify(cachedObject.model !== cachedObject2.model);
108
function createAndDestroy(test) {
109
var cachedObject = model.createObject(null,
111
"busName": "com.canonical."+test,
112
"menuObjectPath": "/com/canonical/"+test,
113
"actionsObjectPath": "/com/canonical/"+test
115
var cachedObject2 = model.createObject(null,
117
"busName": "com.canonical."+test,
118
"menuObjectPath": "/com/canonical/"+test,
119
"actionsObjectPath": "/com/canonical/"+test
121
cachedObject.destroy();
122
return cachedObject2;
125
function test_destroyAllKeepsModel() {
126
createAndDestroy("test6");
128
compare(Indicators.UnityMenuModelCache.contains("/com/canonical/test6"), true);
131
function test_destroyPartialKeepsModel() {
132
var model = createAndDestroy("test7");
134
compare(Indicators.UnityMenuModelCache.contains("/com/canonical/test7"), true);