Changeset View
Changeset View
Standalone View
Standalone View
autotests/client/test_wayland_seat.cpp
Show First 20 Lines • Show All 72 Lines • ▼ Show 20 Line(s) | 64 | private Q_SLOTS: | |||
---|---|---|---|---|---|
73 | void testPointerTransformation(); | 73 | void testPointerTransformation(); | ||
74 | void testPointerButton_data(); | 74 | void testPointerButton_data(); | ||
75 | void testPointerButton(); | 75 | void testPointerButton(); | ||
76 | void testPointerSubSurfaceTree(); | 76 | void testPointerSubSurfaceTree(); | ||
77 | void testPointerSwipeGesture_data(); | 77 | void testPointerSwipeGesture_data(); | ||
78 | void testPointerSwipeGesture(); | 78 | void testPointerSwipeGesture(); | ||
79 | void testPointerPinchGesture_data(); | 79 | void testPointerPinchGesture_data(); | ||
80 | void testPointerPinchGesture(); | 80 | void testPointerPinchGesture(); | ||
81 | void testPointerAxis(); | ||||
81 | void testKeyboardSubSurfaceTreeFromPointer(); | 82 | void testKeyboardSubSurfaceTreeFromPointer(); | ||
82 | void testCursor(); | 83 | void testCursor(); | ||
83 | void testCursorDamage(); | 84 | void testCursorDamage(); | ||
84 | void testKeyboard(); | 85 | void testKeyboard(); | ||
85 | void testCast(); | 86 | void testCast(); | ||
86 | void testDestroy(); | 87 | void testDestroy(); | ||
87 | void testSelection(); | 88 | void testSelection(); | ||
88 | void testSelectionNoDataSource(); | 89 | void testSelectionNoDataSource(); | ||
▲ Show 20 Lines • Show All 1057 Lines • ▼ Show 20 Line(s) | 1046 | { | |||
1146 | if (cancel) { | 1147 | if (cancel) { | ||
1147 | m_seatInterface->cancelPointerPinchGesture(); | 1148 | m_seatInterface->cancelPointerPinchGesture(); | ||
1148 | } else { | 1149 | } else { | ||
1149 | m_seatInterface->endPointerPinchGesture(); | 1150 | m_seatInterface->endPointerPinchGesture(); | ||
1150 | } | 1151 | } | ||
1151 | QVERIFY(spy->wait()); | 1152 | QVERIFY(spy->wait()); | ||
1152 | } | 1153 | } | ||
1153 | 1154 | | |||
1155 | void TestWaylandSeat::testPointerAxis() | ||||
1156 | { | ||||
1157 | using namespace KWayland::Client; | ||||
1158 | using namespace KWayland::Server; | ||||
1159 | | ||||
1160 | // first create the pointer | ||||
1161 | QSignalSpy hasPointerChangedSpy(m_seat, &Seat::hasPointerChanged); | ||||
1162 | QVERIFY(hasPointerChangedSpy.isValid()); | ||||
1163 | m_seatInterface->setHasPointer(true); | ||||
1164 | QVERIFY(hasPointerChangedSpy.wait()); | ||||
1165 | QScopedPointer<Pointer> pointer(m_seat->createPointer()); | ||||
1166 | QVERIFY(pointer); | ||||
1167 | | ||||
1168 | // now create a surface | ||||
1169 | QSignalSpy surfaceCreatedSpy(m_compositorInterface, &CompositorInterface::surfaceCreated); | ||||
1170 | QVERIFY(surfaceCreatedSpy.isValid()); | ||||
1171 | QScopedPointer<Surface> surface(m_compositor->createSurface()); | ||||
1172 | QVERIFY(surfaceCreatedSpy.wait()); | ||||
1173 | auto serverSurface = surfaceCreatedSpy.first().first().value<SurfaceInterface*>(); | ||||
1174 | QVERIFY(serverSurface); | ||||
1175 | m_seatInterface->setFocusedPointerSurface(serverSurface); | ||||
1176 | QCOMPARE(m_seatInterface->focusedPointerSurface(), serverSurface); | ||||
1177 | QVERIFY(m_seatInterface->focusedPointer()); | ||||
1178 | QSignalSpy frameSpy(pointer.data(), &Pointer::frame); | ||||
1179 | QVERIFY(frameSpy.isValid()); | ||||
1180 | QVERIFY(frameSpy.wait()); | ||||
1181 | QCOMPARE(frameSpy.count(), 1); | ||||
1182 | | ||||
1183 | // let's scroll vertically | ||||
1184 | QSignalSpy axisSourceSpy(pointer.data(), &Pointer::axisSourceChanged); | ||||
1185 | QVERIFY(axisSourceSpy.isValid()); | ||||
1186 | QSignalSpy axisSpy(pointer.data(), &Pointer::axisChanged); | ||||
1187 | QVERIFY(axisSpy.isValid()); | ||||
1188 | QSignalSpy axisDiscreteSpy(pointer.data(), &Pointer::axisDiscreteChanged); | ||||
1189 | QVERIFY(axisDiscreteSpy.isValid()); | ||||
1190 | QSignalSpy axisStoppedSpy(pointer.data(), &Pointer::axisStopped); | ||||
1191 | QVERIFY(axisStoppedSpy.isValid()); | ||||
1192 | | ||||
1193 | quint32 timestamp = 1; | ||||
1194 | m_seatInterface->setTimestamp(timestamp++); | ||||
1195 | m_seatInterface->pointerAxisV5(Qt::Vertical, 10, 1, PointerAxisSource::Wheel); | ||||
1196 | QVERIFY(frameSpy.wait()); | ||||
1197 | QCOMPARE(frameSpy.count(), 2); | ||||
1198 | QCOMPARE(axisSourceSpy.count(), 1); | ||||
1199 | QCOMPARE(axisSourceSpy.last().at(0).value<Pointer::AxisSource>(), Pointer::AxisSource::Wheel); | ||||
1200 | QCOMPARE(axisDiscreteSpy.count(), 1); | ||||
1201 | QCOMPARE(axisDiscreteSpy.last().at(0).value<Pointer::Axis>(), Pointer::Axis::Vertical); | ||||
1202 | QCOMPARE(axisDiscreteSpy.last().at(1).value<qint32>(), 1); | ||||
1203 | QCOMPARE(axisSpy.count(), 1); | ||||
1204 | QCOMPARE(axisSpy.last().at(0).value<quint32>(), quint32(1)); | ||||
1205 | QCOMPARE(axisSpy.last().at(1).value<Pointer::Axis>(), Pointer::Axis::Vertical); | ||||
1206 | QCOMPARE(axisSpy.last().at(2).value<qreal>(), 10.0); | ||||
1207 | QCOMPARE(axisStoppedSpy.count(), 0); | ||||
1208 | | ||||
1209 | // let's scroll using fingers | ||||
1210 | m_seatInterface->setTimestamp(timestamp++); | ||||
1211 | m_seatInterface->pointerAxisV5(Qt::Horizontal, 42, 0, PointerAxisSource::Finger); | ||||
1212 | QVERIFY(frameSpy.wait()); | ||||
1213 | QCOMPARE(frameSpy.count(), 3); | ||||
1214 | QCOMPARE(axisSourceSpy.count(), 2); | ||||
1215 | QCOMPARE(axisSourceSpy.last().at(0).value<Pointer::AxisSource>(), Pointer::AxisSource::Finger); | ||||
1216 | QCOMPARE(axisDiscreteSpy.count(), 1); | ||||
1217 | QCOMPARE(axisSpy.count(), 2); | ||||
1218 | QCOMPARE(axisSpy.last().at(0).value<quint32>(), quint32(2)); | ||||
1219 | QCOMPARE(axisSpy.last().at(1).value<Pointer::Axis>(), Pointer::Axis::Horizontal); | ||||
1220 | QCOMPARE(axisSpy.last().at(2).value<qreal>(), 42.0); | ||||
1221 | QCOMPARE(axisStoppedSpy.count(), 0); | ||||
1222 | | ||||
1223 | // lift the fingers off the device | ||||
1224 | m_seatInterface->setTimestamp(timestamp++); | ||||
1225 | m_seatInterface->pointerAxisV5(Qt::Horizontal, 0, 0, PointerAxisSource::Finger); | ||||
1226 | QVERIFY(frameSpy.wait()); | ||||
1227 | QCOMPARE(frameSpy.count(), 4); | ||||
1228 | QCOMPARE(axisSourceSpy.count(), 3); | ||||
1229 | QCOMPARE(axisSourceSpy.last().at(0).value<Pointer::AxisSource>(), Pointer::AxisSource::Finger); | ||||
1230 | QCOMPARE(axisDiscreteSpy.count(), 1); | ||||
1231 | QCOMPARE(axisSpy.count(), 2); | ||||
1232 | QCOMPARE(axisStoppedSpy.count(), 1); | ||||
1233 | QCOMPARE(axisStoppedSpy.last().at(0).value<quint32>(), 3); | ||||
1234 | QCOMPARE(axisStoppedSpy.last().at(1).value<Pointer::Axis>(), Pointer::Axis::Horizontal); | ||||
1235 | } | ||||
1236 | | ||||
1154 | void TestWaylandSeat::testKeyboardSubSurfaceTreeFromPointer() | 1237 | void TestWaylandSeat::testKeyboardSubSurfaceTreeFromPointer() | ||
1155 | { | 1238 | { | ||
1156 | // this test verifies that when clicking on a sub-surface the keyboard focus passes to it | 1239 | // this test verifies that when clicking on a sub-surface the keyboard focus passes to it | ||
1157 | using namespace KWayland::Client; | 1240 | using namespace KWayland::Client; | ||
1158 | using namespace KWayland::Server; | 1241 | using namespace KWayland::Server; | ||
1159 | 1242 | | |||
1160 | // first create the pointer | 1243 | // first create the pointer | ||
1161 | QSignalSpy hasPointerChangedSpy(m_seat, &Seat::hasPointerChanged); | 1244 | QSignalSpy hasPointerChangedSpy(m_seat, &Seat::hasPointerChanged); | ||
▲ Show 20 Lines • Show All 1151 Lines • Show Last 20 Lines |