Changeset View
Changeset View
Standalone View
Standalone View
autotests/libinput/device_test.cpp
Show All 39 Lines | 35 | private Q_SLOTS: | |||
---|---|---|---|---|---|
40 | void testGestureSupport(); | 40 | void testGestureSupport(); | ||
41 | void testNames_data(); | 41 | void testNames_data(); | ||
42 | void testNames(); | 42 | void testNames(); | ||
43 | void testProduct(); | 43 | void testProduct(); | ||
44 | void testVendor(); | 44 | void testVendor(); | ||
45 | void testTapFingerCount(); | 45 | void testTapFingerCount(); | ||
46 | void testSize_data(); | 46 | void testSize_data(); | ||
47 | void testSize(); | 47 | void testSize(); | ||
48 | void testLeftHandedEnabledByDefault_data(); | ||||
49 | void testLeftHandedEnabledByDefault(); | ||||
48 | void testTapEnabledByDefault_data(); | 50 | void testTapEnabledByDefault_data(); | ||
49 | void testTapEnabledByDefault(); | 51 | void testTapEnabledByDefault(); | ||
50 | void testMiddleEmulationEnabledByDefault_data(); | 52 | void testMiddleEmulationEnabledByDefault_data(); | ||
51 | void testMiddleEmulationEnabledByDefault(); | 53 | void testMiddleEmulationEnabledByDefault(); | ||
52 | void testNaturalScrollEnabledByDefault_data(); | 54 | void testNaturalScrollEnabledByDefault_data(); | ||
53 | void testNaturalScrollEnabledByDefault(); | 55 | void testNaturalScrollEnabledByDefault(); | ||
54 | void testScrollTwoFingerEnabledByDefault_data(); | 56 | void testScrollTwoFingerEnabledByDefault_data(); | ||
55 | void testScrollTwoFingerEnabledByDefault(); | 57 | void testScrollTwoFingerEnabledByDefault(); | ||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | |||||
128 | void testLoadScrollTwoFinger_data(); | 130 | void testLoadScrollTwoFinger_data(); | ||
129 | void testLoadScrollTwoFinger(); | 131 | void testLoadScrollTwoFinger(); | ||
130 | void testLoadScrollEdge_data(); | 132 | void testLoadScrollEdge_data(); | ||
131 | void testLoadScrollEdge(); | 133 | void testLoadScrollEdge(); | ||
132 | void testLoadScrollOnButton_data(); | 134 | void testLoadScrollOnButton_data(); | ||
133 | void testLoadScrollOnButton(); | 135 | void testLoadScrollOnButton(); | ||
134 | void testLoadScrollButton_data(); | 136 | void testLoadScrollButton_data(); | ||
135 | void testLoadScrollButton(); | 137 | void testLoadScrollButton(); | ||
138 | void testLoadLeftHanded_data(); | ||||
139 | void testLoadLeftHanded(); | ||||
136 | }; | 140 | }; | ||
137 | 141 | | |||
138 | void TestLibinputDevice::testStaticGetter() | 142 | void TestLibinputDevice::testStaticGetter() | ||
139 | { | 143 | { | ||
140 | // this test verifies that the static getter for Device works as expected | 144 | // this test verifies that the static getter for Device works as expected | ||
141 | QVERIFY(Device::devices().isEmpty()); | 145 | QVERIFY(Device::devices().isEmpty()); | ||
142 | 146 | | |||
143 | // create some device | 147 | // create some device | ||
▲ Show 20 Lines • Show All 178 Lines • ▼ Show 20 Line(s) | 321 | { | |||
322 | device.deviceSize = setSize; | 326 | device.deviceSize = setSize; | ||
323 | device.deviceSizeReturnValue = returnValue; | 327 | device.deviceSizeReturnValue = returnValue; | ||
324 | 328 | | |||
325 | Device d(&device); | 329 | Device d(&device); | ||
326 | QTEST(d.size(), "expectedSize"); | 330 | QTEST(d.size(), "expectedSize"); | ||
327 | QTEST(d.property("size").toSizeF(), "expectedSize"); | 331 | QTEST(d.property("size").toSizeF(), "expectedSize"); | ||
328 | } | 332 | } | ||
329 | 333 | | |||
334 | void TestLibinputDevice::testLeftHandedEnabledByDefault_data() | ||||
335 | { | ||||
336 | QTest::addColumn<bool>("enabled"); | ||||
337 | | ||||
338 | QTest::newRow("enabled") << true; | ||||
339 | QTest::newRow("disabled") << false; | ||||
340 | } | ||||
341 | | ||||
342 | void TestLibinputDevice::testLeftHandedEnabledByDefault() | ||||
343 | { | ||||
344 | QFETCH(bool, enabled); | ||||
345 | libinput_device device; | ||||
346 | device.leftHandedEnabledByDefault = enabled; | ||||
347 | | ||||
348 | Device d(&device); | ||||
349 | QCOMPARE(d.leftHandedEnabledByDefault(), enabled); | ||||
350 | QCOMPARE(d.property("leftHandedEnabledByDefault").toBool(), enabled); | ||||
351 | } | ||||
352 | | ||||
330 | void TestLibinputDevice::testTapEnabledByDefault_data() | 353 | void TestLibinputDevice::testTapEnabledByDefault_data() | ||
331 | { | 354 | { | ||
332 | QTest::addColumn<bool>("enabled"); | 355 | QTest::addColumn<bool>("enabled"); | ||
333 | 356 | | |||
334 | QTest::newRow("enabled") << true; | 357 | QTest::newRow("enabled") << true; | ||
335 | QTest::newRow("disabled") << false; | 358 | QTest::newRow("disabled") << false; | ||
336 | } | 359 | } | ||
337 | 360 | | |||
▲ Show 20 Lines • Show All 1356 Lines • ▼ Show 20 Line(s) | 1691 | { | |||
1694 | 1717 | | |||
1695 | // and try to store | 1718 | // and try to store | ||
1696 | if (configValue != initValue) { | 1719 | if (configValue != initValue) { | ||
1697 | d.setScrollButton(initValue); | 1720 | d.setScrollButton(initValue); | ||
1698 | QCOMPARE(inputConfig.readEntry("ScrollButton", configValue), initValue); | 1721 | QCOMPARE(inputConfig.readEntry("ScrollButton", configValue), initValue); | ||
1699 | } | 1722 | } | ||
1700 | } | 1723 | } | ||
1701 | 1724 | | |||
1725 | void TestLibinputDevice::testLoadLeftHanded_data() | ||||
1726 | { | ||||
1727 | QTest::addColumn<bool>("initValue"); | ||||
1728 | QTest::addColumn<bool>("configValue"); | ||||
1729 | | ||||
1730 | QTest::newRow("false -> true") << false << true; | ||||
1731 | QTest::newRow("true -> false") << true << false; | ||||
1732 | QTest::newRow("true -> true") << true << true; | ||||
1733 | QTest::newRow("false -> false") << false << false; | ||||
1734 | } | ||||
1735 | | ||||
1736 | void TestLibinputDevice::testLoadLeftHanded() | ||||
1737 | { | ||||
1738 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||||
1739 | KConfigGroup inputConfig(config, QStringLiteral("Test")); | ||||
1740 | QFETCH(bool, configValue); | ||||
1741 | QFETCH(bool, initValue); | ||||
1742 | inputConfig.writeEntry("LeftHanded", configValue); | ||||
1743 | | ||||
1744 | libinput_device device; | ||||
1745 | device.supportsLeftHanded = true; | ||||
1746 | device.leftHanded = initValue; | ||||
1747 | device.setLeftHandedReturnValue = false; | ||||
1748 | | ||||
1749 | Device d(&device); | ||||
1750 | QCOMPARE(d.isLeftHanded(), initValue); | ||||
1751 | // no config group set, should not change | ||||
1752 | d.loadConfiguration(); | ||||
1753 | QCOMPARE(d.isLeftHanded(), initValue); | ||||
1754 | | ||||
1755 | // set the group | ||||
1756 | d.setConfig(inputConfig); | ||||
1757 | d.loadConfiguration(); | ||||
1758 | QCOMPARE(d.isLeftHanded(), configValue); | ||||
1759 | | ||||
1760 | // and try to store | ||||
1761 | if (configValue != initValue) { | ||||
1762 | d.setLeftHanded(initValue); | ||||
1763 | QCOMPARE(inputConfig.readEntry("LeftHanded", configValue), initValue); | ||||
1764 | } | ||||
1765 | } | ||||
1766 | | ||||
1702 | QTEST_GUILESS_MAIN(TestLibinputDevice) | 1767 | QTEST_GUILESS_MAIN(TestLibinputDevice) | ||
1703 | #include "device_test.moc" | 1768 | #include "device_test.moc" |