@@ -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 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+
17+import QtQuick 2.0
18+import QtTest 1.0
19+import "../../../qml/Dash"
20+import Unity.Test 0.1 as UT
21+import Unity 0.2 as Unity
22+import Dash 0.1
23+
24+Rectangle {
25+ id: root
26+ width: units.gu(60)
27+ height: units.gu(60)
28+ color: Theme.palette.selected.background
29+
30+ Unity.MockScope {
31+ id: mockScope
32+ }
33+
34+ Unity.FakeResultsModel {
35+ id: mockResultsModel
36+ }
37+
38+ PreviewListView {
39+ id: listView
40+ anchors.fill: parent
41+ scope: mockScope
42+ scopeStyle: ScopeStyle { }
43+ }
44+
45+ UT.UnityTestCase {
46+ id: testCase
47+ name: "PreviewListView"
48+ when: windowShown
49+
50+ property MouseArea mouseArea: findChild(listView, "processingMouseArea")
51+
52+ SignalSpy {
53+ id: clickedSpy
54+ signalName: "clicked"
55+ target: testCase.mouseArea
56+ }
57+
58+ function init() {
59+ listView.model = mockResultsModel;
60+ listView.currentIndex = 1;
61+ listView.open = true;
62+ verify(testCase.mouseArea, "Can't find the processingMouseArea object.");
63+ }
64+
65+ function cleanup() {
66+ listView.open = false;
67+ listView.model = null;
68+ clickedSpy.clear();
69+ }
70+
71+ function test_notProcessing() {
72+ expectFail("", "processingMouseArea should not receive the click.");
73+ mouseClick(listView, listView.width / 2, listView.height / 2);
74+ clickedSpy.wait();
75+ }
76+
77+ function test_processing() {
78+ verify(listView.currentItem, "currentItem is not ready yet");
79+ listView.currentItem.previewModel.setLoaded(false);
80+
81+ tryCompare(listView, "processing", true);
82+
83+ mouseClick(listView, listView.width / 2, listView.height / 2);
84+ clickedSpy.wait();
85+ }
86+ }
87+}