@@ -0,0 +1,112 @@
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
21+import Unity 0.1 as Unity
27+ color: Theme.palette.selected.background
33+ property var applicationManager: null
36+ Unity.FakePreviewModel {
44+ previewModel: mockPreviewModel
49+ target: mockPreviewModel
50+ signalName: "actionTriggered"
57+ function test_triggered() {
58+ waitForRendering(preview);
59+ var widget = findChild(preview, "widget-3");
61+ compare(typeof widget, "object", "Could not find the widget object.");
63+ widget.triggered(widget.widgetId, "mockAction", {"mock": "data"});
67+ var args = triggeredSpy.signalArguments[0];
69+ compare(args[0], "widget-3", "Widget id not passed correctly.");
70+ compare(args[1], "mockAction", "Action id not passed correctly.");
71+ compare(args[2]["mock"], "data", "Data not passed correctly.");
74+ function test_showProcessing() {
75+ waitForRendering(preview);
76+ var widget = findChild(preview, "widget-3");
77+ widget.triggered(widget.widgetId, "mockAction", {"mock": "data"});
79+ var processing = findChild(preview, "processingMouseArea");
81+ tryCompare(processing, "enabled", true);
83+ preview.previewModelChanged();
85+ tryCompare(processing, "enabled", false);
88+ function test_containOnFocus() {
89+ waitForRendering(preview);
90+ var widget = findChild(preview, "widget-13");
92+ widget.forceActiveFocus();
94+ var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
96+ tryCompareFunction(function () { return bottomLeft.y <= preview.height }, true);
99+ function test_containOnGrow() {
100+ waitForRendering(preview);
101+ var widget = findChild(preview, "widget-13");
103+ widget.forceActiveFocus();
104+ widget.height += 200;
106+ tryCompareFunction(function () {
107+ var bottomLeft = preview.mapFromItem(widget, 0, widget.height);
108+ return bottomLeft.y <= preview.height