@@ -0,0 +1,121 @@
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 Ubuntu.Components 0.1
29+ property var actionDataActions: {
30+ "actions": [{"label": "10", "id": "someid", "icon": Qt.resolvedUrl("../artwork/avatar@12.png"), "temporaryIcon": Qt.resolvedUrl("../artwork/emblem.png")},
31+ {"label": "12", "id": "someid2", "icon": Qt.resolvedUrl("../artwork/checkers.png"), "temporaryIcon": Qt.resolvedUrl("../artwork/background.png")},
32+ {"label": "", "id": "someid3", "icon": Qt.resolvedUrl("../artwork/music-player-design.png")},
38+ signalName: "triggered"
43+ widgetId: "iconActions"
44+ widgetData: actionDataActions
46+ if (timer.index !== -1) {
47+ console.log("Processing other click, ignoring");
51+ for (var i in actionDataActions.actions) {
52+ if (actionId == actionDataActions.actions[i].id) {
59+ console.log("triggered", widgetId, actionId);
67+ property int index: -1
70+ actionDataActions.actions[index].icon = Qt.resolvedUrl("../../UnityLogo.png");
71+ preview.widgetDataChanged();
77+ name: "PreviewIconActionTest"
85+ function test_checkButtonWithTemporary_data() {
87+ {tag: "with temporary", temporaryIcon: "emblem", index: 0},
88+ {tag: "without temporary", temporaryIcon: undefined, index: 2},
92+ function test_checkButtonWithTemporary(data) {
93+ spy.target = preview;
95+ var buttonId = actionDataActions.actions[data.index].id;
96+ var buttonIcon = actionDataActions.actions[data.index].icon;
97+ var buttonTemporaryIcon = actionDataActions.actions[data.index]["temporaryIcon"];
98+ var buttonLabel = actionDataActions.actions[data.index].label;
100+ var button = findChild(root, "button" + buttonId);
101+ var image = findChildsByType(button, "QQuickImage")[0];
102+ var label = findChildsByType(button, "Label")[0];
104+ compare(image.source, buttonIcon);
105+ compare(label.text, buttonLabel);
107+ compare(spy.count, 1);
108+ compare(spy.signalArguments[0][1], buttonId);
110+ if (buttonTemporaryIcon) {
111+ compare(image.source, buttonTemporaryIcon);
114+ tryCompareFunction(function() {
115+ var button = findChild(root, "button" + buttonId);
116+ var image = findChildsByType(button, "QQuickImage")[0];
117+ return image.source && image.source.toString().indexOf("UnityLogo") > -1;