@@ -0,0 +1,85 @@
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/Previews"
20+import Unity.Test 0.1 as UT
21+import Ubuntu.Components 0.1
22+
23+Rectangle {
24+ id: root
25+ width: units.gu(60)
26+ height: units.gu(80)
27+
28+ property var progressjson: {
29+ "type": "progress",
30+ "source": { "dbus-name" : "somename", "dbus-object": "somestring" }
31+ }
32+
33+ property var progressjsonFinish: {
34+ "type": "progress",
35+ "source": { "dbus-name" : "somename", "dbus-object": "finish" }
36+ }
37+
38+ property var progressjsonError: {
39+ "type": "progress",
40+ "source": { "dbus-name" : "somename", "dbus-object": "error" }
41+ }
42+
43+ SignalSpy {
44+ id: spy
45+ signalName: "triggered"
46+ }
47+
48+ PreviewProgress {
49+ id: previewProgress
50+ widgetId: "previewProgress"
51+ widgetData: progressjson
52+ width: units.gu(30)
53+
54+ Rectangle {
55+ anchors.fill: parent
56+ color: "red"
57+ opacity: 0.1
58+ }
59+ }
60+
61+ UT.UnityTestCase {
62+ name: "PreviewHeaderTest"
63+ when: windowShown
64+
65+ function test_json() {
66+ spy.target = previewProgress
67+
68+ // The mock DownloadTracker triggers its signals when you pass
69+ // finish/error as dbus-object to it. Exercise it here
70+ previewProgress.widgetData = progressjsonFinish;
71+ compare(spy.count, 1);
72+ var args = spy.signalArguments[0];
73+ compare(args[0], "previewProgress");
74+ compare(args[1], "finished");
75+ compare(args[2], progressjsonFinish);
76+
77+ previewProgress.widgetData = progressjsonError;
78+ compare(spy.count, 2);
79+ var args = spy.signalArguments[1];
80+ compare(args[0], "previewProgress");
81+ compare(args[1], "failed");
82+ compare(args[2], progressjsonError);
83+ }
84+ }
85+}