21 void testCapabilities();
23 void testPointerButton();
24 void testPointerPos();
25 void testRepeatInfo();
29static const QString s_socketName = QStringLiteral(
"kwin-wayland-server-seat-test-0");
31void TestWaylandServerSeat::testCapabilities()
37 QVERIFY(!seat->hasKeyboard());
38 QVERIFY(!seat->hasPointer());
39 QVERIFY(!seat->hasTouch());
42 seat->setHasKeyboard(
true);
43 QCOMPARE(keyboardSpy.count(), 1);
44 QVERIFY(keyboardSpy.last().first().toBool());
45 QVERIFY(seat->hasKeyboard());
46 seat->setHasKeyboard(
false);
47 QCOMPARE(keyboardSpy.count(), 2);
48 QVERIFY(!keyboardSpy.last().first().toBool());
49 QVERIFY(!seat->hasKeyboard());
50 seat->setHasKeyboard(
false);
51 QCOMPARE(keyboardSpy.count(), 2);
54 seat->setHasPointer(
true);
55 QCOMPARE(pointerSpy.count(), 1);
56 QVERIFY(pointerSpy.last().first().toBool());
57 QVERIFY(seat->hasPointer());
58 seat->setHasPointer(
false);
59 QCOMPARE(pointerSpy.count(), 2);
60 QVERIFY(!pointerSpy.last().first().toBool());
61 QVERIFY(!seat->hasPointer());
62 seat->setHasPointer(
false);
63 QCOMPARE(pointerSpy.count(), 2);
66 seat->setHasTouch(
true);
67 QCOMPARE(touchSpy.count(), 1);
68 QVERIFY(touchSpy.last().first().toBool());
69 QVERIFY(seat->hasTouch());
70 seat->setHasTouch(
false);
71 QCOMPARE(touchSpy.count(), 2);
72 QVERIFY(!touchSpy.last().first().toBool());
73 QVERIFY(!seat->hasTouch());
74 seat->setHasTouch(
false);
75 QCOMPARE(touchSpy.count(), 2);
78void TestWaylandServerSeat::testName()
84 QCOMPARE(
seat->name(), QString());
87 const QString name = QStringLiteral(
"foobar");
89 QCOMPARE(
seat->name(), name);
90 QCOMPARE(nameSpy.count(), 1);
91 QCOMPARE(nameSpy.first().first().toString(), name);
93 QCOMPARE(nameSpy.count(), 1);
96void TestWaylandServerSeat::testPointerButton()
102 seat->setHasPointer(
true);
105 QVERIFY(!
seat->isPointerButtonPressed(0));
106 QVERIFY(!
seat->isPointerButtonPressed(1));
107 QCOMPARE(
seat->pointerButtonSerial(0), quint32(0));
108 QCOMPARE(
seat->pointerButtonSerial(1), quint32(0));
111 seat->notifyPointerButton(0, PointerButtonState::Pressed);
112 seat->notifyPointerFrame();
113 QVERIFY(
seat->isPointerButtonPressed(0));
114 QCOMPARE(
seat->pointerButtonSerial(0), display.
serial());
117 QVERIFY(!
seat->isPointerButtonPressed(1));
118 QCOMPARE(
seat->pointerButtonSerial(1), quint32(0));
121 seat->notifyPointerButton(0, PointerButtonState::Released);
122 seat->notifyPointerFrame();
123 QVERIFY(!
seat->isPointerButtonPressed(0));
124 QCOMPARE(
seat->pointerButtonSerial(0), display.
serial());
127void TestWaylandServerSeat::testPointerPos()
133 seat->setHasPointer(
true);
136 QCOMPARE(
seat->pointerPos(), QPointF());
138 seat->notifyPointerMotion(QPointF(10, 15));
139 seat->notifyPointerFrame();
140 QCOMPARE(
seat->pointerPos(), QPointF(10, 15));
141 QCOMPARE(seatPosSpy.count(), 1);
142 QCOMPARE(seatPosSpy.first().first().toPointF(), QPointF(10, 15));
144 seat->notifyPointerMotion(QPointF(10, 15));
145 seat->notifyPointerFrame();
146 QCOMPARE(seatPosSpy.count(), 1);
148 seat->notifyPointerMotion(QPointF(5, 7));
149 seat->notifyPointerFrame();
150 QCOMPARE(
seat->pointerPos(), QPointF(5, 7));
151 QCOMPARE(seatPosSpy.count(), 2);
152 QCOMPARE(seatPosSpy.first().first().toPointF(), QPointF(10, 15));
153 QCOMPARE(seatPosSpy.last().first().toPointF(), QPointF(5, 7));
156void TestWaylandServerSeat::testRepeatInfo()
162 seat->setHasKeyboard(
true);
163 QCOMPARE(
seat->keyboard()->keyRepeatRate(), 0);
164 QCOMPARE(
seat->keyboard()->keyRepeatDelay(), 0);
165 seat->keyboard()->setRepeatInfo(25, 660);
166 QCOMPARE(
seat->keyboard()->keyRepeatRate(), 25);
167 QCOMPARE(
seat->keyboard()->keyRepeatDelay(), 660);
169 seat->keyboard()->setRepeatInfo(-25, -660);
170 QCOMPARE(
seat->keyboard()->keyRepeatRate(), 0);
171 QCOMPARE(
seat->keyboard()->keyRepeatDelay(), 0);
174void TestWaylandServerSeat::testMultiple()
179 QVERIFY(display.
seats().isEmpty());
181 QCOMPARE(display.
seats().count(), 1);
182 QCOMPARE(display.
seats().at(0), seat1);
184 QCOMPARE(display.
seats().count(), 2);
185 QCOMPARE(display.
seats().at(0), seat1);
186 QCOMPARE(display.
seats().at(1), seat2);
188 QCOMPARE(display.
seats().count(), 3);
189 QCOMPARE(display.
seats().at(0), seat1);
190 QCOMPARE(display.
seats().at(1), seat2);
191 QCOMPARE(display.
seats().at(2), seat3);
194 QCOMPARE(display.
seats().count(), 2);
195 QCOMPARE(display.
seats().at(0), seat1);
196 QCOMPARE(display.
seats().at(1), seat2);
199 QCOMPARE(display.
seats().count(), 1);
200 QCOMPARE(display.
seats().at(0), seat1);
203 QCOMPARE(display.
seats().count(), 0);
207#include "test_seat.moc"
Class holding the Wayland server display loop.
bool addSocketName(const QString &name=QString())
QList< SeatInterface * > seats() const
Represents a Seat on the Wayland Display.
void hasTouchChanged(bool)
void hasKeyboardChanged(bool)
void pointerPosChanged(const QPointF &pos)
void nameChanged(const QString &)
void hasPointerChanged(bool)
KWayland::Client::Seat * seat