Changeset View
Changeset View
Standalone View
Standalone View
autotests/libinput/device_test.cpp
Show First 20 Lines • Show All 149 Lines • ▼ Show 20 Line(s) | 35 | private Q_SLOTS: | |||
---|---|---|---|---|---|
150 | void testLoadScrollButton_data(); | 150 | void testLoadScrollButton_data(); | ||
151 | void testLoadScrollButton(); | 151 | void testLoadScrollButton(); | ||
152 | void testLoadDisableWhileTyping_data(); | 152 | void testLoadDisableWhileTyping_data(); | ||
153 | void testLoadDisableWhileTyping(); | 153 | void testLoadDisableWhileTyping(); | ||
154 | void testLoadLmrTapButtonMap_data(); | 154 | void testLoadLmrTapButtonMap_data(); | ||
155 | void testLoadLmrTapButtonMap(); | 155 | void testLoadLmrTapButtonMap(); | ||
156 | void testLoadLeftHanded_data(); | 156 | void testLoadLeftHanded_data(); | ||
157 | void testLoadLeftHanded(); | 157 | void testLoadLeftHanded(); | ||
158 | void testScreenId(); | ||||
159 | void testOrientation_data(); | ||||
160 | void testOrientation(); | ||||
161 | void testCalibrationWithDefault(); | ||||
158 | }; | 162 | }; | ||
159 | 163 | | |||
160 | void TestLibinputDevice::testStaticGetter() | 164 | void TestLibinputDevice::testStaticGetter() | ||
161 | { | 165 | { | ||
162 | // this test verifies that the static getter for Device works as expected | 166 | // this test verifies that the static getter for Device works as expected | ||
163 | QVERIFY(Device::devices().isEmpty()); | 167 | QVERIFY(Device::devices().isEmpty()); | ||
164 | 168 | | |||
165 | // create some device | 169 | // create some device | ||
▲ Show 20 Lines • Show All 1924 Lines • ▼ Show 20 Line(s) | 2072 | { | |||
2090 | 2094 | | |||
2091 | // and try to store | 2095 | // and try to store | ||
2092 | if (configValue != initValue) { | 2096 | if (configValue != initValue) { | ||
2093 | d.setLmrTapButtonMap(initValue); | 2097 | d.setLmrTapButtonMap(initValue); | ||
2094 | QCOMPARE(inputConfig.readEntry("LmrTapButtonMap", configValue), initValue); | 2098 | QCOMPARE(inputConfig.readEntry("LmrTapButtonMap", configValue), initValue); | ||
2095 | } | 2099 | } | ||
2096 | } | 2100 | } | ||
2097 | 2101 | | |||
2102 | void TestLibinputDevice::testScreenId() | ||||
2103 | { | ||||
2104 | libinput_device device; | ||||
2105 | Device d(&device); | ||||
2106 | QCOMPARE(d.screenId(), 0); | ||||
2107 | d.setScreenId(1); | ||||
2108 | QCOMPARE(d.screenId(), 1); | ||||
2109 | } | ||||
2110 | | ||||
2111 | void TestLibinputDevice::testOrientation_data() | ||||
2112 | { | ||||
2113 | QTest::addColumn<Qt::ScreenOrientation>("orientation"); | ||||
2114 | QTest::addColumn<float>("m11"); | ||||
2115 | QTest::addColumn<float>("m12"); | ||||
2116 | QTest::addColumn<float>("m13"); | ||||
2117 | QTest::addColumn<float>("m21"); | ||||
2118 | QTest::addColumn<float>("m22"); | ||||
2119 | QTest::addColumn<float>("m23"); | ||||
2120 | QTest::addColumn<bool>("defaultIsIdentity"); | ||||
2121 | | ||||
2122 | QTest::newRow("Primary") << Qt::PrimaryOrientation << 1.0f << 2.0f << 3.0f << 4.0f << 5.0f << 6.0f << false; | ||||
2123 | QTest::newRow("Landscape") << Qt::LandscapeOrientation << 1.0f << 2.0f << 3.0f << 4.0f << 5.0f << 6.0f << false; | ||||
2124 | QTest::newRow("Portrait") << Qt::PortraitOrientation << 0.0f << -1.0f << 1.0f << 1.0f << 0.0f << 0.0f << true; | ||||
2125 | QTest::newRow("InvertedLandscape") << Qt::InvertedLandscapeOrientation << -1.0f << 0.0f << 1.0f << 0.0f << -1.0f << 1.0f << true; | ||||
2126 | QTest::newRow("InvertedPortrait") << Qt::InvertedPortraitOrientation << 0.0f << 1.0f << 0.0f << -1.0f << 0.0f << 1.0f << true; | ||||
2127 | } | ||||
2128 | | ||||
2129 | void TestLibinputDevice::testOrientation() | ||||
2130 | { | ||||
2131 | libinput_device device; | ||||
2132 | device.supportsCalibrationMatrix = true; | ||||
2133 | device.defaultCalibrationMatrix = std::array<float, 6>{{1.0, 2.0, 3.0, 4.0, 5.0, 6.0}}; | ||||
2134 | QFETCH(bool, defaultIsIdentity); | ||||
2135 | device.defaultCalibrationMatrixIsIdentity = defaultIsIdentity; | ||||
2136 | Device d(&device); | ||||
2137 | QFETCH(Qt::ScreenOrientation, orientation); | ||||
2138 | d.setOrientation(orientation); | ||||
2139 | QTEST(device.calibrationMatrix[0], "m11"); | ||||
2140 | QTEST(device.calibrationMatrix[1], "m12"); | ||||
2141 | QTEST(device.calibrationMatrix[2], "m13"); | ||||
2142 | QTEST(device.calibrationMatrix[3], "m21"); | ||||
2143 | QTEST(device.calibrationMatrix[4], "m22"); | ||||
2144 | QTEST(device.calibrationMatrix[5], "m23"); | ||||
2145 | } | ||||
2146 | | ||||
2147 | void TestLibinputDevice::testCalibrationWithDefault() | ||||
2148 | { | ||||
2149 | libinput_device device; | ||||
2150 | device.supportsCalibrationMatrix = true; | ||||
2151 | device.defaultCalibrationMatrix = std::array<float, 6>{{2.0, 3.0, 0.0, 4.0, 5.0, 0.0}}; | ||||
2152 | device.defaultCalibrationMatrixIsIdentity = false; | ||||
2153 | Device d(&device); | ||||
2154 | d.setOrientation(Qt::PortraitOrientation); | ||||
2155 | QCOMPARE(device.calibrationMatrix[0], 3.0f); | ||||
2156 | QCOMPARE(device.calibrationMatrix[1], -2.0f); | ||||
2157 | QCOMPARE(device.calibrationMatrix[2], 2.0f); | ||||
2158 | QCOMPARE(device.calibrationMatrix[3], 5.0f); | ||||
2159 | QCOMPARE(device.calibrationMatrix[4], -4.0f); | ||||
2160 | QCOMPARE(device.calibrationMatrix[5], 4.0f); | ||||
2161 | } | ||||
2162 | | ||||
2098 | QTEST_GUILESS_MAIN(TestLibinputDevice) | 2163 | QTEST_GUILESS_MAIN(TestLibinputDevice) | ||
2099 | #include "device_test.moc" | 2164 | #include "device_test.moc" |