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 "../../../../qml/Dash/Previews"
20
import Unity.Test 0.1 as UT
26
color: Theme.palette.selected.background
28
PreviewWidgetFactory {
39
signalName: "triggered"
43
name: "PreviewWidgetFactory"
46
property Item mockWidget: findChild(factory, "mockPreviewWidget")
49
factory.source = Qt.binding(function() { return factory.widgetSource });
52
function test_previewData() {
53
factory.source = Qt.resolvedUrl("MockPreviewWidget.qml");
55
verify(typeof mockWidget === "object", "Could not find the mock preview widget.");
57
tryCompare(mockWidget, "widgetData", factory.widgetData);
60
function test_triggered() {
61
factory.source = Qt.resolvedUrl("MockPreviewWidget.qml");
63
verify(typeof mockWidget === "object", "Could not find the mock preview widget.");
69
var args = triggeredSpy.signalArguments[0];
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.");
76
function test_mapping_data() {
78
{ tag: "Actions", type: "actions", source: "PreviewActions.qml" },
79
{ tag: "Audio", type: "audio", source: "PreviewAudioPlayback.qml" },
80
{ tag: "Gallery", type: "gallery", source: "PreviewImageGallery.qml" },
81
{ tag: "Header", type: "header", source: "PreviewHeader.qml" },
82
{ tag: "Image", type: "image", source: "PreviewZoomableImage.qml" },
83
{ tag: "Progress", type: "progress", source: "PreviewProgress.qml" },
84
{ tag: "Rating Input", type: "rating-input", source: "PreviewRatingInput.qml" },
85
{ tag: "Rating Display", type: "reviews", source: "PreviewRatingDisplay.qml" },
86
{ tag: "Text", type: "text", source: "PreviewTextSummary.qml" },
87
{ tag: "Video", type: "video", source: "PreviewVideoPlayback.qml" },
91
function test_mapping(data) {
92
factory.widgetData = { type: data.type };
93
factory.widgetType = data.type;
95
verify(("" + factory.source).indexOf(data.source) != -1);