@@ -1,5 +1,5 @@
2− * Copyright (C) 2014 Canonical, Ltd.
2+ * Copyright (C) 2014, 2015 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
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
5 * it under the terms of the GNU General Public License as published by
@@ -14,10 +14,12 @@
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17−import QtQuick 2.0
17+import QtQuick 2.4
18+import QtQuick.Layouts 1.1
18import QtTest 1.0
19import QtTest 1.0
19import ".."
20import ".."
20import "../../../qml/Notifications"
21import "../../../qml/Notifications"
22+import "../../../qml/Components/UnityInputInfo"
21import Ubuntu.Components 0.1
23import Ubuntu.Components 0.1
22import Unity.Test 0.1
24import Unity.Test 0.1
23import Unity.Notifications 1.0
25import Unity.Notifications 1.0
@@ -74,7 +76,10 @@ Item {
74 icon: "../graphics/avatars/amanda.png",
76 icon: "../graphics/avatars/amanda.png",
75 secondaryIcon: "incoming-call",
77 secondaryIcon: "incoming-call",
76 actions: [{ id: "ok_id", label: "Ok"},
78 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"}
80 mockModel.append(n)
85 mockModel.append(n)
@@ -97,7 +102,6 @@ Item {
98 MouseArea{
103 MouseArea{
99 id: clickThroughCatcher
104 id: clickThroughCatcher
101 anchors.fill: parent
105 anchors.fill: parent
@@ -108,6 +112,7 @@ Item {
109 anchors.fill: parent
113 anchors.fill: parent
110 model: mockModel
114 model: mockModel
115+ hasMouse: UnityInputInfo.mice > 0 // for testing, we add/remove only a mock mouse
@@ -140,6 +145,24 @@ Item {
140 text: "clear model"
145 text: "clear model"
141 onClicked: rootRow.clearNotifications()
146 onClicked: rootRow.clearNotifications()
150+ Layout.fillWidth: true
155+ UnityInputInfo.inputInfo.addMockMouse();
157+ UnityInputInfo.inputInfo.removeMockMouse();
162+ text: "With fake mouse"
163+ anchors.verticalCenter: parent.verticalCenter
@@ -258,21 +281,42 @@ Item {
259 if(data.buttonRowVisible) {
282 if(data.buttonRowVisible) {
260 var swipeButton = findChild(buttonRow, "notify_swipe_button")
283 var swipeButton = findChild(buttonRow, "notify_swipe_button")
285+ if (!swipeButton.clickToAct) { // don't run if there's a real mouse
261− var slider = findChild(swipeButton, "slider")
286+ var slider = findChild(swipeButton, "slider")
262− var swipeMouseArea = findChild(swipeButton, "swipeMouseArea")
287+ var swipeMouseArea = findChild(swipeButton, "swipeMouseArea")
263− var x = swipeMouseArea.width / 2
288+ var x = swipeMouseArea.width / 2
264− var y = swipeMouseArea.height / 2
289+ var y = swipeMouseArea.height / 2
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");
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");
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");
266 if(data.checkSwipeToActAccept) {
308 if(data.checkSwipeToActAccept) {
267− tryCompareFunction(function() { mouseDrag(slider, x, y, (swipeMouseArea.width / 2) - slider.width, 0); return actionSpy.signalArguments.length > 0; }, true);
309+ mouseClick(rightButton);
268− compare(actionSpy.signalArguments[0][0], data.actions.data(0, ActionModel.RoleActionId), "got wrong id for positive action")
310+ compare(actionSpy.signalArguments[0][0], data.actions.data(0, ActionModel.RoleActionId), "got wrong id for positive action");
269− actionSpy.clear()
311+ actionSpy.clear();
271 if(data.checkSwipeToActReject) {
314 if(data.checkSwipeToActReject) {
272− tryCompareFunction(function() { mouseDrag(slider, x, y, -(swipeMouseArea.width / 2), 0); return actionSpy.signalArguments.length > 0; }, true);
315+ mouseClick(leftButton);
273− compare(actionSpy.signalArguments[0][0], data.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action")
316+ compare(actionSpy.signalArguments[0][0], data.actions.data(1, ActionModel.RoleActionId), "got wrong id for negative action");
274− actionSpy.clear()
317+ actionSpy.clear();
319+ UnityInputInfo.inputInfo.removeMockMouse();