Changeset View
Changeset View
Standalone View
Standalone View
autotests/libinput/device_test.cpp
Show All 17 Lines | |||||
18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
19 | *********************************************************************/ | 19 | *********************************************************************/ | ||
20 | #include "mock_libinput.h" | 20 | #include "mock_libinput.h" | ||
21 | #include "../../libinput/device.h" | 21 | #include "../../libinput/device.h" | ||
22 | #include <config-kwin.h> | 22 | #include <config-kwin.h> | ||
23 | 23 | | |||
24 | #include <KSharedConfig> | 24 | #include <KSharedConfig> | ||
25 | 25 | | |||
26 | #include <QDBusInterface> | ||||
27 | #include <QDBusConnection> | ||||
26 | #include <QtTest> | 28 | #include <QtTest> | ||
27 | 29 | | |||
28 | #include <linux/input.h> | 30 | #include <linux/input.h> | ||
29 | 31 | | |||
30 | using namespace KWin::LibInput; | 32 | using namespace KWin::LibInput; | ||
31 | 33 | | |||
32 | class TestLibinputDevice : public QObject | 34 | class TestLibinputDevice : public QObject | ||
33 | { | 35 | { | ||
34 | Q_OBJECT | 36 | Q_OBJECT | ||
35 | private Q_SLOTS: | 37 | private Q_SLOTS: | ||
38 | void initTestCase(); | ||||
36 | void testStaticGetter(); | 39 | void testStaticGetter(); | ||
37 | void testDeviceType_data(); | 40 | void testDeviceType_data(); | ||
38 | void testDeviceType(); | 41 | void testDeviceType(); | ||
39 | void testGestureSupport_data(); | 42 | void testGestureSupport_data(); | ||
40 | void testGestureSupport(); | 43 | void testGestureSupport(); | ||
41 | void testNames_data(); | 44 | void testNames_data(); | ||
42 | void testNames(); | 45 | void testNames(); | ||
43 | void testProduct(); | 46 | void testProduct(); | ||
▲ Show 20 Lines • Show All 114 Lines • ▼ Show 20 Line(s) | |||||
158 | void testScreenId(); | 161 | void testScreenId(); | ||
159 | void testOrientation_data(); | 162 | void testOrientation_data(); | ||
160 | void testOrientation(); | 163 | void testOrientation(); | ||
161 | void testCalibrationWithDefault(); | 164 | void testCalibrationWithDefault(); | ||
162 | void testSwitch_data(); | 165 | void testSwitch_data(); | ||
163 | void testSwitch(); | 166 | void testSwitch(); | ||
164 | }; | 167 | }; | ||
165 | 168 | | |||
169 | namespace { | ||||
170 | template <typename T> | ||||
171 | T dbusProperty(const QString &name, const char *property) | ||||
172 | { | ||||
173 | QDBusInterface interface{QStringLiteral("org.kde.kwin.tests.libinputdevice"), | ||||
174 | QStringLiteral("/org/kde/KWin/InputDevice/") + name, | ||||
175 | QStringLiteral("org.kde.KWin.InputDevice")}; | ||||
176 | return interface.property(property).value<T>(); | ||||
177 | } | ||||
178 | } | ||||
179 | | ||||
180 | void TestLibinputDevice::initTestCase() | ||||
181 | { | ||||
182 | QDBusConnection::sessionBus().registerService(QStringLiteral("org.kde.kwin.tests.libinputdevice")); | ||||
183 | } | ||||
184 | | ||||
166 | void TestLibinputDevice::testStaticGetter() | 185 | void TestLibinputDevice::testStaticGetter() | ||
167 | { | 186 | { | ||
168 | // this test verifies that the static getter for Device works as expected | 187 | // this test verifies that the static getter for Device works as expected | ||
169 | QVERIFY(Device::devices().isEmpty()); | 188 | QVERIFY(Device::devices().isEmpty()); | ||
170 | 189 | | |||
171 | // create some device | 190 | // create some device | ||
172 | libinput_device device1; | 191 | libinput_device device1; | ||
173 | libinput_device device2; | 192 | libinput_device device2; | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 247 | { | |||
238 | device.pointer = pointer; | 257 | device.pointer = pointer; | ||
239 | device.touch = touch; | 258 | device.touch = touch; | ||
240 | device.tabletTool = tabletTool; | 259 | device.tabletTool = tabletTool; | ||
241 | device.switchDevice = switchDevice; | 260 | device.switchDevice = switchDevice; | ||
242 | 261 | | |||
243 | Device d(&device); | 262 | Device d(&device); | ||
244 | QCOMPARE(d.isKeyboard(), keyboard); | 263 | QCOMPARE(d.isKeyboard(), keyboard); | ||
245 | QCOMPARE(d.property("keyboard").toBool(), keyboard); | 264 | QCOMPARE(d.property("keyboard").toBool(), keyboard); | ||
265 | QCOMPARE(dbusProperty<bool>(d.sysName(), "keyboard"), keyboard); | ||||
246 | QCOMPARE(d.isPointer(), pointer); | 266 | QCOMPARE(d.isPointer(), pointer); | ||
247 | QCOMPARE(d.property("pointer").toBool(), pointer); | 267 | QCOMPARE(d.property("pointer").toBool(), pointer); | ||
268 | QCOMPARE(dbusProperty<bool>(d.sysName(), "pointer"), pointer); | ||||
248 | QCOMPARE(d.isTouch(), touch); | 269 | QCOMPARE(d.isTouch(), touch); | ||
249 | QCOMPARE(d.property("touch").toBool(), touch); | 270 | QCOMPARE(d.property("touch").toBool(), touch); | ||
271 | QCOMPARE(dbusProperty<bool>(d.sysName(), "touch"), touch); | ||||
250 | QCOMPARE(d.isTabletPad(), false); | 272 | QCOMPARE(d.isTabletPad(), false); | ||
251 | QCOMPARE(d.property("tabletPad").toBool(), false); | 273 | QCOMPARE(d.property("tabletPad").toBool(), false); | ||
274 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tabletPad"), false); | ||||
252 | QCOMPARE(d.isTabletTool(), tabletTool); | 275 | QCOMPARE(d.isTabletTool(), tabletTool); | ||
253 | QCOMPARE(d.property("tabletTool").toBool(), tabletTool); | 276 | QCOMPARE(d.property("tabletTool").toBool(), tabletTool); | ||
277 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tabletTool"), tabletTool); | ||||
254 | QCOMPARE(d.isSwitch(), switchDevice); | 278 | QCOMPARE(d.isSwitch(), switchDevice); | ||
255 | QCOMPARE(d.property("switchDevice").toBool(), switchDevice); | 279 | QCOMPARE(d.property("switchDevice").toBool(), switchDevice); | ||
280 | QCOMPARE(dbusProperty<bool>(d.sysName(), "switchDevice"), switchDevice); | ||||
256 | 281 | | |||
257 | QCOMPARE(d.device(), &device); | 282 | QCOMPARE(d.device(), &device); | ||
258 | } | 283 | } | ||
259 | 284 | | |||
260 | void TestLibinputDevice::testGestureSupport_data() | 285 | void TestLibinputDevice::testGestureSupport_data() | ||
261 | { | 286 | { | ||
262 | QTest::addColumn<bool>("supported"); | 287 | QTest::addColumn<bool>("supported"); | ||
263 | 288 | | |||
264 | QTest::newRow("supported") << true; | 289 | QTest::newRow("supported") << true; | ||
265 | QTest::newRow("not supported") << false; | 290 | QTest::newRow("not supported") << false; | ||
266 | } | 291 | } | ||
267 | 292 | | |||
268 | void TestLibinputDevice::testGestureSupport() | 293 | void TestLibinputDevice::testGestureSupport() | ||
269 | { | 294 | { | ||
270 | // this test verifies whether the Device supports gestures | 295 | // this test verifies whether the Device supports gestures | ||
271 | QFETCH(bool, supported); | 296 | QFETCH(bool, supported); | ||
272 | libinput_device device; | 297 | libinput_device device; | ||
273 | device.gestureSupported = supported; | 298 | device.gestureSupported = supported; | ||
274 | 299 | | |||
275 | Device d(&device); | 300 | Device d(&device); | ||
276 | QCOMPARE(d.supportsGesture(), supported); | 301 | QCOMPARE(d.supportsGesture(), supported); | ||
277 | QCOMPARE(d.property("gestureSupport").toBool(), supported); | 302 | QCOMPARE(d.property("gestureSupport").toBool(), supported); | ||
303 | QCOMPARE(dbusProperty<bool>(d.sysName(), "gestureSupport"), supported); | ||||
278 | } | 304 | } | ||
279 | 305 | | |||
280 | void TestLibinputDevice::testNames_data() | 306 | void TestLibinputDevice::testNames_data() | ||
281 | { | 307 | { | ||
282 | QTest::addColumn<QByteArray>("name"); | 308 | QTest::addColumn<QByteArray>("name"); | ||
283 | QTest::addColumn<QByteArray>("sysName"); | 309 | QTest::addColumn<QByteArray>("sysName"); | ||
284 | QTest::addColumn<QByteArray>("outputName"); | 310 | QTest::addColumn<QByteArray>("outputName"); | ||
285 | 311 | | |||
Show All 10 Lines | 317 | { | |||
296 | libinput_device device; | 322 | libinput_device device; | ||
297 | device.name = name; | 323 | device.name = name; | ||
298 | device.sysName = sysName; | 324 | device.sysName = sysName; | ||
299 | device.outputName = outputName; | 325 | device.outputName = outputName; | ||
300 | 326 | | |||
301 | Device d(&device); | 327 | Device d(&device); | ||
302 | QCOMPARE(d.name().toUtf8(), name); | 328 | QCOMPARE(d.name().toUtf8(), name); | ||
303 | QCOMPARE(d.property("name").toString().toUtf8(), name); | 329 | QCOMPARE(d.property("name").toString().toUtf8(), name); | ||
330 | QCOMPARE(dbusProperty<QString>(d.sysName(), "name"), name); | ||||
304 | QCOMPARE(d.sysName().toUtf8(), sysName); | 331 | QCOMPARE(d.sysName().toUtf8(), sysName); | ||
305 | QCOMPARE(d.property("sysName").toString().toUtf8(), sysName); | 332 | QCOMPARE(d.property("sysName").toString().toUtf8(), sysName); | ||
333 | QCOMPARE(dbusProperty<QString>(d.sysName(), "sysName"), sysName); | ||||
306 | QCOMPARE(d.outputName().toUtf8(), outputName); | 334 | QCOMPARE(d.outputName().toUtf8(), outputName); | ||
307 | QCOMPARE(d.property("outputName").toString().toUtf8(), outputName); | 335 | QCOMPARE(d.property("outputName").toString().toUtf8(), outputName); | ||
336 | QCOMPARE(dbusProperty<QString>(d.sysName(), "outputName"), outputName); | ||||
308 | } | 337 | } | ||
309 | 338 | | |||
310 | void TestLibinputDevice::testProduct() | 339 | void TestLibinputDevice::testProduct() | ||
311 | { | 340 | { | ||
312 | // this test verifies the product property | 341 | // this test verifies the product property | ||
313 | libinput_device device; | 342 | libinput_device device; | ||
314 | device.product = 100u; | 343 | device.product = 100u; | ||
315 | Device d(&device); | 344 | Device d(&device); | ||
316 | QCOMPARE(d.product(), 100u); | 345 | QCOMPARE(d.product(), 100u); | ||
317 | QCOMPARE(d.property("product").toUInt(), 100u); | 346 | QCOMPARE(d.property("product").toUInt(), 100u); | ||
347 | QCOMPARE(dbusProperty<quint32>(d.sysName(), "product"), 100u); | ||||
318 | } | 348 | } | ||
319 | 349 | | |||
320 | void TestLibinputDevice::testVendor() | 350 | void TestLibinputDevice::testVendor() | ||
321 | { | 351 | { | ||
322 | // this test verifies the vendor property | 352 | // this test verifies the vendor property | ||
323 | libinput_device device; | 353 | libinput_device device; | ||
324 | device.vendor = 200u; | 354 | device.vendor = 200u; | ||
325 | Device d(&device); | 355 | Device d(&device); | ||
326 | QCOMPARE(d.vendor(), 200u); | 356 | QCOMPARE(d.vendor(), 200u); | ||
327 | QCOMPARE(d.property("vendor").toUInt(), 200u); | 357 | QCOMPARE(d.property("vendor").toUInt(), 200u); | ||
358 | QCOMPARE(dbusProperty<quint32>(d.sysName(), "vendor"), 200u); | ||||
328 | } | 359 | } | ||
329 | 360 | | |||
330 | void TestLibinputDevice::testTapFingerCount() | 361 | void TestLibinputDevice::testTapFingerCount() | ||
331 | { | 362 | { | ||
332 | // this test verifies the tap finger count property | 363 | // this test verifies the tap finger count property | ||
333 | libinput_device device; | 364 | libinput_device device; | ||
334 | device.tapFingerCount = 3; | 365 | device.tapFingerCount = 3; | ||
335 | Device d(&device); | 366 | Device d(&device); | ||
336 | QCOMPARE(d.tapFingerCount(), 3); | 367 | QCOMPARE(d.tapFingerCount(), 3); | ||
337 | QCOMPARE(d.property("tapFingerCount").toInt(), 3); | 368 | QCOMPARE(d.property("tapFingerCount").toInt(), 3); | ||
369 | QCOMPARE(dbusProperty<int>(d.sysName(), "tapFingerCount"), 3); | ||||
338 | } | 370 | } | ||
339 | 371 | | |||
340 | void TestLibinputDevice::testSize_data() | 372 | void TestLibinputDevice::testSize_data() | ||
341 | { | 373 | { | ||
342 | QTest::addColumn<QSizeF>("setSize"); | 374 | QTest::addColumn<QSizeF>("setSize"); | ||
343 | QTest::addColumn<int>("returnValue"); | 375 | QTest::addColumn<int>("returnValue"); | ||
344 | QTest::addColumn<QSizeF>("expectedSize"); | 376 | QTest::addColumn<QSizeF>("expectedSize"); | ||
345 | 377 | | |||
346 | QTest::newRow("10/20") << QSizeF(10.5, 20.2) << 0 << QSizeF(10.5, 20.2); | 378 | QTest::newRow("10/20") << QSizeF(10.5, 20.2) << 0 << QSizeF(10.5, 20.2); | ||
347 | QTest::newRow("failure") << QSizeF(10, 20) << 1 << QSizeF(); | 379 | QTest::newRow("failure") << QSizeF(10, 20) << 1 << QSizeF(); | ||
348 | } | 380 | } | ||
349 | 381 | | |||
350 | void TestLibinputDevice::testSize() | 382 | void TestLibinputDevice::testSize() | ||
351 | { | 383 | { | ||
352 | // this test verifies that getting the size works correctly including failures | 384 | // this test verifies that getting the size works correctly including failures | ||
353 | QFETCH(QSizeF, setSize); | 385 | QFETCH(QSizeF, setSize); | ||
354 | QFETCH(int, returnValue); | 386 | QFETCH(int, returnValue); | ||
355 | libinput_device device; | 387 | libinput_device device; | ||
356 | device.deviceSize = setSize; | 388 | device.deviceSize = setSize; | ||
357 | device.deviceSizeReturnValue = returnValue; | 389 | device.deviceSizeReturnValue = returnValue; | ||
358 | 390 | | |||
359 | Device d(&device); | 391 | Device d(&device); | ||
360 | QTEST(d.size(), "expectedSize"); | 392 | QTEST(d.size(), "expectedSize"); | ||
361 | QTEST(d.property("size").toSizeF(), "expectedSize"); | 393 | QTEST(d.property("size").toSizeF(), "expectedSize"); | ||
394 | QTEST(dbusProperty<QSizeF>(d.sysName(), "size"), "expectedSize"); | ||||
362 | } | 395 | } | ||
363 | 396 | | |||
364 | void TestLibinputDevice::testLeftHandedEnabledByDefault_data() | 397 | void TestLibinputDevice::testLeftHandedEnabledByDefault_data() | ||
365 | { | 398 | { | ||
366 | QTest::addColumn<bool>("enabled"); | 399 | QTest::addColumn<bool>("enabled"); | ||
367 | 400 | | |||
368 | QTest::newRow("enabled") << true; | 401 | QTest::newRow("enabled") << true; | ||
369 | QTest::newRow("disabled") << false; | 402 | QTest::newRow("disabled") << false; | ||
370 | } | 403 | } | ||
371 | 404 | | |||
372 | void TestLibinputDevice::testLeftHandedEnabledByDefault() | 405 | void TestLibinputDevice::testLeftHandedEnabledByDefault() | ||
373 | { | 406 | { | ||
374 | QFETCH(bool, enabled); | 407 | QFETCH(bool, enabled); | ||
375 | libinput_device device; | 408 | libinput_device device; | ||
376 | device.leftHandedEnabledByDefault = enabled; | 409 | device.leftHandedEnabledByDefault = enabled; | ||
377 | 410 | | |||
378 | Device d(&device); | 411 | Device d(&device); | ||
379 | QCOMPARE(d.leftHandedEnabledByDefault(), enabled); | 412 | QCOMPARE(d.leftHandedEnabledByDefault(), enabled); | ||
380 | QCOMPARE(d.property("leftHandedEnabledByDefault").toBool(), enabled); | 413 | QCOMPARE(d.property("leftHandedEnabledByDefault").toBool(), enabled); | ||
414 | QCOMPARE(dbusProperty<bool>(d.sysName(), "leftHandedEnabledByDefault"), enabled); | ||||
381 | } | 415 | } | ||
382 | 416 | | |||
383 | void TestLibinputDevice::testTapEnabledByDefault_data() | 417 | void TestLibinputDevice::testTapEnabledByDefault_data() | ||
384 | { | 418 | { | ||
385 | QTest::addColumn<bool>("enabled"); | 419 | QTest::addColumn<bool>("enabled"); | ||
386 | 420 | | |||
387 | QTest::newRow("enabled") << true; | 421 | QTest::newRow("enabled") << true; | ||
388 | QTest::newRow("disabled") << false; | 422 | QTest::newRow("disabled") << false; | ||
389 | } | 423 | } | ||
390 | 424 | | |||
391 | void TestLibinputDevice::testTapEnabledByDefault() | 425 | void TestLibinputDevice::testTapEnabledByDefault() | ||
392 | { | 426 | { | ||
393 | QFETCH(bool, enabled); | 427 | QFETCH(bool, enabled); | ||
394 | libinput_device device; | 428 | libinput_device device; | ||
395 | device.tapEnabledByDefault = enabled; | 429 | device.tapEnabledByDefault = enabled; | ||
396 | 430 | | |||
397 | Device d(&device); | 431 | Device d(&device); | ||
398 | QCOMPARE(d.tapToClickEnabledByDefault(), enabled); | 432 | QCOMPARE(d.tapToClickEnabledByDefault(), enabled); | ||
399 | QCOMPARE(d.property("tapToClickEnabledByDefault").toBool(), enabled); | 433 | QCOMPARE(d.property("tapToClickEnabledByDefault").toBool(), enabled); | ||
434 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapToClickEnabledByDefault"), enabled); | ||||
400 | } | 435 | } | ||
401 | 436 | | |||
402 | void TestLibinputDevice::testMiddleEmulationEnabledByDefault_data() | 437 | void TestLibinputDevice::testMiddleEmulationEnabledByDefault_data() | ||
403 | { | 438 | { | ||
404 | QTest::addColumn<bool>("enabled"); | 439 | QTest::addColumn<bool>("enabled"); | ||
405 | 440 | | |||
406 | QTest::newRow("enabled") << true; | 441 | QTest::newRow("enabled") << true; | ||
407 | QTest::newRow("disabled") << false; | 442 | QTest::newRow("disabled") << false; | ||
408 | } | 443 | } | ||
409 | 444 | | |||
410 | void TestLibinputDevice::testMiddleEmulationEnabledByDefault() | 445 | void TestLibinputDevice::testMiddleEmulationEnabledByDefault() | ||
411 | { | 446 | { | ||
412 | QFETCH(bool, enabled); | 447 | QFETCH(bool, enabled); | ||
413 | libinput_device device; | 448 | libinput_device device; | ||
414 | device.middleEmulationEnabledByDefault = enabled; | 449 | device.middleEmulationEnabledByDefault = enabled; | ||
415 | 450 | | |||
416 | Device d(&device); | 451 | Device d(&device); | ||
417 | QCOMPARE(d.middleEmulationEnabledByDefault(), enabled); | 452 | QCOMPARE(d.middleEmulationEnabledByDefault(), enabled); | ||
418 | QCOMPARE(d.property("middleEmulationEnabledByDefault").toBool(), enabled); | 453 | QCOMPARE(d.property("middleEmulationEnabledByDefault").toBool(), enabled); | ||
454 | QCOMPARE(dbusProperty<bool>(d.sysName(), "middleEmulationEnabledByDefault"), enabled); | ||||
419 | } | 455 | } | ||
420 | 456 | | |||
421 | void TestLibinputDevice::testNaturalScrollEnabledByDefault_data() | 457 | void TestLibinputDevice::testNaturalScrollEnabledByDefault_data() | ||
422 | { | 458 | { | ||
423 | QTest::addColumn<bool>("enabled"); | 459 | QTest::addColumn<bool>("enabled"); | ||
424 | 460 | | |||
425 | QTest::newRow("enabled") << true; | 461 | QTest::newRow("enabled") << true; | ||
426 | QTest::newRow("disabled") << false; | 462 | QTest::newRow("disabled") << false; | ||
427 | } | 463 | } | ||
428 | 464 | | |||
429 | void TestLibinputDevice::testNaturalScrollEnabledByDefault() | 465 | void TestLibinputDevice::testNaturalScrollEnabledByDefault() | ||
430 | { | 466 | { | ||
431 | QFETCH(bool, enabled); | 467 | QFETCH(bool, enabled); | ||
432 | libinput_device device; | 468 | libinput_device device; | ||
433 | device.naturalScrollEnabledByDefault = enabled; | 469 | device.naturalScrollEnabledByDefault = enabled; | ||
434 | 470 | | |||
435 | Device d(&device); | 471 | Device d(&device); | ||
436 | QCOMPARE(d.naturalScrollEnabledByDefault(), enabled); | 472 | QCOMPARE(d.naturalScrollEnabledByDefault(), enabled); | ||
437 | QCOMPARE(d.property("naturalScrollEnabledByDefault").toBool(), enabled); | 473 | QCOMPARE(d.property("naturalScrollEnabledByDefault").toBool(), enabled); | ||
474 | QCOMPARE(dbusProperty<bool>(d.sysName(), "naturalScrollEnabledByDefault"), enabled); | ||||
438 | } | 475 | } | ||
439 | 476 | | |||
440 | void TestLibinputDevice::testScrollTwoFingerEnabledByDefault_data() | 477 | void TestLibinputDevice::testScrollTwoFingerEnabledByDefault_data() | ||
441 | { | 478 | { | ||
442 | QTest::addColumn<bool>("enabled"); | 479 | QTest::addColumn<bool>("enabled"); | ||
443 | 480 | | |||
444 | QTest::newRow("enabled") << true; | 481 | QTest::newRow("enabled") << true; | ||
445 | QTest::newRow("disabled") << false; | 482 | QTest::newRow("disabled") << false; | ||
446 | } | 483 | } | ||
447 | 484 | | |||
448 | void TestLibinputDevice::testScrollTwoFingerEnabledByDefault() | 485 | void TestLibinputDevice::testScrollTwoFingerEnabledByDefault() | ||
449 | { | 486 | { | ||
450 | QFETCH(bool, enabled); | 487 | QFETCH(bool, enabled); | ||
451 | libinput_device device; | 488 | libinput_device device; | ||
452 | device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 489 | device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
453 | 490 | | |||
454 | Device d(&device); | 491 | Device d(&device); | ||
455 | QCOMPARE(d.scrollTwoFingerEnabledByDefault(), enabled); | 492 | QCOMPARE(d.scrollTwoFingerEnabledByDefault(), enabled); | ||
456 | QCOMPARE(d.property("scrollTwoFingerEnabledByDefault").toBool(), enabled); | 493 | QCOMPARE(d.property("scrollTwoFingerEnabledByDefault").toBool(), enabled); | ||
494 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollTwoFingerEnabledByDefault"), enabled); | ||||
457 | } | 495 | } | ||
458 | 496 | | |||
459 | void TestLibinputDevice::testScrollEdgeEnabledByDefault_data() | 497 | void TestLibinputDevice::testScrollEdgeEnabledByDefault_data() | ||
460 | { | 498 | { | ||
461 | QTest::addColumn<bool>("enabled"); | 499 | QTest::addColumn<bool>("enabled"); | ||
462 | 500 | | |||
463 | QTest::newRow("enabled") << true; | 501 | QTest::newRow("enabled") << true; | ||
464 | QTest::newRow("disabled") << false; | 502 | QTest::newRow("disabled") << false; | ||
465 | } | 503 | } | ||
466 | 504 | | |||
467 | void TestLibinputDevice::testScrollEdgeEnabledByDefault() | 505 | void TestLibinputDevice::testScrollEdgeEnabledByDefault() | ||
468 | { | 506 | { | ||
469 | QFETCH(bool, enabled); | 507 | QFETCH(bool, enabled); | ||
470 | libinput_device device; | 508 | libinput_device device; | ||
471 | device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 509 | device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
472 | 510 | | |||
473 | Device d(&device); | 511 | Device d(&device); | ||
474 | QCOMPARE(d.scrollEdgeEnabledByDefault(), enabled); | 512 | QCOMPARE(d.scrollEdgeEnabledByDefault(), enabled); | ||
475 | QCOMPARE(d.property("scrollEdgeEnabledByDefault").toBool(), enabled); | 513 | QCOMPARE(d.property("scrollEdgeEnabledByDefault").toBool(), enabled); | ||
514 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollEdgeEnabledByDefault"), enabled); | ||||
476 | } | 515 | } | ||
477 | 516 | | |||
478 | void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat_data() | 517 | void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat_data() | ||
479 | { | 518 | { | ||
480 | QTest::addColumn<bool>("enabled"); | 519 | QTest::addColumn<bool>("enabled"); | ||
481 | 520 | | |||
482 | QTest::newRow("enabled") << true; | 521 | QTest::newRow("enabled") << true; | ||
483 | QTest::newRow("disabled") << false; | 522 | QTest::newRow("disabled") << false; | ||
484 | } | 523 | } | ||
485 | 524 | | |||
486 | void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat() | 525 | void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat() | ||
487 | { | 526 | { | ||
488 | QFETCH(bool, enabled); | 527 | QFETCH(bool, enabled); | ||
489 | libinput_device device; | 528 | libinput_device device; | ||
490 | device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; | 529 | device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; | ||
491 | 530 | | |||
492 | Device d(&device); | 531 | Device d(&device); | ||
493 | QCOMPARE(d.defaultPointerAccelerationProfileFlat(), enabled); | 532 | QCOMPARE(d.defaultPointerAccelerationProfileFlat(), enabled); | ||
494 | QCOMPARE(d.property("defaultPointerAccelerationProfileFlat").toBool(), enabled); | 533 | QCOMPARE(d.property("defaultPointerAccelerationProfileFlat").toBool(), enabled); | ||
534 | QCOMPARE(dbusProperty<bool>(d.sysName(), "defaultPointerAccelerationProfileFlat"), enabled); | ||||
495 | } | 535 | } | ||
496 | 536 | | |||
497 | void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive_data() | 537 | void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive_data() | ||
498 | { | 538 | { | ||
499 | QTest::addColumn<bool>("enabled"); | 539 | QTest::addColumn<bool>("enabled"); | ||
500 | 540 | | |||
501 | QTest::newRow("enabled") << true; | 541 | QTest::newRow("enabled") << true; | ||
502 | QTest::newRow("disabled") << false; | 542 | QTest::newRow("disabled") << false; | ||
503 | } | 543 | } | ||
504 | 544 | | |||
505 | void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive() | 545 | void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive() | ||
506 | { | 546 | { | ||
507 | QFETCH(bool, enabled); | 547 | QFETCH(bool, enabled); | ||
508 | libinput_device device; | 548 | libinput_device device; | ||
509 | device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; | 549 | device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; | ||
510 | 550 | | |||
511 | Device d(&device); | 551 | Device d(&device); | ||
512 | QCOMPARE(d.defaultPointerAccelerationProfileAdaptive(), enabled); | 552 | QCOMPARE(d.defaultPointerAccelerationProfileAdaptive(), enabled); | ||
513 | QCOMPARE(d.property("defaultPointerAccelerationProfileAdaptive").toBool(), enabled); | 553 | QCOMPARE(d.property("defaultPointerAccelerationProfileAdaptive").toBool(), enabled); | ||
554 | QCOMPARE(dbusProperty<bool>(d.sysName(), "defaultPointerAccelerationProfileAdaptive"), enabled); | ||||
514 | } | 555 | } | ||
515 | 556 | | |||
516 | void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault_data() | 557 | void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault_data() | ||
517 | { | 558 | { | ||
518 | QTest::addColumn<bool>("enabled"); | 559 | QTest::addColumn<bool>("enabled"); | ||
519 | 560 | | |||
520 | QTest::newRow("enabled") << true; | 561 | QTest::newRow("enabled") << true; | ||
521 | QTest::newRow("disabled") << false; | 562 | QTest::newRow("disabled") << false; | ||
522 | } | 563 | } | ||
523 | 564 | | |||
524 | void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault() | 565 | void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault() | ||
525 | { | 566 | { | ||
526 | QFETCH(bool, enabled); | 567 | QFETCH(bool, enabled); | ||
527 | libinput_device device; | 568 | libinput_device device; | ||
528 | device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 569 | device.defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
529 | 570 | | |||
530 | Device d(&device); | 571 | Device d(&device); | ||
531 | QCOMPARE(d.scrollOnButtonDownEnabledByDefault(), enabled); | 572 | QCOMPARE(d.scrollOnButtonDownEnabledByDefault(), enabled); | ||
532 | QCOMPARE(d.property("scrollOnButtonDownEnabledByDefault").toBool(), enabled); | 573 | QCOMPARE(d.property("scrollOnButtonDownEnabledByDefault").toBool(), enabled); | ||
574 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollOnButtonDownEnabledByDefault"), enabled); | ||||
533 | } | 575 | } | ||
534 | 576 | | |||
535 | void TestLibinputDevice::testDefaultScrollButton_data() | 577 | void TestLibinputDevice::testDefaultScrollButton_data() | ||
536 | { | 578 | { | ||
537 | QTest::addColumn<quint32>("button"); | 579 | QTest::addColumn<quint32>("button"); | ||
538 | 580 | | |||
539 | QTest::newRow("0") << 0u; | 581 | QTest::newRow("0") << 0u; | ||
540 | QTest::newRow("BTN_LEFT") << quint32(BTN_LEFT); | 582 | QTest::newRow("BTN_LEFT") << quint32(BTN_LEFT); | ||
Show All 10 Lines | |||||
551 | { | 593 | { | ||
552 | libinput_device device; | 594 | libinput_device device; | ||
553 | QFETCH(quint32, button); | 595 | QFETCH(quint32, button); | ||
554 | device.defaultScrollButton = button; | 596 | device.defaultScrollButton = button; | ||
555 | 597 | | |||
556 | Device d(&device); | 598 | Device d(&device); | ||
557 | QCOMPARE(d.defaultScrollButton(), button); | 599 | QCOMPARE(d.defaultScrollButton(), button); | ||
558 | QCOMPARE(d.property("defaultScrollButton").value<quint32>(), button); | 600 | QCOMPARE(d.property("defaultScrollButton").value<quint32>(), button); | ||
601 | QCOMPARE(dbusProperty<quint32>(d.sysName(), "defaultScrollButton"), button); | ||||
559 | } | 602 | } | ||
560 | 603 | | |||
561 | void TestLibinputDevice::testSupportsDisableWhileTyping_data() | 604 | void TestLibinputDevice::testSupportsDisableWhileTyping_data() | ||
562 | { | 605 | { | ||
563 | QTest::addColumn<bool>("enabled"); | 606 | QTest::addColumn<bool>("enabled"); | ||
564 | 607 | | |||
565 | QTest::newRow("enabled") << true; | 608 | QTest::newRow("enabled") << true; | ||
566 | QTest::newRow("disabled") << false; | 609 | QTest::newRow("disabled") << false; | ||
567 | } | 610 | } | ||
568 | 611 | | |||
569 | void TestLibinputDevice::testSupportsDisableWhileTyping() | 612 | void TestLibinputDevice::testSupportsDisableWhileTyping() | ||
570 | { | 613 | { | ||
571 | QFETCH(bool, enabled); | 614 | QFETCH(bool, enabled); | ||
572 | libinput_device device; | 615 | libinput_device device; | ||
573 | device.supportsDisableWhileTyping = enabled; | 616 | device.supportsDisableWhileTyping = enabled; | ||
574 | 617 | | |||
575 | Device d(&device); | 618 | Device d(&device); | ||
576 | QCOMPARE(d.supportsDisableWhileTyping(), enabled); | 619 | QCOMPARE(d.supportsDisableWhileTyping(), enabled); | ||
577 | QCOMPARE(d.property("supportsDisableWhileTyping").toBool(), enabled); | 620 | QCOMPARE(d.property("supportsDisableWhileTyping").toBool(), enabled); | ||
621 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsDisableWhileTyping"), enabled); | ||||
578 | } | 622 | } | ||
579 | 623 | | |||
580 | void TestLibinputDevice::testSupportsPointerAcceleration_data() | 624 | void TestLibinputDevice::testSupportsPointerAcceleration_data() | ||
581 | { | 625 | { | ||
582 | QTest::addColumn<bool>("enabled"); | 626 | QTest::addColumn<bool>("enabled"); | ||
583 | 627 | | |||
584 | QTest::newRow("enabled") << true; | 628 | QTest::newRow("enabled") << true; | ||
585 | QTest::newRow("disabled") << false; | 629 | QTest::newRow("disabled") << false; | ||
586 | } | 630 | } | ||
587 | 631 | | |||
588 | void TestLibinputDevice::testSupportsPointerAcceleration() | 632 | void TestLibinputDevice::testSupportsPointerAcceleration() | ||
589 | { | 633 | { | ||
590 | QFETCH(bool, enabled); | 634 | QFETCH(bool, enabled); | ||
591 | libinput_device device; | 635 | libinput_device device; | ||
592 | device.supportsPointerAcceleration = enabled; | 636 | device.supportsPointerAcceleration = enabled; | ||
593 | 637 | | |||
594 | Device d(&device); | 638 | Device d(&device); | ||
595 | QCOMPARE(d.supportsPointerAcceleration(), enabled); | 639 | QCOMPARE(d.supportsPointerAcceleration(), enabled); | ||
596 | QCOMPARE(d.property("supportsPointerAcceleration").toBool(), enabled); | 640 | QCOMPARE(d.property("supportsPointerAcceleration").toBool(), enabled); | ||
641 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsPointerAcceleration"), enabled); | ||||
597 | } | 642 | } | ||
598 | 643 | | |||
599 | void TestLibinputDevice::testSupportsLeftHanded_data() | 644 | void TestLibinputDevice::testSupportsLeftHanded_data() | ||
600 | { | 645 | { | ||
601 | QTest::addColumn<bool>("enabled"); | 646 | QTest::addColumn<bool>("enabled"); | ||
602 | 647 | | |||
603 | QTest::newRow("enabled") << true; | 648 | QTest::newRow("enabled") << true; | ||
604 | QTest::newRow("disabled") << false; | 649 | QTest::newRow("disabled") << false; | ||
605 | } | 650 | } | ||
606 | 651 | | |||
607 | void TestLibinputDevice::testSupportsLeftHanded() | 652 | void TestLibinputDevice::testSupportsLeftHanded() | ||
608 | { | 653 | { | ||
609 | QFETCH(bool, enabled); | 654 | QFETCH(bool, enabled); | ||
610 | libinput_device device; | 655 | libinput_device device; | ||
611 | device.supportsLeftHanded = enabled; | 656 | device.supportsLeftHanded = enabled; | ||
612 | 657 | | |||
613 | Device d(&device); | 658 | Device d(&device); | ||
614 | QCOMPARE(d.supportsLeftHanded(), enabled); | 659 | QCOMPARE(d.supportsLeftHanded(), enabled); | ||
615 | QCOMPARE(d.property("supportsLeftHanded").toBool(), enabled); | 660 | QCOMPARE(d.property("supportsLeftHanded").toBool(), enabled); | ||
661 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsLeftHanded"), enabled); | ||||
616 | } | 662 | } | ||
617 | 663 | | |||
618 | void TestLibinputDevice::testSupportsCalibrationMatrix_data() | 664 | void TestLibinputDevice::testSupportsCalibrationMatrix_data() | ||
619 | { | 665 | { | ||
620 | QTest::addColumn<bool>("enabled"); | 666 | QTest::addColumn<bool>("enabled"); | ||
621 | 667 | | |||
622 | QTest::newRow("enabled") << true; | 668 | QTest::newRow("enabled") << true; | ||
623 | QTest::newRow("disabled") << false; | 669 | QTest::newRow("disabled") << false; | ||
624 | } | 670 | } | ||
625 | 671 | | |||
626 | void TestLibinputDevice::testSupportsCalibrationMatrix() | 672 | void TestLibinputDevice::testSupportsCalibrationMatrix() | ||
627 | { | 673 | { | ||
628 | QFETCH(bool, enabled); | 674 | QFETCH(bool, enabled); | ||
629 | libinput_device device; | 675 | libinput_device device; | ||
630 | device.supportsCalibrationMatrix = enabled; | 676 | device.supportsCalibrationMatrix = enabled; | ||
631 | 677 | | |||
632 | Device d(&device); | 678 | Device d(&device); | ||
633 | QCOMPARE(d.supportsCalibrationMatrix(), enabled); | 679 | QCOMPARE(d.supportsCalibrationMatrix(), enabled); | ||
634 | QCOMPARE(d.property("supportsCalibrationMatrix").toBool(), enabled); | 680 | QCOMPARE(d.property("supportsCalibrationMatrix").toBool(), enabled); | ||
681 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsCalibrationMatrix"), enabled); | ||||
635 | } | 682 | } | ||
636 | 683 | | |||
637 | void TestLibinputDevice::testSupportsDisableEvents_data() | 684 | void TestLibinputDevice::testSupportsDisableEvents_data() | ||
638 | { | 685 | { | ||
639 | QTest::addColumn<bool>("enabled"); | 686 | QTest::addColumn<bool>("enabled"); | ||
640 | 687 | | |||
641 | QTest::newRow("enabled") << true; | 688 | QTest::newRow("enabled") << true; | ||
642 | QTest::newRow("disabled") << false; | 689 | QTest::newRow("disabled") << false; | ||
643 | } | 690 | } | ||
644 | 691 | | |||
645 | void TestLibinputDevice::testSupportsDisableEvents() | 692 | void TestLibinputDevice::testSupportsDisableEvents() | ||
646 | { | 693 | { | ||
647 | QFETCH(bool, enabled); | 694 | QFETCH(bool, enabled); | ||
648 | libinput_device device; | 695 | libinput_device device; | ||
649 | device.supportsDisableEvents = enabled; | 696 | device.supportsDisableEvents = enabled; | ||
650 | 697 | | |||
651 | Device d(&device); | 698 | Device d(&device); | ||
652 | QCOMPARE(d.supportsDisableEvents(), enabled); | 699 | QCOMPARE(d.supportsDisableEvents(), enabled); | ||
653 | QCOMPARE(d.property("supportsDisableEvents").toBool(), enabled); | 700 | QCOMPARE(d.property("supportsDisableEvents").toBool(), enabled); | ||
701 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsDisableEvents"), enabled); | ||||
654 | } | 702 | } | ||
655 | 703 | | |||
656 | void TestLibinputDevice::testSupportsDisableEventsOnExternalMouse_data() | 704 | void TestLibinputDevice::testSupportsDisableEventsOnExternalMouse_data() | ||
657 | { | 705 | { | ||
658 | QTest::addColumn<bool>("enabled"); | 706 | QTest::addColumn<bool>("enabled"); | ||
659 | 707 | | |||
660 | QTest::newRow("enabled") << true; | 708 | QTest::newRow("enabled") << true; | ||
661 | QTest::newRow("disabled") << false; | 709 | QTest::newRow("disabled") << false; | ||
662 | } | 710 | } | ||
663 | 711 | | |||
664 | void TestLibinputDevice::testSupportsDisableEventsOnExternalMouse() | 712 | void TestLibinputDevice::testSupportsDisableEventsOnExternalMouse() | ||
665 | { | 713 | { | ||
666 | QFETCH(bool, enabled); | 714 | QFETCH(bool, enabled); | ||
667 | libinput_device device; | 715 | libinput_device device; | ||
668 | device.supportsDisableEventsOnExternalMouse = enabled; | 716 | device.supportsDisableEventsOnExternalMouse = enabled; | ||
669 | 717 | | |||
670 | Device d(&device); | 718 | Device d(&device); | ||
671 | QCOMPARE(d.supportsDisableEventsOnExternalMouse(), enabled); | 719 | QCOMPARE(d.supportsDisableEventsOnExternalMouse(), enabled); | ||
672 | QCOMPARE(d.property("supportsDisableEventsOnExternalMouse").toBool(), enabled); | 720 | QCOMPARE(d.property("supportsDisableEventsOnExternalMouse").toBool(), enabled); | ||
721 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsDisableEventsOnExternalMouse"), enabled); | ||||
673 | } | 722 | } | ||
674 | 723 | | |||
675 | void TestLibinputDevice::testSupportsMiddleEmulation_data() | 724 | void TestLibinputDevice::testSupportsMiddleEmulation_data() | ||
676 | { | 725 | { | ||
677 | QTest::addColumn<bool>("enabled"); | 726 | QTest::addColumn<bool>("enabled"); | ||
678 | 727 | | |||
679 | QTest::newRow("enabled") << true; | 728 | QTest::newRow("enabled") << true; | ||
680 | QTest::newRow("disabled") << false; | 729 | QTest::newRow("disabled") << false; | ||
681 | } | 730 | } | ||
682 | 731 | | |||
683 | void TestLibinputDevice::testSupportsMiddleEmulation() | 732 | void TestLibinputDevice::testSupportsMiddleEmulation() | ||
684 | { | 733 | { | ||
685 | QFETCH(bool, enabled); | 734 | QFETCH(bool, enabled); | ||
686 | libinput_device device; | 735 | libinput_device device; | ||
687 | device.supportsMiddleEmulation = enabled; | 736 | device.supportsMiddleEmulation = enabled; | ||
688 | 737 | | |||
689 | Device d(&device); | 738 | Device d(&device); | ||
690 | QCOMPARE(d.supportsMiddleEmulation(), enabled); | 739 | QCOMPARE(d.supportsMiddleEmulation(), enabled); | ||
691 | QCOMPARE(d.property("supportsMiddleEmulation").toBool(), enabled); | 740 | QCOMPARE(d.property("supportsMiddleEmulation").toBool(), enabled); | ||
741 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsMiddleEmulation"), enabled); | ||||
692 | } | 742 | } | ||
693 | 743 | | |||
694 | void TestLibinputDevice::testSupportsNaturalScroll_data() | 744 | void TestLibinputDevice::testSupportsNaturalScroll_data() | ||
695 | { | 745 | { | ||
696 | QTest::addColumn<bool>("enabled"); | 746 | QTest::addColumn<bool>("enabled"); | ||
697 | 747 | | |||
698 | QTest::newRow("enabled") << true; | 748 | QTest::newRow("enabled") << true; | ||
699 | QTest::newRow("disabled") << false; | 749 | QTest::newRow("disabled") << false; | ||
700 | } | 750 | } | ||
701 | 751 | | |||
702 | void TestLibinputDevice::testSupportsNaturalScroll() | 752 | void TestLibinputDevice::testSupportsNaturalScroll() | ||
703 | { | 753 | { | ||
704 | QFETCH(bool, enabled); | 754 | QFETCH(bool, enabled); | ||
705 | libinput_device device; | 755 | libinput_device device; | ||
706 | device.supportsNaturalScroll = enabled; | 756 | device.supportsNaturalScroll = enabled; | ||
707 | 757 | | |||
708 | Device d(&device); | 758 | Device d(&device); | ||
709 | QCOMPARE(d.supportsNaturalScroll(), enabled); | 759 | QCOMPARE(d.supportsNaturalScroll(), enabled); | ||
710 | QCOMPARE(d.property("supportsNaturalScroll").toBool(), enabled); | 760 | QCOMPARE(d.property("supportsNaturalScroll").toBool(), enabled); | ||
761 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsNaturalScroll"), enabled); | ||||
711 | } | 762 | } | ||
712 | 763 | | |||
713 | void TestLibinputDevice::testSupportsScrollTwoFinger_data() | 764 | void TestLibinputDevice::testSupportsScrollTwoFinger_data() | ||
714 | { | 765 | { | ||
715 | QTest::addColumn<bool>("enabled"); | 766 | QTest::addColumn<bool>("enabled"); | ||
716 | 767 | | |||
717 | QTest::newRow("enabled") << true; | 768 | QTest::newRow("enabled") << true; | ||
718 | QTest::newRow("disabled") << false; | 769 | QTest::newRow("disabled") << false; | ||
719 | } | 770 | } | ||
720 | 771 | | |||
721 | void TestLibinputDevice::testSupportsScrollTwoFinger() | 772 | void TestLibinputDevice::testSupportsScrollTwoFinger() | ||
722 | { | 773 | { | ||
723 | QFETCH(bool, enabled); | 774 | QFETCH(bool, enabled); | ||
724 | libinput_device device; | 775 | libinput_device device; | ||
725 | device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 776 | device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
726 | 777 | | |||
727 | Device d(&device); | 778 | Device d(&device); | ||
728 | QCOMPARE(d.supportsScrollTwoFinger(), enabled); | 779 | QCOMPARE(d.supportsScrollTwoFinger(), enabled); | ||
729 | QCOMPARE(d.property("supportsScrollTwoFinger").toBool(), enabled); | 780 | QCOMPARE(d.property("supportsScrollTwoFinger").toBool(), enabled); | ||
781 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsScrollTwoFinger"), enabled); | ||||
730 | } | 782 | } | ||
731 | 783 | | |||
732 | void TestLibinputDevice::testSupportsScrollEdge_data() | 784 | void TestLibinputDevice::testSupportsScrollEdge_data() | ||
733 | { | 785 | { | ||
734 | QTest::addColumn<bool>("enabled"); | 786 | QTest::addColumn<bool>("enabled"); | ||
735 | 787 | | |||
736 | QTest::newRow("enabled") << true; | 788 | QTest::newRow("enabled") << true; | ||
737 | QTest::newRow("disabled") << false; | 789 | QTest::newRow("disabled") << false; | ||
738 | } | 790 | } | ||
739 | 791 | | |||
740 | void TestLibinputDevice::testSupportsScrollEdge() | 792 | void TestLibinputDevice::testSupportsScrollEdge() | ||
741 | { | 793 | { | ||
742 | QFETCH(bool, enabled); | 794 | QFETCH(bool, enabled); | ||
743 | libinput_device device; | 795 | libinput_device device; | ||
744 | device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 796 | device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
745 | 797 | | |||
746 | Device d(&device); | 798 | Device d(&device); | ||
747 | QCOMPARE(d.supportsScrollEdge(), enabled); | 799 | QCOMPARE(d.supportsScrollEdge(), enabled); | ||
748 | QCOMPARE(d.property("supportsScrollEdge").toBool(), enabled); | 800 | QCOMPARE(d.property("supportsScrollEdge").toBool(), enabled); | ||
801 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsScrollEdge"), enabled); | ||||
749 | } | 802 | } | ||
750 | 803 | | |||
751 | void TestLibinputDevice::testSupportsScrollOnButtonDown_data() | 804 | void TestLibinputDevice::testSupportsScrollOnButtonDown_data() | ||
752 | { | 805 | { | ||
753 | QTest::addColumn<bool>("enabled"); | 806 | QTest::addColumn<bool>("enabled"); | ||
754 | 807 | | |||
755 | QTest::newRow("enabled") << true; | 808 | QTest::newRow("enabled") << true; | ||
756 | QTest::newRow("disabled") << false; | 809 | QTest::newRow("disabled") << false; | ||
757 | } | 810 | } | ||
758 | 811 | | |||
759 | void TestLibinputDevice::testSupportsScrollOnButtonDown() | 812 | void TestLibinputDevice::testSupportsScrollOnButtonDown() | ||
760 | { | 813 | { | ||
761 | QFETCH(bool, enabled); | 814 | QFETCH(bool, enabled); | ||
762 | libinput_device device; | 815 | libinput_device device; | ||
763 | device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 816 | device.supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
764 | 817 | | |||
765 | Device d(&device); | 818 | Device d(&device); | ||
766 | QCOMPARE(d.supportsScrollOnButtonDown(), enabled); | 819 | QCOMPARE(d.supportsScrollOnButtonDown(), enabled); | ||
767 | QCOMPARE(d.property("supportsScrollOnButtonDown").toBool(), enabled); | 820 | QCOMPARE(d.property("supportsScrollOnButtonDown").toBool(), enabled); | ||
821 | QCOMPARE(dbusProperty<bool>(d.sysName(), "supportsScrollOnButtonDown"), enabled); | ||||
768 | } | 822 | } | ||
769 | 823 | | |||
770 | void TestLibinputDevice::testDefaultPointerAcceleration_data() | 824 | void TestLibinputDevice::testDefaultPointerAcceleration_data() | ||
771 | { | 825 | { | ||
772 | QTest::addColumn<qreal>("accel"); | 826 | QTest::addColumn<qreal>("accel"); | ||
773 | 827 | | |||
774 | QTest::newRow("-1.0") << -1.0; | 828 | QTest::newRow("-1.0") << -1.0; | ||
775 | QTest::newRow("-0.5") << -0.5; | 829 | QTest::newRow("-0.5") << -0.5; | ||
776 | QTest::newRow("0.0") << 0.0; | 830 | QTest::newRow("0.0") << 0.0; | ||
777 | QTest::newRow("0.3") << 0.3; | 831 | QTest::newRow("0.3") << 0.3; | ||
778 | QTest::newRow("1.0") << 1.0; | 832 | QTest::newRow("1.0") << 1.0; | ||
779 | } | 833 | } | ||
780 | 834 | | |||
781 | void TestLibinputDevice::testDefaultPointerAcceleration() | 835 | void TestLibinputDevice::testDefaultPointerAcceleration() | ||
782 | { | 836 | { | ||
783 | QFETCH(qreal, accel); | 837 | QFETCH(qreal, accel); | ||
784 | libinput_device device; | 838 | libinput_device device; | ||
785 | device.defaultPointerAcceleration = accel; | 839 | device.defaultPointerAcceleration = accel; | ||
786 | 840 | | |||
787 | Device d(&device); | 841 | Device d(&device); | ||
788 | QCOMPARE(d.defaultPointerAcceleration(), accel); | 842 | QCOMPARE(d.defaultPointerAcceleration(), accel); | ||
789 | QCOMPARE(d.property("defaultPointerAcceleration").toReal(), accel); | 843 | QCOMPARE(d.property("defaultPointerAcceleration").toReal(), accel); | ||
844 | QCOMPARE(dbusProperty<qreal>(d.sysName(), "defaultPointerAcceleration"), accel); | ||||
790 | } | 845 | } | ||
791 | 846 | | |||
792 | void TestLibinputDevice::testPointerAcceleration_data() | 847 | void TestLibinputDevice::testPointerAcceleration_data() | ||
793 | { | 848 | { | ||
794 | QTest::addColumn<bool>("supported"); | 849 | QTest::addColumn<bool>("supported"); | ||
795 | QTest::addColumn<bool>("setShouldFail"); | 850 | QTest::addColumn<bool>("setShouldFail"); | ||
796 | QTest::addColumn<qreal>("accel"); | 851 | QTest::addColumn<qreal>("accel"); | ||
797 | QTest::addColumn<qreal>("setAccel"); | 852 | QTest::addColumn<qreal>("setAccel"); | ||
Show All 15 Lines | 864 | { | |||
813 | libinput_device device; | 868 | libinput_device device; | ||
814 | device.supportsPointerAcceleration = supported; | 869 | device.supportsPointerAcceleration = supported; | ||
815 | device.pointerAcceleration = accel; | 870 | device.pointerAcceleration = accel; | ||
816 | device.setPointerAccelerationReturnValue = setShouldFail; | 871 | device.setPointerAccelerationReturnValue = setShouldFail; | ||
817 | 872 | | |||
818 | Device d(&device); | 873 | Device d(&device); | ||
819 | QCOMPARE(d.pointerAcceleration(), accel); | 874 | QCOMPARE(d.pointerAcceleration(), accel); | ||
820 | QCOMPARE(d.property("pointerAcceleration").toReal(), accel); | 875 | QCOMPARE(d.property("pointerAcceleration").toReal(), accel); | ||
876 | QCOMPARE(dbusProperty<qreal>(d.sysName(), "pointerAcceleration"), accel); | ||||
821 | 877 | | |||
822 | QSignalSpy pointerAccelChangedSpy(&d, &Device::pointerAccelerationChanged); | 878 | QSignalSpy pointerAccelChangedSpy(&d, &Device::pointerAccelerationChanged); | ||
823 | QVERIFY(pointerAccelChangedSpy.isValid()); | 879 | QVERIFY(pointerAccelChangedSpy.isValid()); | ||
824 | QFETCH(qreal, setAccel); | 880 | QFETCH(qreal, setAccel); | ||
825 | d.setPointerAcceleration(setAccel); | 881 | d.setPointerAcceleration(setAccel); | ||
826 | QTEST(d.pointerAcceleration(), "expectedAccel"); | 882 | QTEST(d.pointerAcceleration(), "expectedAccel"); | ||
827 | QTEST(!pointerAccelChangedSpy.isEmpty(), "expectedChanged"); | 883 | QTEST(!pointerAccelChangedSpy.isEmpty(), "expectedChanged"); | ||
884 | QTEST(dbusProperty<qreal>(d.sysName(), "pointerAcceleration"), "expectedAccel"); | ||||
828 | } | 885 | } | ||
829 | 886 | | |||
830 | void TestLibinputDevice::testLeftHanded_data() | 887 | void TestLibinputDevice::testLeftHanded_data() | ||
831 | { | 888 | { | ||
832 | QTest::addColumn<bool>("supported"); | 889 | QTest::addColumn<bool>("supported"); | ||
833 | QTest::addColumn<bool>("setShouldFail"); | 890 | QTest::addColumn<bool>("setShouldFail"); | ||
834 | QTest::addColumn<bool>("initValue"); | 891 | QTest::addColumn<bool>("initValue"); | ||
835 | QTest::addColumn<bool>("setValue"); | 892 | QTest::addColumn<bool>("setValue"); | ||
Show All 16 Lines | 905 | { | |||
852 | libinput_device device; | 909 | libinput_device device; | ||
853 | device.supportsLeftHanded = supported; | 910 | device.supportsLeftHanded = supported; | ||
854 | device.leftHanded = initValue; | 911 | device.leftHanded = initValue; | ||
855 | device.setLeftHandedReturnValue = setShouldFail; | 912 | device.setLeftHandedReturnValue = setShouldFail; | ||
856 | 913 | | |||
857 | Device d(&device); | 914 | Device d(&device); | ||
858 | QCOMPARE(d.isLeftHanded(), supported && initValue); | 915 | QCOMPARE(d.isLeftHanded(), supported && initValue); | ||
859 | QCOMPARE(d.property("leftHanded").toBool(), supported && initValue); | 916 | QCOMPARE(d.property("leftHanded").toBool(), supported && initValue); | ||
917 | QCOMPARE(dbusProperty<bool>(d.sysName(), "leftHanded"), supported && initValue); | ||||
860 | 918 | | |||
861 | QSignalSpy leftHandedChangedSpy(&d, &Device::leftHandedChanged); | 919 | QSignalSpy leftHandedChangedSpy(&d, &Device::leftHandedChanged); | ||
862 | QVERIFY(leftHandedChangedSpy.isValid()); | 920 | QVERIFY(leftHandedChangedSpy.isValid()); | ||
863 | QFETCH(bool, setValue); | 921 | QFETCH(bool, setValue); | ||
864 | d.setLeftHanded(setValue); | 922 | d.setLeftHanded(setValue); | ||
865 | QFETCH(bool, expectedValue); | 923 | QFETCH(bool, expectedValue); | ||
866 | QCOMPARE(d.isLeftHanded(), expectedValue); | 924 | QCOMPARE(d.isLeftHanded(), expectedValue); | ||
867 | QCOMPARE(leftHandedChangedSpy.isEmpty(), (supported && initValue) == expectedValue); | 925 | QCOMPARE(leftHandedChangedSpy.isEmpty(), (supported && initValue) == expectedValue); | ||
926 | QCOMPARE(dbusProperty<bool>(d.sysName(), "leftHanded"), expectedValue); | ||||
868 | } | 927 | } | ||
869 | 928 | | |||
870 | void TestLibinputDevice::testSupportedButtons_data() | 929 | void TestLibinputDevice::testSupportedButtons_data() | ||
871 | { | 930 | { | ||
872 | QTest::addColumn<bool>("isPointer"); | 931 | QTest::addColumn<bool>("isPointer"); | ||
873 | QTest::addColumn<Qt::MouseButtons>("setButtons"); | 932 | QTest::addColumn<Qt::MouseButtons>("setButtons"); | ||
874 | QTest::addColumn<Qt::MouseButtons>("expectedButtons"); | 933 | QTest::addColumn<Qt::MouseButtons>("expectedButtons"); | ||
875 | 934 | | |||
Show All 26 Lines | 959 | { | |||
902 | QFETCH(bool, isPointer); | 961 | QFETCH(bool, isPointer); | ||
903 | device.pointer = isPointer; | 962 | device.pointer = isPointer; | ||
904 | QFETCH(Qt::MouseButtons, setButtons); | 963 | QFETCH(Qt::MouseButtons, setButtons); | ||
905 | device.supportedButtons = setButtons; | 964 | device.supportedButtons = setButtons; | ||
906 | 965 | | |||
907 | Device d(&device); | 966 | Device d(&device); | ||
908 | QCOMPARE(d.isPointer(), isPointer); | 967 | QCOMPARE(d.isPointer(), isPointer); | ||
909 | QTEST(d.supportedButtons(), "expectedButtons"); | 968 | QTEST(d.supportedButtons(), "expectedButtons"); | ||
969 | QTEST(Qt::MouseButtons(dbusProperty<int>(d.sysName(), "supportedButtons")), "expectedButtons"); | ||||
910 | } | 970 | } | ||
911 | 971 | | |||
912 | void TestLibinputDevice::testAlphaNumericKeyboard_data() | 972 | void TestLibinputDevice::testAlphaNumericKeyboard_data() | ||
913 | { | 973 | { | ||
914 | QTest::addColumn<QVector<quint32>>("supportedKeys"); | 974 | QTest::addColumn<QVector<quint32>>("supportedKeys"); | ||
915 | QTest::addColumn<bool>("isAlpha"); | 975 | QTest::addColumn<bool>("isAlpha"); | ||
916 | 976 | | |||
917 | QVector<quint32> keys; | 977 | QVector<quint32> keys; | ||
Show All 36 Lines | 1013 | { | |||
954 | QFETCH(QVector<quint32>, supportedKeys); | 1014 | QFETCH(QVector<quint32>, supportedKeys); | ||
955 | libinput_device device; | 1015 | libinput_device device; | ||
956 | device.keyboard = true; | 1016 | device.keyboard = true; | ||
957 | device.keys = supportedKeys; | 1017 | device.keys = supportedKeys; | ||
958 | 1018 | | |||
959 | Device d(&device); | 1019 | Device d(&device); | ||
960 | QCOMPARE(d.isKeyboard(), true); | 1020 | QCOMPARE(d.isKeyboard(), true); | ||
961 | QTEST(d.isAlphaNumericKeyboard(), "isAlpha"); | 1021 | QTEST(d.isAlphaNumericKeyboard(), "isAlpha"); | ||
1022 | QTEST(dbusProperty<bool>(d.sysName(), "alphaNumericKeyboard"), "isAlpha"); | ||||
962 | } | 1023 | } | ||
963 | 1024 | | |||
964 | 1025 | | |||
965 | void TestLibinputDevice::testEnabled_data() | 1026 | void TestLibinputDevice::testEnabled_data() | ||
966 | { | 1027 | { | ||
967 | QTest::addColumn<bool>("supported"); | 1028 | QTest::addColumn<bool>("supported"); | ||
968 | QTest::addColumn<bool>("setShouldFail"); | 1029 | QTest::addColumn<bool>("setShouldFail"); | ||
969 | QTest::addColumn<bool>("initValue"); | 1030 | QTest::addColumn<bool>("initValue"); | ||
Show All 17 Lines | 1044 | { | |||
987 | QFETCH(bool, initValue); | 1048 | QFETCH(bool, initValue); | ||
988 | device.supportsDisableEvents = supported; | 1049 | device.supportsDisableEvents = supported; | ||
989 | device.enabled = initValue; | 1050 | device.enabled = initValue; | ||
990 | device.setEnableModeReturnValue = setShouldFail; | 1051 | device.setEnableModeReturnValue = setShouldFail; | ||
991 | 1052 | | |||
992 | Device d(&device); | 1053 | Device d(&device); | ||
993 | QCOMPARE(d.isEnabled(), !supported || initValue); | 1054 | QCOMPARE(d.isEnabled(), !supported || initValue); | ||
994 | QCOMPARE(d.property("enabled").toBool(), !supported || initValue); | 1055 | QCOMPARE(d.property("enabled").toBool(), !supported || initValue); | ||
1056 | QCOMPARE(dbusProperty<bool>(d.sysName(), "enabled"), !supported || initValue); | ||||
995 | 1057 | | |||
996 | QSignalSpy enabledChangedSpy(&d, &Device::enabledChanged); | 1058 | QSignalSpy enabledChangedSpy(&d, &Device::enabledChanged); | ||
997 | QVERIFY(enabledChangedSpy.isValid()); | 1059 | QVERIFY(enabledChangedSpy.isValid()); | ||
998 | QFETCH(bool, setValue); | 1060 | QFETCH(bool, setValue); | ||
999 | d.setEnabled(setValue); | 1061 | d.setEnabled(setValue); | ||
1000 | QFETCH(bool, expectedValue); | 1062 | QFETCH(bool, expectedValue); | ||
1001 | QCOMPARE(d.isEnabled(), expectedValue); | 1063 | QCOMPARE(d.isEnabled(), expectedValue); | ||
1064 | | ||||
1065 | QCOMPARE(dbusProperty<bool>(d.sysName(), "enabled"), expectedValue); | ||||
1002 | } | 1066 | } | ||
1003 | 1067 | | |||
1004 | void TestLibinputDevice::testTapToClick_data() | 1068 | void TestLibinputDevice::testTapToClick_data() | ||
1005 | { | 1069 | { | ||
1006 | QTest::addColumn<int>("fingerCount"); | 1070 | QTest::addColumn<int>("fingerCount"); | ||
1007 | QTest::addColumn<bool>("initValue"); | 1071 | QTest::addColumn<bool>("initValue"); | ||
1008 | QTest::addColumn<bool>("setValue"); | 1072 | QTest::addColumn<bool>("setValue"); | ||
1009 | QTest::addColumn<bool>("setShouldFail"); | 1073 | QTest::addColumn<bool>("setShouldFail"); | ||
Show All 16 Lines | 1085 | { | |||
1026 | device.tapFingerCount = fingerCount; | 1090 | device.tapFingerCount = fingerCount; | ||
1027 | device.tapToClick = initValue; | 1091 | device.tapToClick = initValue; | ||
1028 | device.setTapToClickReturnValue = setShouldFail; | 1092 | device.setTapToClickReturnValue = setShouldFail; | ||
1029 | 1093 | | |||
1030 | Device d(&device); | 1094 | Device d(&device); | ||
1031 | QCOMPARE(d.tapFingerCount(), fingerCount); | 1095 | QCOMPARE(d.tapFingerCount(), fingerCount); | ||
1032 | QCOMPARE(d.isTapToClick(), initValue); | 1096 | QCOMPARE(d.isTapToClick(), initValue); | ||
1033 | QCOMPARE(d.property("tapToClick").toBool(), initValue); | 1097 | QCOMPARE(d.property("tapToClick").toBool(), initValue); | ||
1098 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapToClick"), initValue); | ||||
1034 | 1099 | | |||
1035 | QSignalSpy tapToClickChangedSpy(&d, &Device::tapToClickChanged); | 1100 | QSignalSpy tapToClickChangedSpy(&d, &Device::tapToClickChanged); | ||
1036 | QVERIFY(tapToClickChangedSpy.isValid()); | 1101 | QVERIFY(tapToClickChangedSpy.isValid()); | ||
1037 | QFETCH(bool, setValue); | 1102 | QFETCH(bool, setValue); | ||
1038 | d.setTapToClick(setValue); | 1103 | d.setTapToClick(setValue); | ||
1039 | QFETCH(bool, expectedValue); | 1104 | QFETCH(bool, expectedValue); | ||
1040 | QCOMPARE(d.isTapToClick(), expectedValue); | 1105 | QCOMPARE(d.isTapToClick(), expectedValue); | ||
1041 | QCOMPARE(tapToClickChangedSpy.isEmpty(), initValue == expectedValue); | 1106 | QCOMPARE(tapToClickChangedSpy.isEmpty(), initValue == expectedValue); | ||
1107 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapToClick"), expectedValue); | ||||
1042 | } | 1108 | } | ||
1043 | 1109 | | |||
1044 | void TestLibinputDevice::testTapAndDragEnabledByDefault_data() | 1110 | void TestLibinputDevice::testTapAndDragEnabledByDefault_data() | ||
1045 | { | 1111 | { | ||
1046 | QTest::addColumn<bool>("enabled"); | 1112 | QTest::addColumn<bool>("enabled"); | ||
1047 | 1113 | | |||
1048 | QTest::newRow("enabled") << true; | 1114 | QTest::newRow("enabled") << true; | ||
1049 | QTest::newRow("disabled") << false; | 1115 | QTest::newRow("disabled") << false; | ||
1050 | } | 1116 | } | ||
1051 | 1117 | | |||
1052 | void TestLibinputDevice::testTapAndDragEnabledByDefault() | 1118 | void TestLibinputDevice::testTapAndDragEnabledByDefault() | ||
1053 | { | 1119 | { | ||
1054 | QFETCH(bool, enabled); | 1120 | QFETCH(bool, enabled); | ||
1055 | libinput_device device; | 1121 | libinput_device device; | ||
1056 | device.tapAndDragEnabledByDefault = enabled; | 1122 | device.tapAndDragEnabledByDefault = enabled; | ||
1057 | 1123 | | |||
1058 | Device d(&device); | 1124 | Device d(&device); | ||
1059 | QCOMPARE(d.tapAndDragEnabledByDefault(), enabled); | 1125 | QCOMPARE(d.tapAndDragEnabledByDefault(), enabled); | ||
1060 | QCOMPARE(d.property("tapAndDragEnabledByDefault").toBool(), enabled); | 1126 | QCOMPARE(d.property("tapAndDragEnabledByDefault").toBool(), enabled); | ||
1127 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapAndDragEnabledByDefault"), enabled); | ||||
1061 | } | 1128 | } | ||
1062 | 1129 | | |||
1063 | void TestLibinputDevice::testTapAndDrag_data() | 1130 | void TestLibinputDevice::testTapAndDrag_data() | ||
1064 | { | 1131 | { | ||
1065 | QTest::addColumn<bool>("initValue"); | 1132 | QTest::addColumn<bool>("initValue"); | ||
1066 | QTest::addColumn<bool>("setValue"); | 1133 | QTest::addColumn<bool>("setValue"); | ||
1067 | QTest::addColumn<bool>("setShouldFail"); | 1134 | QTest::addColumn<bool>("setShouldFail"); | ||
1068 | QTest::addColumn<bool>("expectedValue"); | 1135 | QTest::addColumn<bool>("expectedValue"); | ||
Show All 11 Lines | 1145 | { | |||
1080 | QFETCH(bool, initValue); | 1147 | QFETCH(bool, initValue); | ||
1081 | QFETCH(bool, setShouldFail); | 1148 | QFETCH(bool, setShouldFail); | ||
1082 | device.tapAndDrag = initValue; | 1149 | device.tapAndDrag = initValue; | ||
1083 | device.setTapAndDragReturnValue = setShouldFail; | 1150 | device.setTapAndDragReturnValue = setShouldFail; | ||
1084 | 1151 | | |||
1085 | Device d(&device); | 1152 | Device d(&device); | ||
1086 | QCOMPARE(d.isTapAndDrag(), initValue); | 1153 | QCOMPARE(d.isTapAndDrag(), initValue); | ||
1087 | QCOMPARE(d.property("tapAndDrag").toBool(), initValue); | 1154 | QCOMPARE(d.property("tapAndDrag").toBool(), initValue); | ||
1155 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapAndDrag"), initValue); | ||||
1088 | 1156 | | |||
1089 | QSignalSpy tapAndDragChangedSpy(&d, &Device::tapAndDragChanged); | 1157 | QSignalSpy tapAndDragChangedSpy(&d, &Device::tapAndDragChanged); | ||
1090 | QVERIFY(tapAndDragChangedSpy.isValid()); | 1158 | QVERIFY(tapAndDragChangedSpy.isValid()); | ||
1091 | QFETCH(bool, setValue); | 1159 | QFETCH(bool, setValue); | ||
1092 | d.setTapAndDrag(setValue); | 1160 | d.setTapAndDrag(setValue); | ||
1093 | QFETCH(bool, expectedValue); | 1161 | QFETCH(bool, expectedValue); | ||
1094 | QCOMPARE(d.isTapAndDrag(), expectedValue); | 1162 | QCOMPARE(d.isTapAndDrag(), expectedValue); | ||
1095 | QCOMPARE(tapAndDragChangedSpy.isEmpty(), initValue == expectedValue); | 1163 | QCOMPARE(tapAndDragChangedSpy.isEmpty(), initValue == expectedValue); | ||
1164 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapAndDrag"), expectedValue); | ||||
1096 | } | 1165 | } | ||
1097 | 1166 | | |||
1098 | void TestLibinputDevice::testTapDragLockEnabledByDefault_data() | 1167 | void TestLibinputDevice::testTapDragLockEnabledByDefault_data() | ||
1099 | { | 1168 | { | ||
1100 | QTest::addColumn<bool>("enabled"); | 1169 | QTest::addColumn<bool>("enabled"); | ||
1101 | 1170 | | |||
1102 | QTest::newRow("enabled") << true; | 1171 | QTest::newRow("enabled") << true; | ||
1103 | QTest::newRow("disabled") << false; | 1172 | QTest::newRow("disabled") << false; | ||
1104 | } | 1173 | } | ||
1105 | 1174 | | |||
1106 | void TestLibinputDevice::testTapDragLockEnabledByDefault() | 1175 | void TestLibinputDevice::testTapDragLockEnabledByDefault() | ||
1107 | { | 1176 | { | ||
1108 | QFETCH(bool, enabled); | 1177 | QFETCH(bool, enabled); | ||
1109 | libinput_device device; | 1178 | libinput_device device; | ||
1110 | device.tapDragLockEnabledByDefault = enabled; | 1179 | device.tapDragLockEnabledByDefault = enabled; | ||
1111 | 1180 | | |||
1112 | Device d(&device); | 1181 | Device d(&device); | ||
1113 | QCOMPARE(d.tapDragLockEnabledByDefault(), enabled); | 1182 | QCOMPARE(d.tapDragLockEnabledByDefault(), enabled); | ||
1114 | QCOMPARE(d.property("tapDragLockEnabledByDefault").toBool(), enabled); | 1183 | QCOMPARE(d.property("tapDragLockEnabledByDefault").toBool(), enabled); | ||
1184 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapDragLockEnabledByDefault"), enabled); | ||||
1115 | } | 1185 | } | ||
1116 | 1186 | | |||
1117 | void TestLibinputDevice::testTapDragLock_data() | 1187 | void TestLibinputDevice::testTapDragLock_data() | ||
1118 | { | 1188 | { | ||
1119 | QTest::addColumn<bool>("initValue"); | 1189 | QTest::addColumn<bool>("initValue"); | ||
1120 | QTest::addColumn<bool>("setValue"); | 1190 | QTest::addColumn<bool>("setValue"); | ||
1121 | QTest::addColumn<bool>("setShouldFail"); | 1191 | QTest::addColumn<bool>("setShouldFail"); | ||
1122 | QTest::addColumn<bool>("expectedValue"); | 1192 | QTest::addColumn<bool>("expectedValue"); | ||
Show All 11 Lines | 1202 | { | |||
1134 | QFETCH(bool, initValue); | 1204 | QFETCH(bool, initValue); | ||
1135 | QFETCH(bool, setShouldFail); | 1205 | QFETCH(bool, setShouldFail); | ||
1136 | device.tapDragLock = initValue; | 1206 | device.tapDragLock = initValue; | ||
1137 | device.setTapDragLockReturnValue = setShouldFail; | 1207 | device.setTapDragLockReturnValue = setShouldFail; | ||
1138 | 1208 | | |||
1139 | Device d(&device); | 1209 | Device d(&device); | ||
1140 | QCOMPARE(d.isTapDragLock(), initValue); | 1210 | QCOMPARE(d.isTapDragLock(), initValue); | ||
1141 | QCOMPARE(d.property("tapDragLock").toBool(), initValue); | 1211 | QCOMPARE(d.property("tapDragLock").toBool(), initValue); | ||
1212 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapDragLock"), initValue); | ||||
1142 | 1213 | | |||
1143 | QSignalSpy tapDragLockChangedSpy(&d, &Device::tapDragLockChanged); | 1214 | QSignalSpy tapDragLockChangedSpy(&d, &Device::tapDragLockChanged); | ||
1144 | QVERIFY(tapDragLockChangedSpy.isValid()); | 1215 | QVERIFY(tapDragLockChangedSpy.isValid()); | ||
1145 | QFETCH(bool, setValue); | 1216 | QFETCH(bool, setValue); | ||
1146 | d.setTapDragLock(setValue); | 1217 | d.setTapDragLock(setValue); | ||
1147 | QFETCH(bool, expectedValue); | 1218 | QFETCH(bool, expectedValue); | ||
1148 | QCOMPARE(d.isTapDragLock(), expectedValue); | 1219 | QCOMPARE(d.isTapDragLock(), expectedValue); | ||
1149 | QCOMPARE(tapDragLockChangedSpy.isEmpty(), initValue == expectedValue); | 1220 | QCOMPARE(tapDragLockChangedSpy.isEmpty(), initValue == expectedValue); | ||
1221 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tapDragLock"), expectedValue); | ||||
1150 | } | 1222 | } | ||
1151 | 1223 | | |||
1152 | void TestLibinputDevice::testMiddleEmulation_data() | 1224 | void TestLibinputDevice::testMiddleEmulation_data() | ||
1153 | { | 1225 | { | ||
1154 | QTest::addColumn<bool>("initValue"); | 1226 | QTest::addColumn<bool>("initValue"); | ||
1155 | QTest::addColumn<bool>("setValue"); | 1227 | QTest::addColumn<bool>("setValue"); | ||
1156 | QTest::addColumn<bool>("setShouldFail"); | 1228 | QTest::addColumn<bool>("setShouldFail"); | ||
1157 | QTest::addColumn<bool>("expectedValue"); | 1229 | QTest::addColumn<bool>("expectedValue"); | ||
Show All 16 Lines | 1242 | { | |||
1174 | QFETCH(bool, supportsMiddleButton); | 1246 | QFETCH(bool, supportsMiddleButton); | ||
1175 | device.supportsMiddleEmulation = supportsMiddleButton; | 1247 | device.supportsMiddleEmulation = supportsMiddleButton; | ||
1176 | device.middleEmulation = initValue; | 1248 | device.middleEmulation = initValue; | ||
1177 | device.setMiddleEmulationReturnValue = setShouldFail; | 1249 | device.setMiddleEmulationReturnValue = setShouldFail; | ||
1178 | 1250 | | |||
1179 | Device d(&device); | 1251 | Device d(&device); | ||
1180 | QCOMPARE(d.isMiddleEmulation(), initValue); | 1252 | QCOMPARE(d.isMiddleEmulation(), initValue); | ||
1181 | QCOMPARE(d.property("middleEmulation").toBool(), initValue); | 1253 | QCOMPARE(d.property("middleEmulation").toBool(), initValue); | ||
1254 | QCOMPARE(dbusProperty<bool>(d.sysName(), "middleEmulation"), initValue); | ||||
1182 | 1255 | | |||
1183 | QSignalSpy middleEmulationChangedSpy(&d, &Device::middleEmulationChanged); | 1256 | QSignalSpy middleEmulationChangedSpy(&d, &Device::middleEmulationChanged); | ||
1184 | QVERIFY(middleEmulationChangedSpy.isValid()); | 1257 | QVERIFY(middleEmulationChangedSpy.isValid()); | ||
1185 | QFETCH(bool, setValue); | 1258 | QFETCH(bool, setValue); | ||
1186 | d.setMiddleEmulation(setValue); | 1259 | d.setMiddleEmulation(setValue); | ||
1187 | QFETCH(bool, expectedValue); | 1260 | QFETCH(bool, expectedValue); | ||
1188 | QCOMPARE(d.isMiddleEmulation(), expectedValue); | 1261 | QCOMPARE(d.isMiddleEmulation(), expectedValue); | ||
1189 | QCOMPARE(d.property("middleEmulation").toBool(), expectedValue); | 1262 | QCOMPARE(d.property("middleEmulation").toBool(), expectedValue); | ||
1190 | QCOMPARE(middleEmulationChangedSpy.isEmpty(), initValue == expectedValue); | 1263 | QCOMPARE(middleEmulationChangedSpy.isEmpty(), initValue == expectedValue); | ||
1264 | QCOMPARE(dbusProperty<bool>(d.sysName(), "middleEmulation"), expectedValue); | ||||
1191 | } | 1265 | } | ||
1192 | 1266 | | |||
1193 | void TestLibinputDevice::testNaturalScroll_data() | 1267 | void TestLibinputDevice::testNaturalScroll_data() | ||
1194 | { | 1268 | { | ||
1195 | QTest::addColumn<bool>("initValue"); | 1269 | QTest::addColumn<bool>("initValue"); | ||
1196 | QTest::addColumn<bool>("setValue"); | 1270 | QTest::addColumn<bool>("setValue"); | ||
1197 | QTest::addColumn<bool>("setShouldFail"); | 1271 | QTest::addColumn<bool>("setShouldFail"); | ||
1198 | QTest::addColumn<bool>("expectedValue"); | 1272 | QTest::addColumn<bool>("expectedValue"); | ||
Show All 16 Lines | 1285 | { | |||
1215 | QFETCH(bool, supportsNaturalScroll); | 1289 | QFETCH(bool, supportsNaturalScroll); | ||
1216 | device.supportsNaturalScroll = supportsNaturalScroll; | 1290 | device.supportsNaturalScroll = supportsNaturalScroll; | ||
1217 | device.naturalScroll = initValue; | 1291 | device.naturalScroll = initValue; | ||
1218 | device.setNaturalScrollReturnValue = setShouldFail; | 1292 | device.setNaturalScrollReturnValue = setShouldFail; | ||
1219 | 1293 | | |||
1220 | Device d(&device); | 1294 | Device d(&device); | ||
1221 | QCOMPARE(d.isNaturalScroll(), initValue); | 1295 | QCOMPARE(d.isNaturalScroll(), initValue); | ||
1222 | QCOMPARE(d.property("naturalScroll").toBool(), initValue); | 1296 | QCOMPARE(d.property("naturalScroll").toBool(), initValue); | ||
1297 | QCOMPARE(dbusProperty<bool>(d.sysName(), "naturalScroll"), initValue); | ||||
1223 | 1298 | | |||
1224 | QSignalSpy naturalScrollChangedSpy(&d, &Device::naturalScrollChanged); | 1299 | QSignalSpy naturalScrollChangedSpy(&d, &Device::naturalScrollChanged); | ||
1225 | QVERIFY(naturalScrollChangedSpy.isValid()); | 1300 | QVERIFY(naturalScrollChangedSpy.isValid()); | ||
1226 | QFETCH(bool, setValue); | 1301 | QFETCH(bool, setValue); | ||
1227 | d.setNaturalScroll(setValue); | 1302 | d.setNaturalScroll(setValue); | ||
1228 | QFETCH(bool, expectedValue); | 1303 | QFETCH(bool, expectedValue); | ||
1229 | QCOMPARE(d.isNaturalScroll(), expectedValue); | 1304 | QCOMPARE(d.isNaturalScroll(), expectedValue); | ||
1230 | QCOMPARE(d.property("naturalScroll").toBool(), expectedValue); | 1305 | QCOMPARE(d.property("naturalScroll").toBool(), expectedValue); | ||
1231 | QCOMPARE(naturalScrollChangedSpy.isEmpty(), initValue == expectedValue); | 1306 | QCOMPARE(naturalScrollChangedSpy.isEmpty(), initValue == expectedValue); | ||
1307 | QCOMPARE(dbusProperty<bool>(d.sysName(), "naturalScroll"), expectedValue); | ||||
1232 | } | 1308 | } | ||
1233 | 1309 | | |||
1234 | void TestLibinputDevice::testScrollTwoFinger_data() | 1310 | void TestLibinputDevice::testScrollTwoFinger_data() | ||
1235 | { | 1311 | { | ||
1236 | QTest::addColumn<bool>("initValue"); | 1312 | QTest::addColumn<bool>("initValue"); | ||
1237 | QTest::addColumn<bool>("otherValue"); | 1313 | QTest::addColumn<bool>("otherValue"); | ||
1238 | QTest::addColumn<bool>("setValue"); | 1314 | QTest::addColumn<bool>("setValue"); | ||
1239 | QTest::addColumn<bool>("setShouldFail"); | 1315 | QTest::addColumn<bool>("setShouldFail"); | ||
Show All 20 Lines | 1330 | { | |||
1260 | device.supportedScrollMethods = (supportsScrollTwoFinger ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_EDGE; | 1336 | device.supportedScrollMethods = (supportsScrollTwoFinger ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_EDGE; | ||
1261 | device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 1337 | device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
1262 | device.setScrollMethodReturnValue = setShouldFail; | 1338 | device.setScrollMethodReturnValue = setShouldFail; | ||
1263 | 1339 | | |||
1264 | Device d(&device); | 1340 | Device d(&device); | ||
1265 | QCOMPARE(d.isScrollTwoFinger(), initValue); | 1341 | QCOMPARE(d.isScrollTwoFinger(), initValue); | ||
1266 | QCOMPARE(d.property("scrollTwoFinger").toBool(), initValue); | 1342 | QCOMPARE(d.property("scrollTwoFinger").toBool(), initValue); | ||
1267 | QCOMPARE(d.property("scrollEdge").toBool(), otherValue); | 1343 | QCOMPARE(d.property("scrollEdge").toBool(), otherValue); | ||
1344 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollTwoFinger"), initValue); | ||||
1345 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollEdge"), otherValue); | ||||
1268 | 1346 | | |||
1269 | QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); | 1347 | QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); | ||
1270 | QVERIFY(scrollMethodChangedSpy.isValid()); | 1348 | QVERIFY(scrollMethodChangedSpy.isValid()); | ||
1271 | QFETCH(bool, setValue); | 1349 | QFETCH(bool, setValue); | ||
1272 | d.setScrollTwoFinger(setValue); | 1350 | d.setScrollTwoFinger(setValue); | ||
1273 | QFETCH(bool, expectedValue); | 1351 | QFETCH(bool, expectedValue); | ||
1274 | QCOMPARE(d.isScrollTwoFinger(), expectedValue); | 1352 | QCOMPARE(d.isScrollTwoFinger(), expectedValue); | ||
1275 | QCOMPARE(d.property("scrollTwoFinger").toBool(), expectedValue); | 1353 | QCOMPARE(d.property("scrollTwoFinger").toBool(), expectedValue); | ||
1276 | QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue); | 1354 | QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue); | ||
1355 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollTwoFinger"), expectedValue); | ||||
1277 | } | 1356 | } | ||
1278 | 1357 | | |||
1279 | void TestLibinputDevice::testScrollEdge_data() | 1358 | void TestLibinputDevice::testScrollEdge_data() | ||
1280 | { | 1359 | { | ||
1281 | QTest::addColumn<bool>("initValue"); | 1360 | QTest::addColumn<bool>("initValue"); | ||
1282 | QTest::addColumn<bool>("otherValue"); | 1361 | QTest::addColumn<bool>("otherValue"); | ||
1283 | QTest::addColumn<bool>("setValue"); | 1362 | QTest::addColumn<bool>("setValue"); | ||
1284 | QTest::addColumn<bool>("setShouldFail"); | 1363 | QTest::addColumn<bool>("setShouldFail"); | ||
Show All 20 Lines | 1378 | { | |||
1305 | device.supportedScrollMethods = (supportsScrollEdge ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; | 1384 | device.supportedScrollMethods = (supportsScrollEdge ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; | ||
1306 | device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 1385 | device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
1307 | device.setScrollMethodReturnValue = setShouldFail; | 1386 | device.setScrollMethodReturnValue = setShouldFail; | ||
1308 | 1387 | | |||
1309 | Device d(&device); | 1388 | Device d(&device); | ||
1310 | QCOMPARE(d.isScrollEdge(), initValue); | 1389 | QCOMPARE(d.isScrollEdge(), initValue); | ||
1311 | QCOMPARE(d.property("scrollEdge").toBool(), initValue); | 1390 | QCOMPARE(d.property("scrollEdge").toBool(), initValue); | ||
1312 | QCOMPARE(d.property("scrollTwoFinger").toBool(), otherValue); | 1391 | QCOMPARE(d.property("scrollTwoFinger").toBool(), otherValue); | ||
1392 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollEdge"), initValue); | ||||
1393 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollTwoFinger"), otherValue); | ||||
1313 | 1394 | | |||
1314 | QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); | 1395 | QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); | ||
1315 | QVERIFY(scrollMethodChangedSpy.isValid()); | 1396 | QVERIFY(scrollMethodChangedSpy.isValid()); | ||
1316 | QFETCH(bool, setValue); | 1397 | QFETCH(bool, setValue); | ||
1317 | d.setScrollEdge(setValue); | 1398 | d.setScrollEdge(setValue); | ||
1318 | QFETCH(bool, expectedValue); | 1399 | QFETCH(bool, expectedValue); | ||
1319 | QCOMPARE(d.isScrollEdge(), expectedValue); | 1400 | QCOMPARE(d.isScrollEdge(), expectedValue); | ||
1320 | QCOMPARE(d.property("scrollEdge").toBool(), expectedValue); | 1401 | QCOMPARE(d.property("scrollEdge").toBool(), expectedValue); | ||
1321 | QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue); | 1402 | QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue); | ||
1403 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollEdge"), expectedValue); | ||||
1322 | } | 1404 | } | ||
1323 | 1405 | | |||
1324 | void TestLibinputDevice::testScrollButtonDown_data() | 1406 | void TestLibinputDevice::testScrollButtonDown_data() | ||
1325 | { | 1407 | { | ||
1326 | QTest::addColumn<bool>("initValue"); | 1408 | QTest::addColumn<bool>("initValue"); | ||
1327 | QTest::addColumn<bool>("otherValue"); | 1409 | QTest::addColumn<bool>("otherValue"); | ||
1328 | QTest::addColumn<bool>("setValue"); | 1410 | QTest::addColumn<bool>("setValue"); | ||
1329 | QTest::addColumn<bool>("setShouldFail"); | 1411 | QTest::addColumn<bool>("setShouldFail"); | ||
Show All 20 Lines | 1426 | { | |||
1350 | device.supportedScrollMethods = (supportsScrollButtonDown ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; | 1432 | device.supportedScrollMethods = (supportsScrollButtonDown ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG; | ||
1351 | device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 1433 | device.scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
1352 | device.setScrollMethodReturnValue = setShouldFail; | 1434 | device.setScrollMethodReturnValue = setShouldFail; | ||
1353 | 1435 | | |||
1354 | Device d(&device); | 1436 | Device d(&device); | ||
1355 | QCOMPARE(d.isScrollOnButtonDown(), initValue); | 1437 | QCOMPARE(d.isScrollOnButtonDown(), initValue); | ||
1356 | QCOMPARE(d.property("scrollOnButtonDown").toBool(), initValue); | 1438 | QCOMPARE(d.property("scrollOnButtonDown").toBool(), initValue); | ||
1357 | QCOMPARE(d.property("scrollTwoFinger").toBool(), otherValue); | 1439 | QCOMPARE(d.property("scrollTwoFinger").toBool(), otherValue); | ||
1440 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollOnButtonDown"), initValue); | ||||
1441 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollTwoFinger"), otherValue); | ||||
1358 | 1442 | | |||
1359 | QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); | 1443 | QSignalSpy scrollMethodChangedSpy(&d, &Device::scrollMethodChanged); | ||
1360 | QVERIFY(scrollMethodChangedSpy.isValid()); | 1444 | QVERIFY(scrollMethodChangedSpy.isValid()); | ||
1361 | QFETCH(bool, setValue); | 1445 | QFETCH(bool, setValue); | ||
1362 | d.setScrollOnButtonDown(setValue); | 1446 | d.setScrollOnButtonDown(setValue); | ||
1363 | QFETCH(bool, expectedValue); | 1447 | QFETCH(bool, expectedValue); | ||
1364 | QCOMPARE(d.isScrollOnButtonDown(), expectedValue); | 1448 | QCOMPARE(d.isScrollOnButtonDown(), expectedValue); | ||
1365 | QCOMPARE(d.property("scrollOnButtonDown").toBool(), expectedValue); | 1449 | QCOMPARE(d.property("scrollOnButtonDown").toBool(), expectedValue); | ||
1366 | QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue); | 1450 | QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue); | ||
1451 | QCOMPARE(dbusProperty<bool>(d.sysName(), "scrollOnButtonDown"), expectedValue); | ||||
1367 | } | 1452 | } | ||
1368 | 1453 | | |||
1369 | void TestLibinputDevice::testScrollButton_data() | 1454 | void TestLibinputDevice::testScrollButton_data() | ||
1370 | { | 1455 | { | ||
1371 | QTest::addColumn<quint32>("initValue"); | 1456 | QTest::addColumn<quint32>("initValue"); | ||
1372 | QTest::addColumn<quint32>("setValue"); | 1457 | QTest::addColumn<quint32>("setValue"); | ||
1373 | QTest::addColumn<quint32>("expectedValue"); | 1458 | QTest::addColumn<quint32>("expectedValue"); | ||
1374 | QTest::addColumn<bool>("setShouldFail"); | 1459 | QTest::addColumn<bool>("setShouldFail"); | ||
Show All 13 Lines | 1469 | { | |||
1388 | QFETCH(bool, scrollOnButton); | 1473 | QFETCH(bool, scrollOnButton); | ||
1389 | device.scrollButton = initValue; | 1474 | device.scrollButton = initValue; | ||
1390 | device.supportedScrollMethods = scrollOnButton ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | 1475 | device.supportedScrollMethods = scrollOnButton ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL; | ||
1391 | device.setScrollButtonReturnValue = setShouldFail; | 1476 | device.setScrollButtonReturnValue = setShouldFail; | ||
1392 | 1477 | | |||
1393 | Device d(&device); | 1478 | Device d(&device); | ||
1394 | QCOMPARE(d.scrollButton(), initValue); | 1479 | QCOMPARE(d.scrollButton(), initValue); | ||
1395 | QCOMPARE(d.property("scrollButton").value<quint32>(), initValue); | 1480 | QCOMPARE(d.property("scrollButton").value<quint32>(), initValue); | ||
1481 | QCOMPARE(dbusProperty<quint32>(d.sysName(), "scrollButton"), initValue); | ||||
1396 | 1482 | | |||
1397 | QSignalSpy scrollButtonChangedSpy(&d, &Device::scrollButtonChanged); | 1483 | QSignalSpy scrollButtonChangedSpy(&d, &Device::scrollButtonChanged); | ||
1398 | QVERIFY(scrollButtonChangedSpy.isValid()); | 1484 | QVERIFY(scrollButtonChangedSpy.isValid()); | ||
1399 | QFETCH(quint32, setValue); | 1485 | QFETCH(quint32, setValue); | ||
1400 | d.setScrollButton(setValue); | 1486 | d.setScrollButton(setValue); | ||
1401 | QFETCH(quint32, expectedValue); | 1487 | QFETCH(quint32, expectedValue); | ||
1402 | QCOMPARE(d.scrollButton(), expectedValue); | 1488 | QCOMPARE(d.scrollButton(), expectedValue); | ||
1403 | QCOMPARE(d.property("scrollButton").value<quint32>(), expectedValue); | 1489 | QCOMPARE(d.property("scrollButton").value<quint32>(), expectedValue); | ||
1404 | QCOMPARE(scrollButtonChangedSpy.isEmpty(), initValue == expectedValue); | 1490 | QCOMPARE(scrollButtonChangedSpy.isEmpty(), initValue == expectedValue); | ||
1491 | QCOMPARE(dbusProperty<quint32>(d.sysName(), "scrollButton"), expectedValue); | ||||
1405 | } | 1492 | } | ||
1406 | 1493 | | |||
1407 | void TestLibinputDevice::testDisableWhileTypingEnabledByDefault_data() | 1494 | void TestLibinputDevice::testDisableWhileTypingEnabledByDefault_data() | ||
1408 | { | 1495 | { | ||
1409 | QTest::addColumn<bool>("enabled"); | 1496 | QTest::addColumn<bool>("enabled"); | ||
1410 | 1497 | | |||
1411 | QTest::newRow("enabled") << true; | 1498 | QTest::newRow("enabled") << true; | ||
1412 | QTest::newRow("disabled") << false; | 1499 | QTest::newRow("disabled") << false; | ||
1413 | } | 1500 | } | ||
1414 | 1501 | | |||
1415 | void TestLibinputDevice::testDisableWhileTypingEnabledByDefault() | 1502 | void TestLibinputDevice::testDisableWhileTypingEnabledByDefault() | ||
1416 | { | 1503 | { | ||
1417 | QFETCH(bool, enabled); | 1504 | QFETCH(bool, enabled); | ||
1418 | libinput_device device; | 1505 | libinput_device device; | ||
1419 | device.disableWhileTypingEnabledByDefault = enabled ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED; | 1506 | device.disableWhileTypingEnabledByDefault = enabled ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED; | ||
1420 | 1507 | | |||
1421 | Device d(&device); | 1508 | Device d(&device); | ||
1422 | QCOMPARE(d.disableWhileTypingEnabledByDefault(), enabled); | 1509 | QCOMPARE(d.disableWhileTypingEnabledByDefault(), enabled); | ||
1423 | QCOMPARE(d.property("disableWhileTypingEnabledByDefault").toBool(), enabled); | 1510 | QCOMPARE(d.property("disableWhileTypingEnabledByDefault").toBool(), enabled); | ||
1511 | QCOMPARE(dbusProperty<bool>(d.sysName(), "disableWhileTypingEnabledByDefault"), enabled); | ||||
1424 | } | 1512 | } | ||
1425 | 1513 | | |||
1426 | void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault_data() | 1514 | void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault_data() | ||
1427 | { | 1515 | { | ||
1428 | QTest::addColumn<bool>("enabled"); | 1516 | QTest::addColumn<bool>("enabled"); | ||
1429 | 1517 | | |||
1430 | QTest::newRow("enabled") << true; | 1518 | QTest::newRow("enabled") << true; | ||
1431 | QTest::newRow("disabled") << false; | 1519 | QTest::newRow("disabled") << false; | ||
1432 | } | 1520 | } | ||
1433 | 1521 | | |||
1434 | void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault() | 1522 | void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault() | ||
1435 | { | 1523 | { | ||
1436 | QFETCH(bool, enabled); | 1524 | QFETCH(bool, enabled); | ||
1437 | libinput_device device; | 1525 | libinput_device device; | ||
1438 | device.defaultTapButtonMap = enabled ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM; | 1526 | device.defaultTapButtonMap = enabled ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM; | ||
1439 | 1527 | | |||
1440 | Device d(&device); | 1528 | Device d(&device); | ||
1441 | QCOMPARE(d.lmrTapButtonMapEnabledByDefault(), enabled); | 1529 | QCOMPARE(d.lmrTapButtonMapEnabledByDefault(), enabled); | ||
1442 | QCOMPARE(d.property("lmrTapButtonMapEnabledByDefault").toBool(), enabled); | 1530 | QCOMPARE(d.property("lmrTapButtonMapEnabledByDefault").toBool(), enabled); | ||
1531 | QCOMPARE(dbusProperty<bool>(d.sysName(), "lmrTapButtonMapEnabledByDefault"), enabled); | ||||
1443 | } | 1532 | } | ||
1444 | 1533 | | |||
1445 | void TestLibinputDevice::testLmrTapButtonMap_data() | 1534 | void TestLibinputDevice::testLmrTapButtonMap_data() | ||
1446 | { | 1535 | { | ||
1447 | QTest::addColumn<bool>("initValue"); | 1536 | QTest::addColumn<bool>("initValue"); | ||
1448 | QTest::addColumn<bool>("setValue"); | 1537 | QTest::addColumn<bool>("setValue"); | ||
1449 | QTest::addColumn<bool>("setShouldFail"); | 1538 | QTest::addColumn<bool>("setShouldFail"); | ||
1450 | QTest::addColumn<bool>("expectedValue"); | 1539 | QTest::addColumn<bool>("expectedValue"); | ||
▲ Show 20 Lines • Show All 66 Lines • ▼ Show 20 Line(s) | 1602 | { | |||
1517 | QFETCH(bool, supportsDisableWhileTyping); | 1606 | QFETCH(bool, supportsDisableWhileTyping); | ||
1518 | device.supportsDisableWhileTyping = supportsDisableWhileTyping; | 1607 | device.supportsDisableWhileTyping = supportsDisableWhileTyping; | ||
1519 | device.disableWhileTyping = initValue ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED; | 1608 | device.disableWhileTyping = initValue ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED; | ||
1520 | device.setDisableWhileTypingReturnValue = setShouldFail; | 1609 | device.setDisableWhileTypingReturnValue = setShouldFail; | ||
1521 | 1610 | | |||
1522 | Device d(&device); | 1611 | Device d(&device); | ||
1523 | QCOMPARE(d.isDisableWhileTyping(), initValue); | 1612 | QCOMPARE(d.isDisableWhileTyping(), initValue); | ||
1524 | QCOMPARE(d.property("disableWhileTyping").toBool(), initValue); | 1613 | QCOMPARE(d.property("disableWhileTyping").toBool(), initValue); | ||
1614 | QCOMPARE(dbusProperty<bool>(d.sysName(), "disableWhileTyping"), initValue); | ||||
1525 | 1615 | | |||
1526 | QSignalSpy disableWhileTypingChangedSpy(&d, &Device::disableWhileTypingChanged); | 1616 | QSignalSpy disableWhileTypingChangedSpy(&d, &Device::disableWhileTypingChanged); | ||
1527 | QVERIFY(disableWhileTypingChangedSpy.isValid()); | 1617 | QVERIFY(disableWhileTypingChangedSpy.isValid()); | ||
1528 | QFETCH(bool, setValue); | 1618 | QFETCH(bool, setValue); | ||
1529 | d.setDisableWhileTyping(setValue); | 1619 | d.setDisableWhileTyping(setValue); | ||
1530 | QFETCH(bool, expectedValue); | 1620 | QFETCH(bool, expectedValue); | ||
1531 | QCOMPARE(d.isDisableWhileTyping(), expectedValue); | 1621 | QCOMPARE(d.isDisableWhileTyping(), expectedValue); | ||
1532 | QCOMPARE(d.property("disableWhileTyping").toBool(), expectedValue); | 1622 | QCOMPARE(d.property("disableWhileTyping").toBool(), expectedValue); | ||
1533 | QCOMPARE(disableWhileTypingChangedSpy.isEmpty(), initValue == expectedValue); | 1623 | QCOMPARE(disableWhileTypingChangedSpy.isEmpty(), initValue == expectedValue); | ||
1624 | QCOMPARE(dbusProperty<bool>(d.sysName(), "disableWhileTyping"), expectedValue); | ||||
1534 | } | 1625 | } | ||
1535 | 1626 | | |||
1536 | void TestLibinputDevice::testLoadEnabled_data() | 1627 | void TestLibinputDevice::testLoadEnabled_data() | ||
1537 | { | 1628 | { | ||
1538 | QTest::addColumn<bool>("initValue"); | 1629 | QTest::addColumn<bool>("initValue"); | ||
1539 | QTest::addColumn<bool>("configValue"); | 1630 | QTest::addColumn<bool>("configValue"); | ||
1540 | 1631 | | |||
1541 | QTest::newRow("false -> true") << false << true; | 1632 | QTest::newRow("false -> true") << false << true; | ||
▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Line(s) | 1732 | { | |||
1664 | QCOMPARE(d.property(initValuePropName).toBool(), true); | 1755 | QCOMPARE(d.property(initValuePropName).toBool(), true); | ||
1665 | QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue); | 1756 | QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue); | ||
1666 | 1757 | | |||
1667 | // set the group | 1758 | // set the group | ||
1668 | d.setConfig(inputConfig); | 1759 | d.setConfig(inputConfig); | ||
1669 | d.loadConfiguration(); | 1760 | d.loadConfiguration(); | ||
1670 | QCOMPARE(d.property(initValuePropName).toBool(), initValue == configValue); | 1761 | QCOMPARE(d.property(initValuePropName).toBool(), initValue == configValue); | ||
1671 | QCOMPARE(d.property(configValuePropName).toBool(), true); | 1762 | QCOMPARE(d.property(configValuePropName).toBool(), true); | ||
1763 | QCOMPARE(dbusProperty<bool>(d.sysName(), initValuePropName), initValue == configValue); | ||||
1764 | QCOMPARE(dbusProperty<bool>(d.sysName(), configValuePropName), true); | ||||
1672 | 1765 | | |||
1673 | // and try to store | 1766 | // and try to store | ||
1674 | if (configValue != initValue) { | 1767 | if (configValue != initValue) { | ||
1675 | d.setProperty(initValuePropName, true); | 1768 | d.setProperty(initValuePropName, true); | ||
1676 | QCOMPARE(inputConfig.readEntry("PointerAccelerationProfile", configValue), initValue); | 1769 | QCOMPARE(inputConfig.readEntry("PointerAccelerationProfile", configValue), initValue); | ||
1677 | } | 1770 | } | ||
1678 | } | 1771 | } | ||
1679 | 1772 | | |||
▲ Show 20 Lines • Show All 409 Lines • ▼ Show 20 Line(s) | 2173 | { | |||
2089 | device.tapButtonMap = initValue ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM; | 2182 | device.tapButtonMap = initValue ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM; | ||
2090 | device.setTapButtonMapReturnValue = false; | 2183 | device.setTapButtonMapReturnValue = false; | ||
2091 | 2184 | | |||
2092 | Device d(&device); | 2185 | Device d(&device); | ||
2093 | QCOMPARE(d.lmrTapButtonMap(), initValue); | 2186 | QCOMPARE(d.lmrTapButtonMap(), initValue); | ||
2094 | // no config group set, should not change | 2187 | // no config group set, should not change | ||
2095 | d.loadConfiguration(); | 2188 | d.loadConfiguration(); | ||
2096 | QCOMPARE(d.lmrTapButtonMap(), initValue); | 2189 | QCOMPARE(d.lmrTapButtonMap(), initValue); | ||
2190 | QCOMPARE(dbusProperty<bool>(d.sysName(), "lmrTapButtonMap"), initValue); | ||||
2097 | 2191 | | |||
2098 | // set the group | 2192 | // set the group | ||
2099 | d.setConfig(inputConfig); | 2193 | d.setConfig(inputConfig); | ||
2100 | d.loadConfiguration(); | 2194 | d.loadConfiguration(); | ||
2101 | QCOMPARE(d.lmrTapButtonMap(), configValue); | 2195 | QCOMPARE(d.lmrTapButtonMap(), configValue); | ||
2196 | QCOMPARE(dbusProperty<bool>(d.sysName(), "lmrTapButtonMap"), configValue); | ||||
2102 | 2197 | | |||
2103 | // and try to store | 2198 | // and try to store | ||
2104 | if (configValue != initValue) { | 2199 | if (configValue != initValue) { | ||
2105 | d.setLmrTapButtonMap(initValue); | 2200 | d.setLmrTapButtonMap(initValue); | ||
2106 | QCOMPARE(inputConfig.readEntry("LmrTapButtonMap", configValue), initValue); | 2201 | QCOMPARE(inputConfig.readEntry("LmrTapButtonMap", configValue), initValue); | ||
2107 | } | 2202 | } | ||
2108 | } | 2203 | } | ||
2109 | 2204 | | |||
▲ Show 20 Lines • Show All 75 Lines • ▼ Show 20 Line(s) | 2276 | { | |||
2185 | QFETCH(bool, tablet); | 2280 | QFETCH(bool, tablet); | ||
2186 | device.lidSwitch = lid; | 2281 | device.lidSwitch = lid; | ||
2187 | device.tabletModeSwitch = tablet; | 2282 | device.tabletModeSwitch = tablet; | ||
2188 | 2283 | | |||
2189 | Device d(&device); | 2284 | Device d(&device); | ||
2190 | QCOMPARE(d.isSwitch(), true); | 2285 | QCOMPARE(d.isSwitch(), true); | ||
2191 | QCOMPARE(d.isLidSwitch(), lid); | 2286 | QCOMPARE(d.isLidSwitch(), lid); | ||
2192 | QCOMPARE(d.property("lidSwitch").toBool(), lid); | 2287 | QCOMPARE(d.property("lidSwitch").toBool(), lid); | ||
2288 | QCOMPARE(dbusProperty<bool>(d.sysName(), "lidSwitch"), lid); | ||||
2193 | QCOMPARE(d.isTabletModeSwitch(), tablet); | 2289 | QCOMPARE(d.isTabletModeSwitch(), tablet); | ||
2194 | QCOMPARE(d.property("tabletModeSwitch").toBool(), tablet); | 2290 | QCOMPARE(d.property("tabletModeSwitch").toBool(), tablet); | ||
2291 | QCOMPARE(dbusProperty<bool>(d.sysName(), "tabletModeSwitch"), tablet); | ||||
2195 | } | 2292 | } | ||
2196 | 2293 | | |||
2197 | QTEST_GUILESS_MAIN(TestLibinputDevice) | 2294 | QTEST_GUILESS_MAIN(TestLibinputDevice) | ||
2198 | #include "device_test.moc" | 2295 | #include "device_test.moc" |