From 5ac0c0cc1c6aa837c239c71571364e71a11d2af0 Mon Sep 17 00:00:00 2001 From: equalsraf <redacted> Date: Wed, 24 Jul 2024 17:42:04 +0100 Subject: [PATCH] Add unit tests for x1/x2 mouse events --- test/tst_input_common.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/test/tst_input_common.cpp b/test/tst_input_common.cpp index a0adb77b2..c13215ce1 100644 --- a/test/tst_input_common.cpp +++ b/test/tst_input_common.cpp @@ -21,6 +21,8 @@ private slots: void MouseLeftClick() noexcept; void MouseRightClick() noexcept; void MouseMiddleClick() noexcept; + void MouseX1Click() noexcept; + void MouseX2Click() noexcept; }; void TestInputCommon::LessThanKey() noexcept @@ -255,5 +257,43 @@ void TestInputCommon::MouseMiddleClick() noexcept QCOMPARE(middleClickRelease, QString{ "<MiddleRelease><1,2>" }); } +void TestInputCommon::MouseX1Click() noexcept +{ + QString x1Press{ NeovimQt::Input::convertMouse( + Qt::XButton1, + QEvent::MouseButtonPress, + Qt::NoModifier, + { 1, 2 }, + 1 /*clickCount*/) }; + QString x1Release{ NeovimQt::Input::convertMouse( + Qt::XButton1, + QEvent::MouseButtonRelease, + Qt::NoModifier, + { 1, 2 }, + 1 /*clickCount*/) }; + + QCOMPARE(x1Press, QString{ "<X1Mouse><1,2>" }); + QCOMPARE(x1Release, QString{ "<X1Release><1,2>" }); +} + +void TestInputCommon::MouseX2Click() noexcept +{ + QString x2Press{ NeovimQt::Input::convertMouse( + Qt::XButton2, + QEvent::MouseButtonPress, + Qt::NoModifier, + { 1, 2 }, + 1 /*clickCount*/) }; + QString x2Release{ NeovimQt::Input::convertMouse( + Qt::XButton2, + QEvent::MouseButtonRelease, + Qt::NoModifier, + { 1, 2 }, + 1 /*clickCount*/) }; + + QCOMPARE(x2Press, QString{ "<X2Mouse><1,2>" }); + QCOMPARE(x2Release, QString{ "<X2Release><1,2>" }); +} + #include "tst_input_common.moc" QTEST_MAIN(TestInputCommon)