2
* Copyright (C) 2015 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/>.
21
import "../../../qml/Components"
36
target: touchScreenPad.uinput
40
target: touchScreenPad.uinput
45
name: "VirtualTouchPad"
49
mouseEventSpy1.clear();
50
mouseEventSpy2.clear();
53
function test_click() {
54
mouseEventSpy1.signalName = "mousePressed"
55
mouseEventSpy2.signalName = "mouseReleased"
57
var touchPadArea = findChild(touchScreenPad, "touchPadArea");
60
tryCompare(mouseEventSpy1, "count", 1)
61
tryCompare(mouseEventSpy2, "count", 1)
64
function test_doubleClick() {
65
mouseEventSpy1.signalName = "mousePressed"
66
mouseEventSpy2.signalName = "mouseReleased"
68
var touchPadArea = findChild(touchScreenPad, "touchPadArea");
73
tryCompare(mouseEventSpy1, "count", 2)
74
tryCompare(mouseEventSpy2, "count", 2)
77
function test_move() {
78
mouseEventSpy1.signalName = "mouseMoved"
80
var touchPadArea = findChild(touchScreenPad, "touchPadArea");
82
var moveDiff = units.gu(2);
85
touchFlick(touchPadArea, units.gu(1), units.gu(1), units.gu(1) + moveDiff, units.gu(1) + moveDiff, true, true, 10, moveSteps)
87
tryCompare(mouseEventSpy1, "count", moveSteps)
90
for (var i = 0; i < 5; i++) {
91
movedX += mouseEventSpy1.signalArguments[i][0]
92
movedY += mouseEventSpy1.signalArguments[i][1]
94
compare(movedX, moveDiff)
95
compare(movedY, moveDiff)
98
function test_doubleTapAndHoldToDrag() {
99
mouseEventSpy1.signalName = "mousePressed"
100
mouseEventSpy2.signalName = "mouseReleased"
102
var touchPadArea = findChild(touchScreenPad, "touchPadArea");
104
mouseClick(touchPadArea)
105
mousePress(touchPadArea)
106
mouseMove(touchPadArea, touchPadArea.width / 4, touchPadArea.height / 4)
108
tryCompare(mouseEventSpy1, "count", 1)
109
tryCompare(mouseEventSpy2, "count", 0)
110
mouseRelease(touchPadArea)
111
tryCompare(mouseEventSpy2, "count", 1)
114
function test_twoFingerScroll() {
115
var touchPadArea = findChild(touchScreenPad, "touchPadArea");
117
mouseEventSpy1.signalName = "mouseScrolled"
119
var startX = touchPadArea.width / 2;
120
var startY = touchPadArea.height / 2;
122
var startX1 = startX - units.gu(1);
123
var startX2 = startX + units.gu(1);
125
var event = touchEvent(touchPadArea)
126
event.press(0, startX1, startY)
127
event.press(1, startX2, startY);
130
for (var i = 0; i < 10; i++) {
131
event.move(0, startX1, startY + units.gu(i))
132
event.move(1, startX2, startY + units.gu(i));
135
tryCompare(mouseEventSpy1, "count", i + 1);
138
event.release(0, startX1, startY + units.gu(11))
139
event.release(1, startX2, startY + units.gu(11));