Changeset View
Changeset View
Standalone View
Standalone View
autotests/libinput/device_test.cpp
Show First 20 Lines • Show All 48 Lines • ▼ Show 20 Line(s) | 37 | private Q_SLOTS: | |||
---|---|---|---|---|---|
49 | void testSize_data(); | 49 | void testSize_data(); | ||
50 | void testSize(); | 50 | void testSize(); | ||
51 | void testDefaultPointerAcceleration_data(); | 51 | void testDefaultPointerAcceleration_data(); | ||
52 | void testDefaultPointerAcceleration(); | 52 | void testDefaultPointerAcceleration(); | ||
53 | void testDefaultPointerAccelerationProfileFlat_data(); | 53 | void testDefaultPointerAccelerationProfileFlat_data(); | ||
54 | void testDefaultPointerAccelerationProfileFlat(); | 54 | void testDefaultPointerAccelerationProfileFlat(); | ||
55 | void testDefaultPointerAccelerationProfileAdaptive_data(); | 55 | void testDefaultPointerAccelerationProfileAdaptive_data(); | ||
56 | void testDefaultPointerAccelerationProfileAdaptive(); | 56 | void testDefaultPointerAccelerationProfileAdaptive(); | ||
57 | void testDefaultClickMethodAreas_data(); | ||||
58 | void testDefaultClickMethodAreas(); | ||||
59 | void testDefaultClickMethodClickfinger_data(); | ||||
60 | void testDefaultClickMethodClickfinger(); | ||||
57 | void testLeftHandedEnabledByDefault_data(); | 61 | void testLeftHandedEnabledByDefault_data(); | ||
58 | void testLeftHandedEnabledByDefault(); | 62 | void testLeftHandedEnabledByDefault(); | ||
59 | void testTapEnabledByDefault_data(); | 63 | void testTapEnabledByDefault_data(); | ||
60 | void testTapEnabledByDefault(); | 64 | void testTapEnabledByDefault(); | ||
61 | void testMiddleEmulationEnabledByDefault_data(); | 65 | void testMiddleEmulationEnabledByDefault_data(); | ||
62 | void testMiddleEmulationEnabledByDefault(); | 66 | void testMiddleEmulationEnabledByDefault(); | ||
63 | void testNaturalScrollEnabledByDefault_data(); | 67 | void testNaturalScrollEnabledByDefault_data(); | ||
64 | void testNaturalScrollEnabledByDefault(); | 68 | void testNaturalScrollEnabledByDefault(); | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | |||||
133 | void testLmrTapButtonMap_data(); | 137 | void testLmrTapButtonMap_data(); | ||
134 | void testLmrTapButtonMap(); | 138 | void testLmrTapButtonMap(); | ||
135 | void testLoadEnabled_data(); | 139 | void testLoadEnabled_data(); | ||
136 | void testLoadEnabled(); | 140 | void testLoadEnabled(); | ||
137 | void testLoadPointerAcceleration_data(); | 141 | void testLoadPointerAcceleration_data(); | ||
138 | void testLoadPointerAcceleration(); | 142 | void testLoadPointerAcceleration(); | ||
139 | void testLoadPointerAccelerationProfile_data(); | 143 | void testLoadPointerAccelerationProfile_data(); | ||
140 | void testLoadPointerAccelerationProfile(); | 144 | void testLoadPointerAccelerationProfile(); | ||
145 | void testLoadClickMethod_data(); | ||||
146 | void testLoadClickMethod(); | ||||
141 | void testLoadTapToClick_data(); | 147 | void testLoadTapToClick_data(); | ||
142 | void testLoadTapToClick(); | 148 | void testLoadTapToClick(); | ||
143 | void testLoadTapAndDrag_data(); | 149 | void testLoadTapAndDrag_data(); | ||
144 | void testLoadTapAndDrag(); | 150 | void testLoadTapAndDrag(); | ||
145 | void testLoadTapDragLock_data(); | 151 | void testLoadTapDragLock_data(); | ||
146 | void testLoadTapDragLock(); | 152 | void testLoadTapDragLock(); | ||
147 | void testLoadMiddleButtonEmulation_data(); | 153 | void testLoadMiddleButtonEmulation_data(); | ||
148 | void testLoadMiddleButtonEmulation(); | 154 | void testLoadMiddleButtonEmulation(); | ||
▲ Show 20 Lines • Show All 400 Lines • ▼ Show 20 Line(s) | 552 | { | |||
549 | device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; | 555 | device.defaultPointerAccelerationProfile = enabled ? LIBINPUT_CONFIG_ACCEL_PROFILE_ADAPTIVE : LIBINPUT_CONFIG_ACCEL_PROFILE_NONE; | ||
550 | 556 | | |||
551 | Device d(&device); | 557 | Device d(&device); | ||
552 | QCOMPARE(d.defaultPointerAccelerationProfileAdaptive(), enabled); | 558 | QCOMPARE(d.defaultPointerAccelerationProfileAdaptive(), enabled); | ||
553 | QCOMPARE(d.property("defaultPointerAccelerationProfileAdaptive").toBool(), enabled); | 559 | QCOMPARE(d.property("defaultPointerAccelerationProfileAdaptive").toBool(), enabled); | ||
554 | QCOMPARE(dbusProperty<bool>(d.sysName(), "defaultPointerAccelerationProfileAdaptive"), enabled); | 560 | QCOMPARE(dbusProperty<bool>(d.sysName(), "defaultPointerAccelerationProfileAdaptive"), enabled); | ||
555 | } | 561 | } | ||
556 | 562 | | |||
563 | void TestLibinputDevice::testDefaultClickMethodAreas_data() | ||||
564 | { | ||||
565 | QTest::addColumn<bool>("enabled"); | ||||
566 | | ||||
567 | QTest::addRow("enabled") << true; | ||||
568 | QTest::addRow("disabled") << false; | ||||
569 | } | ||||
570 | | ||||
571 | void TestLibinputDevice::testDefaultClickMethodAreas() | ||||
572 | { | ||||
573 | QFETCH(bool, enabled); | ||||
574 | libinput_device device; | ||||
575 | device.defaultClickMethod = enabled ? LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS : LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; | ||||
576 | | ||||
577 | Device d(&device); | ||||
578 | QCOMPARE(d.defaultClickMethodAreas(), enabled); | ||||
579 | QCOMPARE(d.property("defaultClickMethodAreas").toBool(), enabled); | ||||
580 | QCOMPARE(dbusProperty<bool>(d.sysName(), "defaultClickMethodAreas"), enabled); | ||||
581 | } | ||||
582 | | ||||
583 | void TestLibinputDevice::testDefaultClickMethodClickfinger_data() | ||||
584 | { | ||||
585 | QTest::addColumn<bool>("enabled"); | ||||
586 | | ||||
587 | QTest::addRow("enabled") << true; | ||||
588 | QTest::addRow("disabled") << false; | ||||
589 | } | ||||
590 | | ||||
591 | void TestLibinputDevice::testDefaultClickMethodClickfinger() | ||||
592 | { | ||||
593 | QFETCH(bool, enabled); | ||||
594 | libinput_device device; | ||||
595 | device.defaultClickMethod = enabled ? LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER : LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS; | ||||
596 | | ||||
597 | Device d(&device); | ||||
598 | QCOMPARE(d.defaultClickMethodClickfinger(), enabled); | ||||
599 | QCOMPARE(d.property("defaultClickMethodClickfinger").toBool(), enabled); | ||||
600 | QCOMPARE(dbusProperty<bool>(d.sysName(), "defaultClickMethodClickfinger"), enabled); | ||||
601 | } | ||||
602 | | ||||
557 | void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault_data() | 603 | void TestLibinputDevice::testScrollOnButtonDownEnabledByDefault_data() | ||
558 | { | 604 | { | ||
559 | QTest::addColumn<bool>("enabled"); | 605 | QTest::addColumn<bool>("enabled"); | ||
560 | 606 | | |||
561 | QTest::newRow("enabled") << true; | 607 | QTest::newRow("enabled") << true; | ||
562 | QTest::newRow("disabled") << false; | 608 | QTest::newRow("disabled") << false; | ||
563 | } | 609 | } | ||
564 | 610 | | |||
▲ Show 20 Lines • Show All 1200 Lines • ▼ Show 20 Line(s) | 1778 | { | |||
1765 | 1811 | | |||
1766 | // and try to store | 1812 | // and try to store | ||
1767 | if (configValue != initValue) { | 1813 | if (configValue != initValue) { | ||
1768 | d.setProperty(initValuePropName, true); | 1814 | d.setProperty(initValuePropName, true); | ||
1769 | QCOMPARE(inputConfig.readEntry("PointerAccelerationProfile", configValue), initValue); | 1815 | QCOMPARE(inputConfig.readEntry("PointerAccelerationProfile", configValue), initValue); | ||
1770 | } | 1816 | } | ||
1771 | } | 1817 | } | ||
1772 | 1818 | | |||
1819 | void TestLibinputDevice::testLoadClickMethod_data() | ||||
1820 | { | ||||
1821 | QTest::addColumn<quint32>("initValue"); | ||||
1822 | QTest::addColumn<QString>("initValuePropNameString"); | ||||
1823 | QTest::addColumn<quint32>("configValue"); | ||||
1824 | QTest::addColumn<QString>("configValuePropNameString"); | ||||
1825 | | ||||
1826 | QTest::newRow("clickMethodAreas -> clickMethodClickfinger") | ||||
1827 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas" | ||||
zzag: Please use static_cast instead of c-style casts. | |||||
1828 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"; | ||||
1829 | QTest::newRow("clickMethodClickfinger -> clickMethodAreas") | ||||
1830 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger" | ||||
1831 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"; | ||||
1832 | QTest::newRow("clickMethodAreas -> clickMethodAreas") | ||||
1833 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas" | ||||
1834 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS) << "clickMethodAreas"; | ||||
1835 | QTest::newRow("clickMethodClickfinger -> clickMethodClickfinger") | ||||
1836 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger" | ||||
1837 | << static_cast<quint32>(LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER) << "clickMethodClickfinger"; | ||||
1838 | } | ||||
1839 | | ||||
1840 | void TestLibinputDevice::testLoadClickMethod() | ||||
1841 | { | ||||
1842 | auto config = KSharedConfig::openConfig(QString(), KConfig::SimpleConfig); | ||||
1843 | KConfigGroup inputConfig(config, QStringLiteral("Test")); | ||||
1844 | QFETCH(quint32, initValue); | ||||
1845 | QFETCH(quint32, configValue); | ||||
1846 | QFETCH(QString, initValuePropNameString); | ||||
1847 | QFETCH(QString, configValuePropNameString); | ||||
1848 | | ||||
1849 | QByteArray initValuePropName = initValuePropNameString.toLatin1(); | ||||
1850 | QByteArray configValuePropName = configValuePropNameString.toLatin1(); | ||||
1851 | | ||||
1852 | inputConfig.writeEntry("ClickMethod", configValue); | ||||
1853 | | ||||
1854 | libinput_device device; | ||||
1855 | device.supportedClickMethods = LIBINPUT_CONFIG_CLICK_METHOD_BUTTON_AREAS | LIBINPUT_CONFIG_CLICK_METHOD_CLICKFINGER; | ||||
1856 | device.clickMethod = (libinput_config_click_method) initValue; | ||||
1857 | device.setClickMethodReturnValue = false; | ||||
1858 | | ||||
1859 | Device d(&device); | ||||
1860 | QCOMPARE(d.property(initValuePropName).toBool(), true); | ||||
1861 | QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue); | ||||
1862 | // no config group set, should not change | ||||
1863 | d.loadConfiguration(); | ||||
1864 | QCOMPARE(d.property(initValuePropName).toBool(), true); | ||||
1865 | QCOMPARE(d.property(configValuePropName).toBool(), initValue == configValue); | ||||
1866 | | ||||
1867 | // set the group | ||||
1868 | d.setConfig(inputConfig); | ||||
1869 | d.loadConfiguration(); | ||||
1870 | QCOMPARE(d.property(initValuePropName).toBool(), initValue == configValue); | ||||
1871 | QCOMPARE(d.property(configValuePropName).toBool(), true); | ||||
1872 | QCOMPARE(dbusProperty<bool>(d.sysName(), initValuePropName), initValue == configValue); | ||||
1873 | QCOMPARE(dbusProperty<bool>(d.sysName(), configValuePropName), true); | ||||
1874 | | ||||
1875 | // and try to store | ||||
1876 | if (configValue != initValue) { | ||||
1877 | d.setProperty(initValuePropName, true); | ||||
1878 | QCOMPARE(inputConfig.readEntry("ClickMethod", configValue), initValue); | ||||
1879 | } | ||||
1880 | } | ||||
1881 | | ||||
1773 | void TestLibinputDevice::testLoadTapToClick_data() | 1882 | void TestLibinputDevice::testLoadTapToClick_data() | ||
1774 | { | 1883 | { | ||
1775 | QTest::addColumn<bool>("initValue"); | 1884 | QTest::addColumn<bool>("initValue"); | ||
1776 | QTest::addColumn<bool>("configValue"); | 1885 | QTest::addColumn<bool>("configValue"); | ||
1777 | 1886 | | |||
1778 | QTest::newRow("false -> true") << false << true; | 1887 | QTest::newRow("false -> true") << false << true; | ||
1779 | QTest::newRow("true -> false") << true << false; | 1888 | QTest::newRow("true -> false") << true << false; | ||
1780 | QTest::newRow("true -> true") << true << true; | 1889 | QTest::newRow("true -> true") << true << true; | ||
▲ Show 20 Lines • Show All 515 Lines • Show Last 20 Lines |
Please use static_cast instead of c-style casts.