@@ -0,0 +1,121 @@
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
30+ Indicators.CachedUnityMenuModel {}
34+ name: "CachedUnityMenuModel"
37+ function test_createDifferent() {
38+ var cachedObject = model.createObject(root,
40+ "busName": "com.canonical.test1",
41+ "menuObjectPath": "com/canonical/test1",
42+ "actionsObjectPath": "com/canonical/test1/actions"
45+ var cachedObject2 = model.createObject(root,
47+ "busName": "com.canonical.test2",
48+ "menuObjectPath": "com/canonical/test2",
49+ "actionsObjectPath": "com/canonical/test2/actions"
52+ verify(cachedObject.model !== cachedObject2.model);
54+ cachedObject.destroy();
55+ cachedObject2.destroy();
58+ function test_createSame() {
59+ var cachedObject = model.createObject(root,
61+ "busName": "com.canonical.test1",
62+ "menuObjectPath": "com/canonical/test1",
63+ "actionsObjectPath": "com/canonical/test1/actions"
66+ var cachedObject2 = model.createObject(root,
68+ "busName": "com.canonical.test1",
69+ "menuObjectPath": "com/canonical/test1",
70+ "actionsObjectPath": "com/canonical/test1/actions"
73+ verify(cachedObject.model === cachedObject2.model);
75+ cachedObject.destroy();
76+ cachedObject2.destroy();
79+ function test_destroyAllDeletesModel() {
80+ var cachedObject = model.createObject(root,
82+ "busName": "com.canonical.test1",
83+ "menuObjectPath": "com/canonical/test1",
84+ "actionsObjectPath": "com/canonical/test1/actions"
87+ var cachedObject2 = model.createObject(root,
89+ "busName": "com.canonical.test1",
90+ "menuObjectPath": "com/canonical/test1",
91+ "actionsObjectPath": "com/canonical/test1/actions"
94+ var menuModel = cachedObject.model;
95+ cachedObject.destroy();
96+ cachedObject2.destroy();
97+ tryCompareFunction(function() { return Indicators.UnityMenuModelCache.contains(menuModel) }, false);
100+ function test_destroyPartialKeepsModel() {
101+ var cachedObject = model.createObject(root,
103+ "busName": "com.canonical.test1",
104+ "menuObjectPath": "com/canonical/test1",
105+ "actionsObjectPath": "com/canonical/test1/actions"
108+ var cachedObject2 = model.createObject(root,
110+ "busName": "com.canonical.test1",
111+ "menuObjectPath": "com/canonical/test1",
112+ "actionsObjectPath": "com/canonical/test1/actions"
115+ var menuModel = cachedObject.model;
116+ cachedObject.destroy();
118+ compare(Indicators.UnityMenuModelCache.contains(menuModel), true);