[autotests] Fix failing KeyboardLayoutTest::testNumLock()
Summary: Since Qt::KeypadModifier is set only for keypad keys and not the NumLock key, we need to press at least one keypad key to determine whether numlock is actually on. On the other hand, we know that when numlock is on, the corresponding LED is also on. So we could check the LED rather than press two keys. Test Plan: testKeyboardLayout passes. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D27789
This commit is contained in:
parent
bbcc51fabf
commit
5d580b9fb2
1 changed files with 7 additions and 7 deletions
|
@ -471,16 +471,16 @@ void KeyboardLayoutTest::testNumLock()
|
||||||
QTRY_COMPARE(xkb->layoutName(), QStringLiteral("English (US)"));
|
QTRY_COMPARE(xkb->layoutName(), QStringLiteral("English (US)"));
|
||||||
|
|
||||||
// by default not set
|
// by default not set
|
||||||
QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier));
|
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
quint32 timestamp = 0;
|
quint32 timestamp = 0;
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
// now it should be on
|
// now it should be on
|
||||||
QVERIFY(xkb->modifiers().testFlag(Qt::KeypadModifier));
|
QVERIFY(xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
// and back to off
|
// and back to off
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier));
|
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
|
|
||||||
// let's reconfigure to enable through config
|
// let's reconfigure to enable through config
|
||||||
auto group = kwinApp()->inputConfig()->group("Keyboard");
|
auto group = kwinApp()->inputConfig()->group("Keyboard");
|
||||||
|
@ -488,22 +488,22 @@ void KeyboardLayoutTest::testNumLock()
|
||||||
group.sync();
|
group.sync();
|
||||||
xkb->reconfigure();
|
xkb->reconfigure();
|
||||||
// now it should be on
|
// now it should be on
|
||||||
QVERIFY(xkb->modifiers().testFlag(Qt::KeypadModifier));
|
QVERIFY(xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
// pressing should result in it being off
|
// pressing should result in it being off
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier));
|
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
|
|
||||||
// pressing again should enable it
|
// pressing again should enable it
|
||||||
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
|
||||||
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
|
||||||
QVERIFY(xkb->modifiers().testFlag(Qt::KeypadModifier));
|
QVERIFY(xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
|
|
||||||
// now reconfigure to disable on load
|
// now reconfigure to disable on load
|
||||||
group.writeEntry("NumLock", 1);
|
group.writeEntry("NumLock", 1);
|
||||||
group.sync();
|
group.sync();
|
||||||
xkb->reconfigure();
|
xkb->reconfigure();
|
||||||
QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier));
|
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue