From 5d580b9fb2ee2118fe292e3f31c87b08af8f679a Mon Sep 17 00:00:00 2001 From: Vlad Zahorodnii Date: Mon, 2 Mar 2020 17:37:08 +0200 Subject: [PATCH] [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 --- autotests/integration/keyboard_layout_test.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/autotests/integration/keyboard_layout_test.cpp b/autotests/integration/keyboard_layout_test.cpp index 054ff8bccd..dd9a07a191 100644 --- a/autotests/integration/keyboard_layout_test.cpp +++ b/autotests/integration/keyboard_layout_test.cpp @@ -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)); }