@@ -0,0 +1,76 @@
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 Ubuntu.Components 0.1
20+import "../../../../qml/Dash/Previews"
21+import Unity.Test 0.1 as UT
22+import QtMultimedia 5.0
23+
24+Rectangle {
25+ id: root
26+ width: units.gu(60)
27+ height: units.gu(80)
28+ color: Theme.palette.selected.background
29+
30+ PreviewWidgetFactory {
31+ id: factory
32+ anchors {
33+ left: parent.left
34+ right: parent.right
35+ }
36+
37+ source: Qt.resolvedUrl("MockPreviewWidget.qml")
38+
39+ widgetData: {
40+ "type": "mock"
41+ }
42+ }
43+
44+ SignalSpy {
45+ id: triggeredSpy
46+ target: factory
47+ signalName: "triggered"
48+ }
49+
50+ UT.UnityTestCase {
51+ name: "PreviewWidgetFactory"
52+ when: windowShown
53+
54+ property Item mockWidget: findChild(factory, "mockPreviewWidget")
55+
56+ function init() {
57+ verify(typeof mockWidget === "object", "Could not find the mock preview widget.");
58+ }
59+
60+ function test_previewData() {
61+ tryCompare(mockWidget, "widgetData", factory.widgetData);
62+ }
63+
64+ function test_triggered() {
65+ mockWidget.trigger();
66+
67+ triggeredSpy.wait();
68+
69+ var args = triggeredSpy.signalArguments[0];
70+
71+ compare(args[0], "mockWidget", "Widget id not passed correctly.");
72+ compare(args[1], "mockAction", "Action id not passed correctly.");
73+ compare(args[2]["mock"], "data", "Data not passed correctly.");
74+ }
75+ }
76+}