Changeset View
Changeset View
Standalone View
Standalone View
autotests/libinput/input_event_test.cpp
Show First 20 Lines • Show All 115 Lines • ▼ Show 20 Line(s) | 93 | { | |||
---|---|---|---|---|---|
116 | // and our custom argument | 116 | // and our custom argument | ||
117 | QCOMPARE(event.device(), &d); | 117 | QCOMPARE(event.device(), &d); | ||
118 | } | 118 | } | ||
119 | 119 | | |||
120 | void InputEventsTest::testInitWheelEvent_data() | 120 | void InputEventsTest::testInitWheelEvent_data() | ||
121 | { | 121 | { | ||
122 | QTest::addColumn<Qt::Orientation>("orientation"); | 122 | QTest::addColumn<Qt::Orientation>("orientation"); | ||
123 | QTest::addColumn<qreal>("delta"); | 123 | QTest::addColumn<qreal>("delta"); | ||
124 | QTest::addColumn<qint32>("discreteDelta"); | ||||
124 | QTest::addColumn<QPoint>("expectedAngleDelta"); | 125 | QTest::addColumn<QPoint>("expectedAngleDelta"); | ||
125 | 126 | | |||
126 | QTest::newRow("horiz") << Qt::Horizontal << 3.0 << QPoint(3, 0); | 127 | QTest::newRow("horiz") << Qt::Horizontal << 3.3 << 1 << QPoint(3, 0); | ||
127 | QTest::newRow("vert") << Qt::Vertical << 2.0 << QPoint(0, 2); | 128 | QTest::newRow("vert") << Qt::Vertical << 2.4 << 2 << QPoint(0, 2); | ||
128 | } | 129 | } | ||
129 | 130 | | |||
130 | void InputEventsTest::testInitWheelEvent() | 131 | void InputEventsTest::testInitWheelEvent() | ||
131 | { | 132 | { | ||
132 | // this test verifies that a WheelEvent is constructed correctly | 133 | // this test verifies that a WheelEvent is constructed correctly | ||
133 | 134 | | |||
134 | // first create the test LibInput::Device | 135 | // first create the test LibInput::Device | ||
135 | libinput_device device; | 136 | libinput_device device; | ||
136 | Device d(&device); | 137 | Device d(&device); | ||
137 | 138 | | |||
138 | // setup event | 139 | // setup event | ||
139 | QFETCH(Qt::Orientation, orientation); | 140 | QFETCH(Qt::Orientation, orientation); | ||
140 | QFETCH(qreal, delta); | 141 | QFETCH(qreal, delta); | ||
141 | WheelEvent event(QPointF(100, 200), delta, orientation, Qt::LeftButton | Qt::RightButton, | 142 | QFETCH(qint32, discreteDelta); | ||
142 | Qt::ShiftModifier | Qt::ControlModifier, 300, &d); | 143 | WheelEvent event(QPointF(100, 200), delta, discreteDelta, orientation, Qt::LeftButton | Qt::RightButton, | ||
144 | Qt::ShiftModifier | Qt::ControlModifier, InputRedirection::PointerAxisSourceWheel, 300, &d); | ||||
143 | // compare QWheelEvent contract | 145 | // compare QWheelEvent contract | ||
144 | QCOMPARE(event.type(), QEvent::Wheel); | 146 | QCOMPARE(event.type(), QEvent::Wheel); | ||
145 | QCOMPARE(event.posF(), QPointF(100, 200)); | 147 | QCOMPARE(event.posF(), QPointF(100, 200)); | ||
146 | QCOMPARE(event.globalPosF(), QPointF(100, 200)); | 148 | QCOMPARE(event.globalPosF(), QPointF(100, 200)); | ||
147 | QCOMPARE(event.buttons(), Qt::LeftButton | Qt::RightButton); | 149 | QCOMPARE(event.buttons(), Qt::LeftButton | Qt::RightButton); | ||
148 | QCOMPARE(event.modifiers(), Qt::ShiftModifier | Qt::ControlModifier); | 150 | QCOMPARE(event.modifiers(), Qt::ShiftModifier | Qt::ControlModifier); | ||
149 | QCOMPARE(event.timestamp(), 300ul); | 151 | QCOMPARE(event.timestamp(), 300ul); | ||
150 | QTEST(event.angleDelta(), "expectedAngleDelta"); | 152 | QTEST(event.angleDelta(), "expectedAngleDelta"); | ||
153 | QTEST(event.orientation(), "orientation"); | ||||
154 | QTEST(event.delta(), "delta"); | ||||
155 | QTEST(event.discreteDelta(), "discreteDelta"); | ||||
156 | QCOMPARE(event.axisSource(), InputRedirection::PointerAxisSourceWheel); | ||||
151 | // and our custom argument | 157 | // and our custom argument | ||
152 | QCOMPARE(event.device(), &d); | 158 | QCOMPARE(event.device(), &d); | ||
153 | 159 | | |||
154 | } | 160 | } | ||
155 | 161 | | |||
156 | void InputEventsTest::testInitSwitchEvent_data() | 162 | void InputEventsTest::testInitSwitchEvent_data() | ||
157 | { | 163 | { | ||
158 | QTest::addColumn<KWin::SwitchEvent::State>("state"); | 164 | QTest::addColumn<KWin::SwitchEvent::State>("state"); | ||
Show All 26 Lines |