Commit 5d580b9f authored by Vlad Zahorodnii's avatar Vlad Zahorodnii

[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
parent bbcc51fa
......@@ -471,16 +471,16 @@ void KeyboardLayoutTest::testNumLock()
QTRY_COMPARE(xkb->layoutName(), QStringLiteral("English (US)"));
// by default not set
QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier));
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
quint32 timestamp = 0;
kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++);
kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++);
// now it should be on
QVERIFY(xkb->modifiers().testFlag(Qt::KeypadModifier));
QVERIFY(xkb->leds().testFlag(Xkb::LED::NumLock));
// and back to off
kwinApp()->platform()->keyboardKeyPressed(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
auto group = kwinApp()->inputConfig()->group("Keyboard");
......@@ -488,22 +488,22 @@ void KeyboardLayoutTest::testNumLock()
group.sync();
xkb->reconfigure();
// 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
kwinApp()->platform()->keyboardKeyPressed(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
kwinApp()->platform()->keyboardKeyPressed(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
group.writeEntry("NumLock", 1);
group.sync();
xkb->reconfigure();
QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier));
QVERIFY(!xkb->leds().testFlag(Xkb::LED::NumLock));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment