Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/modifier_only_shortcut_test.cpp
Show First 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | 139 | { | |||
---|---|---|---|---|---|
246 | QCOMPARE(triggeredSpy.count(), 2); | 246 | QCOMPARE(triggeredSpy.count(), 2); | ||
247 | 247 | | |||
248 | QVERIFY(Test::unlockScreen()); | 248 | QVERIFY(Test::unlockScreen()); | ||
249 | } | 249 | } | ||
250 | 250 | | |||
251 | void ModifierOnlyShortcutTest::testCapsLock() | 251 | void ModifierOnlyShortcutTest::testCapsLock() | ||
252 | { | 252 | { | ||
253 | // this test verifies that Capslock does not trigger the shift shortcut | 253 | // this test verifies that Capslock does not trigger the shift shortcut | ||
254 | // and that the shift modifier on capslock does not trigger either | 254 | // but other shortcuts still trigger even when Capslock is on | ||
255 | Target target; | 255 | Target target; | ||
256 | QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered); | 256 | QSignalSpy triggeredSpy(&target, &Target::shortcutTriggered); | ||
257 | QVERIFY(triggeredSpy.isValid()); | 257 | QVERIFY(triggeredSpy.isValid()); | ||
258 | 258 | | |||
259 | KConfigGroup group = kwinApp()->config()->group("ModifierOnlyShortcuts"); | 259 | KConfigGroup group = kwinApp()->config()->group("ModifierOnlyShortcuts"); | ||
260 | group.writeEntry("Meta", QStringList()); | 260 | group.writeEntry("Meta", QStringList()); | ||
261 | group.writeEntry("Alt", QStringList()); | 261 | group.writeEntry("Alt", QStringList()); | ||
262 | group.writeEntry("Shift", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); | 262 | group.writeEntry("Shift", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); | ||
Show All 10 Lines | |||||
273 | 273 | | |||
274 | // now capslock | 274 | // now capslock | ||
275 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | 275 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | ||
276 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | 276 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||
277 | QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier); | 277 | QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier); | ||
278 | QCOMPARE(triggeredSpy.count(), 1); | 278 | QCOMPARE(triggeredSpy.count(), 1); | ||
279 | 279 | | |||
280 | // currently caps lock is on | 280 | // currently caps lock is on | ||
281 | // shift is ignored | 281 | // shift still triggers | ||
davidedmundson: I don't get this change:
This is the " // this test verifies that Capslock does not trigger… | |||||
No, it is the capslock key which got released in 276. So at that point here capslock is on, typing an a would result in A. So far when that was the case pressing shift did not trigger the modifier only shortcut, now it does. graesslin: No, it is the capslock key which got released in 276. So at that point here capslock is on… | |||||
282 | kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); | 282 | kwinApp()->platform()->keyboardKeyPressed(modifier, timestamp++); | ||
283 | kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); | 283 | kwinApp()->platform()->keyboardKeyReleased(modifier, timestamp++); | ||
284 | QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier); | 284 | QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier); | ||
285 | QCOMPARE(triggeredSpy.count(), 1); | 285 | QCOMPARE(triggeredSpy.count(), 2); | ||
286 | 286 | | |||
287 | // meta on the other hand should trigger | 287 | // meta should also trigger | ||
288 | group.writeEntry("Meta", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); | 288 | group.writeEntry("Meta", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); | ||
289 | group.writeEntry("Alt", QStringList()); | 289 | group.writeEntry("Alt", QStringList()); | ||
290 | group.writeEntry("Shift", QStringList{}); | 290 | group.writeEntry("Shift", QStringList{}); | ||
291 | group.writeEntry("Control", QStringList()); | 291 | group.writeEntry("Control", QStringList()); | ||
292 | group.sync(); | 292 | group.sync(); | ||
293 | workspace()->slotReconfigure(); | 293 | workspace()->slotReconfigure(); | ||
294 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); | 294 | kwinApp()->platform()->keyboardKeyPressed(KEY_LEFTMETA, timestamp++); | ||
295 | QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier | Qt::MetaModifier); | 295 | QCOMPARE(input()->keyboardModifiers(), Qt::ShiftModifier | Qt::MetaModifier); | ||
296 | QCOMPARE(input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts(), Qt::MetaModifier); | 296 | QCOMPARE(input()->keyboard()->xkb()->modifiersRelevantForGlobalShortcuts(), Qt::MetaModifier); | ||
297 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); | 297 | kwinApp()->platform()->keyboardKeyReleased(KEY_LEFTMETA, timestamp++); | ||
298 | QEXPECT_FAIL("", "BUG 375355", Continue); | 298 | QCOMPARE(triggeredSpy.count(), 3); | ||
299 | QCOMPARE(triggeredSpy.count(), 2); | 299 | | ||
300 | // set back to shift to ensure we don't trigger with capslock | ||||
301 | group.writeEntry("Meta", QStringList()); | ||||
302 | group.writeEntry("Alt", QStringList()); | ||||
303 | group.writeEntry("Shift", QStringList{s_serviceName, s_path, s_serviceName, QStringLiteral("shortcut")}); | ||||
304 | group.writeEntry("Control", QStringList()); | ||||
305 | group.sync(); | ||||
306 | workspace()->slotReconfigure(); | ||||
300 | 307 | | |||
301 | // release caps lock | 308 | // release caps lock | ||
302 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | 309 | kwinApp()->platform()->keyboardKeyPressed(KEY_CAPSLOCK, timestamp++); | ||
303 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | 310 | kwinApp()->platform()->keyboardKeyReleased(KEY_CAPSLOCK, timestamp++); | ||
304 | QCOMPARE(input()->keyboardModifiers(), Qt::NoModifier); | 311 | QCOMPARE(input()->keyboardModifiers(), Qt::NoModifier); | ||
305 | QEXPECT_FAIL("", "BUG 375355", Continue); | 312 | QCOMPARE(triggeredSpy.count(), 3); | ||
306 | QCOMPARE(triggeredSpy.count(), 2); | | |||
307 | } | 313 | } | ||
308 | 314 | | |||
309 | void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled_data() | 315 | void ModifierOnlyShortcutTest::testGlobalShortcutsDisabled_data() | ||
310 | { | 316 | { | ||
311 | QTest::addColumn<QStringList>("metaConfig"); | 317 | QTest::addColumn<QStringList>("metaConfig"); | ||
312 | QTest::addColumn<QStringList>("altConfig"); | 318 | QTest::addColumn<QStringList>("altConfig"); | ||
313 | QTest::addColumn<QStringList>("controlConfig"); | 319 | QTest::addColumn<QStringList>("controlConfig"); | ||
314 | QTest::addColumn<QStringList>("shiftConfig"); | 320 | QTest::addColumn<QStringList>("shiftConfig"); | ||
▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines |
I don't get this change:
This is the " // this test verifies that Capslock does not trigger the shift shortcut" part of the test.
Shift has been released on line 276, so triggeredSpy shouldn't be going up.