diff --git a/tests/pointing/mousekeys_only/config.h b/tests/mousekeys/config.h similarity index 100% rename from tests/pointing/mousekeys_only/config.h rename to tests/mousekeys/config.h diff --git a/tests/mousekeys/test.mk b/tests/mousekeys/test.mk new file mode 100644 index 00000000000..6c605daecf5 --- /dev/null +++ b/tests/mousekeys/test.mk @@ -0,0 +1 @@ +MOUSEKEY_ENABLE = yes diff --git a/tests/pointing/mousekeys_only/test_mousekeys.cpp b/tests/mousekeys/test_mousekeys.cpp similarity index 67% rename from tests/pointing/mousekeys_only/test_mousekeys.cpp rename to tests/mousekeys/test_mousekeys.cpp index d02358028c4..a1b8e06cf7a 100644 --- a/tests/pointing/mousekeys_only/test_mousekeys.cpp +++ b/tests/mousekeys/test_mousekeys.cpp @@ -4,7 +4,6 @@ #include "gtest/gtest.h" #include "mouse_report_util.hpp" #include "test_common.hpp" -#include "test_pointing_device_driver.h" using testing::_; @@ -16,10 +15,55 @@ struct MouseKeyExpectations { uint16_t button_mask; }; -class Pointing : public TestFixture {}; -class PointingKeycodesParametrizedTestFixture : public ::testing::WithParamInterface>, public Pointing {}; +class Mousekey : public TestFixture {}; +class MousekeyParametrized : public ::testing::WithParamInterface>, public Mousekey {}; -TEST_P(PointingKeycodesParametrizedTestFixture, PointingMouseKeysViaPointingDriver) { +TEST_F(Mousekey, SendMouseNotCalledWhenNoKeyIsPressed) { + TestDriver driver; + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Mousekey, PressAndHoldCursorUpIsCorrectlyReported) { + TestDriver driver; + KeymapKey mouse_key = KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_UP}; + + set_keymap({mouse_key}); + + EXPECT_MOUSE_REPORT(driver, (0, -8, 0, 0, 0)); + mouse_key.press(); + run_one_scan_loop(); + + EXPECT_MOUSE_REPORT(driver, (0, -2, 0, 0, 0)); + idle_for(MOUSEKEY_INTERVAL); + + EXPECT_EMPTY_MOUSE_REPORT(driver); + mouse_key.release(); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Mousekey, PressAndHoldButtonOneCorrectlyReported) { + TestDriver driver; + KeymapKey mouse_key = KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}; + + set_keymap({mouse_key}); + + EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1)); + mouse_key.press(); + run_one_scan_loop(); + + idle_for(MOUSEKEY_INTERVAL); + + EXPECT_EMPTY_MOUSE_REPORT(driver); + mouse_key.release(); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_P(MousekeyParametrized, PressAndReleaseIsCorrectlyReported) { TestDriver driver; KeymapKey mouse_key = GetParam().first; MouseKeyExpectations expectations = GetParam().second; @@ -41,8 +85,8 @@ TEST_P(PointingKeycodesParametrizedTestFixture, PointingMouseKeysViaPointingDriv } // clang-format off INSTANTIATE_TEST_CASE_P( - PointingMouseKeysOnlyTests, - PointingKeycodesParametrizedTestFixture, + Keys, + MousekeyParametrized, ::testing::Values( // Key , X, Y, H, V, Buttons Mask std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, MouseKeyExpectations{ 0, 0, 0, 0, 1}), diff --git a/tests/pointing/mousekeys_only/test.mk b/tests/pointing/mousekeys_only/test.mk deleted file mode 100644 index acee807f069..00000000000 --- a/tests/pointing/mousekeys_only/test.mk +++ /dev/null @@ -1,5 +0,0 @@ -POINTING_DEVICE_ENABLE = no -MOUSEKEY_ENABLE = yes -POINTING_DEVICE_DRIVER = custom - -