@@ -0,0 +1,133 @@
2+ * Copyright 2013 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 "../../../Dash"
20+import Ubuntu.Components 0.1
21+import Unity.Test 0.1 as UT
28+ property ListModel searchHistory : ListModel {}
33+ showLensOnLoaded: "MockLens2"
37+ id: lens_delegate_mapper
38+ lensDelegateMapping: {
39+ "MockLens1": "../tests/qmltests/Dash/qml/fake_lensView1.qml",
40+ "MockLens2": "../tests/qmltests/Dash/qml/fake_lensView2.qml",
41+ "MockLens3": "../tests/qmltests/Dash/qml/fake_lensView3.qml",
42+ "MockLens4": "../tests/qmltests/Dash/qml/fake_lensView4.qml"
44+ genericLens: "../tests/qmltests/Dash/qml/fake_generic_lensView.qml"
53+ Component.onCompleted: {
54+ var dashContent = findChild(dash, "dashContent");
55+ dashContent.lens_mapper = lens_delegate_mapper;
56+ lenses = dashContent.lenses;
60+ // clear and reload the lenses.
62+ var dashContentList = findChild(dash, "dashContentList");
63+ verify(dashContentList != undefined);
64+ tryCompare(dashContentList, "count", 0);
68+ function get_lens_data() {
70+ { tag: "MockLens1", visual_index: 0, should_be_visible: true },
71+ { tag: "MockLens2", visual_index: -1, should_be_visible: false },
72+ { tag: "MockLens3", visual_index: 1, should_be_visible: true },
73+ { tag: "MockLens4", visual_index: 2, should_be_visible: true },
74+ { tag: "MockLens5", visual_index: 3, should_be_visible: true },
78+ function test_set_current_lens_data() {
79+ return get_lens_data()
82+ function test_set_current_lens(data) {
83+ // wait for lenses to load
84+ tryCompare(lenses, "loaded", true);
86+ var dashbar = findChild(dash, "dashbar");
87+ verify(dashbar != undefined)
88+ var dashContent = findChild(dash, "dashContent");
89+ var current_index = dashContent.currentIndex;
91+ dash.setCurrentLens(data.tag, true, false);
92+ compare(dashContent.currentIndex, data.should_be_visible ? data.visual_index : current_index);
93+ compare(dashbar.currentIndex, data.should_be_visible ? data.visual_index : current_index);
96+ function test_show_lens_on_load_data() {
97+ return get_lens_data()
100+ function test_show_lens_on_load(data) {
101+ if (data.should_be_visible == false) {
102+ console.log("Not testing " + data.tag + ": not visible");
105+ dash.showLensOnLoaded = data.tag
107+ var dashContentList = findChild(dash, "dashContentList");
108+ verify(dashContentList != undefined);
109+ tryCompare(dashContentList, "currentIndex", data.visual_index);
112+ function test_dash_bar_set_index_connection_data() {
113+ return get_lens_data()
116+ function test_dash_bar_set_index_connection(data) {
117+ if (data.should_be_visible == false) {
118+ console.log("Not testing " + data.tag + ": not visible");
121+ // wait for lenses to load
122+ tryCompare(lenses, "loaded", true);
124+ var dashbar = findChild(dash, "dashbar");
125+ verify(dashbar != undefined)
126+ var dashContent = findChild(dash, "dashContent");
127+ var current_index = dashContent.currentIndex;
129+ dashbar.itemSelected(data.visual_index);
130+ compare(dashContent.currentIndex, data.should_be_visible ? data.visual_index : current_index);