@@ -45,22 +45,30 @@ Rectangle {
4545 ]
4646 }
4747
48+ SignalSpy {
49+ id: spy
50+ signalName: "triggered"
51+ }
52+
4853 Column {
4954 spacing: units.gu(1)
5055
5156 PreviewActions {
57+ id: oneAction
5258 widgetId: "button"
5359 widgetData: actionDataOneAction
5460 onTriggered: console.log("triggered", widgetId, actionId, data);
5561 }
5662
5763 PreviewActions {
64+ id: buttonAndCombo
5865 widgetId: "buttonAndCombo"
5966 widgetData: actionDataFiveActions
6067 onTriggered: console.log("triggered", widgetId, actionId, data);
6168 }
6269
6370 PreviewActions {
71+ id: twoActions
6472 widgetId: "2buttons"
6573 widgetData: actionDataTwoActions
6674 onTriggered: console.log("triggered", widgetId, actionId, data);
@@ -71,11 +79,50 @@ Rectangle {
7179 name: "PreviewActionTest"
7280 when: windowShown
7381
74− function test_changeEmptyModel() {
75− wait(5000);
76−// imageGallery.widgetData = sourcesModel0;
77−// var placeholderScreenshot = findChild(imageGallery, "placeholderScreenshot");
78−// compare(placeholderScreenshot.visible, true);
82+ function checkButtonPressSignal(target, id, buttonNumber)
83+ {
84+ var button = findChild(root, "button" + id);
85+ verify(button != null);
86+ spy.target = target;
87+ spy.clear();
88+ mouseClick(button, button.width / 2, button.height / 2);
89+ compare(spy.count, 1);
90+ compare(spy.signalArguments[0][0], target.widgetId);
91+ compare(spy.signalArguments[0][1], id);
92+ compare(spy.signalArguments[0][2], target.widgetData["actions"][buttonNumber]);
93+ }
94+
95+ function test_checkButtons_data() {
96+ return [
97+ {tag: "oneActionButton", target: oneAction, id: "someid", buttonNumber: 0 },
98+ {tag: "twobuttonsButton0", target: twoActions, id: "someid1", buttonNumber: 0 },
99+ {tag: "twobuttonsButton1", target: twoActions, id: "someid2", buttonNumber: 1 },
100+ {tag: "buttonAndComboButton0", target: buttonAndCombo, id: "someid3", buttonNumber: 0 }
101+ ]
102+ }
103+
104+ function test_checkButtons(data) {
105+ checkButtonPressSignal(data.target, data.id, data.buttonNumber)
106+ }
107+
108+ function test_comboButton_data() {
109+ return [
110+ {tag: "button1", id: "someid4", buttonNumber: 1 },
111+ {tag: "button2", id: "someid5", buttonNumber: 2 },
112+ {tag: "button3", id: "someid6", buttonNumber: 3 },
113+ {tag: "button4", id: "someid7", buttonNumber: 4 }
114+ ]
115+ }
116+
117+ function test_comboButton(data) {
118+ var button = findChild(root, "moreLessButton");
119+ verify(button != null);
120+ var twoActionsY = twoActions.y
121+ mouseClick(button, button.width / 2, button.height / 2);
122+ tryCompareFunction(function () { return twoActions.y <= twoActionsY; }, false);
123+ checkButtonPressSignal(buttonAndCombo, data.id, data.buttonNumber);
124+ mouseClick(button, button.width / 2, button.height / 2);
125+ tryCompare(twoActions, "y", twoActionsY);
79126 }
80127 }
81128}