@@ -0,0 +1,137 @@
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");
105+ mousePress(touchPadArea)
107+ tryCompare(mouseEventSpy1, "count", 1)
108+ tryCompare(mouseEventSpy2, "count", 0)
109+ mouseRelease(touchPadArea)
112+ function test_buttons_data() {
114+ { tag: "left", button: UInput.ButtonLeft },
115+ { tag: "left", button: UInput.ButtonRight }
119+ function test_buttons(data) {
120+ mouseEventSpy1.signalName = "mousePressed"
121+ mouseEventSpy2.signalName = "mouseReleased"
123+ var button = findChild(touchScreenPad, data.button === UInput.ButtonLeft ? "leftButton" : "rightButton");
126+ tryCompare(mouseEventSpy1, "count", 1)
127+ tryCompare(mouseEventSpy2, "count", 0)
128+ compare(mouseEventSpy1.signalArguments[0][0], data.button)
130+ mouseRelease(button);
131+ tryCompare(mouseEventSpy1, "count", 1)
132+ tryCompare(mouseEventSpy2, "count", 1)
133+ compare(mouseEventSpy2.signalArguments[0][0], data.button)