9#include <config-kwin.h>
14#include <KSharedConfig>
16#include <QDBusConnection>
17#include <QDBusInterface>
21#include <linux/input.h>
30 void testDeviceType_data();
31 void testDeviceType();
32 void testGestureSupport_data();
33 void testGestureSupport();
34 void testNames_data();
38 void testTapFingerCount();
41 void testDefaultPointerAcceleration_data();
42 void testDefaultPointerAcceleration();
43 void testDefaultPointerAccelerationProfileFlat_data();
44 void testDefaultPointerAccelerationProfileFlat();
45 void testDefaultPointerAccelerationProfileAdaptive_data();
46 void testDefaultPointerAccelerationProfileAdaptive();
47 void testDefaultClickMethodAreas_data();
48 void testDefaultClickMethodAreas();
49 void testDefaultClickMethodClickfinger_data();
50 void testDefaultClickMethodClickfinger();
51 void testLeftHandedEnabledByDefault_data();
52 void testLeftHandedEnabledByDefault();
53 void testTapEnabledByDefault_data();
54 void testTapEnabledByDefault();
55 void testMiddleEmulationEnabledByDefault_data();
56 void testMiddleEmulationEnabledByDefault();
57 void testNaturalScrollEnabledByDefault_data();
58 void testNaturalScrollEnabledByDefault();
59 void testScrollTwoFingerEnabledByDefault_data();
60 void testScrollTwoFingerEnabledByDefault();
61 void testScrollEdgeEnabledByDefault_data();
62 void testScrollEdgeEnabledByDefault();
63 void testScrollOnButtonDownEnabledByDefault_data();
64 void testScrollOnButtonDownEnabledByDefault();
65 void testDisableWhileTypingEnabledByDefault_data();
66 void testDisableWhileTypingEnabledByDefault();
67 void testLmrTapButtonMapEnabledByDefault_data();
68 void testLmrTapButtonMapEnabledByDefault();
69 void testSupportsDisableWhileTyping_data();
70 void testSupportsDisableWhileTyping();
71 void testSupportsPointerAcceleration_data();
72 void testSupportsPointerAcceleration();
73 void testSupportsLeftHanded_data();
74 void testSupportsLeftHanded();
75 void testSupportsCalibrationMatrix_data();
76 void testSupportsCalibrationMatrix();
77 void testSupportsDisableEvents_data();
78 void testSupportsDisableEvents();
79 void testSupportsDisableEventsOnExternalMouse_data();
80 void testSupportsDisableEventsOnExternalMouse();
81 void testSupportsMiddleEmulation_data();
82 void testSupportsMiddleEmulation();
83 void testSupportsNaturalScroll_data();
84 void testSupportsNaturalScroll();
85 void testSupportsScrollTwoFinger_data();
86 void testSupportsScrollTwoFinger();
87 void testSupportsScrollEdge_data();
88 void testSupportsScrollEdge();
89 void testSupportsScrollOnButtonDown_data();
90 void testSupportsScrollOnButtonDown();
91 void testDefaultScrollButton_data();
92 void testDefaultScrollButton();
93 void testPointerAcceleration_data();
94 void testPointerAcceleration();
95 void testLeftHanded_data();
96 void testLeftHanded();
97 void testSupportedButtons_data();
98 void testSupportedButtons();
99 void testAlphaNumericKeyboard_data();
100 void testAlphaNumericKeyboard();
101 void testEnabled_data();
103 void testTapToClick_data();
104 void testTapToClick();
105 void testTapAndDragEnabledByDefault_data();
106 void testTapAndDragEnabledByDefault();
107 void testTapAndDrag_data();
108 void testTapAndDrag();
109 void testTapDragLockEnabledByDefault_data();
110 void testTapDragLockEnabledByDefault();
111 void testTapDragLock_data();
112 void testTapDragLock();
113 void testMiddleEmulation_data();
114 void testMiddleEmulation();
115 void testNaturalScroll_data();
116 void testNaturalScroll();
117 void testScrollFactor();
118 void testScrollTwoFinger_data();
119 void testScrollTwoFinger();
120 void testScrollEdge_data();
121 void testScrollEdge();
122 void testScrollButtonDown_data();
123 void testScrollButtonDown();
124 void testScrollButton_data();
125 void testScrollButton();
126 void testDisableWhileTyping_data();
127 void testDisableWhileTyping();
128 void testLmrTapButtonMap_data();
129 void testLmrTapButtonMap();
130 void testLoadEnabled_data();
131 void testLoadEnabled();
132 void testLoadPointerAcceleration_data();
133 void testLoadPointerAcceleration();
134 void testLoadPointerAccelerationProfile_data();
135 void testLoadPointerAccelerationProfile();
136 void testLoadClickMethod_data();
137 void testLoadClickMethod();
138 void testLoadTapToClick_data();
139 void testLoadTapToClick();
140 void testLoadTapAndDrag_data();
141 void testLoadTapAndDrag();
142 void testLoadTapDragLock_data();
143 void testLoadTapDragLock();
144 void testLoadMiddleButtonEmulation_data();
145 void testLoadMiddleButtonEmulation();
146 void testLoadNaturalScroll_data();
147 void testLoadNaturalScroll();
148 void testLoadScrollMethod_data();
149 void testLoadScrollMethod();
150 void testLoadScrollButton_data();
151 void testLoadScrollButton();
152 void testLoadDisableWhileTyping_data();
153 void testLoadDisableWhileTyping();
154 void testLoadLmrTapButtonMap_data();
155 void testLoadLmrTapButtonMap();
156 void testLoadLeftHanded_data();
157 void testLoadLeftHanded();
158 void testOrientation_data();
159 void testOrientation();
160 void testCalibrationWithDefault();
161 void testSwitch_data();
168T dbusProperty(
const QString &name,
const char *property)
170 QDBusInterface
interface {
171 QStringLiteral(
"org.kde.kwin.tests.libinputdevice"),
172 QStringLiteral(
"/org/kde/KWin/InputDevice/") + name,
173 QStringLiteral(
"org.kde.KWin.InputDevice")
175 return interface.property(property).value<T>();
179void TestLibinputDevice::initTestCase()
181 QDBusConnection::sessionBus().registerService(QStringLiteral(
"org.kde.kwin.tests.libinputdevice"));
184void TestLibinputDevice::testDeviceType_data()
186 QTest::addColumn<bool>(
"keyboard");
187 QTest::addColumn<bool>(
"pointer");
188 QTest::addColumn<bool>(
"touch");
189 QTest::addColumn<bool>(
"tabletTool");
190 QTest::addColumn<bool>(
"switchDevice");
192 QTest::newRow(
"keyboard") <<
true <<
false <<
false <<
false <<
false;
193 QTest::newRow(
"pointer") <<
false <<
true <<
false <<
false <<
false;
194 QTest::newRow(
"touch") <<
false <<
false <<
true <<
false <<
false;
195 QTest::newRow(
"keyboard/pointer") <<
true <<
true <<
false <<
false <<
false;
196 QTest::newRow(
"keyboard/touch") <<
true <<
false <<
true <<
false <<
false;
197 QTest::newRow(
"pointer/touch") <<
false <<
true <<
true <<
false <<
false;
198 QTest::newRow(
"keyboard/pointer/touch") <<
true <<
true <<
true <<
false <<
false;
199 QTest::newRow(
"tabletTool") <<
false <<
false <<
false <<
true <<
false;
200 QTest::newRow(
"switch") <<
false <<
false <<
false <<
false <<
true;
203void TestLibinputDevice::testDeviceType()
206 QFETCH(
bool, keyboard);
207 QFETCH(
bool, pointer);
209 QFETCH(
bool, tabletTool);
210 QFETCH(
bool, switchDevice);
215 device.
touch = touch;
220 QCOMPARE(d.isKeyboard(), keyboard);
221 QCOMPARE(d.property(
"keyboard").toBool(), keyboard);
222 QCOMPARE(dbusProperty<bool>(d.sysName(),
"keyboard"), keyboard);
223 QCOMPARE(d.isPointer(), pointer);
224 QCOMPARE(d.property(
"pointer").toBool(), pointer);
225 QCOMPARE(dbusProperty<bool>(d.sysName(),
"pointer"), pointer);
226 QCOMPARE(d.isTouch(), touch);
227 QCOMPARE(d.property(
"touch").toBool(), touch);
228 QCOMPARE(dbusProperty<bool>(d.sysName(),
"touch"), touch);
229 QCOMPARE(d.isTabletPad(),
false);
230 QCOMPARE(d.property(
"tabletPad").toBool(),
false);
231 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tabletPad"),
false);
232 QCOMPARE(d.isTabletTool(), tabletTool);
233 QCOMPARE(d.property(
"tabletTool").toBool(), tabletTool);
234 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tabletTool"), tabletTool);
235 QCOMPARE(d.isSwitch(), switchDevice);
236 QCOMPARE(d.property(
"switchDevice").toBool(), switchDevice);
237 QCOMPARE(dbusProperty<bool>(d.sysName(),
"switchDevice"), switchDevice);
239 QCOMPARE(d.device(), &device);
242void TestLibinputDevice::testGestureSupport_data()
244 QTest::addColumn<bool>(
"supported");
246 QTest::newRow(
"supported") <<
true;
247 QTest::newRow(
"not supported") <<
false;
250void TestLibinputDevice::testGestureSupport()
253 QFETCH(
bool, supported);
258 QCOMPARE(d.supportsGesture(), supported);
259 QCOMPARE(d.property(
"gestureSupport").toBool(), supported);
260 QCOMPARE(dbusProperty<bool>(d.sysName(),
"gestureSupport"), supported);
263void TestLibinputDevice::testNames_data()
265 QTest::addColumn<QByteArray>(
"name");
266 QTest::addColumn<QByteArray>(
"sysName");
267 QTest::addColumn<QByteArray>(
"outputName");
269 QTest::newRow(
"empty") << QByteArray() << QByteArrayLiteral(
"event1") << QByteArray();
270 QTest::newRow(
"set") << QByteArrayLiteral(
"awesome test device") << QByteArrayLiteral(
"event0") << QByteArrayLiteral(
"hdmi0");
273void TestLibinputDevice::testNames()
276 QFETCH(QByteArray, name);
277 QFETCH(QByteArray, sysName);
278 QFETCH(QByteArray, outputName);
285 QCOMPARE(d.name().toUtf8(), name);
286 QCOMPARE(d.property(
"name").toString().toUtf8(), name);
287 QCOMPARE(dbusProperty<QString>(d.sysName(),
"name"), name);
288 QCOMPARE(d.sysName().toUtf8(), sysName);
289 QCOMPARE(d.property(
"sysName").toString().toUtf8(), sysName);
290 QCOMPARE(dbusProperty<QString>(d.sysName(),
"sysName"), sysName);
291 QCOMPARE(d.outputName().toUtf8(), outputName);
292 QCOMPARE(d.property(
"outputName").toString().toUtf8(), outputName);
293 QCOMPARE(dbusProperty<QString>(d.sysName(),
"outputName"), outputName);
296void TestLibinputDevice::testProduct()
302 QCOMPARE(d.product(), 100u);
303 QCOMPARE(d.property(
"product").toUInt(), 100u);
304 QCOMPARE(dbusProperty<quint32>(d.sysName(),
"product"), 100u);
307void TestLibinputDevice::testVendor()
313 QCOMPARE(d.vendor(), 200u);
314 QCOMPARE(d.property(
"vendor").toUInt(), 200u);
315 QCOMPARE(dbusProperty<quint32>(d.sysName(),
"vendor"), 200u);
318void TestLibinputDevice::testTapFingerCount()
324 QCOMPARE(d.tapFingerCount(), 3);
325 QCOMPARE(d.property(
"tapFingerCount").toInt(), 3);
326 QCOMPARE(dbusProperty<int>(d.sysName(),
"tapFingerCount"), 3);
329void TestLibinputDevice::testSize_data()
331 QTest::addColumn<QSizeF>(
"setSize");
332 QTest::addColumn<int>(
"returnValue");
333 QTest::addColumn<QSizeF>(
"expectedSize");
335 QTest::newRow(
"10/20") << QSizeF(10.5, 20.2) << 0 << QSizeF(10.5, 20.2);
336 QTest::newRow(
"failure") << QSizeF(10, 20) << 1 << QSizeF();
339void TestLibinputDevice::testSize()
342 QFETCH(QSizeF, setSize);
343 QFETCH(
int, returnValue);
349 QTEST(d.size(),
"expectedSize");
350 QTEST(d.property(
"size").toSizeF(),
"expectedSize");
351 QTEST(dbusProperty<QSizeF>(d.sysName(),
"size"),
"expectedSize");
354void TestLibinputDevice::testLeftHandedEnabledByDefault_data()
356 QTest::addColumn<bool>(
"enabled");
358 QTest::newRow(
"enabled") <<
true;
359 QTest::newRow(
"disabled") <<
false;
362void TestLibinputDevice::testLeftHandedEnabledByDefault()
364 QFETCH(
bool, enabled);
369 QCOMPARE(d.leftHandedEnabledByDefault(), enabled);
370 QCOMPARE(d.property(
"leftHandedEnabledByDefault").toBool(), enabled);
371 QCOMPARE(dbusProperty<bool>(d.sysName(),
"leftHandedEnabledByDefault"), enabled);
374void TestLibinputDevice::testTapEnabledByDefault_data()
376 QTest::addColumn<bool>(
"enabled");
378 QTest::newRow(
"enabled") <<
true;
379 QTest::newRow(
"disabled") <<
false;
382void TestLibinputDevice::testTapEnabledByDefault()
384 QFETCH(
bool, enabled);
389 QCOMPARE(d.tapToClickEnabledByDefault(),
true);
390 QCOMPARE(d.property(
"tapToClickEnabledByDefault").toBool(),
true);
391 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapToClickEnabledByDefault"),
true);
394void TestLibinputDevice::testMiddleEmulationEnabledByDefault_data()
396 QTest::addColumn<bool>(
"enabled");
398 QTest::newRow(
"enabled") <<
true;
399 QTest::newRow(
"disabled") <<
false;
402void TestLibinputDevice::testMiddleEmulationEnabledByDefault()
404 QFETCH(
bool, enabled);
409 QCOMPARE(d.middleEmulationEnabledByDefault(), enabled);
410 QCOMPARE(d.property(
"middleEmulationEnabledByDefault").toBool(), enabled);
411 QCOMPARE(dbusProperty<bool>(d.sysName(),
"middleEmulationEnabledByDefault"), enabled);
414void TestLibinputDevice::testNaturalScrollEnabledByDefault_data()
416 QTest::addColumn<bool>(
"enabled");
418 QTest::newRow(
"enabled") <<
true;
419 QTest::newRow(
"disabled") <<
false;
422void TestLibinputDevice::testNaturalScrollEnabledByDefault()
424 QFETCH(
bool, enabled);
429 QCOMPARE(d.naturalScrollEnabledByDefault(), enabled);
430 QCOMPARE(d.property(
"naturalScrollEnabledByDefault").toBool(), enabled);
431 QCOMPARE(dbusProperty<bool>(d.sysName(),
"naturalScrollEnabledByDefault"), enabled);
434void TestLibinputDevice::testScrollTwoFingerEnabledByDefault_data()
436 QTest::addColumn<bool>(
"enabled");
438 QTest::newRow(
"enabled") <<
true;
439 QTest::newRow(
"disabled") <<
false;
442void TestLibinputDevice::testScrollTwoFingerEnabledByDefault()
444 QFETCH(
bool, enabled);
446 device.
defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
449 QCOMPARE(d.scrollTwoFingerEnabledByDefault(), enabled);
450 QCOMPARE(d.property(
"scrollTwoFingerEnabledByDefault").toBool(), enabled);
451 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollTwoFingerEnabledByDefault"), enabled);
454void TestLibinputDevice::testScrollEdgeEnabledByDefault_data()
456 QTest::addColumn<bool>(
"enabled");
458 QTest::newRow(
"enabled") <<
true;
459 QTest::newRow(
"disabled") <<
false;
462void TestLibinputDevice::testScrollEdgeEnabledByDefault()
464 QFETCH(
bool, enabled);
466 device.
defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
469 QCOMPARE(d.scrollEdgeEnabledByDefault(), enabled);
470 QCOMPARE(d.property(
"scrollEdgeEnabledByDefault").toBool(), enabled);
471 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollEdgeEnabledByDefault"), enabled);
474void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat_data()
476 QTest::addColumn<bool>(
"enabled");
478 QTest::newRow(
"enabled") <<
true;
479 QTest::newRow(
"disabled") <<
false;
482void TestLibinputDevice::testDefaultPointerAccelerationProfileFlat()
484 QFETCH(
bool, enabled);
489 QCOMPARE(d.defaultPointerAccelerationProfileFlat(), enabled);
490 QCOMPARE(d.property(
"defaultPointerAccelerationProfileFlat").toBool(), enabled);
491 QCOMPARE(dbusProperty<bool>(d.sysName(),
"defaultPointerAccelerationProfileFlat"), enabled);
494void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive_data()
496 QTest::addColumn<bool>(
"enabled");
498 QTest::newRow(
"enabled") <<
true;
499 QTest::newRow(
"disabled") <<
false;
502void TestLibinputDevice::testDefaultPointerAccelerationProfileAdaptive()
504 QFETCH(
bool, enabled);
509 QCOMPARE(d.defaultPointerAccelerationProfileAdaptive(), enabled);
510 QCOMPARE(d.property(
"defaultPointerAccelerationProfileAdaptive").toBool(), enabled);
511 QCOMPARE(dbusProperty<bool>(d.sysName(),
"defaultPointerAccelerationProfileAdaptive"), enabled);
514void TestLibinputDevice::testDefaultClickMethodAreas_data()
516 QTest::addColumn<bool>(
"enabled");
518 QTest::addRow(
"enabled") <<
true;
519 QTest::addRow(
"disabled") <<
false;
522void TestLibinputDevice::testDefaultClickMethodAreas()
524 QFETCH(
bool, enabled);
526 device.
defaultClickMethod = enabled ? LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS : LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
529 QCOMPARE(d.defaultClickMethodAreas(), enabled);
530 QCOMPARE(d.property(
"defaultClickMethodAreas").toBool(), enabled);
531 QCOMPARE(dbusProperty<bool>(d.sysName(),
"defaultClickMethodAreas"), enabled);
534void TestLibinputDevice::testDefaultClickMethodClickfinger_data()
536 QTest::addColumn<bool>(
"enabled");
538 QTest::addRow(
"enabled") <<
true;
539 QTest::addRow(
"disabled") <<
false;
542void TestLibinputDevice::testDefaultClickMethodClickfinger()
544 QFETCH(
bool, enabled);
546 device.
defaultClickMethod = enabled ? LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER : LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS;
549 QCOMPARE(d.defaultClickMethodClickfinger(), enabled);
550 QCOMPARE(d.property(
"defaultClickMethodClickfinger").toBool(), enabled);
551 QCOMPARE(dbusProperty<bool>(d.sysName(),
"defaultClickMethodClickfinger"), enabled);
554void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault_data()
556 QTest::addColumn<bool>(
"enabled");
558 QTest::newRow(
"enabled") <<
true;
559 QTest::newRow(
"disabled") <<
false;
562void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault()
564 QFETCH(
bool, enabled);
566 device.
defaultScrollMethod = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
569 QCOMPARE(d.scrollOnButtonDownEnabledByDefault(), enabled);
570 QCOMPARE(d.property(
"scrollOnButtonDownEnabledByDefault").toBool(), enabled);
571 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollOnButtonDownEnabledByDefault"), enabled);
574void TestLibinputDevice::testDefaultScrollButton_data()
576 QTest::addColumn<quint32>(
"button");
578 QTest::newRow(
"0") << 0u;
579 QTest::newRow(
"BTN_LEFT") << quint32(BTN_LEFT);
580 QTest::newRow(
"BTN_RIGHT") << quint32(BTN_RIGHT);
581 QTest::newRow(
"BTN_MIDDLE") << quint32(BTN_MIDDLE);
582 QTest::newRow(
"BTN_SIDE") << quint32(BTN_SIDE);
583 QTest::newRow(
"BTN_EXTRA") << quint32(BTN_EXTRA);
584 QTest::newRow(
"BTN_FORWARD") << quint32(BTN_FORWARD);
585 QTest::newRow(
"BTN_BACK") << quint32(BTN_BACK);
586 QTest::newRow(
"BTN_TASK") << quint32(BTN_TASK);
589void TestLibinputDevice::testDefaultScrollButton()
592 QFETCH(quint32, button);
596 QCOMPARE(d.defaultScrollButton(), button);
597 QCOMPARE(d.property(
"defaultScrollButton").value<quint32>(), button);
598 QCOMPARE(dbusProperty<quint32>(d.sysName(),
"defaultScrollButton"), button);
601void TestLibinputDevice::testSupportsDisableWhileTyping_data()
603 QTest::addColumn<bool>(
"enabled");
605 QTest::newRow(
"enabled") <<
true;
606 QTest::newRow(
"disabled") <<
false;
609void TestLibinputDevice::testSupportsDisableWhileTyping()
611 QFETCH(
bool, enabled);
616 QCOMPARE(d.supportsDisableWhileTyping(), enabled);
617 QCOMPARE(d.property(
"supportsDisableWhileTyping").toBool(), enabled);
618 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsDisableWhileTyping"), enabled);
621void TestLibinputDevice::testSupportsPointerAcceleration_data()
623 QTest::addColumn<bool>(
"enabled");
625 QTest::newRow(
"enabled") <<
true;
626 QTest::newRow(
"disabled") <<
false;
629void TestLibinputDevice::testSupportsPointerAcceleration()
631 QFETCH(
bool, enabled);
636 QCOMPARE(d.supportsPointerAcceleration(), enabled);
637 QCOMPARE(d.property(
"supportsPointerAcceleration").toBool(), enabled);
638 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsPointerAcceleration"), enabled);
641void TestLibinputDevice::testSupportsLeftHanded_data()
643 QTest::addColumn<bool>(
"enabled");
645 QTest::newRow(
"enabled") <<
true;
646 QTest::newRow(
"disabled") <<
false;
649void TestLibinputDevice::testSupportsLeftHanded()
651 QFETCH(
bool, enabled);
656 QCOMPARE(d.supportsLeftHanded(), enabled);
657 QCOMPARE(d.property(
"supportsLeftHanded").toBool(), enabled);
658 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsLeftHanded"), enabled);
661void TestLibinputDevice::testSupportsCalibrationMatrix_data()
663 QTest::addColumn<bool>(
"enabled");
665 QTest::newRow(
"enabled") <<
true;
666 QTest::newRow(
"disabled") <<
false;
669void TestLibinputDevice::testSupportsCalibrationMatrix()
671 QFETCH(
bool, enabled);
676 QCOMPARE(d.supportsCalibrationMatrix(), enabled);
677 QCOMPARE(d.property(
"supportsCalibrationMatrix").toBool(), enabled);
678 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsCalibrationMatrix"), enabled);
681void TestLibinputDevice::testSupportsDisableEvents_data()
683 QTest::addColumn<bool>(
"enabled");
685 QTest::newRow(
"enabled") <<
true;
686 QTest::newRow(
"disabled") <<
false;
689void TestLibinputDevice::testSupportsDisableEvents()
691 QFETCH(
bool, enabled);
696 QCOMPARE(d.supportsDisableEvents(), enabled);
697 QCOMPARE(d.property(
"supportsDisableEvents").toBool(), enabled);
698 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsDisableEvents"), enabled);
701void TestLibinputDevice::testSupportsDisableEventsOnExternalMouse_data()
703 QTest::addColumn<bool>(
"enabled");
705 QTest::newRow(
"enabled") <<
true;
706 QTest::newRow(
"disabled") <<
false;
709void TestLibinputDevice::testSupportsDisableEventsOnExternalMouse()
711 QFETCH(
bool, enabled);
716 QCOMPARE(d.supportsDisableEventsOnExternalMouse(), enabled);
717 QCOMPARE(d.property(
"supportsDisableEventsOnExternalMouse").toBool(), enabled);
718 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsDisableEventsOnExternalMouse"), enabled);
721void TestLibinputDevice::testSupportsMiddleEmulation_data()
723 QTest::addColumn<bool>(
"enabled");
725 QTest::newRow(
"enabled") <<
true;
726 QTest::newRow(
"disabled") <<
false;
729void TestLibinputDevice::testSupportsMiddleEmulation()
731 QFETCH(
bool, enabled);
736 QCOMPARE(d.supportsMiddleEmulation(), enabled);
737 QCOMPARE(d.property(
"supportsMiddleEmulation").toBool(), enabled);
738 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsMiddleEmulation"), enabled);
741void TestLibinputDevice::testSupportsNaturalScroll_data()
743 QTest::addColumn<bool>(
"enabled");
745 QTest::newRow(
"enabled") <<
true;
746 QTest::newRow(
"disabled") <<
false;
749void TestLibinputDevice::testSupportsNaturalScroll()
751 QFETCH(
bool, enabled);
756 QCOMPARE(d.supportsNaturalScroll(), enabled);
757 QCOMPARE(d.property(
"supportsNaturalScroll").toBool(), enabled);
758 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsNaturalScroll"), enabled);
761void TestLibinputDevice::testSupportsScrollTwoFinger_data()
763 QTest::addColumn<bool>(
"enabled");
765 QTest::newRow(
"enabled") <<
true;
766 QTest::newRow(
"disabled") <<
false;
769void TestLibinputDevice::testSupportsScrollTwoFinger()
771 QFETCH(
bool, enabled);
776 QCOMPARE(d.supportsScrollTwoFinger(), enabled);
777 QCOMPARE(d.property(
"supportsScrollTwoFinger").toBool(), enabled);
778 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsScrollTwoFinger"), enabled);
781void TestLibinputDevice::testSupportsScrollEdge_data()
783 QTest::addColumn<bool>(
"enabled");
785 QTest::newRow(
"enabled") <<
true;
786 QTest::newRow(
"disabled") <<
false;
789void TestLibinputDevice::testSupportsScrollEdge()
791 QFETCH(
bool, enabled);
796 QCOMPARE(d.supportsScrollEdge(), enabled);
797 QCOMPARE(d.property(
"supportsScrollEdge").toBool(), enabled);
798 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsScrollEdge"), enabled);
801void TestLibinputDevice::testSupportsScrollOnButtonDown_data()
803 QTest::addColumn<bool>(
"enabled");
805 QTest::newRow(
"enabled") <<
true;
806 QTest::newRow(
"disabled") <<
false;
809void TestLibinputDevice::testSupportsScrollOnButtonDown()
811 QFETCH(
bool, enabled);
813 device.
supportedScrollMethods = enabled ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
816 QCOMPARE(d.supportsScrollOnButtonDown(), enabled);
817 QCOMPARE(d.property(
"supportsScrollOnButtonDown").toBool(), enabled);
818 QCOMPARE(dbusProperty<bool>(d.sysName(),
"supportsScrollOnButtonDown"), enabled);
821void TestLibinputDevice::testDefaultPointerAcceleration_data()
823 QTest::addColumn<qreal>(
"accel");
825 QTest::newRow(
"-1.0") << -1.0;
826 QTest::newRow(
"-0.5") << -0.5;
827 QTest::newRow(
"0.0") << 0.0;
828 QTest::newRow(
"0.3") << 0.3;
829 QTest::newRow(
"1.0") << 1.0;
832void TestLibinputDevice::testDefaultPointerAcceleration()
834 QFETCH(qreal, accel);
839 QCOMPARE(d.defaultPointerAcceleration(), accel);
840 QCOMPARE(d.property(
"defaultPointerAcceleration").toReal(), accel);
841 QCOMPARE(dbusProperty<qreal>(d.sysName(),
"defaultPointerAcceleration"), accel);
844void TestLibinputDevice::testPointerAcceleration_data()
846 QTest::addColumn<bool>(
"supported");
847 QTest::addColumn<bool>(
"setShouldFail");
848 QTest::addColumn<qreal>(
"accel");
849 QTest::addColumn<qreal>(
"setAccel");
850 QTest::addColumn<qreal>(
"expectedAccel");
851 QTest::addColumn<bool>(
"expectedChanged");
853 QTest::newRow(
"-1 -> 2.0") <<
true <<
false << -1.0 << 2.0 << 1.0 <<
true;
854 QTest::newRow(
"0 -> -1.0") <<
true <<
false << 0.0 << -1.0 << -1.0 <<
true;
855 QTest::newRow(
"1 -> 1") <<
true <<
false << 1.0 << 1.0 << 1.0 <<
false;
856 QTest::newRow(
"unsupported") <<
false <<
false << 0.0 << 1.0 << 0.0 <<
false;
857 QTest::newRow(
"set fails") <<
true <<
true << -1.0 << 1.0 << -1.0 <<
false;
860void TestLibinputDevice::testPointerAcceleration()
862 QFETCH(
bool, supported);
863 QFETCH(
bool, setShouldFail);
864 QFETCH(qreal, accel);
871 QCOMPARE(d.pointerAcceleration(), accel);
872 QCOMPARE(d.property(
"pointerAcceleration").toReal(), accel);
873 QCOMPARE(dbusProperty<qreal>(d.sysName(),
"pointerAcceleration"), accel);
876 QFETCH(qreal, setAccel);
877 d.setPointerAcceleration(setAccel);
878 QTEST(d.pointerAcceleration(),
"expectedAccel");
879 QTEST(!pointerAccelChangedSpy.isEmpty(),
"expectedChanged");
880 QTEST(dbusProperty<qreal>(d.sysName(),
"pointerAcceleration"),
"expectedAccel");
883void TestLibinputDevice::testLeftHanded_data()
885 QTest::addColumn<bool>(
"supported");
886 QTest::addColumn<bool>(
"setShouldFail");
887 QTest::addColumn<bool>(
"initValue");
888 QTest::addColumn<bool>(
"setValue");
889 QTest::addColumn<bool>(
"expectedValue");
891 QTest::newRow(
"unsupported/true") <<
false <<
false <<
true <<
false <<
false;
892 QTest::newRow(
"unsupported/false") <<
false <<
false <<
false <<
true <<
false;
893 QTest::newRow(
"true -> false") <<
true <<
false <<
true <<
false <<
false;
894 QTest::newRow(
"false -> true") <<
true <<
false <<
false <<
true <<
true;
895 QTest::newRow(
"set fails") <<
true <<
true <<
true <<
false <<
true;
896 QTest::newRow(
"true -> true") <<
true <<
false <<
true <<
true <<
true;
897 QTest::newRow(
"false -> false") <<
true <<
false <<
false <<
false <<
false;
900void TestLibinputDevice::testLeftHanded()
902 QFETCH(
bool, supported);
903 QFETCH(
bool, setShouldFail);
904 QFETCH(
bool, initValue);
911 QCOMPARE(d.isLeftHanded(), supported && initValue);
912 QCOMPARE(d.property(
"leftHanded").toBool(), supported && initValue);
913 QCOMPARE(dbusProperty<bool>(d.sysName(),
"leftHanded"), supported && initValue);
916 QFETCH(
bool, setValue);
917 d.setLeftHanded(setValue);
918 QFETCH(
bool, expectedValue);
919 QCOMPARE(d.isLeftHanded(), expectedValue);
920 QCOMPARE(leftHandedChangedSpy.isEmpty(), (supported && initValue) == expectedValue);
921 QCOMPARE(dbusProperty<bool>(d.sysName(),
"leftHanded"), expectedValue);
924void TestLibinputDevice::testSupportedButtons_data()
926 QTest::addColumn<bool>(
"isPointer");
927 QTest::addColumn<Qt::MouseButtons>(
"setButtons");
928 QTest::addColumn<Qt::MouseButtons>(
"expectedButtons");
930 QTest::newRow(
"left") <<
true << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons(Qt::LeftButton);
931 QTest::newRow(
"right") <<
true << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons(Qt::RightButton);
932 QTest::newRow(
"middle") <<
true << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons(Qt::MiddleButton);
933 QTest::newRow(
"extra1") <<
true << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons(Qt::ExtraButton1);
934 QTest::newRow(
"extra2") <<
true << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons(Qt::ExtraButton2);
935 QTest::newRow(
"back") <<
true << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons(Qt::BackButton);
936 QTest::newRow(
"forward") <<
true << Qt::MouseButtons(Qt::ForwardButton) << Qt::MouseButtons(Qt::ForwardButton);
937 QTest::newRow(
"task") <<
true << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons(Qt::TaskButton);
939 QTest::newRow(
"no pointer/left") <<
false << Qt::MouseButtons(Qt::LeftButton) << Qt::MouseButtons();
940 QTest::newRow(
"no pointer/right") <<
false << Qt::MouseButtons(Qt::RightButton) << Qt::MouseButtons();
941 QTest::newRow(
"no pointer/middle") <<
false << Qt::MouseButtons(Qt::MiddleButton) << Qt::MouseButtons();
942 QTest::newRow(
"no pointer/extra1") <<
false << Qt::MouseButtons(Qt::ExtraButton1) << Qt::MouseButtons();
943 QTest::newRow(
"no pointer/extra2") <<
false << Qt::MouseButtons(Qt::ExtraButton2) << Qt::MouseButtons();
944 QTest::newRow(
"no pointer/back") <<
false << Qt::MouseButtons(Qt::BackButton) << Qt::MouseButtons();
945 QTest::newRow(
"no pointer/forward") <<
false << Qt::MouseButtons(Qt::ForwardButton) << Qt::MouseButtons();
946 QTest::newRow(
"no pointer/task") <<
false << Qt::MouseButtons(Qt::TaskButton) << Qt::MouseButtons();
948 QTest::newRow(
"all") <<
true
949 << Qt::MouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton | Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::BackButton | Qt::ForwardButton | Qt::TaskButton)
950 << Qt::MouseButtons(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton | Qt::ExtraButton1 | Qt::ExtraButton2 | Qt::BackButton | Qt::ForwardButton | Qt::TaskButton);
953void TestLibinputDevice::testSupportedButtons()
956 QFETCH(
bool, isPointer);
958 QFETCH(Qt::MouseButtons, setButtons);
962 QCOMPARE(d.isPointer(), isPointer);
963 QTEST(d.supportedButtons(),
"expectedButtons");
964 QTEST(Qt::MouseButtons(dbusProperty<int>(d.sysName(),
"supportedButtons")),
"expectedButtons");
967void TestLibinputDevice::testAlphaNumericKeyboard_data()
969 QTest::addColumn<QList<quint32>>(
"supportedKeys");
970 QTest::addColumn<bool>(
"isAlpha");
974 for (
int i = KEY_1; i <= KEY_0; i++) {
976 QByteArray row = QByteArrayLiteral(
"number");
977 row.append(QByteArray::number(i));
978 QTest::newRow(row.constData()) << keys <<
false;
980 for (
int i = KEY_Q; i <= KEY_P; i++) {
982 QByteArray row = QByteArrayLiteral(
"alpha");
983 row.append(QByteArray::number(i));
984 QTest::newRow(row.constData()) << keys <<
false;
986 for (
int i = KEY_A; i <= KEY_L; i++) {
988 QByteArray row = QByteArrayLiteral(
"alpha");
989 row.append(QByteArray::number(i));
990 QTest::newRow(row.constData()) << keys <<
false;
992 for (
int i = KEY_Z; i < KEY_M; i++) {
994 QByteArray row = QByteArrayLiteral(
"alpha");
995 row.append(QByteArray::number(i));
996 QTest::newRow(row.constData()) << keys <<
false;
999 keys << KEY_SEMICOLON;
1000 QTest::newRow(
"semicolon") << keys <<
false;
1004 QTest::newRow(
"alphanumeric") << keys <<
true;
1007void TestLibinputDevice::testAlphaNumericKeyboard()
1009 QFETCH(QList<quint32>, supportedKeys);
1012 device.
keys = supportedKeys;
1015 QCOMPARE(d.isKeyboard(),
true);
1016 QTEST(d.isAlphaNumericKeyboard(),
"isAlpha");
1017 QTEST(dbusProperty<bool>(d.sysName(),
"alphaNumericKeyboard"),
"isAlpha");
1020void TestLibinputDevice::testEnabled_data()
1022 QTest::addColumn<bool>(
"supported");
1023 QTest::addColumn<bool>(
"setShouldFail");
1024 QTest::addColumn<bool>(
"initValue");
1025 QTest::addColumn<bool>(
"setValue");
1026 QTest::addColumn<bool>(
"expectedValue");
1028 QTest::newRow(
"unsupported/true") <<
false <<
false <<
true <<
false <<
true;
1029 QTest::newRow(
"unsupported/false") <<
false <<
false <<
false <<
true <<
true;
1030 QTest::newRow(
"true -> false") <<
true <<
false <<
true <<
false <<
false;
1031 QTest::newRow(
"false -> true") <<
true <<
false <<
false <<
true <<
true;
1032 QTest::newRow(
"set fails") <<
true <<
true <<
true <<
false <<
true;
1033 QTest::newRow(
"true -> true") <<
true <<
false <<
true <<
true <<
true;
1034 QTest::newRow(
"false -> false") <<
true <<
false <<
false <<
false <<
false;
1037void TestLibinputDevice::testEnabled()
1040 QFETCH(
bool, supported);
1041 QFETCH(
bool, setShouldFail);
1042 QFETCH(
bool, initValue);
1048 QCOMPARE(d.isEnabled(), !supported || initValue);
1049 QCOMPARE(d.property(
"enabled").toBool(), !supported || initValue);
1050 QCOMPARE(dbusProperty<bool>(d.sysName(),
"enabled"), !supported || initValue);
1053 QFETCH(
bool, setValue);
1054 d.setEnabled(setValue);
1055 QFETCH(
bool, expectedValue);
1056 QCOMPARE(d.isEnabled(), expectedValue);
1058 QCOMPARE(dbusProperty<bool>(d.sysName(),
"enabled"), expectedValue);
1061void TestLibinputDevice::testTapToClick_data()
1063 QTest::addColumn<int>(
"fingerCount");
1064 QTest::addColumn<bool>(
"initValue");
1065 QTest::addColumn<bool>(
"setValue");
1066 QTest::addColumn<bool>(
"setShouldFail");
1067 QTest::addColumn<bool>(
"expectedValue");
1069 QTest::newRow(
"unsupported") << 0 <<
false <<
true <<
true <<
false;
1070 QTest::newRow(
"true -> false") << 1 <<
true <<
false <<
false <<
false;
1071 QTest::newRow(
"false -> true") << 2 <<
false <<
true <<
false <<
true;
1072 QTest::newRow(
"set fails") << 3 <<
true <<
false <<
true <<
true;
1073 QTest::newRow(
"true -> true") << 2 <<
true <<
true <<
false <<
true;
1074 QTest::newRow(
"false -> false") << 1 <<
false <<
false <<
false <<
false;
1077void TestLibinputDevice::testTapToClick()
1080 QFETCH(
int, fingerCount);
1081 QFETCH(
bool, initValue);
1082 QFETCH(
bool, setShouldFail);
1088 QCOMPARE(d.tapFingerCount(), fingerCount);
1089 QCOMPARE(d.isTapToClick(), initValue);
1090 QCOMPARE(d.property(
"tapToClick").toBool(), initValue);
1091 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapToClick"), initValue);
1094 QFETCH(
bool, setValue);
1095 d.setTapToClick(setValue);
1096 QFETCH(
bool, expectedValue);
1097 QCOMPARE(d.isTapToClick(), expectedValue);
1098 QCOMPARE(tapToClickChangedSpy.isEmpty(), initValue == expectedValue);
1099 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapToClick"), expectedValue);
1102void TestLibinputDevice::testTapAndDragEnabledByDefault_data()
1104 QTest::addColumn<bool>(
"enabled");
1106 QTest::newRow(
"enabled") <<
true;
1107 QTest::newRow(
"disabled") <<
false;
1110void TestLibinputDevice::testTapAndDragEnabledByDefault()
1112 QFETCH(
bool, enabled);
1117 QCOMPARE(d.tapAndDragEnabledByDefault(),
true);
1118 QCOMPARE(d.property(
"tapAndDragEnabledByDefault").toBool(),
true);
1119 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapAndDragEnabledByDefault"),
true);
1122void TestLibinputDevice::testTapAndDrag_data()
1124 QTest::addColumn<bool>(
"initValue");
1125 QTest::addColumn<bool>(
"setValue");
1126 QTest::addColumn<bool>(
"setShouldFail");
1127 QTest::addColumn<bool>(
"expectedValue");
1129 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false;
1130 QTest::newRow(
"false -> true") <<
false <<
true <<
false <<
true;
1131 QTest::newRow(
"set fails") <<
true <<
false <<
true <<
true;
1132 QTest::newRow(
"true -> true") <<
true <<
true <<
false <<
true;
1133 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false;
1136void TestLibinputDevice::testTapAndDrag()
1139 QFETCH(
bool, initValue);
1140 QFETCH(
bool, setShouldFail);
1145 QCOMPARE(d.isTapAndDrag(), initValue);
1146 QCOMPARE(d.property(
"tapAndDrag").toBool(), initValue);
1147 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapAndDrag"), initValue);
1150 QFETCH(
bool, setValue);
1151 d.setTapAndDrag(setValue);
1152 QFETCH(
bool, expectedValue);
1153 QCOMPARE(d.isTapAndDrag(), expectedValue);
1154 QCOMPARE(tapAndDragChangedSpy.isEmpty(), initValue == expectedValue);
1155 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapAndDrag"), expectedValue);
1158void TestLibinputDevice::testTapDragLockEnabledByDefault_data()
1160 QTest::addColumn<bool>(
"enabled");
1162 QTest::newRow(
"enabled") <<
true;
1163 QTest::newRow(
"disabled") <<
false;
1166void TestLibinputDevice::testTapDragLockEnabledByDefault()
1168 QFETCH(
bool, enabled);
1173 QCOMPARE(d.tapDragLockEnabledByDefault(), enabled);
1174 QCOMPARE(d.property(
"tapDragLockEnabledByDefault").toBool(), enabled);
1175 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapDragLockEnabledByDefault"), enabled);
1178void TestLibinputDevice::testTapDragLock_data()
1180 QTest::addColumn<bool>(
"initValue");
1181 QTest::addColumn<bool>(
"setValue");
1182 QTest::addColumn<bool>(
"setShouldFail");
1183 QTest::addColumn<bool>(
"expectedValue");
1185 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false;
1186 QTest::newRow(
"false -> true") <<
false <<
true <<
false <<
true;
1187 QTest::newRow(
"set fails") <<
true <<
false <<
true <<
true;
1188 QTest::newRow(
"true -> true") <<
true <<
true <<
false <<
true;
1189 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false;
1192void TestLibinputDevice::testTapDragLock()
1195 QFETCH(
bool, initValue);
1196 QFETCH(
bool, setShouldFail);
1201 QCOMPARE(d.isTapDragLock(), initValue);
1202 QCOMPARE(d.property(
"tapDragLock").toBool(), initValue);
1203 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapDragLock"), initValue);
1206 QFETCH(
bool, setValue);
1207 d.setTapDragLock(setValue);
1208 QFETCH(
bool, expectedValue);
1209 QCOMPARE(d.isTapDragLock(), expectedValue);
1210 QCOMPARE(tapDragLockChangedSpy.isEmpty(), initValue == expectedValue);
1211 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tapDragLock"), expectedValue);
1214void TestLibinputDevice::testMiddleEmulation_data()
1216 QTest::addColumn<bool>(
"initValue");
1217 QTest::addColumn<bool>(
"setValue");
1218 QTest::addColumn<bool>(
"setShouldFail");
1219 QTest::addColumn<bool>(
"expectedValue");
1220 QTest::addColumn<bool>(
"supportsMiddleButton");
1222 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false <<
true;
1223 QTest::newRow(
"false -> true") <<
false <<
true <<
false <<
true <<
true;
1224 QTest::newRow(
"set fails") <<
true <<
false <<
true <<
true <<
true;
1225 QTest::newRow(
"true -> true") <<
true <<
true <<
false <<
true <<
true;
1226 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false <<
true;
1228 QTest::newRow(
"false -> true, unsupported") <<
false <<
true <<
true <<
false <<
false;
1231void TestLibinputDevice::testMiddleEmulation()
1234 QFETCH(
bool, initValue);
1235 QFETCH(
bool, setShouldFail);
1236 QFETCH(
bool, supportsMiddleButton);
1242 QCOMPARE(d.isMiddleEmulation(), initValue);
1243 QCOMPARE(d.property(
"middleEmulation").toBool(), initValue);
1244 QCOMPARE(dbusProperty<bool>(d.sysName(),
"middleEmulation"), initValue);
1247 QFETCH(
bool, setValue);
1248 d.setMiddleEmulation(setValue);
1249 QFETCH(
bool, expectedValue);
1250 QCOMPARE(d.isMiddleEmulation(), expectedValue);
1251 QCOMPARE(d.property(
"middleEmulation").toBool(), expectedValue);
1252 QCOMPARE(middleEmulationChangedSpy.isEmpty(), initValue == expectedValue);
1253 QCOMPARE(dbusProperty<bool>(d.sysName(),
"middleEmulation"), expectedValue);
1256void TestLibinputDevice::testNaturalScroll_data()
1258 QTest::addColumn<bool>(
"initValue");
1259 QTest::addColumn<bool>(
"setValue");
1260 QTest::addColumn<bool>(
"setShouldFail");
1261 QTest::addColumn<bool>(
"expectedValue");
1262 QTest::addColumn<bool>(
"supportsNaturalScroll");
1264 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false <<
true;
1265 QTest::newRow(
"false -> true") <<
false <<
true <<
false <<
true <<
true;
1266 QTest::newRow(
"set fails") <<
true <<
false <<
true <<
true <<
true;
1267 QTest::newRow(
"true -> true") <<
true <<
true <<
false <<
true <<
true;
1268 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false <<
true;
1270 QTest::newRow(
"false -> true, unsupported") <<
false <<
true <<
true <<
false <<
false;
1273void TestLibinputDevice::testNaturalScroll()
1276 QFETCH(
bool, initValue);
1277 QFETCH(
bool, setShouldFail);
1278 QFETCH(
bool, supportsNaturalScroll);
1284 QCOMPARE(d.isNaturalScroll(), initValue);
1285 QCOMPARE(d.property(
"naturalScroll").toBool(), initValue);
1286 QCOMPARE(dbusProperty<bool>(d.sysName(),
"naturalScroll"), initValue);
1289 QFETCH(
bool, setValue);
1290 d.setNaturalScroll(setValue);
1291 QFETCH(
bool, expectedValue);
1292 QCOMPARE(d.isNaturalScroll(), expectedValue);
1293 QCOMPARE(d.property(
"naturalScroll").toBool(), expectedValue);
1294 QCOMPARE(naturalScrollChangedSpy.isEmpty(), initValue == expectedValue);
1295 QCOMPARE(dbusProperty<bool>(d.sysName(),
"naturalScroll"), expectedValue);
1298void TestLibinputDevice::testScrollFactor()
1302 qreal initValue = 1.0;
1305 QCOMPARE(d.scrollFactor(), initValue);
1306 QCOMPARE(d.property(
"scrollFactor").toReal(), initValue);
1307 QCOMPARE(dbusProperty<qreal>(d.sysName(),
"scrollFactor"), initValue);
1311 qreal expectedValue = 2.0;
1313 d.setScrollFactor(expectedValue);
1314 QCOMPARE(d.scrollFactor(), expectedValue);
1315 QCOMPARE(d.property(
"scrollFactor").toReal(), expectedValue);
1316 QCOMPARE(scrollFactorChangedSpy.isEmpty(),
false);
1317 QCOMPARE(dbusProperty<qreal>(d.sysName(),
"scrollFactor"), expectedValue);
1320void TestLibinputDevice::testScrollTwoFinger_data()
1322 QTest::addColumn<bool>(
"initValue");
1323 QTest::addColumn<bool>(
"otherValue");
1324 QTest::addColumn<bool>(
"setValue");
1325 QTest::addColumn<bool>(
"setShouldFail");
1326 QTest::addColumn<bool>(
"expectedValue");
1327 QTest::addColumn<bool>(
"supportsScrollTwoFinger");
1329 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false <<
false <<
true;
1330 QTest::newRow(
"other -> false") <<
false <<
true <<
false <<
false <<
false <<
true;
1331 QTest::newRow(
"false -> true") <<
false <<
false <<
true <<
false <<
true <<
true;
1332 QTest::newRow(
"set fails") <<
true <<
false <<
false <<
true <<
true <<
true;
1333 QTest::newRow(
"true -> true") <<
true <<
false <<
true <<
false <<
true <<
true;
1334 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false <<
false <<
true;
1336 QTest::newRow(
"false -> true, unsupported") <<
false <<
false <<
true <<
true <<
false <<
false;
1339void TestLibinputDevice::testScrollTwoFinger()
1342 QFETCH(
bool, initValue);
1343 QFETCH(
bool, otherValue);
1344 QFETCH(
bool, setShouldFail);
1345 QFETCH(
bool, supportsScrollTwoFinger);
1346 device.
supportedScrollMethods = (supportsScrollTwoFinger ? LIBINPUT_CONFIG_SCROLL_2FG : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_EDGE;
1347 device.
scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_2FG : otherValue ? LIBINPUT_CONFIG_SCROLL_EDGE
1348 : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
1352 QCOMPARE(d.isScrollTwoFinger(), initValue);
1353 QCOMPARE(d.property(
"scrollTwoFinger").toBool(), initValue);
1354 QCOMPARE(d.property(
"scrollEdge").toBool(), otherValue);
1355 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollTwoFinger"), initValue);
1356 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollEdge"), otherValue);
1359 QFETCH(
bool, setValue);
1360 d.setScrollTwoFinger(setValue);
1361 QFETCH(
bool, expectedValue);
1362 QCOMPARE(d.isScrollTwoFinger(), expectedValue);
1363 QCOMPARE(d.property(
"scrollTwoFinger").toBool(), expectedValue);
1364 QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue);
1365 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollTwoFinger"), expectedValue);
1368void TestLibinputDevice::testScrollEdge_data()
1370 QTest::addColumn<bool>(
"initValue");
1371 QTest::addColumn<bool>(
"otherValue");
1372 QTest::addColumn<bool>(
"setValue");
1373 QTest::addColumn<bool>(
"setShouldFail");
1374 QTest::addColumn<bool>(
"expectedValue");
1375 QTest::addColumn<bool>(
"supportsScrollEdge");
1377 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false <<
false <<
true;
1378 QTest::newRow(
"other -> false") <<
false <<
true <<
false <<
false <<
false <<
true;
1379 QTest::newRow(
"false -> true") <<
false <<
false <<
true <<
false <<
true <<
true;
1380 QTest::newRow(
"set fails") <<
true <<
false <<
false <<
true <<
true <<
true;
1381 QTest::newRow(
"true -> true") <<
true <<
false <<
true <<
false <<
true <<
true;
1382 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false <<
false <<
true;
1384 QTest::newRow(
"false -> true, unsupported") <<
false <<
false <<
true <<
true <<
false <<
false;
1387void TestLibinputDevice::testScrollEdge()
1390 QFETCH(
bool, initValue);
1391 QFETCH(
bool, otherValue);
1392 QFETCH(
bool, setShouldFail);
1393 QFETCH(
bool, supportsScrollEdge);
1394 device.
supportedScrollMethods = (supportsScrollEdge ? LIBINPUT_CONFIG_SCROLL_EDGE : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG;
1395 device.
scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_EDGE : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG
1396 : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
1400 QCOMPARE(d.isScrollEdge(), initValue);
1401 QCOMPARE(d.property(
"scrollEdge").toBool(), initValue);
1402 QCOMPARE(d.property(
"scrollTwoFinger").toBool(), otherValue);
1403 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollEdge"), initValue);
1404 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollTwoFinger"), otherValue);
1407 QFETCH(
bool, setValue);
1408 d.setScrollEdge(setValue);
1409 QFETCH(
bool, expectedValue);
1410 QCOMPARE(d.isScrollEdge(), expectedValue);
1411 QCOMPARE(d.property(
"scrollEdge").toBool(), expectedValue);
1412 QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue);
1413 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollEdge"), expectedValue);
1416void TestLibinputDevice::testScrollButtonDown_data()
1418 QTest::addColumn<bool>(
"initValue");
1419 QTest::addColumn<bool>(
"otherValue");
1420 QTest::addColumn<bool>(
"setValue");
1421 QTest::addColumn<bool>(
"setShouldFail");
1422 QTest::addColumn<bool>(
"expectedValue");
1423 QTest::addColumn<bool>(
"supportsScrollButtonDown");
1425 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false <<
false <<
true;
1426 QTest::newRow(
"other -> false") <<
false <<
true <<
false <<
false <<
false <<
true;
1427 QTest::newRow(
"false -> true") <<
false <<
false <<
true <<
false <<
true <<
true;
1428 QTest::newRow(
"set fails") <<
true <<
false <<
false <<
true <<
true <<
true;
1429 QTest::newRow(
"true -> true") <<
true <<
false <<
true <<
false <<
true <<
true;
1430 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false <<
false <<
true;
1432 QTest::newRow(
"false -> true, unsupported") <<
false <<
false <<
true <<
true <<
false <<
false;
1435void TestLibinputDevice::testScrollButtonDown()
1438 QFETCH(
bool, initValue);
1439 QFETCH(
bool, otherValue);
1440 QFETCH(
bool, setShouldFail);
1441 QFETCH(
bool, supportsScrollButtonDown);
1442 device.
supportedScrollMethods = (supportsScrollButtonDown ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL) | LIBINPUT_CONFIG_SCROLL_2FG;
1443 device.
scrollMethod = initValue ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : otherValue ? LIBINPUT_CONFIG_SCROLL_2FG
1444 : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
1448 QCOMPARE(d.isScrollOnButtonDown(), initValue);
1449 QCOMPARE(d.property(
"scrollOnButtonDown").toBool(), initValue);
1450 QCOMPARE(d.property(
"scrollTwoFinger").toBool(), otherValue);
1451 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollOnButtonDown"), initValue);
1452 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollTwoFinger"), otherValue);
1455 QFETCH(
bool, setValue);
1456 d.setScrollOnButtonDown(setValue);
1457 QFETCH(
bool, expectedValue);
1458 QCOMPARE(d.isScrollOnButtonDown(), expectedValue);
1459 QCOMPARE(d.property(
"scrollOnButtonDown").toBool(), expectedValue);
1460 QCOMPARE(scrollMethodChangedSpy.isEmpty(), initValue == expectedValue);
1461 QCOMPARE(dbusProperty<bool>(d.sysName(),
"scrollOnButtonDown"), expectedValue);
1464void TestLibinputDevice::testScrollButton_data()
1466 QTest::addColumn<quint32>(
"initValue");
1467 QTest::addColumn<quint32>(
"setValue");
1468 QTest::addColumn<quint32>(
"expectedValue");
1469 QTest::addColumn<bool>(
"setShouldFail");
1470 QTest::addColumn<bool>(
"scrollOnButton");
1472 QTest::newRow(
"BTN_LEFT -> BTN_RIGHT") << quint32(BTN_LEFT) << quint32(BTN_RIGHT) << quint32(BTN_RIGHT) <<
false <<
true;
1473 QTest::newRow(
"BTN_LEFT -> BTN_LEFT") << quint32(BTN_LEFT) << quint32(BTN_LEFT) << quint32(BTN_LEFT) <<
false <<
true;
1474 QTest::newRow(
"set should fail") << quint32(BTN_LEFT) << quint32(BTN_RIGHT) << quint32(BTN_LEFT) <<
true <<
true;
1475 QTest::newRow(
"not scroll on button") << quint32(BTN_LEFT) << quint32(BTN_RIGHT) << quint32(BTN_LEFT) <<
false <<
false;
1478void TestLibinputDevice::testScrollButton()
1481 QFETCH(quint32, initValue);
1482 QFETCH(
bool, setShouldFail);
1483 QFETCH(
bool, scrollOnButton);
1485 device.
supportedScrollMethods = scrollOnButton ? LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN : LIBINPUT_CONFIG_SCROLL_NO_SCROLL;
1489 QCOMPARE(d.scrollButton(), initValue);
1490 QCOMPARE(d.property(
"scrollButton").value<quint32>(), initValue);
1491 QCOMPARE(dbusProperty<quint32>(d.sysName(),
"scrollButton"), initValue);
1494 QFETCH(quint32, setValue);
1495 d.setScrollButton(setValue);
1496 QFETCH(quint32, expectedValue);
1497 QCOMPARE(d.scrollButton(), expectedValue);
1498 QCOMPARE(d.property(
"scrollButton").value<quint32>(), expectedValue);
1499 QCOMPARE(scrollButtonChangedSpy.isEmpty(), initValue == expectedValue);
1500 QCOMPARE(dbusProperty<quint32>(d.sysName(),
"scrollButton"), expectedValue);
1503void TestLibinputDevice::testDisableWhileTypingEnabledByDefault_data()
1505 QTest::addColumn<bool>(
"enabled");
1507 QTest::newRow(
"enabled") <<
true;
1508 QTest::newRow(
"disabled") <<
false;
1511void TestLibinputDevice::testDisableWhileTypingEnabledByDefault()
1513 QFETCH(
bool, enabled);
1518 QCOMPARE(d.disableWhileTypingEnabledByDefault(), enabled);
1519 QCOMPARE(d.property(
"disableWhileTypingEnabledByDefault").toBool(), enabled);
1520 QCOMPARE(dbusProperty<bool>(d.sysName(),
"disableWhileTypingEnabledByDefault"), enabled);
1523void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault_data()
1525 QTest::addColumn<bool>(
"enabled");
1527 QTest::newRow(
"enabled") <<
true;
1528 QTest::newRow(
"disabled") <<
false;
1531void TestLibinputDevice::testLmrTapButtonMapEnabledByDefault()
1533 QFETCH(
bool, enabled);
1535 device.
defaultTapButtonMap = enabled ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM;
1538 QCOMPARE(d.lmrTapButtonMapEnabledByDefault(), enabled);
1539 QCOMPARE(d.property(
"lmrTapButtonMapEnabledByDefault").toBool(), enabled);
1540 QCOMPARE(dbusProperty<bool>(d.sysName(),
"lmrTapButtonMapEnabledByDefault"), enabled);
1543void TestLibinputDevice::testLmrTapButtonMap_data()
1545 QTest::addColumn<bool>(
"initValue");
1546 QTest::addColumn<bool>(
"setValue");
1547 QTest::addColumn<bool>(
"setShouldFail");
1548 QTest::addColumn<bool>(
"expectedValue");
1549 QTest::addColumn<int>(
"fingerCount");
1551 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false << 3;
1552 QTest::newRow(
"false -> true") <<
false <<
true <<
false <<
true << 3;
1553 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false << 2;
1554 QTest::newRow(
"false -> true") <<
false <<
true <<
false <<
true << 2;
1556 QTest::newRow(
"set fails") <<
true <<
false <<
true <<
true << 3;
1558 QTest::newRow(
"true -> true") <<
true <<
true <<
false <<
true << 3;
1559 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false << 3;
1560 QTest::newRow(
"true -> true") <<
true <<
true <<
false <<
true << 2;
1561 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false << 2;
1563 QTest::newRow(
"false -> true, fingerCount 0") <<
false <<
true <<
true <<
false << 0;
1569void TestLibinputDevice::testLmrTapButtonMap()
1572 QFETCH(
bool, initValue);
1573 QFETCH(
bool, setShouldFail);
1574 QFETCH(
int, fingerCount);
1576 device.
tapButtonMap = initValue ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM;
1580 QCOMPARE(d.lmrTapButtonMap(), initValue);
1581 QCOMPARE(d.property(
"lmrTapButtonMap").toBool(), initValue);
1584 QFETCH(
bool, setValue);
1585 d.setLmrTapButtonMap(setValue);
1586 QFETCH(
bool, expectedValue);
1587 QCOMPARE(d.lmrTapButtonMap(), expectedValue);
1588 QCOMPARE(d.property(
"lmrTapButtonMap").toBool(), expectedValue);
1589 QCOMPARE(tapButtonMapChangedSpy.isEmpty(), initValue == expectedValue);
1592void TestLibinputDevice::testDisableWhileTyping_data()
1594 QTest::addColumn<bool>(
"initValue");
1595 QTest::addColumn<bool>(
"setValue");
1596 QTest::addColumn<bool>(
"setShouldFail");
1597 QTest::addColumn<bool>(
"expectedValue");
1598 QTest::addColumn<bool>(
"supportsDisableWhileTyping");
1600 QTest::newRow(
"true -> false") <<
true <<
false <<
false <<
false <<
true;
1601 QTest::newRow(
"false -> true") <<
false <<
true <<
false <<
true <<
true;
1602 QTest::newRow(
"set fails") <<
true <<
false <<
true <<
true <<
true;
1603 QTest::newRow(
"true -> true") <<
true <<
true <<
false <<
true <<
true;
1604 QTest::newRow(
"false -> false") <<
false <<
false <<
false <<
false <<
true;
1606 QTest::newRow(
"false -> true, unsupported") <<
false <<
true <<
true <<
false <<
false;
1609void TestLibinputDevice::testDisableWhileTyping()
1612 QFETCH(
bool, initValue);
1613 QFETCH(
bool, setShouldFail);
1614 QFETCH(
bool, supportsDisableWhileTyping);
1616 device.
disableWhileTyping = initValue ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED;
1620 QCOMPARE(d.isDisableWhileTyping(), initValue);
1621 QCOMPARE(d.property(
"disableWhileTyping").toBool(), initValue);
1622 QCOMPARE(dbusProperty<bool>(d.sysName(),
"disableWhileTyping"), initValue);
1625 QFETCH(
bool, setValue);
1626 d.setDisableWhileTyping(setValue);
1627 QFETCH(
bool, expectedValue);
1628 QCOMPARE(d.isDisableWhileTyping(), expectedValue);
1629 QCOMPARE(d.property(
"disableWhileTyping").toBool(), expectedValue);
1630 QCOMPARE(disableWhileTypingChangedSpy.isEmpty(), initValue == expectedValue);
1631 QCOMPARE(dbusProperty<bool>(d.sysName(),
"disableWhileTyping"), expectedValue);
1634void TestLibinputDevice::testLoadEnabled_data()
1636 QTest::addColumn<bool>(
"initValue");
1637 QTest::addColumn<bool>(
"configValue");
1639 QTest::newRow(
"false -> true") <<
false <<
true;
1640 QTest::newRow(
"true -> false") <<
true <<
false;
1641 QTest::newRow(
"true -> true") <<
true <<
true;
1642 QTest::newRow(
"false -> false") <<
false <<
false;
1645void TestLibinputDevice::testLoadEnabled()
1647 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1648 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1649 QFETCH(
bool, configValue);
1650 QFETCH(
bool, initValue);
1651 inputConfig.writeEntry(
"Enabled", configValue);
1659 QCOMPARE(d.isEnabled(), initValue);
1661 d.loadConfiguration();
1662 QCOMPARE(d.isEnabled(), initValue);
1665 d.setConfig(inputConfig);
1666 d.loadConfiguration();
1667 QCOMPARE(d.isEnabled(), configValue);
1670 if (configValue != initValue) {
1671 d.setEnabled(initValue);
1672 QCOMPARE(inputConfig.readEntry(
"Enabled", configValue), initValue);
1676void TestLibinputDevice::testLoadPointerAcceleration_data()
1678 QTest::addColumn<qreal>(
"initValue");
1679 QTest::addColumn<qreal>(
"configValue");
1681 QTest::newRow(
"-0.2 -> 0.9") << -0.2 << 0.9;
1682 QTest::newRow(
"0.0 -> -1.0") << 0.0 << -1.0;
1683 QTest::newRow(
"0.123 -> -0.456") << 0.123 << -0.456;
1684 QTest::newRow(
"0.7 -> 0.7") << 0.7 << 0.7;
1687void TestLibinputDevice::testLoadPointerAcceleration()
1689 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1690 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1691 QFETCH(qreal, configValue);
1692 QFETCH(qreal, initValue);
1693 inputConfig.writeEntry(
"PointerAcceleration", configValue);
1701 QCOMPARE(d.pointerAcceleration(), initValue);
1702 QCOMPARE(d.property(
"pointerAcceleration").toReal(), initValue);
1704 d.loadConfiguration();
1705 QCOMPARE(d.pointerAcceleration(), initValue);
1706 QCOMPARE(d.property(
"pointerAcceleration").toReal(), initValue);
1709 d.setConfig(inputConfig);
1710 d.loadConfiguration();
1711 QCOMPARE(d.pointerAcceleration(), configValue);
1712 QCOMPARE(d.property(
"pointerAcceleration").toReal(), configValue);
1715 if (configValue != initValue) {
1716 d.setPointerAcceleration(initValue);
1717 QCOMPARE(inputConfig.readEntry(
"PointerAcceleration", configValue), initValue);
1721void TestLibinputDevice::testLoadPointerAccelerationProfile_data()
1723 QTest::addColumn<quint32>(
"initValue");
1724 QTest::addColumn<QString>(
"initValuePropNameString");
1725 QTest::addColumn<quint32>(
"configValue");
1726 QTest::addColumn<QString>(
"configValuePropNameString");
1728 QTest::newRow(
"pointerAccelerationProfileFlat -> pointerAccelerationProfileAdaptive")
1729 << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT <<
"pointerAccelerationProfileFlat"
1730 << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE <<
"pointerAccelerationProfileAdaptive";
1731 QTest::newRow(
"pointerAccelerationProfileAdaptive -> pointerAccelerationProfileFlat")
1732 << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE <<
"pointerAccelerationProfileAdaptive"
1733 << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_FLAT <<
"pointerAccelerationProfileFlat";
1734 QTest::newRow(
"pointerAccelerationProfileAdaptive -> pointerAccelerationProfileAdaptive")
1735 << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE <<
"pointerAccelerationProfileAdaptive" << (quint32)LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE <<
"pointerAccelerationProfileAdaptive";
1738void TestLibinputDevice::testLoadPointerAccelerationProfile()
1740 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1741 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1742 QFETCH(quint32, initValue);
1743 QFETCH(quint32, configValue);
1744 QFETCH(QString, initValuePropNameString);
1745 QFETCH(QString, configValuePropNameString);
1747 QByteArray initValuePropName = initValuePropNameString.toLatin1();
1748 QByteArray configValuePropName = configValuePropNameString.toLatin1();
1750 inputConfig.writeEntry(
"PointerAccelerationProfile", configValue);
1758 QCOMPARE(d.property(initValuePropName).toBool(),
true);
1759 QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
1761 d.loadConfiguration();
1762 QCOMPARE(d.property(initValuePropName).toBool(),
true);
1763 QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
1766 d.setConfig(inputConfig);
1767 d.loadConfiguration();
1768 QCOMPARE(d.property(initValuePropName).toBool(), initValue == configValue);
1769 QCOMPARE(d.property(configValuePropName).toBool(),
true);
1770 QCOMPARE(dbusProperty<bool>(d.sysName(), initValuePropName), initValue == configValue);
1771 QCOMPARE(dbusProperty<bool>(d.sysName(), configValuePropName),
true);
1774 if (configValue != initValue) {
1775 d.setProperty(initValuePropName,
true);
1776 QCOMPARE(inputConfig.readEntry(
"PointerAccelerationProfile", configValue), initValue);
1780void TestLibinputDevice::testLoadClickMethod_data()
1782 QTest::addColumn<quint32>(
"initValue");
1783 QTest::addColumn<QString>(
"initValuePropNameString");
1784 QTest::addColumn<quint32>(
"configValue");
1785 QTest::addColumn<QString>(
"configValuePropNameString");
1787 QTest::newRow(
"clickMethodAreas -> clickMethodClickfinger")
1788 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) <<
"clickMethodAreas"
1789 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) <<
"clickMethodClickfinger";
1790 QTest::newRow(
"clickMethodClickfinger -> clickMethodAreas")
1791 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) <<
"clickMethodClickfinger"
1792 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) <<
"clickMethodAreas";
1793 QTest::newRow(
"clickMethodAreas -> clickMethodAreas")
1794 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) <<
"clickMethodAreas"
1795 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) <<
"clickMethodAreas";
1796 QTest::newRow(
"clickMethodClickfinger -> clickMethodClickfinger")
1797 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) <<
"clickMethodClickfinger"
1798 <<
static_cast<quint32
>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) <<
"clickMethodClickfinger";
1801void TestLibinputDevice::testLoadClickMethod()
1803 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1804 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1805 QFETCH(quint32, initValue);
1806 QFETCH(quint32, configValue);
1807 QFETCH(QString, initValuePropNameString);
1808 QFETCH(QString, configValuePropNameString);
1810 QByteArray initValuePropName = initValuePropNameString.toLatin1();
1811 QByteArray configValuePropName = configValuePropNameString.toLatin1();
1813 inputConfig.writeEntry(
"ClickMethod", configValue);
1816 device.
supportedClickMethods = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS | LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER;
1817 device.
clickMethod = (libinput_config_click_method)initValue;
1821 QCOMPARE(d.property(initValuePropName).toBool(),
true);
1822 QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
1824 d.loadConfiguration();
1825 QCOMPARE(d.property(initValuePropName).toBool(),
true);
1826 QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
1829 d.setConfig(inputConfig);
1830 d.loadConfiguration();
1831 QCOMPARE(d.property(initValuePropName).toBool(), initValue == configValue);
1832 QCOMPARE(d.property(configValuePropName).toBool(),
true);
1833 QCOMPARE(dbusProperty<bool>(d.sysName(), initValuePropName), initValue == configValue);
1834 QCOMPARE(dbusProperty<bool>(d.sysName(), configValuePropName),
true);
1837 if (configValue != initValue) {
1838 d.setProperty(initValuePropName,
true);
1839 QCOMPARE(inputConfig.readEntry(
"ClickMethod", configValue), initValue);
1843void TestLibinputDevice::testLoadTapToClick_data()
1845 QTest::addColumn<bool>(
"initValue");
1846 QTest::addColumn<bool>(
"configValue");
1848 QTest::newRow(
"false -> true") <<
false <<
true;
1849 QTest::newRow(
"true -> false") <<
true <<
false;
1850 QTest::newRow(
"true -> true") <<
true <<
true;
1851 QTest::newRow(
"false -> false") <<
false <<
false;
1854void TestLibinputDevice::testLoadTapToClick()
1856 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1857 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1858 QFETCH(
bool, configValue);
1859 QFETCH(
bool, initValue);
1860 inputConfig.writeEntry(
"TapToClick", configValue);
1868 QCOMPARE(d.isTapToClick(), initValue);
1870 d.loadConfiguration();
1871 QCOMPARE(d.isTapToClick(), initValue);
1874 d.setConfig(inputConfig);
1875 d.loadConfiguration();
1876 QCOMPARE(d.isTapToClick(), configValue);
1879 if (configValue != initValue) {
1880 d.setTapToClick(initValue);
1881 QCOMPARE(inputConfig.readEntry(
"TapToClick", configValue), initValue);
1885void TestLibinputDevice::testLoadTapAndDrag_data()
1887 QTest::addColumn<bool>(
"initValue");
1888 QTest::addColumn<bool>(
"configValue");
1890 QTest::newRow(
"false -> true") <<
false <<
true;
1891 QTest::newRow(
"true -> false") <<
true <<
false;
1892 QTest::newRow(
"true -> true") <<
true <<
true;
1893 QTest::newRow(
"false -> false") <<
false <<
false;
1896void TestLibinputDevice::testLoadTapAndDrag()
1898 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1899 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1900 QFETCH(
bool, configValue);
1901 QFETCH(
bool, initValue);
1902 inputConfig.writeEntry(
"TapAndDrag", configValue);
1909 QCOMPARE(d.isTapAndDrag(), initValue);
1911 d.loadConfiguration();
1912 QCOMPARE(d.isTapAndDrag(), initValue);
1915 d.setConfig(inputConfig);
1916 d.loadConfiguration();
1917 QCOMPARE(d.isTapAndDrag(), configValue);
1920 if (configValue != initValue) {
1921 d.setTapAndDrag(initValue);
1922 QCOMPARE(inputConfig.readEntry(
"TapAndDrag", configValue), initValue);
1926void TestLibinputDevice::testLoadTapDragLock_data()
1928 QTest::addColumn<bool>(
"initValue");
1929 QTest::addColumn<bool>(
"configValue");
1931 QTest::newRow(
"false -> true") <<
false <<
true;
1932 QTest::newRow(
"true -> false") <<
true <<
false;
1933 QTest::newRow(
"true -> true") <<
true <<
true;
1934 QTest::newRow(
"false -> false") <<
false <<
false;
1937void TestLibinputDevice::testLoadTapDragLock()
1939 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1940 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1941 QFETCH(
bool, configValue);
1942 QFETCH(
bool, initValue);
1943 inputConfig.writeEntry(
"TapDragLock", configValue);
1950 QCOMPARE(d.isTapDragLock(), initValue);
1952 d.loadConfiguration();
1953 QCOMPARE(d.isTapDragLock(), initValue);
1956 d.setConfig(inputConfig);
1957 d.loadConfiguration();
1958 QCOMPARE(d.isTapDragLock(), configValue);
1961 if (configValue != initValue) {
1962 d.setTapDragLock(initValue);
1963 QCOMPARE(inputConfig.readEntry(
"TapDragLock", configValue), initValue);
1967void TestLibinputDevice::testLoadMiddleButtonEmulation_data()
1969 QTest::addColumn<bool>(
"initValue");
1970 QTest::addColumn<bool>(
"configValue");
1972 QTest::newRow(
"false -> true") <<
false <<
true;
1973 QTest::newRow(
"true -> false") <<
true <<
false;
1974 QTest::newRow(
"true -> true") <<
true <<
true;
1975 QTest::newRow(
"false -> false") <<
false <<
false;
1978void TestLibinputDevice::testLoadMiddleButtonEmulation()
1980 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
1981 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
1982 QFETCH(
bool, configValue);
1983 QFETCH(
bool, initValue);
1984 inputConfig.writeEntry(
"MiddleButtonEmulation", configValue);
1992 QCOMPARE(d.isMiddleEmulation(), initValue);
1994 d.loadConfiguration();
1995 QCOMPARE(d.isMiddleEmulation(), initValue);
1998 d.setConfig(inputConfig);
1999 d.loadConfiguration();
2000 QCOMPARE(d.isMiddleEmulation(), configValue);
2003 if (configValue != initValue) {
2004 d.setMiddleEmulation(initValue);
2005 QCOMPARE(inputConfig.readEntry(
"MiddleButtonEmulation", configValue), initValue);
2009void TestLibinputDevice::testLoadNaturalScroll_data()
2011 QTest::addColumn<bool>(
"initValue");
2012 QTest::addColumn<bool>(
"configValue");
2014 QTest::newRow(
"false -> true") <<
false <<
true;
2015 QTest::newRow(
"true -> false") <<
true <<
false;
2016 QTest::newRow(
"true -> true") <<
true <<
true;
2017 QTest::newRow(
"false -> false") <<
false <<
false;
2020void TestLibinputDevice::testLoadNaturalScroll()
2022 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
2023 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
2024 QFETCH(
bool, configValue);
2025 QFETCH(
bool, initValue);
2026 inputConfig.writeEntry(
"NaturalScroll", configValue);
2034 QCOMPARE(d.isNaturalScroll(), initValue);
2036 d.loadConfiguration();
2037 QCOMPARE(d.isNaturalScroll(), initValue);
2040 d.setConfig(inputConfig);
2041 d.loadConfiguration();
2042 QCOMPARE(d.isNaturalScroll(), configValue);
2045 if (configValue != initValue) {
2046 d.setNaturalScroll(initValue);
2047 QCOMPARE(inputConfig.readEntry(
"NaturalScroll", configValue), initValue);
2051void TestLibinputDevice::testLoadScrollMethod_data()
2053 QTest::addColumn<quint32>(
"initValue");
2054 QTest::addColumn<QString>(
"initValuePropNameString");
2055 QTest::addColumn<quint32>(
"configValue");
2056 QTest::addColumn<QString>(
"configValuePropNameString");
2058 QTest::newRow(
"scrollTwoFinger -> scrollEdge") << (quint32)LIBINPUT_CONFIG_SCROLL_2FG <<
"scrollTwoFinger" << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE <<
"scrollEdge";
2059 QTest::newRow(
"scrollOnButtonDown -> scrollTwoFinger") << (quint32)LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN <<
"scrollOnButtonDown" << (quint32)LIBINPUT_CONFIG_SCROLL_2FG <<
"scrollTwoFinger";
2060 QTest::newRow(
"scrollEdge -> scrollEdge") << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE <<
"scrollEdge" << (quint32)LIBINPUT_CONFIG_SCROLL_EDGE <<
"scrollEdge";
2063void TestLibinputDevice::testLoadScrollMethod()
2065 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
2066 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
2067 QFETCH(quint32, initValue);
2068 QFETCH(quint32, configValue);
2069 QFETCH(QString, initValuePropNameString);
2070 QFETCH(QString, configValuePropNameString);
2072 QByteArray initValuePropName = initValuePropNameString.toLatin1();
2073 QByteArray configValuePropName = configValuePropNameString.toLatin1();
2075 inputConfig.writeEntry(
"ScrollMethod", configValue);
2078 device.
supportedScrollMethods = LIBINPUT_CONFIG_SCROLL_2FG | LIBINPUT_CONFIG_SCROLL_EDGE | LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
2079 device.
scrollMethod = (libinput_config_scroll_method)initValue;
2083 QCOMPARE(d.property(initValuePropName).toBool(),
true);
2084 QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
2086 d.loadConfiguration();
2087 QCOMPARE(d.property(initValuePropName).toBool(),
true);
2088 QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue);
2091 d.setConfig(inputConfig);
2092 d.loadConfiguration();
2093 QCOMPARE(d.property(initValuePropName).toBool(), initValue == configValue);
2094 QCOMPARE(d.property(configValuePropName).toBool(),
true);
2097 if (configValue != initValue) {
2098 d.setProperty(initValuePropName,
true);
2099 QCOMPARE(inputConfig.readEntry(
"ScrollMethod", configValue), initValue);
2103void TestLibinputDevice::testLoadScrollButton_data()
2105 QTest::addColumn<quint32>(
"initValue");
2106 QTest::addColumn<quint32>(
"configValue");
2108 QTest::newRow(
"BTN_LEFT -> BTN_RIGHT") << quint32(BTN_LEFT) << quint32(BTN_RIGHT);
2109 QTest::newRow(
"BTN_LEFT -> BTN_LEFT") << quint32(BTN_LEFT) << quint32(BTN_LEFT);
2112void TestLibinputDevice::testLoadScrollButton()
2114 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
2115 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
2116 QFETCH(quint32, configValue);
2117 QFETCH(quint32, initValue);
2118 inputConfig.writeEntry(
"ScrollButton", configValue);
2122 device.
scrollMethod = LIBINPUT_CONFIG_SCROLL_ON_BUTTON_DOWN;
2127 QCOMPARE(d.isScrollOnButtonDown(),
true);
2128 QCOMPARE(d.scrollButton(), initValue);
2130 d.loadConfiguration();
2131 QCOMPARE(d.isScrollOnButtonDown(),
true);
2132 QCOMPARE(d.scrollButton(), initValue);
2135 d.setConfig(inputConfig);
2136 d.loadConfiguration();
2137 QCOMPARE(d.isScrollOnButtonDown(),
true);
2138 QCOMPARE(d.scrollButton(), configValue);
2141 if (configValue != initValue) {
2142 d.setScrollButton(initValue);
2143 QCOMPARE(inputConfig.readEntry(
"ScrollButton", configValue), initValue);
2147void TestLibinputDevice::testLoadLeftHanded_data()
2149 QTest::addColumn<bool>(
"initValue");
2150 QTest::addColumn<bool>(
"configValue");
2152 QTest::newRow(
"false -> true") <<
false <<
true;
2153 QTest::newRow(
"true -> false") <<
true <<
false;
2154 QTest::newRow(
"true -> true") <<
true <<
true;
2155 QTest::newRow(
"false -> false") <<
false <<
false;
2158void TestLibinputDevice::testLoadLeftHanded()
2160 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
2161 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
2162 QFETCH(
bool, configValue);
2163 QFETCH(
bool, initValue);
2164 inputConfig.writeEntry(
"LeftHanded", configValue);
2172 QCOMPARE(d.isLeftHanded(), initValue);
2174 d.loadConfiguration();
2175 QCOMPARE(d.isLeftHanded(), initValue);
2178 d.setConfig(inputConfig);
2179 d.loadConfiguration();
2180 QCOMPARE(d.isLeftHanded(), configValue);
2183 if (configValue != initValue) {
2184 d.setLeftHanded(initValue);
2185 QCOMPARE(inputConfig.readEntry(
"LeftHanded", configValue), initValue);
2189void TestLibinputDevice::testLoadDisableWhileTyping_data()
2191 QTest::addColumn<bool>(
"initValue");
2192 QTest::addColumn<bool>(
"configValue");
2194 QTest::newRow(
"false -> true") <<
false <<
true;
2195 QTest::newRow(
"true -> false") <<
true <<
false;
2196 QTest::newRow(
"true -> true") <<
true <<
true;
2197 QTest::newRow(
"false -> false") <<
false <<
false;
2200void TestLibinputDevice::testLoadDisableWhileTyping()
2202 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
2203 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
2204 QFETCH(
bool, configValue);
2205 QFETCH(
bool, initValue);
2206 inputConfig.writeEntry(
"DisableWhileTyping", configValue);
2210 device.
disableWhileTyping = initValue ? LIBINPUT_CONFIG_DWT_ENABLED : LIBINPUT_CONFIG_DWT_DISABLED;
2214 QCOMPARE(d.isDisableWhileTyping(), initValue);
2216 d.loadConfiguration();
2217 QCOMPARE(d.isDisableWhileTyping(), initValue);
2220 d.setConfig(inputConfig);
2221 d.loadConfiguration();
2222 QCOMPARE(d.isDisableWhileTyping(), configValue);
2225 if (configValue != initValue) {
2226 d.setDisableWhileTyping(initValue);
2227 QCOMPARE(inputConfig.readEntry(
"DisableWhileTyping", configValue), initValue);
2231void TestLibinputDevice::testLoadLmrTapButtonMap_data()
2233 QTest::addColumn<bool>(
"initValue");
2234 QTest::addColumn<bool>(
"configValue");
2236 QTest::newRow(
"false -> true") <<
false <<
true;
2237 QTest::newRow(
"true -> false") <<
true <<
false;
2238 QTest::newRow(
"true -> true") <<
true <<
true;
2239 QTest::newRow(
"false -> false") <<
false <<
false;
2242void TestLibinputDevice::testLoadLmrTapButtonMap()
2244 auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig);
2245 KConfigGroup inputConfig(config, QStringLiteral(
"Test"));
2246 QFETCH(
bool, configValue);
2247 QFETCH(
bool, initValue);
2248 inputConfig.writeEntry(
"LmrTapButtonMap", configValue);
2252 device.
tapButtonMap = initValue ? LIBINPUT_CONFIG_TAP_MAP_LMR : LIBINPUT_CONFIG_TAP_MAP_LRM;
2256 QCOMPARE(d.lmrTapButtonMap(), initValue);
2258 d.loadConfiguration();
2259 QCOMPARE(d.lmrTapButtonMap(), initValue);
2260 QCOMPARE(dbusProperty<bool>(d.sysName(),
"lmrTapButtonMap"), initValue);
2263 d.setConfig(inputConfig);
2264 d.loadConfiguration();
2265 QCOMPARE(d.lmrTapButtonMap(), configValue);
2266 QCOMPARE(dbusProperty<bool>(d.sysName(),
"lmrTapButtonMap"), configValue);
2269 if (configValue != initValue) {
2270 d.setLmrTapButtonMap(initValue);
2271 QCOMPARE(inputConfig.readEntry(
"LmrTapButtonMap", configValue), initValue);
2275void TestLibinputDevice::testOrientation_data()
2277 QTest::addColumn<Qt::ScreenOrientation>(
"orientation");
2278 QTest::addColumn<float>(
"m11");
2279 QTest::addColumn<float>(
"m12");
2280 QTest::addColumn<float>(
"m13");
2281 QTest::addColumn<float>(
"m21");
2282 QTest::addColumn<float>(
"m22");
2283 QTest::addColumn<float>(
"m23");
2284 QTest::addColumn<bool>(
"defaultIsIdentity");
2286 QTest::newRow(
"Primary") << Qt::PrimaryOrientation << 1.0f << 2.0f << 3.0f << 4.0f << 5.0f << 6.0f <<
false;
2287 QTest::newRow(
"Landscape") << Qt::LandscapeOrientation << 1.0f << 2.0f << 3.0f << 4.0f << 5.0f << 6.0f <<
false;
2288 QTest::newRow(
"Portrait") << Qt::PortraitOrientation << 0.0f << -1.0f << 1.0f << 1.0f << 0.0f << 0.0f <<
true;
2289 QTest::newRow(
"InvertedLandscape") << Qt::InvertedLandscapeOrientation << -1.0f << 0.0f << 1.0f << 0.0f << -1.0f << 1.0f <<
true;
2290 QTest::newRow(
"InvertedPortrait") << Qt::InvertedPortraitOrientation << 0.0f << 1.0f << 0.0f << -1.0f << 0.0f << 1.0f <<
true;
2293void TestLibinputDevice::testOrientation()
2298 QFETCH(
bool, defaultIsIdentity);
2301 QFETCH(Qt::ScreenOrientation, orientation);
2302 d.setOrientation(orientation);
2311void TestLibinputDevice::testCalibrationWithDefault()
2318 d.setOrientation(Qt::PortraitOrientation);
2327void TestLibinputDevice::testSwitch_data()
2329 QTest::addColumn<bool>(
"lid");
2330 QTest::addColumn<bool>(
"tablet");
2332 QTest::newRow(
"lid") <<
true <<
false;
2333 QTest::newRow(
"tablet") <<
false <<
true;
2336void TestLibinputDevice::testSwitch()
2341 QFETCH(
bool, tablet);
2346 QCOMPARE(d.isSwitch(),
true);
2347 QCOMPARE(d.isLidSwitch(), lid);
2348 QCOMPARE(d.property(
"lidSwitch").toBool(), lid);
2349 QCOMPARE(dbusProperty<bool>(d.sysName(),
"lidSwitch"), lid);
2350 QCOMPARE(d.isTabletModeSwitch(), tablet);
2351 QCOMPARE(d.property(
"tabletModeSwitch").toBool(), tablet);
2352 QCOMPARE(dbusProperty<bool>(d.sysName(),
"tabletModeSwitch"), tablet);
2356#include "device_test.moc"