@@ -1,5 +1,5 @@
11/*
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
33 *
44 * This program is free software; you can redistribute it and/or modify
55 * it under the terms of the GNU General Public License as published by
@@ -14,10 +14,12 @@
1414 * along with this program. If not, see <http://www.gnu.org/licenses/>.
1515 */
1616
17−import QtQuick 2.0
17+import QtQuick 2.4
18+import QtQuick.Layouts 1.1
1819import QtTest 1.0
1920import ".."
2021import "../../../qml/Notifications"
22+import "../../../qml/Components/UnityInputInfo"
2123import Ubuntu.Components 0.1
2224import Unity.Test 0.1
2325import Unity.Notifications 1.0
@@ -74,7 +76,10 @@ Item {
7476 icon: "../graphics/avatars/amanda.png",
7577 secondaryIcon: "incoming-call",
7678 actions: [{ id: "ok_id", label: "Ok"},
77− { id: "cancel_id", label: "Cancel"}]
79+ { id: "cancel_id", label: "Cancel"},
80+ { id: "foo_id", label: "Foo"},
81+ { id: "bar_id", label: "Bar"}
82+ ]
7883 }
7984
8085 mockModel.append(n)
@@ -97,7 +102,6 @@ Item {
97102
98103 MouseArea{
99104 id: clickThroughCatcher
100−
101105 anchors.fill: parent
102106 }
103107
@@ -108,6 +112,7 @@ Item {
108112
109113 anchors.fill: parent
110114 model: mockModel
115+ hasMouse: UnityInputInfo.mice > 0 // for testing, we add/remove only a mock mouse
111116 }
112117 }
113118
@@ -140,6 +145,24 @@ Item {
140145 text: "clear model"
141146 onClicked: rootRow.clearNotifications()
142147 }
148+
149+ RowLayout {
150+ Layout.fillWidth: true
151+ CheckBox {
152+ id: fakeMouseCB
153+ onClicked: {
154+ if (checked) {
155+ UnityInputInfo.inputInfo.addMockMouse();
156+ } else {
157+ UnityInputInfo.inputInfo.removeMockMouse();
158+ }
159+ }
160+ }
161+ Label {
162+ text: "With fake mouse"
163+ anchors.verticalCenter: parent.verticalCenter
164+ }
165+ }
143166 }
144167 }
145168
@@ -258,21 +281,42 @@ Item {
258281
259282 if(data.buttonRowVisible) {
260283 var swipeButton = findChild(buttonRow, "notify_swipe_button")
261− var slider = findChild(swipeButton, "slider")
262− var swipeMouseArea = findChild(swipeButton, "swipeMouseArea")
263− var x = swipeMouseArea.width / 2
264− var y = swipeMouseArea.height / 2
284+
285+ if (!swipeButton.clickToAct) { // don't run if there's a real mouse
286+ var slider = findChild(swipeButton, "slider")
287+ var swipeMouseArea = findChild(swipeButton, "swipeMouseArea")
288+ var x = swipeMouseArea.width / 2
289+ var y = swipeMouseArea.height / 2
290+
291+ if(data.checkSwipeToActAccept) {
292+ tryCompareFunction(function() { mouseDrag(slider, x, y, (swipeMouseArea.width / 2) - slider.width, 0); return actionSpy.signalArguments.length > 0; }, true);
293+ compare(actionSpy.signalArguments[0][0], data.actions.data(0, ActionModel.RoleActionId), "got wrong id for positive action");
294+ actionSpy.clear();
295+ }
296+ if(data.checkSwipeToActReject) {
297+ tryCompareFunction(function() { mouseDrag(slider, x, y, -(swipeMouseArea.width / 2), 0); return actionSpy.signalArguments.length > 0; }, true);
298+ compare(actionSpy.signalArguments[0][0], data.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action");
299+ actionSpy.clear();
300+ }
301+ }
302+
303+ // add a mock mouse, test clicking the left/right buttons
304+ UnityInputInfo.inputInfo.addMockMouse();
305+ var leftButton = findChild(swipeButton, "leftButton");
306+ var rightButton = findChild(swipeButton, "rightButton");
265307
266308 if(data.checkSwipeToActAccept) {
267− tryCompareFunction(function() { mouseDrag(slider, x, y, (swipeMouseArea.width / 2) - slider.width, 0); return actionSpy.signalArguments.length > 0; }, true);
268− compare(actionSpy.signalArguments[0][0], data.actions.data(0, ActionModel.RoleActionId), "got wrong id for positive action")
269− actionSpy.clear()
309+ mouseClick(rightButton);
310+ compare(actionSpy.signalArguments[0][0], data.actions.data(0, ActionModel.RoleActionId), "got wrong id for positive action");
311+ actionSpy.clear();
270312 }
313+
271314 if(data.checkSwipeToActReject) {
272− tryCompareFunction(function() { mouseDrag(slider, x, y, -(swipeMouseArea.width / 2), 0); return actionSpy.signalArguments.length > 0; }, true);
273− compare(actionSpy.signalArguments[0][0], data.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action")
274− actionSpy.clear()
315+ mouseClick(leftButton);
316+ compare(actionSpy.signalArguments[0][0], data.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action");
317+ actionSpy.clear();
275318 }
319+ UnityInputInfo.inputInfo.removeMockMouse();
276320 }
277321 }
278322 }