| 1 |
/* |
| 2 |
* Copyright © 2015 Red Hat, Inc. |
| 3 |
* |
| 4 |
* Permission is hereby granted, free of charge, to any person obtaining a |
| 5 |
* copy of this software and associated documentation files (the "Software"), |
| 6 |
* to deal in the Software without restriction, including without limitation |
| 7 |
* the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 8 |
* and/or sell copies of the Software, and to permit persons to whom the |
| 9 |
* Software is furnished to do so, subject to the following conditions: |
| 10 |
* |
| 11 |
* The above copyright notice and this permission notice (including the next |
| 12 |
* paragraph) shall be included in all copies or substantial portions of the |
| 13 |
* Software. |
| 14 |
* |
| 15 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 |
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 |
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 18 |
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 |
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 20 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 21 |
* DEALINGS IN THE SOFTWARE. |
| 22 |
*/ |
| 23 |
|
| 24 |
#include <config.h> |
| 25 |
|
| 26 |
#include <libinput.h> |
| 27 |
#include <valgrind/valgrind.h> |
| 28 |
|
| 29 |
#include "libinput-util.h" |
| 30 |
#include "litest.h" |
| 31 |
|
| 32 |
enum cardinal { N, NE, E, SE, S, SW, W, NW, NCARDINALS }; |
| 33 |
|
| 34 |
enum hold_gesture_behaviour { |
| 35 |
HOLD_GESTURE_IGNORE, |
| 36 |
HOLD_GESTURE_REQUIRE, |
| 37 |
}; |
| 38 |
|
| 39 |
static void |
| 40 |
test_gesture_swipe_3fg(enum cardinal cardinal, enum hold_gesture_behaviour hold) |
| 41 |
{ |
| 42 |
struct litest_device *dev = litest_current_device(); |
| 43 |
struct libinput *li = dev->libinput; |
| 44 |
struct libinput_event *event; |
| 45 |
struct libinput_event_gesture *gevent; |
| 46 |
double dx, dy; |
| 47 |
double dir_x, dir_y; |
| 48 |
int cardinals[NCARDINALS][2] = { |
| 49 |
{ 0, 30 }, { 30, 30 }, { 30, 0 }, { 30, -30 }, |
| 50 |
{ 0, -30 }, { -30, -30 }, { -30, 0 }, { -30, 30 }, |
| 51 |
}; |
| 52 |
|
| 53 |
if (litest_slot_count(dev) < 3) |
| 54 |
return; |
| 55 |
|
| 56 |
dir_x = cardinals[cardinal][0]; |
| 57 |
dir_y = cardinals[cardinal][1]; |
| 58 |
|
| 59 |
litest_drain_events(li); |
| 60 |
|
| 61 |
litest_touch_down(dev, 0, 40, 40); |
| 62 |
litest_touch_down(dev, 1, 50, 40); |
| 63 |
litest_touch_down(dev, 2, 60, 40); |
| 64 |
litest_dispatch(li); |
| 65 |
|
| 66 |
if (hold == HOLD_GESTURE_REQUIRE) |
| 67 |
litest_timeout_gesture_hold(li); |
| 68 |
|
| 69 |
litest_touch_move_three_touches(dev, 40, 40, 50, 40, 60, 40, dir_x, dir_y, 10); |
| 70 |
litest_dispatch(li); |
| 71 |
|
| 72 |
if (hold == HOLD_GESTURE_REQUIRE) { |
| 73 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 3); |
| 74 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 3); |
| 75 |
} |
| 76 |
|
| 77 |
event = libinput_get_event(li); |
| 78 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 3); |
| 79 |
dx = libinput_event_gesture_get_dx(gevent); |
| 80 |
dy = libinput_event_gesture_get_dy(gevent); |
| 81 |
litest_assert(dx == 0.0); |
| 82 |
litest_assert(dy == 0.0); |
| 83 |
libinput_event_destroy(event); |
| 84 |
|
| 85 |
while ((event = libinput_get_event(li)) != NULL) { |
| 86 |
gevent = litest_is_gesture_event(event, |
| 87 |
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, |
| 88 |
3); |
| 89 |
|
| 90 |
dx = libinput_event_gesture_get_dx(gevent); |
| 91 |
dy = libinput_event_gesture_get_dy(gevent); |
| 92 |
if (dir_x == 0.0) |
| 93 |
litest_assert(dx == 0.0); |
| 94 |
else if (dir_x < 0.0) |
| 95 |
litest_assert(dx < 0.0); |
| 96 |
else if (dir_x > 0.0) |
| 97 |
litest_assert(dx > 0.0); |
| 98 |
|
| 99 |
if (dir_y == 0.0) |
| 100 |
litest_assert(dy == 0.0); |
| 101 |
else if (dir_y < 0.0) |
| 102 |
litest_assert(dy < 0.0); |
| 103 |
else if (dir_y > 0.0) |
| 104 |
litest_assert(dy > 0.0); |
| 105 |
|
| 106 |
dx = libinput_event_gesture_get_dx_unaccelerated(gevent); |
| 107 |
dy = libinput_event_gesture_get_dy_unaccelerated(gevent); |
| 108 |
if (dir_x == 0.0) |
| 109 |
litest_assert(dx == 0.0); |
| 110 |
else if (dir_x < 0.0) |
| 111 |
litest_assert(dx < 0.0); |
| 112 |
else if (dir_x > 0.0) |
| 113 |
litest_assert(dx > 0.0); |
| 114 |
|
| 115 |
if (dir_y == 0.0) |
| 116 |
litest_assert(dy == 0.0); |
| 117 |
else if (dir_y < 0.0) |
| 118 |
litest_assert(dy < 0.0); |
| 119 |
else if (dir_y > 0.0) |
| 120 |
litest_assert(dy > 0.0); |
| 121 |
|
| 122 |
libinput_event_destroy(event); |
| 123 |
} |
| 124 |
|
| 125 |
litest_touch_up(dev, 0); |
| 126 |
litest_touch_up(dev, 1); |
| 127 |
litest_touch_up(dev, 2); |
| 128 |
litest_dispatch(li); |
| 129 |
event = libinput_get_event(li); |
| 130 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_END, 3); |
| 131 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 132 |
libinput_event_destroy(event); |
| 133 |
} |
| 134 |
|
| 135 |
static void |
| 136 |
test_gesture_swipe_4fg(enum cardinal cardinal, enum hold_gesture_behaviour hold) |
| 137 |
{ |
| 138 |
struct litest_device *dev = litest_current_device(); |
| 139 |
struct libinput *li = dev->libinput; |
| 140 |
struct libinput_event *event; |
| 141 |
struct libinput_event_gesture *gevent; |
| 142 |
double dx, dy; |
| 143 |
double dir_x, dir_y; |
| 144 |
int cardinals[NCARDINALS][2] = { |
| 145 |
{ 0, 3 }, { 3, 3 }, { 3, 0 }, { 3, -3 }, |
| 146 |
{ 0, -3 }, { -3, -3 }, { -3, 0 }, { -3, 3 }, |
| 147 |
}; |
| 148 |
int i; |
| 149 |
|
| 150 |
if (litest_slot_count(dev) < 4) |
| 151 |
return; |
| 152 |
|
| 153 |
dir_x = cardinals[cardinal][0]; |
| 154 |
dir_y = cardinals[cardinal][1]; |
| 155 |
|
| 156 |
litest_drain_events(li); |
| 157 |
|
| 158 |
litest_touch_down(dev, 0, 40, 40); |
| 159 |
litest_touch_down(dev, 1, 50, 40); |
| 160 |
litest_touch_down(dev, 2, 60, 40); |
| 161 |
litest_touch_down(dev, 3, 70, 40); |
| 162 |
litest_dispatch(li); |
| 163 |
|
| 164 |
if (hold == HOLD_GESTURE_REQUIRE) |
| 165 |
litest_timeout_gesture_hold(li); |
| 166 |
|
| 167 |
for (i = 0; i < 8; i++) { |
| 168 |
litest_push_event_frame(dev); |
| 169 |
|
| 170 |
dir_x += cardinals[cardinal][0]; |
| 171 |
dir_y += cardinals[cardinal][1]; |
| 172 |
|
| 173 |
litest_touch_move(dev, 0, 40 + dir_x, 40 + dir_y); |
| 174 |
litest_touch_move(dev, 1, 50 + dir_x, 40 + dir_y); |
| 175 |
litest_touch_move(dev, 2, 60 + dir_x, 40 + dir_y); |
| 176 |
litest_touch_move(dev, 3, 70 + dir_x, 40 + dir_y); |
| 177 |
litest_pop_event_frame(dev); |
| 178 |
litest_dispatch(li); |
| 179 |
} |
| 180 |
|
| 181 |
litest_dispatch(li); |
| 182 |
|
| 183 |
if (hold == HOLD_GESTURE_REQUIRE) { |
| 184 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 4); |
| 185 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 4); |
| 186 |
} |
| 187 |
|
| 188 |
event = libinput_get_event(li); |
| 189 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 4); |
| 190 |
dx = libinput_event_gesture_get_dx(gevent); |
| 191 |
dy = libinput_event_gesture_get_dy(gevent); |
| 192 |
litest_assert(dx == 0.0); |
| 193 |
litest_assert(dy == 0.0); |
| 194 |
libinput_event_destroy(event); |
| 195 |
|
| 196 |
while ((event = libinput_get_event(li)) != NULL) { |
| 197 |
gevent = litest_is_gesture_event(event, |
| 198 |
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, |
| 199 |
4); |
| 200 |
|
| 201 |
dx = libinput_event_gesture_get_dx(gevent); |
| 202 |
dy = libinput_event_gesture_get_dy(gevent); |
| 203 |
if (dir_x == 0.0) |
| 204 |
litest_assert(dx == 0.0); |
| 205 |
else if (dir_x < 0.0) |
| 206 |
litest_assert(dx < 0.0); |
| 207 |
else if (dir_x > 0.0) |
| 208 |
litest_assert(dx > 0.0); |
| 209 |
|
| 210 |
if (dir_y == 0.0) |
| 211 |
litest_assert(dy == 0.0); |
| 212 |
else if (dir_y < 0.0) |
| 213 |
litest_assert(dy < 0.0); |
| 214 |
else if (dir_y > 0.0) |
| 215 |
litest_assert(dy > 0.0); |
| 216 |
|
| 217 |
dx = libinput_event_gesture_get_dx_unaccelerated(gevent); |
| 218 |
dy = libinput_event_gesture_get_dy_unaccelerated(gevent); |
| 219 |
if (dir_x == 0.0) |
| 220 |
litest_assert(dx == 0.0); |
| 221 |
else if (dir_x < 0.0) |
| 222 |
litest_assert(dx < 0.0); |
| 223 |
else if (dir_x > 0.0) |
| 224 |
litest_assert(dx > 0.0); |
| 225 |
|
| 226 |
if (dir_y == 0.0) |
| 227 |
litest_assert(dy == 0.0); |
| 228 |
else if (dir_y < 0.0) |
| 229 |
litest_assert(dy < 0.0); |
| 230 |
else if (dir_y > 0.0) |
| 231 |
litest_assert(dy > 0.0); |
| 232 |
|
| 233 |
libinput_event_destroy(event); |
| 234 |
} |
| 235 |
|
| 236 |
litest_touch_up(dev, 0); |
| 237 |
litest_touch_up(dev, 1); |
| 238 |
litest_touch_up(dev, 2); |
| 239 |
litest_touch_up(dev, 3); |
| 240 |
litest_dispatch(li); |
| 241 |
event = libinput_get_event(li); |
| 242 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_END, 4); |
| 243 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 244 |
libinput_event_destroy(event); |
| 245 |
} |
| 246 |
|
| 247 |
static void |
| 248 |
test_gesture_pinch_2fg(enum cardinal cardinal, enum hold_gesture_behaviour hold) |
| 249 |
{ |
| 250 |
struct litest_device *dev = litest_current_device(); |
| 251 |
struct libinput *li = dev->libinput; |
| 252 |
struct libinput_event *event; |
| 253 |
struct libinput_event_gesture *gevent; |
| 254 |
double dx, dy; |
| 255 |
double dir_x, dir_y; |
| 256 |
int i; |
| 257 |
double scale, oldscale; |
| 258 |
double angle; |
| 259 |
int cardinals[NCARDINALS][2] = { |
| 260 |
{ 0, 30 }, { 30, 30 }, { 30, 0 }, { 30, -30 }, |
| 261 |
{ 0, -30 }, { -30, -30 }, { -30, 0 }, { -30, 30 }, |
| 262 |
}; |
| 263 |
|
| 264 |
if (litest_slot_count(dev) < 2 || |
| 265 |
!libinput_device_has_capability(dev->libinput_device, |
| 266 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 267 |
return; |
| 268 |
|
| 269 |
/* If the device is too small to provide a finger spread wide enough |
| 270 |
* to avoid the scroll bias, skip the test */ |
| 271 |
if (cardinal == E || cardinal == W) { |
| 272 |
double w = 0, h = 0; |
| 273 |
libinput_device_get_size(dev->libinput_device, &w, &h); |
| 274 |
/* 0.6 because the code below gives us points like 20/y and |
| 275 |
* 80/y. 45 because the threshold in the code is 40mm */ |
| 276 |
if (w * 0.6 < 45) |
| 277 |
return; |
| 278 |
} |
| 279 |
|
| 280 |
dir_x = cardinals[cardinal][0]; |
| 281 |
dir_y = cardinals[cardinal][1]; |
| 282 |
|
| 283 |
litest_drain_events(li); |
| 284 |
|
| 285 |
litest_touch_down(dev, 0, 50 + dir_x, 50 + dir_y); |
| 286 |
litest_touch_down(dev, 1, 50 - dir_x, 50 - dir_y); |
| 287 |
litest_dispatch(li); |
| 288 |
|
| 289 |
if (hold == HOLD_GESTURE_REQUIRE) |
| 290 |
litest_timeout_gesture_hold(li); |
| 291 |
|
| 292 |
for (i = 0; i < 8; i++) { |
| 293 |
litest_push_event_frame(dev); |
| 294 |
if (dir_x > 0.0) |
| 295 |
dir_x -= 2; |
| 296 |
else if (dir_x < 0.0) |
| 297 |
dir_x += 2; |
| 298 |
if (dir_y > 0.0) |
| 299 |
dir_y -= 2; |
| 300 |
else if (dir_y < 0.0) |
| 301 |
dir_y += 2; |
| 302 |
litest_touch_move(dev, 0, 50 + dir_x, 50 + dir_y); |
| 303 |
litest_touch_move(dev, 1, 50 - dir_x, 50 - dir_y); |
| 304 |
litest_pop_event_frame(dev); |
| 305 |
litest_dispatch(li); |
| 306 |
} |
| 307 |
|
| 308 |
if (hold == HOLD_GESTURE_REQUIRE) { |
| 309 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 2); |
| 310 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 2); |
| 311 |
} |
| 312 |
|
| 313 |
event = libinput_get_event(li); |
| 314 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_BEGIN, 2); |
| 315 |
dx = libinput_event_gesture_get_dx(gevent); |
| 316 |
dy = libinput_event_gesture_get_dy(gevent); |
| 317 |
scale = libinput_event_gesture_get_scale(gevent); |
| 318 |
litest_assert(dx == 0.0); |
| 319 |
litest_assert(dy == 0.0); |
| 320 |
litest_assert(scale == 1.0); |
| 321 |
|
| 322 |
libinput_event_destroy(event); |
| 323 |
|
| 324 |
while ((event = libinput_get_event(li)) != NULL) { |
| 325 |
gevent = litest_is_gesture_event(event, |
| 326 |
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE, |
| 327 |
2); |
| 328 |
|
| 329 |
oldscale = scale; |
| 330 |
scale = libinput_event_gesture_get_scale(gevent); |
| 331 |
|
| 332 |
litest_assert(scale < oldscale); |
| 333 |
|
| 334 |
angle = libinput_event_gesture_get_angle_delta(gevent); |
| 335 |
litest_assert_double_le(fabs(angle), 1.0); |
| 336 |
|
| 337 |
libinput_event_destroy(event); |
| 338 |
litest_dispatch(li); |
| 339 |
} |
| 340 |
|
| 341 |
litest_touch_up(dev, 0); |
| 342 |
litest_touch_up(dev, 1); |
| 343 |
litest_dispatch(li); |
| 344 |
event = libinput_get_event(li); |
| 345 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_END, 2); |
| 346 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 347 |
libinput_event_destroy(event); |
| 348 |
} |
| 349 |
|
| 350 |
static void |
| 351 |
test_gesture_pinch_3fg(enum cardinal cardinal, enum hold_gesture_behaviour hold) |
| 352 |
{ |
| 353 |
struct litest_device *dev = litest_current_device(); |
| 354 |
struct libinput *li = dev->libinput; |
| 355 |
struct libinput_event *event; |
| 356 |
struct libinput_event_gesture *gevent; |
| 357 |
double dx, dy; |
| 358 |
double dir_x, dir_y; |
| 359 |
int i; |
| 360 |
double scale, oldscale; |
| 361 |
double angle; |
| 362 |
int cardinals[NCARDINALS][2] = { |
| 363 |
{ 0, 30 }, { 30, 30 }, { 30, 0 }, { 30, -30 }, |
| 364 |
{ 0, -30 }, { -30, -30 }, { -30, 0 }, { -30, 30 }, |
| 365 |
}; |
| 366 |
|
| 367 |
if (litest_slot_count(dev) < 3) |
| 368 |
return; |
| 369 |
|
| 370 |
dir_x = cardinals[cardinal][0]; |
| 371 |
dir_y = cardinals[cardinal][1]; |
| 372 |
|
| 373 |
litest_drain_events(li); |
| 374 |
|
| 375 |
litest_touch_down(dev, 0, 50 + dir_x, 50 + dir_y); |
| 376 |
litest_touch_down(dev, 1, 50 - dir_x, 50 - dir_y); |
| 377 |
litest_touch_down(dev, 2, 51 - dir_x, 51 - dir_y); |
| 378 |
litest_dispatch(li); |
| 379 |
|
| 380 |
if (hold == HOLD_GESTURE_REQUIRE) |
| 381 |
litest_timeout_gesture_hold(li); |
| 382 |
|
| 383 |
for (i = 0; i < 8; i++) { |
| 384 |
litest_push_event_frame(dev); |
| 385 |
if (dir_x > 0.0) |
| 386 |
dir_x -= 2; |
| 387 |
else if (dir_x < 0.0) |
| 388 |
dir_x += 2; |
| 389 |
if (dir_y > 0.0) |
| 390 |
dir_y -= 2; |
| 391 |
else if (dir_y < 0.0) |
| 392 |
dir_y += 2; |
| 393 |
litest_touch_move(dev, 0, 50 + dir_x, 50 + dir_y); |
| 394 |
litest_touch_move(dev, 1, 50 - dir_x, 50 - dir_y); |
| 395 |
litest_touch_move(dev, 2, 51 - dir_x, 51 - dir_y); |
| 396 |
litest_pop_event_frame(dev); |
| 397 |
litest_dispatch(li); |
| 398 |
} |
| 399 |
|
| 400 |
if (hold == HOLD_GESTURE_REQUIRE) { |
| 401 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 3); |
| 402 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 3); |
| 403 |
} |
| 404 |
event = libinput_get_event(li); |
| 405 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_BEGIN, 3); |
| 406 |
dx = libinput_event_gesture_get_dx(gevent); |
| 407 |
dy = libinput_event_gesture_get_dy(gevent); |
| 408 |
scale = libinput_event_gesture_get_scale(gevent); |
| 409 |
litest_assert(dx == 0.0); |
| 410 |
litest_assert(dy == 0.0); |
| 411 |
litest_assert(scale == 1.0); |
| 412 |
|
| 413 |
libinput_event_destroy(event); |
| 414 |
|
| 415 |
while ((event = libinput_get_event(li)) != NULL) { |
| 416 |
gevent = litest_is_gesture_event(event, |
| 417 |
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE, |
| 418 |
3); |
| 419 |
|
| 420 |
oldscale = scale; |
| 421 |
scale = libinput_event_gesture_get_scale(gevent); |
| 422 |
|
| 423 |
litest_assert(scale < oldscale); |
| 424 |
|
| 425 |
angle = libinput_event_gesture_get_angle_delta(gevent); |
| 426 |
litest_assert_double_le(fabs(angle), 1.0); |
| 427 |
|
| 428 |
libinput_event_destroy(event); |
| 429 |
litest_dispatch(li); |
| 430 |
} |
| 431 |
|
| 432 |
litest_touch_up(dev, 0); |
| 433 |
litest_touch_up(dev, 1); |
| 434 |
litest_touch_up(dev, 2); |
| 435 |
litest_dispatch(li); |
| 436 |
event = libinput_get_event(li); |
| 437 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_END, 3); |
| 438 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 439 |
libinput_event_destroy(event); |
| 440 |
} |
| 441 |
|
| 442 |
static void |
| 443 |
test_gesture_pinch_4fg(enum cardinal cardinal, enum hold_gesture_behaviour hold) |
| 444 |
{ |
| 445 |
struct litest_device *dev = litest_current_device(); |
| 446 |
struct libinput *li = dev->libinput; |
| 447 |
struct libinput_event *event; |
| 448 |
struct libinput_event_gesture *gevent; |
| 449 |
double dx, dy; |
| 450 |
double dir_x, dir_y; |
| 451 |
int i; |
| 452 |
double scale, oldscale; |
| 453 |
double angle; |
| 454 |
int cardinals[NCARDINALS][2] = { |
| 455 |
{ 0, 30 }, { 30, 30 }, { 30, 0 }, { 30, -30 }, |
| 456 |
{ 0, -30 }, { -30, -30 }, { -30, 0 }, { -30, 30 }, |
| 457 |
}; |
| 458 |
|
| 459 |
if (litest_slot_count(dev) < 4) |
| 460 |
return; |
| 461 |
|
| 462 |
dir_x = cardinals[cardinal][0]; |
| 463 |
dir_y = cardinals[cardinal][1]; |
| 464 |
|
| 465 |
litest_drain_events(li); |
| 466 |
|
| 467 |
litest_touch_down(dev, 0, 50 + dir_x, 50 + dir_y); |
| 468 |
litest_touch_down(dev, 1, 50 - dir_x, 50 - dir_y); |
| 469 |
litest_touch_down(dev, 2, 51 - dir_x, 51 - dir_y); |
| 470 |
litest_touch_down(dev, 3, 52 - dir_x, 52 - dir_y); |
| 471 |
litest_dispatch(li); |
| 472 |
|
| 473 |
if (hold == HOLD_GESTURE_REQUIRE) |
| 474 |
litest_timeout_gesture_hold(li); |
| 475 |
|
| 476 |
for (i = 0; i < 7; i++) { |
| 477 |
litest_push_event_frame(dev); |
| 478 |
if (dir_x > 0.0) |
| 479 |
dir_x -= 2; |
| 480 |
else if (dir_x < 0.0) |
| 481 |
dir_x += 2; |
| 482 |
if (dir_y > 0.0) |
| 483 |
dir_y -= 2; |
| 484 |
else if (dir_y < 0.0) |
| 485 |
dir_y += 2; |
| 486 |
litest_touch_move(dev, 0, 50 + dir_x, 50 + dir_y); |
| 487 |
litest_touch_move(dev, 1, 50 - dir_x, 50 - dir_y); |
| 488 |
litest_touch_move(dev, 2, 51 - dir_x, 51 - dir_y); |
| 489 |
litest_touch_move(dev, 3, 52 - dir_x, 52 - dir_y); |
| 490 |
litest_pop_event_frame(dev); |
| 491 |
litest_dispatch(li); |
| 492 |
} |
| 493 |
|
| 494 |
if (hold == HOLD_GESTURE_REQUIRE) { |
| 495 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 4); |
| 496 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 4); |
| 497 |
} |
| 498 |
|
| 499 |
event = libinput_get_event(li); |
| 500 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_BEGIN, 4); |
| 501 |
dx = libinput_event_gesture_get_dx(gevent); |
| 502 |
dy = libinput_event_gesture_get_dy(gevent); |
| 503 |
scale = libinput_event_gesture_get_scale(gevent); |
| 504 |
litest_assert(dx == 0.0); |
| 505 |
litest_assert(dy == 0.0); |
| 506 |
litest_assert(scale == 1.0); |
| 507 |
|
| 508 |
libinput_event_destroy(event); |
| 509 |
|
| 510 |
while ((event = libinput_get_event(li)) != NULL) { |
| 511 |
gevent = litest_is_gesture_event(event, |
| 512 |
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE, |
| 513 |
4); |
| 514 |
|
| 515 |
oldscale = scale; |
| 516 |
scale = libinput_event_gesture_get_scale(gevent); |
| 517 |
|
| 518 |
litest_assert(scale < oldscale); |
| 519 |
|
| 520 |
angle = libinput_event_gesture_get_angle_delta(gevent); |
| 521 |
litest_assert_double_le(fabs(angle), 1.0); |
| 522 |
|
| 523 |
libinput_event_destroy(event); |
| 524 |
litest_dispatch(li); |
| 525 |
} |
| 526 |
|
| 527 |
litest_touch_up(dev, 0); |
| 528 |
litest_touch_up(dev, 1); |
| 529 |
litest_touch_up(dev, 2); |
| 530 |
litest_touch_up(dev, 3); |
| 531 |
litest_dispatch(li); |
| 532 |
event = libinput_get_event(li); |
| 533 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_END, 4); |
| 534 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 535 |
libinput_event_destroy(event); |
| 536 |
} |
| 537 |
|
| 538 |
static void |
| 539 |
test_gesture_spread(enum cardinal cardinal, enum hold_gesture_behaviour hold) |
| 540 |
{ |
| 541 |
struct litest_device *dev = litest_current_device(); |
| 542 |
struct libinput *li = dev->libinput; |
| 543 |
struct libinput_event *event; |
| 544 |
struct libinput_event_gesture *gevent; |
| 545 |
double dx, dy; |
| 546 |
double dir_x, dir_y; |
| 547 |
int i; |
| 548 |
double scale, oldscale; |
| 549 |
double angle; |
| 550 |
int cardinals[NCARDINALS][2] = { |
| 551 |
{ 0, 30 }, { 30, 30 }, { 30, 0 }, { 30, -30 }, |
| 552 |
{ 0, -30 }, { -30, -30 }, { -30, 0 }, { -30, 30 }, |
| 553 |
}; |
| 554 |
|
| 555 |
if (litest_slot_count(dev) < 2 || |
| 556 |
!libinput_device_has_capability(dev->libinput_device, |
| 557 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 558 |
return; |
| 559 |
|
| 560 |
/* If the device is too small to provide a finger spread wide enough |
| 561 |
* to avoid the scroll bias, skip the test */ |
| 562 |
if (cardinal == E || cardinal == W) { |
| 563 |
double w = 0, h = 0; |
| 564 |
libinput_device_get_size(dev->libinput_device, &w, &h); |
| 565 |
/* 0.6 because the code below gives us points like 20/y and |
| 566 |
* 80/y. 45 because the threshold in the code is 40mm */ |
| 567 |
if (w * 0.6 < 45) |
| 568 |
return; |
| 569 |
} |
| 570 |
|
| 571 |
dir_x = cardinals[cardinal][0]; |
| 572 |
dir_y = cardinals[cardinal][1]; |
| 573 |
|
| 574 |
litest_drain_events(li); |
| 575 |
|
| 576 |
litest_touch_down(dev, 0, 50 + dir_x, 50 + dir_y); |
| 577 |
litest_touch_down(dev, 1, 50 - dir_x, 50 - dir_y); |
| 578 |
litest_dispatch(li); |
| 579 |
|
| 580 |
if (hold == HOLD_GESTURE_REQUIRE) |
| 581 |
litest_timeout_gesture_hold(li); |
| 582 |
|
| 583 |
for (i = 0; i < 15; i++) { |
| 584 |
litest_push_event_frame(dev); |
| 585 |
if (dir_x > 0.0) |
| 586 |
dir_x += 1; |
| 587 |
else if (dir_x < 0.0) |
| 588 |
dir_x -= 1; |
| 589 |
if (dir_y > 0.0) |
| 590 |
dir_y += 1; |
| 591 |
else if (dir_y < 0.0) |
| 592 |
dir_y -= 1; |
| 593 |
litest_touch_move(dev, 0, 50 + dir_x, 50 + dir_y); |
| 594 |
litest_touch_move(dev, 1, 50 - dir_x, 50 - dir_y); |
| 595 |
litest_pop_event_frame(dev); |
| 596 |
litest_dispatch(li); |
| 597 |
} |
| 598 |
|
| 599 |
if (hold == HOLD_GESTURE_REQUIRE) { |
| 600 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 2); |
| 601 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 2); |
| 602 |
} |
| 603 |
|
| 604 |
event = libinput_get_event(li); |
| 605 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_BEGIN, 2); |
| 606 |
dx = libinput_event_gesture_get_dx(gevent); |
| 607 |
dy = libinput_event_gesture_get_dy(gevent); |
| 608 |
scale = libinput_event_gesture_get_scale(gevent); |
| 609 |
litest_assert(dx == 0.0); |
| 610 |
litest_assert(dy == 0.0); |
| 611 |
litest_assert(scale == 1.0); |
| 612 |
|
| 613 |
libinput_event_destroy(event); |
| 614 |
|
| 615 |
while ((event = libinput_get_event(li)) != NULL) { |
| 616 |
gevent = litest_is_gesture_event(event, |
| 617 |
LIBINPUT_EVENT_GESTURE_PINCH_UPDATE, |
| 618 |
2); |
| 619 |
oldscale = scale; |
| 620 |
scale = libinput_event_gesture_get_scale(gevent); |
| 621 |
litest_assert(scale > oldscale); |
| 622 |
|
| 623 |
angle = libinput_event_gesture_get_angle_delta(gevent); |
| 624 |
litest_assert_double_le(fabs(angle), 1.0); |
| 625 |
|
| 626 |
libinput_event_destroy(event); |
| 627 |
litest_dispatch(li); |
| 628 |
} |
| 629 |
|
| 630 |
litest_touch_up(dev, 0); |
| 631 |
litest_touch_up(dev, 1); |
| 632 |
litest_dispatch(li); |
| 633 |
event = libinput_get_event(li); |
| 634 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_PINCH_END, 2); |
| 635 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 636 |
libinput_event_destroy(event); |
| 637 |
} |
| 638 |
|
| 639 |
static void |
| 640 |
test_gesture_3fg_buttonarea_scroll(enum hold_gesture_behaviour hold) |
| 641 |
{ |
| 642 |
struct litest_device *dev = litest_current_device(); |
| 643 |
struct libinput *li = dev->libinput; |
| 644 |
|
| 645 |
if (litest_slot_count(dev) < 3) |
| 646 |
return; |
| 647 |
|
| 648 |
litest_enable_buttonareas(dev); |
| 649 |
litest_enable_2fg_scroll(dev); |
| 650 |
litest_drain_events(li); |
| 651 |
|
| 652 |
litest_touch_down(dev, 0, 40, 20); |
| 653 |
litest_touch_down(dev, 1, 30, 20); |
| 654 |
/* third finger in btnarea */ |
| 655 |
litest_touch_down(dev, 2, 50, 99); |
| 656 |
litest_dispatch(li); |
| 657 |
|
| 658 |
if (hold == HOLD_GESTURE_REQUIRE) |
| 659 |
litest_timeout_gesture_hold(li); |
| 660 |
|
| 661 |
litest_touch_move_two_touches(dev, 40, 20, 30, 20, 0, 40, 10); |
| 662 |
|
| 663 |
litest_touch_up(dev, 0); |
| 664 |
litest_touch_up(dev, 1); |
| 665 |
litest_dispatch(li); |
| 666 |
|
| 667 |
if (hold == HOLD_GESTURE_REQUIRE) { |
| 668 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 2); |
| 669 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 2); |
| 670 |
} |
| 671 |
|
| 672 |
litest_assert_scroll(li, |
| 673 |
LIBINPUT_EVENT_POINTER_SCROLL_FINGER, |
| 674 |
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, |
| 675 |
4); |
| 676 |
} |
| 677 |
|
| 678 |
START_TEST(gestures_cap) |
| 679 |
{ |
| 680 |
struct litest_device *dev = litest_current_device(); |
| 681 |
struct libinput_device *device = dev->libinput_device; |
| 682 |
|
| 683 |
if (libevdev_has_property(dev->evdev, INPUT_PROP_SEMI_MT)) |
| 684 |
litest_assert( |
| 685 |
!libinput_device_has_capability(device, |
| 686 |
LIBINPUT_DEVICE_CAP_GESTURE)); |
| 687 |
else |
| 688 |
litest_assert( |
| 689 |
libinput_device_has_capability(device, |
| 690 |
LIBINPUT_DEVICE_CAP_GESTURE)); |
| 691 |
} |
| 692 |
END_TEST |
| 693 |
|
| 694 |
START_TEST(gestures_nocap) |
| 695 |
{ |
| 696 |
struct litest_device *dev = litest_current_device(); |
| 697 |
struct libinput_device *device = dev->libinput_device; |
| 698 |
|
| 699 |
litest_assert( |
| 700 |
!libinput_device_has_capability(device, LIBINPUT_DEVICE_CAP_GESTURE)); |
| 701 |
} |
| 702 |
END_TEST |
| 703 |
|
| 704 |
START_TEST(gestures_swipe_3fg) |
| 705 |
{ |
| 706 |
enum cardinal cardinal = |
| 707 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 708 |
test_gesture_swipe_3fg(cardinal, HOLD_GESTURE_IGNORE); |
| 709 |
} |
| 710 |
END_TEST |
| 711 |
|
| 712 |
START_TEST(gestures_swipe_3fg_btntool) |
| 713 |
{ |
| 714 |
struct litest_device *dev = litest_current_device(); |
| 715 |
struct libinput *li = dev->libinput; |
| 716 |
struct libinput_event *event; |
| 717 |
struct libinput_event_gesture *gevent; |
| 718 |
double dx, dy; |
| 719 |
enum cardinal cardinal = |
| 720 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 721 |
double dir_x, dir_y; |
| 722 |
int cardinals[NCARDINALS][2] = { |
| 723 |
{ 0, 30 }, { 30, 30 }, { 30, 0 }, { 30, -30 }, |
| 724 |
{ 0, -30 }, { -30, -30 }, { -30, 0 }, { -30, 30 }, |
| 725 |
}; |
| 726 |
|
| 727 |
if (litest_slot_count(dev) > 2 || |
| 728 |
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP) || |
| 729 |
!libinput_device_has_capability(dev->libinput_device, |
| 730 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 731 |
return LITEST_NOT_APPLICABLE; |
| 732 |
|
| 733 |
dir_x = cardinals[cardinal][0]; |
| 734 |
dir_y = cardinals[cardinal][1]; |
| 735 |
|
| 736 |
litest_drain_events(li); |
| 737 |
|
| 738 |
litest_touch_down(dev, 0, 40, 40); |
| 739 |
litest_touch_down(dev, 1, 50, 40); |
| 740 |
litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0); |
| 741 |
litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1); |
| 742 |
litest_event(dev, EV_SYN, SYN_REPORT, 0); |
| 743 |
|
| 744 |
litest_dispatch(li); |
| 745 |
litest_touch_move_two_touches(dev, 40, 40, 50, 40, dir_x, dir_y, 10); |
| 746 |
litest_dispatch(li); |
| 747 |
|
| 748 |
event = libinput_get_event(li); |
| 749 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 3); |
| 750 |
dx = libinput_event_gesture_get_dx(gevent); |
| 751 |
dy = libinput_event_gesture_get_dy(gevent); |
| 752 |
litest_assert(dx == 0.0); |
| 753 |
litest_assert(dy == 0.0); |
| 754 |
libinput_event_destroy(event); |
| 755 |
|
| 756 |
while ((event = libinput_get_event(li)) != NULL) { |
| 757 |
gevent = litest_is_gesture_event(event, |
| 758 |
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, |
| 759 |
3); |
| 760 |
|
| 761 |
dx = libinput_event_gesture_get_dx(gevent); |
| 762 |
dy = libinput_event_gesture_get_dy(gevent); |
| 763 |
if (dir_x == 0.0) |
| 764 |
litest_assert(dx == 0.0); |
| 765 |
else if (dir_x < 0.0) |
| 766 |
litest_assert(dx < 0.0); |
| 767 |
else if (dir_x > 0.0) |
| 768 |
litest_assert(dx > 0.0); |
| 769 |
|
| 770 |
if (dir_y == 0.0) |
| 771 |
litest_assert(dy == 0.0); |
| 772 |
else if (dir_y < 0.0) |
| 773 |
litest_assert(dy < 0.0); |
| 774 |
else if (dir_y > 0.0) |
| 775 |
litest_assert(dy > 0.0); |
| 776 |
|
| 777 |
dx = libinput_event_gesture_get_dx_unaccelerated(gevent); |
| 778 |
dy = libinput_event_gesture_get_dy_unaccelerated(gevent); |
| 779 |
if (dir_x == 0.0) |
| 780 |
litest_assert(dx == 0.0); |
| 781 |
else if (dir_x < 0.0) |
| 782 |
litest_assert(dx < 0.0); |
| 783 |
else if (dir_x > 0.0) |
| 784 |
litest_assert(dx > 0.0); |
| 785 |
|
| 786 |
if (dir_y == 0.0) |
| 787 |
litest_assert(dy == 0.0); |
| 788 |
else if (dir_y < 0.0) |
| 789 |
litest_assert(dy < 0.0); |
| 790 |
else if (dir_y > 0.0) |
| 791 |
litest_assert(dy > 0.0); |
| 792 |
|
| 793 |
libinput_event_destroy(event); |
| 794 |
} |
| 795 |
|
| 796 |
litest_touch_up(dev, 0); |
| 797 |
litest_touch_up(dev, 1); |
| 798 |
litest_dispatch(li); |
| 799 |
event = libinput_get_event(li); |
| 800 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_END, 3); |
| 801 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 802 |
libinput_event_destroy(event); |
| 803 |
} |
| 804 |
END_TEST |
| 805 |
|
| 806 |
START_TEST(gestures_swipe_3fg_btntool_pinch_like) |
| 807 |
{ |
| 808 |
struct litest_device *dev = litest_current_device(); |
| 809 |
struct libinput *li = dev->libinput; |
| 810 |
struct libinput_event *event; |
| 811 |
struct libinput_event_gesture *gevent; |
| 812 |
|
| 813 |
if (litest_slot_count(dev) > 2 || |
| 814 |
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_TRIPLETAP) || |
| 815 |
!libinput_device_has_capability(dev->libinput_device, |
| 816 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 817 |
return LITEST_NOT_APPLICABLE; |
| 818 |
|
| 819 |
litest_drain_events(li); |
| 820 |
|
| 821 |
/* Technically a pinch position + pinch movement, but expect swipe |
| 822 |
* for nfingers > nslots */ |
| 823 |
litest_touch_down(dev, 0, 20, 60); |
| 824 |
litest_touch_down(dev, 1, 50, 20); |
| 825 |
litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0); |
| 826 |
litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1); |
| 827 |
litest_event(dev, EV_SYN, SYN_REPORT, 0); |
| 828 |
|
| 829 |
litest_dispatch(li); |
| 830 |
litest_touch_move_to(dev, 0, 20, 60, 10, 80, 20); |
| 831 |
litest_dispatch(li); |
| 832 |
|
| 833 |
event = libinput_get_event(li); |
| 834 |
litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 3); |
| 835 |
libinput_event_destroy(event); |
| 836 |
|
| 837 |
while ((event = libinput_get_event(li)) != NULL) { |
| 838 |
litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, 3); |
| 839 |
libinput_event_destroy(event); |
| 840 |
} |
| 841 |
|
| 842 |
litest_touch_up(dev, 0); |
| 843 |
litest_touch_up(dev, 1); |
| 844 |
litest_dispatch(li); |
| 845 |
event = libinput_get_event(li); |
| 846 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_END, 3); |
| 847 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 848 |
libinput_event_destroy(event); |
| 849 |
} |
| 850 |
END_TEST |
| 851 |
|
| 852 |
START_TEST(gestures_swipe_4fg) |
| 853 |
{ |
| 854 |
enum cardinal cardinal = |
| 855 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 856 |
test_gesture_swipe_4fg(cardinal, HOLD_GESTURE_IGNORE); |
| 857 |
} |
| 858 |
END_TEST |
| 859 |
|
| 860 |
START_TEST(gestures_swipe_4fg_btntool) |
| 861 |
{ |
| 862 |
struct litest_device *dev = litest_current_device(); |
| 863 |
struct libinput *li = dev->libinput; |
| 864 |
struct libinput_event *event; |
| 865 |
struct libinput_event_gesture *gevent; |
| 866 |
double dx, dy; |
| 867 |
enum cardinal cardinal = |
| 868 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 869 |
double dir_x, dir_y; |
| 870 |
int cardinals[NCARDINALS][2] = { |
| 871 |
{ 0, 30 }, { 30, 30 }, { 30, 0 }, { 30, -30 }, |
| 872 |
{ 0, -30 }, { -30, -30 }, { -30, 0 }, { -30, 30 }, |
| 873 |
}; |
| 874 |
|
| 875 |
if (litest_slot_count(dev) > 2 || |
| 876 |
!libevdev_has_event_code(dev->evdev, EV_KEY, BTN_TOOL_QUADTAP) || |
| 877 |
!libinput_device_has_capability(dev->libinput_device, |
| 878 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 879 |
return LITEST_NOT_APPLICABLE; |
| 880 |
|
| 881 |
dir_x = cardinals[cardinal][0]; |
| 882 |
dir_y = cardinals[cardinal][1]; |
| 883 |
|
| 884 |
litest_drain_events(li); |
| 885 |
|
| 886 |
litest_touch_down(dev, 0, 40, 40); |
| 887 |
litest_touch_down(dev, 1, 50, 40); |
| 888 |
litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0); |
| 889 |
litest_event(dev, EV_KEY, BTN_TOOL_QUADTAP, 1); |
| 890 |
litest_event(dev, EV_SYN, SYN_REPORT, 0); |
| 891 |
|
| 892 |
litest_dispatch(li); |
| 893 |
litest_touch_move_two_touches(dev, 40, 40, 50, 40, dir_x, dir_y, 10); |
| 894 |
litest_dispatch(li); |
| 895 |
|
| 896 |
event = libinput_get_event(li); |
| 897 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 4); |
| 898 |
dx = libinput_event_gesture_get_dx(gevent); |
| 899 |
dy = libinput_event_gesture_get_dy(gevent); |
| 900 |
litest_assert(dx == 0.0); |
| 901 |
litest_assert(dy == 0.0); |
| 902 |
libinput_event_destroy(event); |
| 903 |
|
| 904 |
while ((event = libinput_get_event(li)) != NULL) { |
| 905 |
gevent = litest_is_gesture_event(event, |
| 906 |
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, |
| 907 |
4); |
| 908 |
|
| 909 |
dx = libinput_event_gesture_get_dx(gevent); |
| 910 |
dy = libinput_event_gesture_get_dy(gevent); |
| 911 |
if (dir_x == 0.0) |
| 912 |
litest_assert(dx == 0.0); |
| 913 |
else if (dir_x < 0.0) |
| 914 |
litest_assert(dx < 0.0); |
| 915 |
else if (dir_x > 0.0) |
| 916 |
litest_assert(dx > 0.0); |
| 917 |
|
| 918 |
if (dir_y == 0.0) |
| 919 |
litest_assert(dy == 0.0); |
| 920 |
else if (dir_y < 0.0) |
| 921 |
litest_assert(dy < 0.0); |
| 922 |
else if (dir_y > 0.0) |
| 923 |
litest_assert(dy > 0.0); |
| 924 |
|
| 925 |
dx = libinput_event_gesture_get_dx_unaccelerated(gevent); |
| 926 |
dy = libinput_event_gesture_get_dy_unaccelerated(gevent); |
| 927 |
if (dir_x == 0.0) |
| 928 |
litest_assert(dx == 0.0); |
| 929 |
else if (dir_x < 0.0) |
| 930 |
litest_assert(dx < 0.0); |
| 931 |
else if (dir_x > 0.0) |
| 932 |
litest_assert(dx > 0.0); |
| 933 |
|
| 934 |
if (dir_y == 0.0) |
| 935 |
litest_assert(dy == 0.0); |
| 936 |
else if (dir_y < 0.0) |
| 937 |
litest_assert(dy < 0.0); |
| 938 |
else if (dir_y > 0.0) |
| 939 |
litest_assert(dy > 0.0); |
| 940 |
|
| 941 |
libinput_event_destroy(event); |
| 942 |
} |
| 943 |
|
| 944 |
litest_touch_up(dev, 0); |
| 945 |
litest_touch_up(dev, 1); |
| 946 |
litest_dispatch(li); |
| 947 |
event = libinput_get_event(li); |
| 948 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_END, 4); |
| 949 |
litest_assert(!libinput_event_gesture_get_cancelled(gevent)); |
| 950 |
libinput_event_destroy(event); |
| 951 |
} |
| 952 |
END_TEST |
| 953 |
|
| 954 |
START_TEST(gestures_pinch) |
| 955 |
{ |
| 956 |
enum cardinal cardinal = |
| 957 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 958 |
test_gesture_pinch_2fg(cardinal, HOLD_GESTURE_IGNORE); |
| 959 |
} |
| 960 |
END_TEST |
| 961 |
|
| 962 |
START_TEST(gestures_pinch_3fg) |
| 963 |
{ |
| 964 |
enum cardinal cardinal = |
| 965 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 966 |
test_gesture_pinch_3fg(cardinal, HOLD_GESTURE_IGNORE); |
| 967 |
} |
| 968 |
END_TEST |
| 969 |
|
| 970 |
START_TEST(gestures_pinch_4fg) |
| 971 |
{ |
| 972 |
enum cardinal cardinal = |
| 973 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 974 |
test_gesture_pinch_4fg(cardinal, HOLD_GESTURE_IGNORE); |
| 975 |
} |
| 976 |
END_TEST |
| 977 |
|
| 978 |
START_TEST(gestures_spread) |
| 979 |
{ |
| 980 |
enum cardinal cardinal = |
| 981 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 982 |
test_gesture_spread(cardinal, HOLD_GESTURE_IGNORE); |
| 983 |
} |
| 984 |
END_TEST |
| 985 |
|
| 986 |
START_TEST(gestures_time_usec) |
| 987 |
{ |
| 988 |
struct litest_device *dev = litest_current_device(); |
| 989 |
struct libinput *li = dev->libinput; |
| 990 |
struct libinput_event *event; |
| 991 |
struct libinput_event_gesture *gevent; |
| 992 |
uint64_t time_usec; |
| 993 |
|
| 994 |
if (litest_slot_count(dev) < 3) |
| 995 |
return LITEST_NOT_APPLICABLE; |
| 996 |
|
| 997 |
litest_drain_events(li); |
| 998 |
|
| 999 |
litest_touch_down(dev, 0, 40, 40); |
| 1000 |
litest_touch_down(dev, 1, 50, 40); |
| 1001 |
litest_touch_down(dev, 2, 60, 40); |
| 1002 |
litest_dispatch(li); |
| 1003 |
litest_touch_move_three_touches(dev, 40, 40, 50, 40, 60, 40, 0, 30, 30); |
| 1004 |
|
| 1005 |
litest_dispatch(li); |
| 1006 |
event = libinput_get_event(li); |
| 1007 |
gevent = litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 3); |
| 1008 |
time_usec = libinput_event_gesture_get_time_usec(gevent); |
| 1009 |
litest_assert_int_eq(libinput_event_gesture_get_time(gevent), |
| 1010 |
(uint32_t)(time_usec / 1000)); |
| 1011 |
libinput_event_destroy(event); |
| 1012 |
} |
| 1013 |
END_TEST |
| 1014 |
|
| 1015 |
START_TEST(gestures_3fg_buttonarea_scroll) |
| 1016 |
{ |
| 1017 |
test_gesture_3fg_buttonarea_scroll(HOLD_GESTURE_IGNORE); |
| 1018 |
} |
| 1019 |
END_TEST |
| 1020 |
|
| 1021 |
START_TEST(gestures_3fg_buttonarea_scroll_btntool) |
| 1022 |
{ |
| 1023 |
struct litest_device *dev = litest_current_device(); |
| 1024 |
struct libinput *li = dev->libinput; |
| 1025 |
|
| 1026 |
if (litest_slot_count(dev) > 2) |
| 1027 |
return LITEST_NOT_APPLICABLE; |
| 1028 |
|
| 1029 |
litest_enable_buttonareas(dev); |
| 1030 |
litest_enable_2fg_scroll(dev); |
| 1031 |
litest_drain_events(li); |
| 1032 |
|
| 1033 |
/* first finger in btnarea */ |
| 1034 |
litest_touch_down(dev, 0, 20, 99); |
| 1035 |
litest_touch_down(dev, 1, 30, 20); |
| 1036 |
litest_event(dev, EV_KEY, BTN_TOOL_DOUBLETAP, 0); |
| 1037 |
litest_event(dev, EV_KEY, BTN_TOOL_TRIPLETAP, 1); |
| 1038 |
litest_event(dev, EV_SYN, SYN_REPORT, 0); |
| 1039 |
litest_dispatch(li); |
| 1040 |
litest_touch_move_to(dev, 1, 30, 20, 30, 70, 10); |
| 1041 |
|
| 1042 |
litest_touch_up(dev, 1); |
| 1043 |
litest_dispatch(li); |
| 1044 |
litest_assert_scroll(li, |
| 1045 |
LIBINPUT_EVENT_POINTER_SCROLL_FINGER, |
| 1046 |
LIBINPUT_POINTER_AXIS_SCROLL_VERTICAL, |
| 1047 |
4); |
| 1048 |
} |
| 1049 |
END_TEST |
| 1050 |
|
| 1051 |
START_TEST(gestures_swipe_3fg_unaccel) |
| 1052 |
{ |
| 1053 |
struct litest_device *dev = litest_current_device(); |
| 1054 |
struct libinput *li = dev->libinput; |
| 1055 |
struct libinput_event *event; |
| 1056 |
double reference_ux = 0, reference_uy = 0; |
| 1057 |
|
| 1058 |
/** |
| 1059 |
* This magic number is an artifact of the acceleration code. |
| 1060 |
* The maximum factor in the touchpad accel profile is 4.8 times the |
| 1061 |
* speed setting (1.000875 at default setting 0). The factor |
| 1062 |
* applied to the const acceleration is the 0.9 baseline. |
| 1063 |
* So our two sets of coordinates are: |
| 1064 |
* accel = 4.8 * delta * normalize_magic |
| 1065 |
* unaccel = 0.9 * delta * normalize_magic |
| 1066 |
* |
| 1067 |
* Since delta and the normalization magic are the same for both, |
| 1068 |
* our accelerated deltas can be a maximum of 4.8/0.9 bigger than |
| 1069 |
* the unaccelerated deltas. |
| 1070 |
* |
| 1071 |
* If any of the accel methods numbers change, this will have to |
| 1072 |
* change here too. |
| 1073 |
*/ |
| 1074 |
const double max_factor = 5.34; |
| 1075 |
|
| 1076 |
if (litest_slot_count(dev) < 3) |
| 1077 |
return LITEST_NOT_APPLICABLE; |
| 1078 |
|
| 1079 |
litest_drain_events(li); |
| 1080 |
litest_touch_down(dev, 0, 40, 20); |
| 1081 |
litest_touch_down(dev, 1, 50, 20); |
| 1082 |
litest_touch_down(dev, 2, 60, 20); |
| 1083 |
litest_dispatch(li); |
| 1084 |
litest_touch_move_three_touches(dev, 40, 20, 50, 20, 60, 20, 30, 40, 10); |
| 1085 |
litest_dispatch(li); |
| 1086 |
|
| 1087 |
event = libinput_get_event(li); |
| 1088 |
litest_is_gesture_event(event, LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, 3); |
| 1089 |
libinput_event_destroy(event); |
| 1090 |
event = libinput_get_event(li); |
| 1091 |
do { |
| 1092 |
struct libinput_event_gesture *gevent; |
| 1093 |
double dx, dy; |
| 1094 |
double ux, uy; |
| 1095 |
|
| 1096 |
gevent = litest_is_gesture_event(event, |
| 1097 |
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, |
| 1098 |
3); |
| 1099 |
dx = libinput_event_gesture_get_dx(gevent); |
| 1100 |
dy = libinput_event_gesture_get_dy(gevent); |
| 1101 |
ux = libinput_event_gesture_get_dx_unaccelerated(gevent); |
| 1102 |
uy = libinput_event_gesture_get_dy_unaccelerated(gevent); |
| 1103 |
|
| 1104 |
litest_assert_double_ne(ux, 0.0); |
| 1105 |
litest_assert_double_ne(uy, 0.0); |
| 1106 |
|
| 1107 |
if (!reference_ux) |
| 1108 |
reference_ux = ux; |
| 1109 |
if (!reference_uy) |
| 1110 |
reference_uy = uy; |
| 1111 |
|
| 1112 |
/* The unaccelerated delta should be the same for every |
| 1113 |
* event, but we have rounding errors since we only control |
| 1114 |
* input data as percentage of the touchpad size. |
| 1115 |
* so we just eyeball it */ |
| 1116 |
litest_assert_double_gt(ux, reference_ux - 2); |
| 1117 |
litest_assert_double_lt(ux, reference_ux + 2); |
| 1118 |
litest_assert_double_gt(uy, reference_uy - 2); |
| 1119 |
litest_assert_double_lt(uy, reference_uy + 2); |
| 1120 |
|
| 1121 |
/* All our touchpads are large enough to make this is a fast |
| 1122 |
* swipe, we don't expect deceleration, unaccel should |
| 1123 |
* always be less than accel delta */ |
| 1124 |
litest_assert_double_lt(ux, dx); |
| 1125 |
litest_assert_double_lt(ux, dx); |
| 1126 |
|
| 1127 |
/* Check our accelerated delta is within the expected |
| 1128 |
* maximum. */ |
| 1129 |
litest_assert_double_lt(dx, ux * max_factor); |
| 1130 |
litest_assert_double_lt(dy, uy * max_factor); |
| 1131 |
|
| 1132 |
libinput_event_destroy(event); |
| 1133 |
} while ((event = libinput_get_event(li))); |
| 1134 |
|
| 1135 |
litest_touch_up(dev, 0); |
| 1136 |
litest_touch_up(dev, 1); |
| 1137 |
litest_touch_up(dev, 2); |
| 1138 |
} |
| 1139 |
END_TEST |
| 1140 |
|
| 1141 |
START_TEST(gestures_hold_config_default_disabled) |
| 1142 |
{ |
| 1143 |
struct litest_device *dev = litest_current_device(); |
| 1144 |
struct libinput_device *device = dev->libinput_device; |
| 1145 |
|
| 1146 |
litest_assert_int_eq(libinput_device_config_gesture_hold_is_available(device), |
| 1147 |
0); |
| 1148 |
litest_assert_enum_eq( |
| 1149 |
libinput_device_config_gesture_get_hold_default_enabled(device), |
| 1150 |
LIBINPUT_CONFIG_HOLD_DISABLED); |
| 1151 |
litest_assert_enum_eq( |
| 1152 |
libinput_device_config_gesture_get_hold_default_enabled(device), |
| 1153 |
LIBINPUT_CONFIG_HOLD_DISABLED); |
| 1154 |
} |
| 1155 |
END_TEST |
| 1156 |
|
| 1157 |
START_TEST(gestures_hold_config_default_enabled) |
| 1158 |
{ |
| 1159 |
struct litest_device *dev = litest_current_device(); |
| 1160 |
struct libinput_device *device = dev->libinput_device; |
| 1161 |
|
| 1162 |
litest_assert_int_eq(libinput_device_config_gesture_hold_is_available(device), |
| 1163 |
1); |
| 1164 |
litest_assert_enum_eq( |
| 1165 |
libinput_device_config_gesture_get_hold_default_enabled(device), |
| 1166 |
LIBINPUT_CONFIG_HOLD_ENABLED); |
| 1167 |
litest_assert_enum_eq(libinput_device_config_gesture_get_hold_enabled(device), |
| 1168 |
LIBINPUT_CONFIG_HOLD_ENABLED); |
| 1169 |
} |
| 1170 |
END_TEST |
| 1171 |
|
| 1172 |
START_TEST(gestures_hold_config_set_invalid) |
| 1173 |
{ |
| 1174 |
struct litest_device *dev = litest_current_device(); |
| 1175 |
struct libinput_device *device = dev->libinput_device; |
| 1176 |
|
| 1177 |
litest_assert_enum_eq( |
| 1178 |
libinput_device_config_gesture_set_hold_enabled(device, -1), |
| 1179 |
LIBINPUT_CONFIG_STATUS_INVALID); |
| 1180 |
litest_assert_enum_eq( |
| 1181 |
libinput_device_config_gesture_set_hold_enabled(device, 2), |
| 1182 |
LIBINPUT_CONFIG_STATUS_INVALID); |
| 1183 |
} |
| 1184 |
END_TEST |
| 1185 |
|
| 1186 |
START_TEST(gestures_hold_config_is_available) |
| 1187 |
{ |
| 1188 |
struct litest_device *dev = litest_current_device(); |
| 1189 |
struct libinput_device *device = dev->libinput_device; |
| 1190 |
|
| 1191 |
litest_assert_int_eq(libinput_device_config_gesture_hold_is_available(device), |
| 1192 |
1); |
| 1193 |
litest_assert_enum_eq(libinput_device_config_gesture_get_hold_enabled(device), |
| 1194 |
LIBINPUT_CONFIG_HOLD_ENABLED); |
| 1195 |
litest_assert_enum_eq(libinput_device_config_gesture_set_hold_enabled( |
| 1196 |
device, |
| 1197 |
LIBINPUT_CONFIG_HOLD_DISABLED), |
| 1198 |
LIBINPUT_CONFIG_STATUS_SUCCESS); |
| 1199 |
litest_assert_enum_eq(libinput_device_config_gesture_get_hold_enabled(device), |
| 1200 |
LIBINPUT_CONFIG_HOLD_DISABLED); |
| 1201 |
} |
| 1202 |
END_TEST |
| 1203 |
|
| 1204 |
START_TEST(gestures_hold_config_is_not_available) |
| 1205 |
{ |
| 1206 |
struct litest_device *dev = litest_current_device(); |
| 1207 |
struct libinput_device *device = dev->libinput_device; |
| 1208 |
|
| 1209 |
litest_assert_int_eq(libinput_device_config_gesture_hold_is_available(device), |
| 1210 |
0); |
| 1211 |
litest_assert_enum_eq(libinput_device_config_gesture_get_hold_enabled(device), |
| 1212 |
LIBINPUT_CONFIG_HOLD_DISABLED); |
| 1213 |
litest_assert_enum_eq(libinput_device_config_gesture_set_hold_enabled( |
| 1214 |
device, |
| 1215 |
LIBINPUT_CONFIG_HOLD_ENABLED), |
| 1216 |
LIBINPUT_CONFIG_STATUS_UNSUPPORTED); |
| 1217 |
litest_assert_enum_eq(libinput_device_config_gesture_set_hold_enabled( |
| 1218 |
device, |
| 1219 |
LIBINPUT_CONFIG_HOLD_DISABLED), |
| 1220 |
LIBINPUT_CONFIG_STATUS_SUCCESS); |
| 1221 |
} |
| 1222 |
END_TEST |
| 1223 |
|
| 1224 |
START_TEST(gestures_hold) |
| 1225 |
{ |
| 1226 |
struct litest_device *dev = litest_current_device(); |
| 1227 |
struct libinput *li = dev->libinput; |
| 1228 |
int nfingers = litest_test_param_get_i32(test_env->params, "fingers"); |
| 1229 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap"); |
| 1230 |
|
| 1231 |
if (litest_slot_count(dev) < nfingers) |
| 1232 |
return LITEST_NOT_APPLICABLE; |
| 1233 |
|
| 1234 |
if (tap_enabled) |
| 1235 |
litest_enable_tap(dev->libinput_device); |
| 1236 |
else |
| 1237 |
litest_disable_tap(dev->libinput_device); |
| 1238 |
|
| 1239 |
litest_drain_events(li); |
| 1240 |
|
| 1241 |
switch (nfingers) { |
| 1242 |
case 4: |
| 1243 |
litest_touch_down(dev, 3, 70, 30); |
| 1244 |
_fallthrough_; |
| 1245 |
case 3: |
| 1246 |
litest_touch_down(dev, 2, 60, 30); |
| 1247 |
_fallthrough_; |
| 1248 |
case 2: |
| 1249 |
litest_touch_down(dev, 1, 50, 30); |
| 1250 |
_fallthrough_; |
| 1251 |
case 1: |
| 1252 |
litest_touch_down(dev, 0, 40, 30); |
| 1253 |
break; |
| 1254 |
} |
| 1255 |
|
| 1256 |
litest_timeout_gesture_hold(li); |
| 1257 |
|
| 1258 |
if (libinput_device_has_capability(dev->libinput_device, |
| 1259 |
LIBINPUT_DEVICE_CAP_GESTURE)) { |
| 1260 |
litest_assert_gesture_event(li, |
| 1261 |
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, |
| 1262 |
nfingers); |
| 1263 |
} else { |
| 1264 |
litest_assert_empty_queue(li); |
| 1265 |
} |
| 1266 |
|
| 1267 |
switch (nfingers) { |
| 1268 |
case 4: |
| 1269 |
litest_touch_up(dev, 3); |
| 1270 |
_fallthrough_; |
| 1271 |
case 3: |
| 1272 |
litest_touch_up(dev, 2); |
| 1273 |
_fallthrough_; |
| 1274 |
case 2: |
| 1275 |
litest_touch_up(dev, 1); |
| 1276 |
_fallthrough_; |
| 1277 |
case 1: |
| 1278 |
litest_touch_up(dev, 0); |
| 1279 |
break; |
| 1280 |
} |
| 1281 |
|
| 1282 |
litest_dispatch(li); |
| 1283 |
if (libinput_device_has_capability(dev->libinput_device, |
| 1284 |
LIBINPUT_DEVICE_CAP_GESTURE)) { |
| 1285 |
_destroy_(libinput_event) *ev = libinput_get_event(li); |
| 1286 |
auto gev = litest_is_gesture_event(ev, |
| 1287 |
LIBINPUT_EVENT_GESTURE_HOLD_END, |
| 1288 |
nfingers); |
| 1289 |
litest_assert(!libinput_event_gesture_get_cancelled(gev)); |
| 1290 |
} |
| 1291 |
|
| 1292 |
litest_assert_empty_queue(li); |
| 1293 |
} |
| 1294 |
END_TEST |
| 1295 |
|
| 1296 |
START_TEST(gestures_hold_cancel) |
| 1297 |
{ |
| 1298 |
struct litest_device *dev = litest_current_device(); |
| 1299 |
struct libinput *li = dev->libinput; |
| 1300 |
int nfingers = litest_test_param_get_i32(test_env->params, "fingers"); |
| 1301 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap"); |
| 1302 |
|
| 1303 |
if (litest_slot_count(dev) < nfingers) |
| 1304 |
return LITEST_NOT_APPLICABLE; |
| 1305 |
|
| 1306 |
if (tap_enabled) |
| 1307 |
litest_enable_tap(dev->libinput_device); |
| 1308 |
else |
| 1309 |
litest_disable_tap(dev->libinput_device); |
| 1310 |
litest_drain_events(li); |
| 1311 |
|
| 1312 |
int last_finger = (nfingers - 1); |
| 1313 |
|
| 1314 |
litest_drain_events(li); |
| 1315 |
|
| 1316 |
switch (nfingers) { |
| 1317 |
case 4: |
| 1318 |
litest_touch_down(dev, 3, 70, 30); |
| 1319 |
_fallthrough_; |
| 1320 |
case 3: |
| 1321 |
litest_touch_down(dev, 2, 60, 30); |
| 1322 |
_fallthrough_; |
| 1323 |
case 2: |
| 1324 |
litest_touch_down(dev, 1, 50, 30); |
| 1325 |
_fallthrough_; |
| 1326 |
case 1: |
| 1327 |
litest_touch_down(dev, 0, 40, 30); |
| 1328 |
break; |
| 1329 |
} |
| 1330 |
|
| 1331 |
litest_timeout_gesture_hold(li); |
| 1332 |
|
| 1333 |
litest_touch_up(dev, last_finger); |
| 1334 |
litest_dispatch(li); |
| 1335 |
litest_timeout_gesture_hold(li); |
| 1336 |
|
| 1337 |
if (libinput_device_has_capability(dev->libinput_device, |
| 1338 |
LIBINPUT_DEVICE_CAP_GESTURE)) { |
| 1339 |
litest_assert_gesture_event(li, |
| 1340 |
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, |
| 1341 |
nfingers); |
| 1342 |
_destroy_(libinput_event) *ev = libinput_get_event(li); |
| 1343 |
auto gev = litest_is_gesture_event(ev, |
| 1344 |
LIBINPUT_EVENT_GESTURE_HOLD_END, |
| 1345 |
nfingers); |
| 1346 |
if (nfingers > 1) |
| 1347 |
litest_assert(libinput_event_gesture_get_cancelled(gev)); |
| 1348 |
else /* can't cancel a 1fg gesture */ |
| 1349 |
litest_assert(!libinput_event_gesture_get_cancelled(gev)); |
| 1350 |
} |
| 1351 |
|
| 1352 |
litest_assert_empty_queue(li); |
| 1353 |
} |
| 1354 |
END_TEST |
| 1355 |
|
| 1356 |
START_TEST(gestures_hold_then_swipe_3fg) |
| 1357 |
{ |
| 1358 |
enum cardinal cardinal = |
| 1359 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 1360 |
test_gesture_swipe_3fg(cardinal, HOLD_GESTURE_REQUIRE); |
| 1361 |
} |
| 1362 |
END_TEST |
| 1363 |
|
| 1364 |
START_TEST(gestures_hold_then_swipe_4fg) |
| 1365 |
{ |
| 1366 |
enum cardinal cardinal = |
| 1367 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 1368 |
test_gesture_swipe_4fg(cardinal, HOLD_GESTURE_REQUIRE); |
| 1369 |
} |
| 1370 |
END_TEST |
| 1371 |
|
| 1372 |
START_TEST(gestures_hold_then_pinch_2fg) |
| 1373 |
{ |
| 1374 |
enum cardinal cardinal = |
| 1375 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 1376 |
test_gesture_pinch_2fg(cardinal, HOLD_GESTURE_REQUIRE); |
| 1377 |
} |
| 1378 |
END_TEST |
| 1379 |
|
| 1380 |
START_TEST(gestures_hold_then_pinch_3fg) |
| 1381 |
{ |
| 1382 |
enum cardinal cardinal = |
| 1383 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 1384 |
test_gesture_pinch_3fg(cardinal, HOLD_GESTURE_REQUIRE); |
| 1385 |
} |
| 1386 |
END_TEST |
| 1387 |
|
| 1388 |
START_TEST(gestures_hold_then_pinch_4fg) |
| 1389 |
{ |
| 1390 |
enum cardinal cardinal = |
| 1391 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 1392 |
test_gesture_pinch_4fg(cardinal, HOLD_GESTURE_REQUIRE); |
| 1393 |
} |
| 1394 |
END_TEST |
| 1395 |
|
| 1396 |
START_TEST(gestures_hold_then_spread) |
| 1397 |
{ |
| 1398 |
enum cardinal cardinal = |
| 1399 |
litest_test_param_get_i32(test_env->params, "direction"); |
| 1400 |
test_gesture_spread(cardinal, HOLD_GESTURE_REQUIRE); |
| 1401 |
} |
| 1402 |
END_TEST |
| 1403 |
|
| 1404 |
START_TEST(gestures_hold_then_3fg_buttonarea_scroll) |
| 1405 |
{ |
| 1406 |
test_gesture_3fg_buttonarea_scroll(HOLD_GESTURE_REQUIRE); |
| 1407 |
} |
| 1408 |
END_TEST |
| 1409 |
|
| 1410 |
START_TEST(gestures_hold_once_on_double_tap) |
| 1411 |
{ |
| 1412 |
struct litest_device *dev = litest_current_device(); |
| 1413 |
struct libinput *li = dev->libinput; |
| 1414 |
|
| 1415 |
if (!libinput_device_has_capability(dev->libinput_device, |
| 1416 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 1417 |
return LITEST_NOT_APPLICABLE; |
| 1418 |
|
| 1419 |
litest_enable_tap(dev->libinput_device); |
| 1420 |
litest_drain_events(li); |
| 1421 |
|
| 1422 |
/* First tap, a hold gesture must be generated */ |
| 1423 |
litest_touch_down(dev, 0, 50, 50); |
| 1424 |
litest_timeout_gesture_quick_hold(li); |
| 1425 |
litest_touch_up(dev, 0); |
| 1426 |
litest_dispatch(li); |
| 1427 |
|
| 1428 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 1); |
| 1429 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 1); |
| 1430 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1431 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 1432 |
litest_assert_empty_queue(li); |
| 1433 |
|
| 1434 |
/* Double tap, don't generate an extra hold gesture */ |
| 1435 |
litest_touch_down(dev, 0, 50, 50); |
| 1436 |
litest_touch_up(dev, 0); |
| 1437 |
litest_timeout_gesture_quick_hold(li); |
| 1438 |
|
| 1439 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1440 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 1441 |
|
| 1442 |
litest_assert_empty_queue(li); |
| 1443 |
} |
| 1444 |
END_TEST |
| 1445 |
|
| 1446 |
START_TEST(gestures_hold_once_tap_n_drag) |
| 1447 |
{ |
| 1448 |
struct litest_device *dev = litest_current_device(); |
| 1449 |
struct libinput *li = dev->libinput; |
| 1450 |
int nfingers = litest_test_param_get_i32(test_env->params, "fingers"); |
| 1451 |
unsigned int button = 0; |
| 1452 |
|
| 1453 |
if (nfingers > litest_slot_count(dev)) |
| 1454 |
return LITEST_NOT_APPLICABLE; |
| 1455 |
|
| 1456 |
if (!libinput_device_has_capability(dev->libinput_device, |
| 1457 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 1458 |
return LITEST_NOT_APPLICABLE; |
| 1459 |
|
| 1460 |
litest_enable_tap(dev->libinput_device); |
| 1461 |
litest_disable_drag_lock(dev->libinput_device); |
| 1462 |
litest_drain_events(li); |
| 1463 |
|
| 1464 |
switch (nfingers) { |
| 1465 |
case 1: |
| 1466 |
button = BTN_LEFT; |
| 1467 |
break; |
| 1468 |
case 2: |
| 1469 |
button = BTN_RIGHT; |
| 1470 |
break; |
| 1471 |
case 3: |
| 1472 |
button = BTN_MIDDLE; |
| 1473 |
break; |
| 1474 |
default: |
| 1475 |
litest_assert_not_reached(); |
| 1476 |
} |
| 1477 |
|
| 1478 |
switch (nfingers) { |
| 1479 |
case 3: |
| 1480 |
litest_touch_down(dev, 2, 60, 30); |
| 1481 |
_fallthrough_; |
| 1482 |
case 2: |
| 1483 |
litest_touch_down(dev, 1, 50, 30); |
| 1484 |
_fallthrough_; |
| 1485 |
case 1: |
| 1486 |
litest_touch_down(dev, 0, 40, 30); |
| 1487 |
break; |
| 1488 |
} |
| 1489 |
litest_timeout_gesture_quick_hold(li); |
| 1490 |
|
| 1491 |
switch (nfingers) { |
| 1492 |
case 3: |
| 1493 |
litest_touch_up(dev, 2); |
| 1494 |
_fallthrough_; |
| 1495 |
case 2: |
| 1496 |
litest_touch_up(dev, 1); |
| 1497 |
_fallthrough_; |
| 1498 |
case 1: |
| 1499 |
litest_touch_up(dev, 0); |
| 1500 |
break; |
| 1501 |
} |
| 1502 |
litest_dispatch(li); |
| 1503 |
|
| 1504 |
/* "Quick" hold gestures are only generated when using 1 or 2 fingers */ |
| 1505 |
if (nfingers == 1 || nfingers == 2) { |
| 1506 |
litest_assert_gesture_event(li, |
| 1507 |
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, |
| 1508 |
nfingers); |
| 1509 |
litest_assert_gesture_event(li, |
| 1510 |
LIBINPUT_EVENT_GESTURE_HOLD_END, |
| 1511 |
nfingers); |
| 1512 |
} |
| 1513 |
|
| 1514 |
/* Tap and drag, don't generate an extra hold gesture */ |
| 1515 |
litest_touch_down(dev, 0, 50, 50); |
| 1516 |
litest_touch_move_to(dev, 0, 50, 50, 80, 80, 20); |
| 1517 |
litest_dispatch(li); |
| 1518 |
|
| 1519 |
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1520 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1521 |
|
| 1522 |
litest_touch_up(dev, 0); |
| 1523 |
litest_dispatch(li); |
| 1524 |
|
| 1525 |
litest_assert_button_event(li, button, LIBINPUT_BUTTON_STATE_RELEASED); |
| 1526 |
litest_assert_empty_queue(li); |
| 1527 |
} |
| 1528 |
END_TEST |
| 1529 |
|
| 1530 |
START_TEST(gestures_hold_and_motion_before_timeout) |
| 1531 |
{ |
| 1532 |
struct litest_device *dev = litest_current_device(); |
| 1533 |
struct libinput *li = dev->libinput; |
| 1534 |
|
| 1535 |
if (!libinput_device_has_capability(dev->libinput_device, |
| 1536 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 1537 |
return LITEST_NOT_APPLICABLE; |
| 1538 |
|
| 1539 |
litest_drain_events(li); |
| 1540 |
|
| 1541 |
litest_touch_down(dev, 0, 50, 50); |
| 1542 |
litest_dispatch(li); |
| 1543 |
|
| 1544 |
litest_touch_move_to(dev, 0, 50, 50, 51, 51, 1); |
| 1545 |
litest_touch_move_to(dev, 0, 51, 51, 50, 50, 1); |
| 1546 |
|
| 1547 |
litest_timeout_gesture_quick_hold(li); |
| 1548 |
|
| 1549 |
litest_drain_events_of_type(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1550 |
|
| 1551 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 1); |
| 1552 |
|
| 1553 |
litest_touch_up(dev, 0); |
| 1554 |
litest_dispatch(li); |
| 1555 |
|
| 1556 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 1); |
| 1557 |
litest_assert_empty_queue(li); |
| 1558 |
} |
| 1559 |
END_TEST |
| 1560 |
|
| 1561 |
START_TEST(gestures_hold_and_motion_after_timeout) |
| 1562 |
{ |
| 1563 |
struct litest_device *dev = litest_current_device(); |
| 1564 |
struct libinput *li = dev->libinput; |
| 1565 |
|
| 1566 |
if (!libinput_device_has_capability(dev->libinput_device, |
| 1567 |
LIBINPUT_DEVICE_CAP_GESTURE)) |
| 1568 |
return LITEST_NOT_APPLICABLE; |
| 1569 |
|
| 1570 |
litest_drain_events(li); |
| 1571 |
|
| 1572 |
litest_touch_down(dev, 0, 50, 50); |
| 1573 |
litest_timeout_gesture_quick_hold(li); |
| 1574 |
|
| 1575 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, 1); |
| 1576 |
|
| 1577 |
litest_touch_move_to(dev, 0, 50, 50, 51, 51, 1); |
| 1578 |
litest_touch_move_to(dev, 0, 51, 51, 50, 50, 1); |
| 1579 |
litest_dispatch(li); |
| 1580 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1581 |
|
| 1582 |
litest_touch_up(dev, 0); |
| 1583 |
litest_dispatch(li); |
| 1584 |
|
| 1585 |
litest_assert_gesture_event(li, LIBINPUT_EVENT_GESTURE_HOLD_END, 1); |
| 1586 |
litest_assert_empty_queue(li); |
| 1587 |
} |
| 1588 |
END_TEST |
| 1589 |
|
| 1590 |
static void |
| 1591 |
drain_cancelled_swipe_gesture(struct libinput *li) |
| 1592 |
{ |
| 1593 |
litest_drain_events_of_type(li, |
| 1594 |
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, |
| 1595 |
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE); |
| 1596 |
|
| 1597 |
_destroy_(libinput_event) *end = libinput_get_event(li); |
| 1598 |
auto gev = litest_is_gesture_event(end, LIBINPUT_EVENT_GESTURE_SWIPE_END, -1); |
| 1599 |
litest_assert(libinput_event_gesture_get_cancelled(gev)); |
| 1600 |
} |
| 1601 |
|
| 1602 |
START_TEST(gestures_3fg_drag) |
| 1603 |
{ |
| 1604 |
struct litest_device *dev = litest_current_device(); |
| 1605 |
struct libinput *li = dev->libinput; |
| 1606 |
|
| 1607 |
uint32_t finger_count = litest_test_param_get_u32(test_env->params, "fingers"); |
| 1608 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap-enabled"); |
| 1609 |
|
| 1610 |
if (litest_slot_count(dev) < 3) |
| 1611 |
return LITEST_NOT_APPLICABLE; |
| 1612 |
|
| 1613 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 1614 |
(int)finger_count) |
| 1615 |
return LITEST_NOT_APPLICABLE; |
| 1616 |
|
| 1617 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 1618 |
if (tap_enabled) |
| 1619 |
litest_enable_tap(dev->libinput_device); |
| 1620 |
else |
| 1621 |
litest_disable_tap(dev->libinput_device); |
| 1622 |
|
| 1623 |
litest_drain_events(li); |
| 1624 |
|
| 1625 |
double y = 30.0; |
| 1626 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1627 |
litest_touch_down(dev, i, 10 + i, y); |
| 1628 |
|
| 1629 |
litest_dispatch(li); |
| 1630 |
|
| 1631 |
litest_drain_events_of_type(li, |
| 1632 |
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, |
| 1633 |
LIBINPUT_EVENT_GESTURE_HOLD_END); |
| 1634 |
|
| 1635 |
if (tap_enabled) { |
| 1636 |
litest_checkpoint( |
| 1637 |
"Expecting no immediate button press as tapping is enabled"); |
| 1638 |
litest_assert_empty_queue(li); |
| 1639 |
} else { |
| 1640 |
litest_checkpoint( |
| 1641 |
"Expecting immediate swipe begin tapping is disabled"); |
| 1642 |
litest_assert_gesture_event(li, |
| 1643 |
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, |
| 1644 |
finger_count); |
| 1645 |
} |
| 1646 |
|
| 1647 |
while (y < 60.0) { |
| 1648 |
y += 2; |
| 1649 |
for (uint32_t i = 0; i < finger_count; i++) { |
| 1650 |
litest_touch_move(dev, i, 10 + i, y); |
| 1651 |
if (i == |
| 1652 |
0) /* Wait after the first movement to escape the swipe */ |
| 1653 |
litest_timeout_3fg_drag_or_swipe(li); |
| 1654 |
} |
| 1655 |
litest_dispatch(li); |
| 1656 |
} |
| 1657 |
|
| 1658 |
drain_cancelled_swipe_gesture(li); |
| 1659 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1660 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1661 |
|
| 1662 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1663 |
litest_touch_up(dev, i); |
| 1664 |
|
| 1665 |
litest_dispatch(li); |
| 1666 |
litest_assert_empty_queue(li); |
| 1667 |
|
| 1668 |
litest_timeout_3fg_drag(li); |
| 1669 |
|
| 1670 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 1671 |
} |
| 1672 |
END_TEST |
| 1673 |
|
| 1674 |
START_TEST(gestures_3fg_drag_lock_resume_3fg_motion) |
| 1675 |
{ |
| 1676 |
struct litest_device *dev = litest_current_device(); |
| 1677 |
struct libinput *li = dev->libinput; |
| 1678 |
|
| 1679 |
uint32_t finger_count = litest_test_param_get_u32(test_env->params, "fingers"); |
| 1680 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap-enabled"); |
| 1681 |
bool wait_for_timeout = litest_test_param_get_bool(test_env->params, "wait"); |
| 1682 |
|
| 1683 |
if (litest_slot_count(dev) < 3) |
| 1684 |
return LITEST_NOT_APPLICABLE; |
| 1685 |
|
| 1686 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 1687 |
(int)finger_count) |
| 1688 |
return LITEST_NOT_APPLICABLE; |
| 1689 |
|
| 1690 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 1691 |
if (tap_enabled) |
| 1692 |
litest_enable_tap(dev->libinput_device); |
| 1693 |
else |
| 1694 |
litest_disable_tap(dev->libinput_device); |
| 1695 |
|
| 1696 |
litest_drain_events(li); |
| 1697 |
|
| 1698 |
litest_checkpoint("Putting three fingers down + movement)"); |
| 1699 |
double y = 30.0; |
| 1700 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1701 |
litest_touch_down(dev, i, 10 + i, y); |
| 1702 |
|
| 1703 |
litest_dispatch(li); |
| 1704 |
|
| 1705 |
while (y < 60.0) { |
| 1706 |
y += 2; |
| 1707 |
for (uint32_t i = 0; i < finger_count; i++) { |
| 1708 |
litest_touch_move(dev, i, 10 + i, y); |
| 1709 |
if (i == |
| 1710 |
0) /* Wait after the first movement to escape the swipe */ |
| 1711 |
litest_timeout_3fg_drag_or_swipe(li); |
| 1712 |
} |
| 1713 |
litest_dispatch(li); |
| 1714 |
} |
| 1715 |
drain_cancelled_swipe_gesture(li); |
| 1716 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1717 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1718 |
|
| 1719 |
litest_checkpoint("Releasing all fingers"); |
| 1720 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1721 |
litest_touch_up(dev, i); |
| 1722 |
|
| 1723 |
litest_dispatch(li); |
| 1724 |
litest_assert_empty_queue(li); |
| 1725 |
|
| 1726 |
litest_checkpoint("Putting three fingers down (no movement)"); |
| 1727 |
y = 30.0; |
| 1728 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1729 |
litest_touch_down(dev, i, 10 + i, y); |
| 1730 |
litest_dispatch(li); |
| 1731 |
litest_assert_empty_queue(li); |
| 1732 |
|
| 1733 |
litest_dispatch(li); |
| 1734 |
|
| 1735 |
litest_checkpoint("Waiting past finger switch timeout"); |
| 1736 |
litest_timeout_finger_switch(li); |
| 1737 |
|
| 1738 |
if (wait_for_timeout) { |
| 1739 |
litest_checkpoint("Waiting past tap/3fg drag timeout"); |
| 1740 |
litest_timeout_3fg_drag(li); |
| 1741 |
litest_assert_empty_queue(li); |
| 1742 |
} |
| 1743 |
|
| 1744 |
litest_checkpoint("Moving three fingers"); |
| 1745 |
while (y < 60.0) { |
| 1746 |
y += 2; |
| 1747 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1748 |
litest_touch_move(dev, i, 10 + i, y); |
| 1749 |
litest_dispatch(li); |
| 1750 |
} |
| 1751 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1752 |
|
| 1753 |
litest_checkpoint("Releasing three fingers"); |
| 1754 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1755 |
litest_touch_up(dev, i); |
| 1756 |
litest_dispatch(li); |
| 1757 |
litest_assert_empty_queue(li); |
| 1758 |
|
| 1759 |
litest_timeout_3fg_drag(li); |
| 1760 |
|
| 1761 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 1762 |
} |
| 1763 |
END_TEST |
| 1764 |
|
| 1765 |
START_TEST(gestures_3fg_drag_lock_resume_3fg_release_no_motion) |
| 1766 |
{ |
| 1767 |
struct litest_device *dev = litest_current_device(); |
| 1768 |
struct libinput *li = dev->libinput; |
| 1769 |
|
| 1770 |
uint32_t finger_count = litest_test_param_get_u32(test_env->params, "fingers"); |
| 1771 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap-enabled"); |
| 1772 |
bool wait_for_timeout = litest_test_param_get_bool(test_env->params, "wait"); |
| 1773 |
|
| 1774 |
/* tap-enabled for 4fg finger count doesn't make a difference */ |
| 1775 |
bool expect_tap = finger_count <= 3 && tap_enabled && !wait_for_timeout; |
| 1776 |
|
| 1777 |
if (litest_slot_count(dev) < 3) |
| 1778 |
return LITEST_NOT_APPLICABLE; |
| 1779 |
|
| 1780 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 1781 |
(int)finger_count) |
| 1782 |
return LITEST_NOT_APPLICABLE; |
| 1783 |
|
| 1784 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 1785 |
|
| 1786 |
if (tap_enabled) |
| 1787 |
litest_enable_tap(dev->libinput_device); |
| 1788 |
else |
| 1789 |
litest_disable_tap(dev->libinput_device); |
| 1790 |
|
| 1791 |
litest_drain_events(li); |
| 1792 |
|
| 1793 |
litest_checkpoint("Putting %d fingers down with motion for drag", finger_count); |
| 1794 |
double y = 30.0; |
| 1795 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1796 |
litest_touch_down(dev, i, 10 + i, y); |
| 1797 |
|
| 1798 |
litest_dispatch(li); |
| 1799 |
while (y < 60.0) { |
| 1800 |
y += 2; |
| 1801 |
for (uint32_t i = 0; i < finger_count; i++) { |
| 1802 |
litest_touch_move(dev, i, 10 + i, y); |
| 1803 |
if (i == |
| 1804 |
0) /* Wait after the first movement to escape the swipe */ |
| 1805 |
litest_timeout_3fg_drag_or_swipe(li); |
| 1806 |
} |
| 1807 |
litest_dispatch(li); |
| 1808 |
} |
| 1809 |
drain_cancelled_swipe_gesture(li); |
| 1810 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1811 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1812 |
|
| 1813 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1814 |
litest_touch_up(dev, i); |
| 1815 |
|
| 1816 |
litest_dispatch(li); |
| 1817 |
litest_assert_empty_queue(li); |
| 1818 |
|
| 1819 |
litest_checkpoint("Putting %d fingers down again (no motion)", finger_count); |
| 1820 |
y = 30.0; |
| 1821 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1822 |
litest_touch_down(dev, i, 10 + i, y); |
| 1823 |
litest_dispatch(li); |
| 1824 |
litest_assert_empty_queue(li); |
| 1825 |
|
| 1826 |
litest_checkpoint("Waiting past finger switch timeout"); |
| 1827 |
litest_timeout_finger_switch(li); |
| 1828 |
|
| 1829 |
if (wait_for_timeout) { |
| 1830 |
litest_checkpoint("Waiting past tap/3fg drag timeout"); |
| 1831 |
litest_timeout_3fg_drag(li); |
| 1832 |
litest_assert_empty_queue(li); |
| 1833 |
} |
| 1834 |
|
| 1835 |
litest_checkpoint("Releasing %d fingers", finger_count); |
| 1836 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1837 |
litest_touch_up(dev, i); |
| 1838 |
litest_dispatch(li); |
| 1839 |
|
| 1840 |
if (expect_tap) { |
| 1841 |
/* If we're not waiting and tapping is enabled, this is |
| 1842 |
* the equivalent of a 3fg tap within the drag timeout */ |
| 1843 |
litest_checkpoint("Expecting 3fg drag release"); |
| 1844 |
litest_assert_button_event(li, |
| 1845 |
BTN_LEFT, |
| 1846 |
LIBINPUT_BUTTON_STATE_RELEASED); |
| 1847 |
litest_checkpoint("Expecting 3fg tap"); |
| 1848 |
litest_assert_button_event(li, |
| 1849 |
BTN_MIDDLE, |
| 1850 |
LIBINPUT_BUTTON_STATE_PRESSED); |
| 1851 |
litest_assert_button_event(li, |
| 1852 |
BTN_MIDDLE, |
| 1853 |
LIBINPUT_BUTTON_STATE_RELEASED); |
| 1854 |
} |
| 1855 |
|
| 1856 |
litest_assert_empty_queue(li); |
| 1857 |
litest_timeout_3fg_drag(li); |
| 1858 |
|
| 1859 |
if (!expect_tap) |
| 1860 |
litest_assert_button_event(li, |
| 1861 |
BTN_LEFT, |
| 1862 |
LIBINPUT_BUTTON_STATE_RELEASED); |
| 1863 |
|
| 1864 |
litest_assert_empty_queue(li); |
| 1865 |
} |
| 1866 |
END_TEST |
| 1867 |
|
| 1868 |
START_TEST(gestures_3fg_drag_lock_resume_1fg_motion) |
| 1869 |
{ |
| 1870 |
struct litest_device *dev = litest_current_device(); |
| 1871 |
struct libinput *li = dev->libinput; |
| 1872 |
|
| 1873 |
uint32_t finger_count = litest_test_param_get_u32(test_env->params, "fingers"); |
| 1874 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap-enabled"); |
| 1875 |
|
| 1876 |
if (litest_slot_count(dev) < 3) |
| 1877 |
return LITEST_NOT_APPLICABLE; |
| 1878 |
|
| 1879 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 1880 |
(int)finger_count) |
| 1881 |
return LITEST_NOT_APPLICABLE; |
| 1882 |
|
| 1883 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 1884 |
|
| 1885 |
if (tap_enabled) |
| 1886 |
litest_enable_tap(dev->libinput_device); |
| 1887 |
else |
| 1888 |
litest_disable_tap(dev->libinput_device); |
| 1889 |
|
| 1890 |
litest_drain_events(li); |
| 1891 |
|
| 1892 |
litest_checkpoint("Putting 3 fingers down + motion to trigger 3fg drag"); |
| 1893 |
double y = 30.0; |
| 1894 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1895 |
litest_touch_down(dev, i, 10 + i, y); |
| 1896 |
|
| 1897 |
while (y < 60.0) { |
| 1898 |
y += 2; |
| 1899 |
for (uint32_t i = 0; i < finger_count; i++) { |
| 1900 |
litest_touch_move(dev, i, 10 + i, y); |
| 1901 |
if (i == |
| 1902 |
0) /* Wait after the first movement to escape the swipe */ |
| 1903 |
litest_timeout_3fg_drag_or_swipe(li); |
| 1904 |
} |
| 1905 |
litest_dispatch(li); |
| 1906 |
} |
| 1907 |
drain_cancelled_swipe_gesture(li); |
| 1908 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1909 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1910 |
|
| 1911 |
litest_checkpoint("Releasing 3 fingers"); |
| 1912 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1913 |
litest_touch_up(dev, i); |
| 1914 |
|
| 1915 |
litest_dispatch(li); |
| 1916 |
litest_assert_empty_queue(li); |
| 1917 |
|
| 1918 |
litest_checkpoint("Putting 1 finger down and moving it"); |
| 1919 |
/* fingers are up, now let's put one finger down and move it */ |
| 1920 |
y = 30.0; |
| 1921 |
litest_touch_down(dev, 0, 10, y); |
| 1922 |
litest_dispatch(li); |
| 1923 |
litest_assert_empty_queue(li); |
| 1924 |
|
| 1925 |
/* We need to wait until the gesture code accepts this is one finger only */ |
| 1926 |
litest_timeout_finger_switch(li); |
| 1927 |
|
| 1928 |
while (y < 60.0) { |
| 1929 |
y += 2; |
| 1930 |
litest_touch_move(dev, 0, 10, y); |
| 1931 |
litest_dispatch(li); |
| 1932 |
} |
| 1933 |
|
| 1934 |
litest_checkpoint("Expecting drag button release and motion"); |
| 1935 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 1936 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1937 |
|
| 1938 |
litest_touch_up(dev, 0); |
| 1939 |
litest_dispatch(li); |
| 1940 |
litest_assert_empty_queue(li); |
| 1941 |
|
| 1942 |
litest_timeout_3fg_drag(li); |
| 1943 |
} |
| 1944 |
END_TEST |
| 1945 |
|
| 1946 |
START_TEST(gestures_3fg_drag_lock_resume_2fg_scroll) |
| 1947 |
{ |
| 1948 |
struct litest_device *dev = litest_current_device(); |
| 1949 |
struct libinput *li = dev->libinput; |
| 1950 |
|
| 1951 |
uint32_t finger_count = litest_test_param_get_u32(test_env->params, "fingers"); |
| 1952 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap-enabled"); |
| 1953 |
|
| 1954 |
if (litest_slot_count(dev) < 3) |
| 1955 |
return LITEST_NOT_APPLICABLE; |
| 1956 |
|
| 1957 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 1958 |
(int)finger_count) |
| 1959 |
return LITEST_NOT_APPLICABLE; |
| 1960 |
|
| 1961 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 1962 |
|
| 1963 |
if (tap_enabled) |
| 1964 |
litest_enable_tap(dev->libinput_device); |
| 1965 |
else |
| 1966 |
litest_disable_tap(dev->libinput_device); |
| 1967 |
|
| 1968 |
litest_drain_events(li); |
| 1969 |
|
| 1970 |
litest_checkpoint("Putting 3 fingers down + motion to trigger 3fg drag"); |
| 1971 |
double y = 30.0; |
| 1972 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1973 |
litest_touch_down(dev, i, 10 + i, y); |
| 1974 |
|
| 1975 |
while (y < 60.0) { |
| 1976 |
y += 2; |
| 1977 |
for (uint32_t i = 0; i < finger_count; i++) { |
| 1978 |
litest_touch_move(dev, i, 10 + i, y); |
| 1979 |
if (i == |
| 1980 |
0) /* Wait after the first movement to escape the swipe */ |
| 1981 |
litest_timeout_3fg_drag_or_swipe(li); |
| 1982 |
} |
| 1983 |
litest_dispatch(li); |
| 1984 |
} |
| 1985 |
drain_cancelled_swipe_gesture(li); |
| 1986 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 1987 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 1988 |
|
| 1989 |
litest_checkpoint("Releasing 3 fingers"); |
| 1990 |
for (uint32_t i = 0; i < finger_count; i++) |
| 1991 |
litest_touch_up(dev, i); |
| 1992 |
|
| 1993 |
litest_dispatch(li); |
| 1994 |
litest_assert_empty_queue(li); |
| 1995 |
|
| 1996 |
litest_checkpoint("Putting 2 fingers down and moving them"); |
| 1997 |
y = 30.0; |
| 1998 |
litest_touch_down(dev, 0, 10, y); |
| 1999 |
litest_touch_down(dev, 1, 20, y); |
| 2000 |
litest_dispatch(li); |
| 2001 |
litest_assert_empty_queue(li); |
| 2002 |
|
| 2003 |
litest_timeout_finger_switch(li); |
| 2004 |
|
| 2005 |
while (y < 60.0) { |
| 2006 |
y += 2; |
| 2007 |
litest_touch_move(dev, 0, 10, y); |
| 2008 |
litest_touch_move(dev, 1, 20, y); |
| 2009 |
litest_dispatch(li); |
| 2010 |
} |
| 2011 |
|
| 2012 |
litest_checkpoint("Expecting drag button release and scroll"); |
| 2013 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 2014 |
litest_assert_only_axis_events(li, LIBINPUT_EVENT_POINTER_SCROLL_FINGER); |
| 2015 |
|
| 2016 |
litest_touch_up(dev, 0); |
| 2017 |
litest_dispatch(li); |
| 2018 |
litest_assert_empty_queue(li); |
| 2019 |
|
| 2020 |
litest_timeout_3fg_drag(li); |
| 2021 |
} |
| 2022 |
END_TEST |
| 2023 |
|
| 2024 |
START_TEST(gestures_3fg_drag_lock_resume_1fg_tap) |
| 2025 |
{ |
| 2026 |
struct litest_device *dev = litest_current_device(); |
| 2027 |
struct libinput *li = dev->libinput; |
| 2028 |
int finger_count = litest_test_param_get_i32(test_env->params, "fingers"); |
| 2029 |
|
| 2030 |
if (litest_slot_count(dev) < 3) |
| 2031 |
return LITEST_NOT_APPLICABLE; |
| 2032 |
|
| 2033 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 2034 |
finger_count) |
| 2035 |
return LITEST_NOT_APPLICABLE; |
| 2036 |
|
| 2037 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 2038 |
litest_enable_tap(dev->libinput_device); |
| 2039 |
|
| 2040 |
litest_drain_events(li); |
| 2041 |
|
| 2042 |
litest_checkpoint("Putting 3 fingers down for 3fg drag"); |
| 2043 |
double y = 30.0; |
| 2044 |
for (int i = 0; i < finger_count; i++) |
| 2045 |
litest_touch_down(dev, i, 10 + i, y); |
| 2046 |
|
| 2047 |
litest_dispatch(li); |
| 2048 |
|
| 2049 |
while (y < 60.0) { |
| 2050 |
y += 2; |
| 2051 |
for (int i = 0; i < finger_count; i++) { |
| 2052 |
litest_touch_move(dev, i, 10 + i, y); |
| 2053 |
if (i == |
| 2054 |
0) /* Wait after the first movement to escape the swipe */ |
| 2055 |
litest_timeout_3fg_drag_or_swipe(li); |
| 2056 |
} |
| 2057 |
litest_dispatch(li); |
| 2058 |
} |
| 2059 |
litest_drain_events_of_type(li, |
| 2060 |
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, |
| 2061 |
LIBINPUT_EVENT_GESTURE_HOLD_END, |
| 2062 |
-1); |
| 2063 |
drain_cancelled_swipe_gesture(li); |
| 2064 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 2065 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 2066 |
|
| 2067 |
litest_checkpoint("Releasing 3 fingers"); |
| 2068 |
for (int i = 0; i < finger_count; i++) |
| 2069 |
litest_touch_up(dev, i); |
| 2070 |
|
| 2071 |
litest_dispatch(li); |
| 2072 |
litest_assert_empty_queue(li); |
| 2073 |
|
| 2074 |
litest_checkpoint("Tapping with 1 finger"); |
| 2075 |
/* fingers are up, now let's tap with one finger */ |
| 2076 |
y = 30.0; |
| 2077 |
litest_touch_down(dev, 0, 10, y); |
| 2078 |
litest_dispatch(li); |
| 2079 |
litest_assert_empty_queue(li); |
| 2080 |
litest_touch_up(dev, 0); |
| 2081 |
litest_dispatch(li); |
| 2082 |
|
| 2083 |
litest_timeout_tap(li); |
| 2084 |
|
| 2085 |
litest_checkpoint("Expecting drag release followed by 1fg tap"); |
| 2086 |
|
| 2087 |
/* 3fg drag lock must be cancelled */ |
| 2088 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 2089 |
/* And a 1fg tap */ |
| 2090 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 2091 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 2092 |
litest_assert_empty_queue(li); |
| 2093 |
|
| 2094 |
litest_timeout_3fg_drag(li); |
| 2095 |
} |
| 2096 |
END_TEST |
| 2097 |
|
| 2098 |
START_TEST(gestures_3fg_drag_fast_swipe) |
| 2099 |
{ |
| 2100 |
struct litest_device *dev = litest_current_device(); |
| 2101 |
struct libinput *li = dev->libinput; |
| 2102 |
|
| 2103 |
uint32_t finger_count = litest_test_param_get_u32(test_env->params, "fingers"); |
| 2104 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap-enabled"); |
| 2105 |
|
| 2106 |
if (litest_slot_count(dev) < 3) |
| 2107 |
return LITEST_NOT_APPLICABLE; |
| 2108 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 2109 |
(int)finger_count) |
| 2110 |
return LITEST_NOT_APPLICABLE; |
| 2111 |
|
| 2112 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 2113 |
if (tap_enabled) |
| 2114 |
litest_enable_tap(dev->libinput_device); |
| 2115 |
else |
| 2116 |
litest_disable_tap(dev->libinput_device); |
| 2117 |
|
| 2118 |
litest_drain_events(li); |
| 2119 |
|
| 2120 |
double y = 30.0; |
| 2121 |
for (uint32_t i = 0; i < finger_count; i++) |
| 2122 |
litest_touch_down(dev, i, 10 + i, y); |
| 2123 |
|
| 2124 |
while (y < 60.0) { |
| 2125 |
y += 2; |
| 2126 |
for (uint32_t i = 0; i < finger_count; i++) { |
| 2127 |
litest_touch_move(dev, i, 10 + i, y); |
| 2128 |
} |
| 2129 |
litest_dispatch(li); |
| 2130 |
} |
| 2131 |
|
| 2132 |
litest_drain_events_of_type(li, |
| 2133 |
LIBINPUT_EVENT_GESTURE_HOLD_BEGIN, |
| 2134 |
LIBINPUT_EVENT_GESTURE_HOLD_END); |
| 2135 |
|
| 2136 |
auto begin = libinput_get_event(li); |
| 2137 |
litest_is_gesture_event(begin, |
| 2138 |
LIBINPUT_EVENT_GESTURE_SWIPE_BEGIN, |
| 2139 |
finger_count); |
| 2140 |
libinput_event_destroy(begin); |
| 2141 |
|
| 2142 |
struct libinput_event *update; |
| 2143 |
while ((update = libinput_get_event(li))) { |
| 2144 |
litest_is_gesture_event(update, |
| 2145 |
LIBINPUT_EVENT_GESTURE_SWIPE_UPDATE, |
| 2146 |
finger_count); |
| 2147 |
libinput_event_destroy(update); |
| 2148 |
} |
| 2149 |
|
| 2150 |
for (uint32_t i = 0; i < finger_count; i++) |
| 2151 |
litest_touch_up(dev, i); |
| 2152 |
|
| 2153 |
litest_dispatch(li); |
| 2154 |
|
| 2155 |
auto end = libinput_get_event(li); |
| 2156 |
auto gev = litest_is_gesture_event(end, |
| 2157 |
LIBINPUT_EVENT_GESTURE_SWIPE_END, |
| 2158 |
finger_count); |
| 2159 |
litest_assert(!libinput_event_gesture_get_cancelled(gev)); |
| 2160 |
libinput_event_destroy(end); |
| 2161 |
} |
| 2162 |
END_TEST |
| 2163 |
|
| 2164 |
START_TEST(gestures_3fg_drag_slow_start) |
| 2165 |
{ |
| 2166 |
struct litest_device *dev = litest_current_device(); |
| 2167 |
struct libinput *li = dev->libinput; |
| 2168 |
|
| 2169 |
uint32_t finger_count = litest_test_param_get_u32(test_env->params, "fingers"); |
| 2170 |
bool tap_enabled = litest_test_param_get_bool(test_env->params, "tap-enabled"); |
| 2171 |
|
| 2172 |
if (litest_slot_count(dev) < 3) |
| 2173 |
return LITEST_NOT_APPLICABLE; |
| 2174 |
if (libinput_device_config_3fg_drag_get_finger_count(dev->libinput_device) < |
| 2175 |
(int)finger_count) |
| 2176 |
return LITEST_NOT_APPLICABLE; |
| 2177 |
|
| 2178 |
litest_enable_3fg_drag(dev->libinput_device, finger_count); |
| 2179 |
if (tap_enabled) |
| 2180 |
litest_enable_tap(dev->libinput_device); |
| 2181 |
else |
| 2182 |
litest_disable_tap(dev->libinput_device); |
| 2183 |
|
| 2184 |
litest_drain_events(li); |
| 2185 |
|
| 2186 |
/* Fingers are set down, then we do nothing, then we swipe fast. Because |
| 2187 |
* we did nothing at first even fast movement must become a 3fg drag, not |
| 2188 |
* a swipe. |
| 2189 |
*/ |
| 2190 |
double y = 30.0; |
| 2191 |
for (uint32_t i = 0; i < finger_count; i++) |
| 2192 |
litest_touch_down(dev, i, 10 + i, y); |
| 2193 |
|
| 2194 |
litest_checkpoint("Waiting past timeout before fast finger move"); |
| 2195 |
litest_timeout_3fg_drag_or_swipe(li); |
| 2196 |
|
| 2197 |
/* Now move fast */ |
| 2198 |
while (y < 60.0) { |
| 2199 |
y += 2; |
| 2200 |
for (uint32_t i = 0; i < finger_count; i++) { |
| 2201 |
litest_touch_move(dev, i, 10 + i, y); |
| 2202 |
} |
| 2203 |
litest_dispatch(li); |
| 2204 |
} |
| 2205 |
|
| 2206 |
drain_cancelled_swipe_gesture(li); |
| 2207 |
litest_checkpoint("Expecting button press for 3fg drag"); |
| 2208 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_PRESSED); |
| 2209 |
litest_assert_only_typed_events(li, LIBINPUT_EVENT_POINTER_MOTION); |
| 2210 |
|
| 2211 |
for (uint32_t i = 0; i < finger_count; i++) |
| 2212 |
litest_touch_up(dev, i); |
| 2213 |
|
| 2214 |
litest_dispatch(li); |
| 2215 |
litest_assert_empty_queue(li); |
| 2216 |
|
| 2217 |
litest_timeout_3fg_drag(li); |
| 2218 |
|
| 2219 |
litest_assert_button_event(li, BTN_LEFT, LIBINPUT_BUTTON_STATE_RELEASED); |
| 2220 |
} |
| 2221 |
END_TEST |
| 2222 |
|
| 2223 |
TEST_COLLECTION(gestures) |
| 2224 |
{ |
| 2225 |
/* clang-format off */ |
| 2226 |
litest_add(gestures_cap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); |
| 2227 |
litest_add(gestures_nocap, LITEST_ANY, LITEST_TOUCHPAD); |
| 2228 |
|
| 2229 |
litest_add(gestures_swipe_3fg_btntool_pinch_like, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); |
| 2230 |
|
| 2231 |
litest_add(gestures_3fg_buttonarea_scroll, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH); |
| 2232 |
litest_add(gestures_3fg_buttonarea_scroll_btntool, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH); |
| 2233 |
|
| 2234 |
litest_add(gestures_time_usec, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); |
| 2235 |
|
| 2236 |
litest_add(gestures_hold_config_default_disabled, LITEST_TOUCHPAD|LITEST_SEMI_MT, LITEST_ANY); |
| 2237 |
litest_add(gestures_hold_config_default_enabled, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT); |
| 2238 |
litest_add(gestures_hold_config_set_invalid, LITEST_TOUCHPAD, LITEST_ANY); |
| 2239 |
litest_add(gestures_hold_config_is_available, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH|LITEST_SEMI_MT); |
| 2240 |
litest_add(gestures_hold_config_is_not_available, LITEST_TOUCHPAD|LITEST_SEMI_MT, LITEST_ANY); |
| 2241 |
|
| 2242 |
litest_with_parameters(params, |
| 2243 |
"fingers", 'i', 4, 1, 2, 3, 4, |
| 2244 |
"tap", 'b') { |
| 2245 |
litest_add_parametrized(gestures_hold, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2246 |
litest_add_parametrized(gestures_hold_cancel, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2247 |
} |
| 2248 |
|
| 2249 |
litest_with_parameters(params, "direction", 'I', 8, litest_named_i32(N), litest_named_i32(NE), |
| 2250 |
litest_named_i32(E), litest_named_i32(SE), |
| 2251 |
litest_named_i32(S), litest_named_i32(SW), |
| 2252 |
litest_named_i32(W), litest_named_i32(NW)) { |
| 2253 |
litest_add_parametrized(gestures_swipe_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2254 |
litest_add_parametrized(gestures_swipe_3fg_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2255 |
litest_add_parametrized(gestures_swipe_4fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2256 |
litest_add_parametrized(gestures_swipe_4fg_btntool, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2257 |
litest_add_parametrized(gestures_pinch, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2258 |
litest_add_parametrized(gestures_pinch_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2259 |
litest_add_parametrized(gestures_pinch_4fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2260 |
litest_add_parametrized(gestures_spread, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2261 |
|
| 2262 |
litest_add_parametrized(gestures_hold_then_swipe_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2263 |
litest_add_parametrized(gestures_hold_then_swipe_4fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2264 |
litest_add_parametrized(gestures_hold_then_pinch_2fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2265 |
litest_add_parametrized(gestures_hold_then_pinch_3fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2266 |
litest_add_parametrized(gestures_hold_then_pinch_4fg, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2267 |
litest_add_parametrized(gestures_hold_then_spread, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2268 |
} |
| 2269 |
|
| 2270 |
litest_add(gestures_hold_then_3fg_buttonarea_scroll, LITEST_CLICKPAD, LITEST_SINGLE_TOUCH); |
| 2271 |
|
| 2272 |
litest_add(gestures_hold_once_on_double_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); |
| 2273 |
litest_with_parameters(params, "fingers", 'i', 3, 1, 2, 3) { |
| 2274 |
litest_add_parametrized(gestures_hold_once_tap_n_drag, LITEST_TOUCHPAD, LITEST_ANY, params); |
| 2275 |
} |
| 2276 |
|
| 2277 |
litest_add(gestures_hold_and_motion_before_timeout, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); |
| 2278 |
litest_add(gestures_hold_and_motion_after_timeout, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); |
| 2279 |
|
| 2280 |
litest_with_parameters(params, |
| 2281 |
"fingers", 'u', 2, 3, 4, |
| 2282 |
"tap-enabled", 'b') { |
| 2283 |
litest_add_parametrized(gestures_3fg_drag, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2284 |
} |
| 2285 |
|
| 2286 |
litest_with_parameters(params, |
| 2287 |
"fingers", 'u', 2, 3, 4, |
| 2288 |
"tap-enabled", 'b', |
| 2289 |
"wait", 'b') { |
| 2290 |
litest_add_parametrized(gestures_3fg_drag_lock_resume_3fg_motion, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2291 |
litest_add_parametrized(gestures_3fg_drag_lock_resume_3fg_release_no_motion, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2292 |
} |
| 2293 |
|
| 2294 |
litest_with_parameters(params, |
| 2295 |
"fingers", 'u', 2, 3, 4, |
| 2296 |
"tap-enabled", 'b') { |
| 2297 |
litest_add_parametrized(gestures_3fg_drag_lock_resume_1fg_motion, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2298 |
litest_add_parametrized(gestures_3fg_drag_lock_resume_2fg_scroll, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2299 |
} |
| 2300 |
|
| 2301 |
litest_with_parameters(params, "fingers", 'i', 2, 3, 4) { |
| 2302 |
litest_add_parametrized(gestures_3fg_drag_lock_resume_1fg_tap, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2303 |
} |
| 2304 |
|
| 2305 |
litest_with_parameters(params, |
| 2306 |
"fingers", 'u', 2, 3, 4, |
| 2307 |
"tap-enabled", 'b') { |
| 2308 |
litest_add_parametrized(gestures_3fg_drag_fast_swipe, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2309 |
litest_add_parametrized(gestures_3fg_drag_slow_start, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH, params); |
| 2310 |
} |
| 2311 |
|
| 2312 |
/* Timing-sensitive test, valgrind is too slow */ |
| 2313 |
if (!RUNNING_ON_VALGRIND) |
| 2314 |
litest_add(gestures_swipe_3fg_unaccel, LITEST_TOUCHPAD, LITEST_SINGLE_TOUCH); |
| 2315 |
/* clang-format on */ |
| 2316 |
} |