@@ -0,0 +1,148 @@
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 actionDataOneAction: {
30+ "actions": [{"label": "Some Label", "icon": "../graphics/play_button.png", "id": "someid"}]
33+ property var actionDataTwoActions: {
34+ "actions": [{"label": "Some Label A", "icon": "../graphics/icon_clear.png", "id": "someid1"},
35+ {"label": "Some Label B", "icon": "../graphics/play_button.png", "id": "someid2"}
39+ property var actionDataFiveActions: {
40+ "actions": [{"label": "Some Label C", "icon": "../graphics/play_button.png", "id": "someid3"},
41+ {"label": "Some Label D", "icon": "../graphics/icon_clear.png", "id": "someid4"},
42+ {"label": "Some Label E", "icon": "../graphics/play_button.png", "id": "someid5"},
43+ {"label": "Some Label F", "icon": "../graphics/icon_clear.png", "id": "someid6"},
44+ {"label": "Some Label G", "icon": "../graphics/play_button.png", "id": "someid7"}
50+ signalName: "triggered"
59+ widgetData: actionDataOneAction
60+ onTriggered: console.log("triggered", widgetId, actionId);
72+ widgetId: "buttonAndCombo"
73+ widgetData: actionDataFiveActions
74+ onTriggered: console.log("triggered", widgetId, actionId);
87+ widgetData: actionDataTwoActions
88+ onTriggered: console.log("triggered", widgetId, actionId);
94+ name: "PreviewActionTest"
102+ function checkButtonPressSignal(target, id)
104+ var button = findChild(root, "button" + id);
105+ verify(button != null);
106+ spy.target = target;
107+ mouseClick(button, button.width / 2, button.height / 2);
108+ compare(spy.count, 1);
109+ compare(spy.signalArguments[0][0], target.widgetId);
110+ compare(spy.signalArguments[0][1], id);
113+ function test_checkButtons_data() {
115+ {tag: "oneActionButton", target: oneAction, id: "someid" },
116+ {tag: "twobuttonsButton0", target: twoActions, id: "someid1" },
117+ {tag: "twobuttonsButton1", target: twoActions, id: "someid2" },
118+ {tag: "buttonAndComboButton0", target: buttonAndCombo, id: "someid3" }
122+ function test_checkButtons(data) {
123+ checkButtonPressSignal(data.target, data.id, data.buttonNumber)
126+ function test_comboButton_data() {
128+ {tag: "button1", id: "someid4" },
129+ {tag: "button2", id: "someid5" },
130+ {tag: "button3", id: "someid6" },
131+ {tag: "button4", id: "someid7" }
135+ function test_comboButton(data) {
136+ var button = findChild(root, "moreLessButton");
137+ var buttonColumn = findChild(root, "buttonColumn");
138+ verify(button != null);
139+ var twoActionsY = twoActions.y
140+ mouseClick(button, button.width / 2, button.height / 2);
141+ tryCompareFunction(function () { return twoActions.y <= twoActionsY; }, false);
142+ tryCompare(buttonColumn, "height", buttonColumn.implicitHeight);
143+ checkButtonPressSignal(buttonAndCombo, data.id, data.buttonNumber);
144+ mouseClick(button, button.width / 2, button.height / 2);
145+ tryCompare(twoActions, "y", twoActionsY);