ButtonRebindsFilter: Add test for disabled bindings

This was missed when it was first implemented, but now there's tests for
checking if bindings can be disabled in the buttons rebind plugin.
This commit is contained in:
Joshua Goins 2024-07-19 17:34:01 -04:00 committed by Joshua Goins
parent 47a538e61c
commit 0ea1bcfe89

View file

@ -36,6 +36,8 @@ private Q_SLOTS:
void testMouse_data(); void testMouse_data();
void testMouse(); void testMouse();
void testDisabled();
private: private:
quint32 timestamp = 1; quint32 timestamp = 1;
}; };
@ -148,5 +150,34 @@ void TestButtonRebind::testMouse()
Test::pointerButtonReleased(0x119, timestamp++); Test::pointerButtonReleased(0x119, timestamp++);
} }
void TestButtonRebind::testDisabled()
{
KConfigGroup buttonGroup = KSharedConfig::openConfig(QStringLiteral("kcminputrc"))->group(QStringLiteral("ButtonRebinds")).group(QStringLiteral("Mouse"));
buttonGroup.writeEntry("ExtraButton7", QStringList{"Disabled"}, KConfig::Notify);
buttonGroup.sync();
std::unique_ptr<KWayland::Client::Surface> surface = Test::createSurface();
std::unique_ptr<Test::XdgToplevel> shellSurface = Test::createXdgToplevelSurface(surface.get());
auto window = Test::renderAndWaitForShown(surface.get(), QSize(100, 50), Qt::blue);
std::unique_ptr<KWayland::Client::Pointer> pointer(Test::waylandSeat()->createPointer());
QSignalSpy enteredSpy(pointer.get(), &KWayland::Client::Pointer::entered);
QSignalSpy buttonChangedSpy(pointer.get(), &KWayland::Client::Pointer::buttonStateChanged);
const QRectF startGeometry = window->frameGeometry();
input()->pointer()->warp(startGeometry.center());
QVERIFY(enteredSpy.wait());
// 0x119 is Qt::ExtraButton7
Test::pointerButtonPressed(0x119, timestamp++);
// Qt::ExtraButton7 should not have been emitted if this button is disabled
QVERIFY(!buttonChangedSpy.wait(std::chrono::milliseconds(100)));
QCOMPARE(buttonChangedSpy.count(), 0);
Test::pointerButtonReleased(0x119, timestamp++);
}
WAYLANDTEST_MAIN(TestButtonRebind) WAYLANDTEST_MAIN(TestButtonRebind)
#include "buttonrebind_test.moc" #include "buttonrebind_test.moc"