diff options
author | Dasky <[email protected]> | 2024-11-23 16:34:32 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2024-11-23 16:34:32 +0000 |
commit | 1f7d10902a7e603a47b9291664fcb9ab0b21f690 (patch) | |
tree | 55202d0ac9edd5bf977e5b0c95bdcf3b3f859c88 /tests/pointing | |
parent | d189de24a0797ea32d00b652fe798f5315566ab3 (diff) | |
download | qmk_firmware-1f7d10902a7e603a47b9291664fcb9ab0b21f690.tar.gz qmk_firmware-1f7d10902a7e603a47b9291664fcb9ab0b21f690.zip |
Add pointing tests (#24513)
Diffstat (limited to 'tests/pointing')
-rw-r--r-- | tests/pointing/config.h | 6 | ||||
-rw-r--r-- | tests/pointing/invertandrotate/config.h | 9 | ||||
-rw-r--r-- | tests/pointing/invertandrotate/test.mk | 2 | ||||
-rw-r--r-- | tests/pointing/invertandrotate/test_invertandrotate.cpp | 59 | ||||
-rw-r--r-- | tests/pointing/invertxy/config.h | 9 | ||||
-rw-r--r-- | tests/pointing/invertxy/test.mk | 2 | ||||
-rw-r--r-- | tests/pointing/invertxy/test_invertxy.cpp | 53 | ||||
-rw-r--r-- | tests/pointing/rotate180/config.h | 8 | ||||
-rw-r--r-- | tests/pointing/rotate180/test.mk | 2 | ||||
-rw-r--r-- | tests/pointing/rotate180/test_rotate180.cpp | 55 | ||||
-rw-r--r-- | tests/pointing/rotate270/config.h | 8 | ||||
-rw-r--r-- | tests/pointing/rotate270/test.mk | 2 | ||||
-rw-r--r-- | tests/pointing/rotate270/test_rotate270.cpp | 60 | ||||
-rw-r--r-- | tests/pointing/rotate90/config.h | 8 | ||||
-rw-r--r-- | tests/pointing/rotate90/test.mk | 2 | ||||
-rw-r--r-- | tests/pointing/rotate90/test_rotate90.cpp | 60 | ||||
-rw-r--r-- | tests/pointing/test.mk | 4 | ||||
-rw-r--r-- | tests/pointing/test_pointing.cpp | 166 |
18 files changed, 515 insertions, 0 deletions
diff --git a/tests/pointing/config.h b/tests/pointing/config.h new file mode 100644 index 0000000000..76bbbe8dae --- /dev/null +++ b/tests/pointing/config.h @@ -0,0 +1,6 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" diff --git a/tests/pointing/invertandrotate/config.h b/tests/pointing/invertandrotate/config.h new file mode 100644 index 0000000000..a3f3df7a54 --- /dev/null +++ b/tests/pointing/invertandrotate/config.h @@ -0,0 +1,9 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" + +#define POINTING_DEVICE_INVERT_X +#define POINTING_DEVICE_ROTATION_90 diff --git a/tests/pointing/invertandrotate/test.mk b/tests/pointing/invertandrotate/test.mk new file mode 100644 index 0000000000..ba224d74f0 --- /dev/null +++ b/tests/pointing/invertandrotate/test.mk @@ -0,0 +1,2 @@ +POINTING_DEVICE_ENABLE = yes +POINTING_DEVICE_DRIVER = custom diff --git a/tests/pointing/invertandrotate/test_invertandrotate.cpp b/tests/pointing/invertandrotate/test_invertandrotate.cpp new file mode 100644 index 0000000000..b47739f415 --- /dev/null +++ b/tests/pointing/invertandrotate/test_invertandrotate.cpp @@ -0,0 +1,59 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "gtest/gtest.h" +#include "mouse_report_util.hpp" +#include "test_common.hpp" +#include "test_pointing_device_driver.h" + +using testing::_; + +struct SimpleReport { + int16_t x; + int16_t y; + int16_t h; + int16_t v; +}; + +class Pointing : public TestFixture {}; +class PointingInvertAndRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {}; + +TEST_P(PointingInvertAndRotateParametrized, PointingInvertAndRotateOrder) { + TestDriver driver; + SimpleReport input = GetParam().first; + SimpleReport expectations = GetParam().second; + + pd_set_x(input.x); + pd_set_y(input.y); + pd_set_h(input.h); + pd_set_v(input.v); + + EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0)); + run_one_scan_loop(); + + // EXPECT_EMPTY_MOUSE_REPORT(driver); + pd_clear_movement(); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} +// clang-format off +INSTANTIATE_TEST_CASE_P( + InvertAndRotate, + PointingInvertAndRotateParametrized, + ::testing::Values( + // Input Expected // Actual Result - Rotate 90 then Invert X + std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // LEFT - DOWN + std::make_pair(SimpleReport{ 0, -1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // UP - RIGHT + std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0, -1, 0, 0}), // RIGHT - UP + std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ -1, 0, 0, 0}) // DOWN - LEFT + // Input Expected // Invert X then Rotate 90 + // std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, -1, 0, 0}), // LEFT - UP + // std::make_pair(SimpleReport{ 0, -1, 0, 0}, SimpleReport{ -1, 0, 0, 0}), // UP - LEFT + // std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // RIGHT - DOWN + // std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 1, 0, 0, 0}) // DOWN - RIGHT + )); +// clang-format on diff --git a/tests/pointing/invertxy/config.h b/tests/pointing/invertxy/config.h new file mode 100644 index 0000000000..6b29185d37 --- /dev/null +++ b/tests/pointing/invertxy/config.h @@ -0,0 +1,9 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" + +#define POINTING_DEVICE_INVERT_X +#define POINTING_DEVICE_INVERT_Y diff --git a/tests/pointing/invertxy/test.mk b/tests/pointing/invertxy/test.mk new file mode 100644 index 0000000000..ba224d74f0 --- /dev/null +++ b/tests/pointing/invertxy/test.mk @@ -0,0 +1,2 @@ +POINTING_DEVICE_ENABLE = yes +POINTING_DEVICE_DRIVER = custom diff --git a/tests/pointing/invertxy/test_invertxy.cpp b/tests/pointing/invertxy/test_invertxy.cpp new file mode 100644 index 0000000000..014f6f3cd0 --- /dev/null +++ b/tests/pointing/invertxy/test_invertxy.cpp @@ -0,0 +1,53 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "gtest/gtest.h" +#include "mouse_report_util.hpp" +#include "test_common.hpp" +#include "test_pointing_device_driver.h" + +using testing::_; + +struct SimpleReport { + int16_t x; + int16_t y; + int16_t h; + int16_t v; +}; + +class Pointing : public TestFixture {}; +class PointingInvertXYParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {}; + +TEST_P(PointingInvertXYParametrized, PointingInvertXY) { + TestDriver driver; + SimpleReport input = GetParam().first; + SimpleReport expectations = GetParam().second; + + pd_set_x(input.x); + pd_set_y(input.y); + pd_set_h(input.h); + pd_set_v(input.v); + + EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0)); + run_one_scan_loop(); + + // EXPECT_EMPTY_MOUSE_REPORT(driver); + pd_clear_movement(); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} +// clang-format off +INSTANTIATE_TEST_CASE_P( + X_Y_XY, + PointingInvertXYParametrized, + ::testing::Values( + // Input Expected + std::make_pair(SimpleReport{ 33, 0, 0, 0}, SimpleReport{ -33, 0, 0, 0}), + std::make_pair(SimpleReport{ 0, -127, 0, 0}, SimpleReport{ 0, 127, 0, 0}), + std::make_pair(SimpleReport{ 10, -20, 0, 0}, SimpleReport{ -10, 20, 0, 0}) + )); +// clang-format on diff --git a/tests/pointing/rotate180/config.h b/tests/pointing/rotate180/config.h new file mode 100644 index 0000000000..a80f5482fd --- /dev/null +++ b/tests/pointing/rotate180/config.h @@ -0,0 +1,8 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" + +#define POINTING_DEVICE_ROTATION_180 diff --git a/tests/pointing/rotate180/test.mk b/tests/pointing/rotate180/test.mk new file mode 100644 index 0000000000..ba224d74f0 --- /dev/null +++ b/tests/pointing/rotate180/test.mk @@ -0,0 +1,2 @@ +POINTING_DEVICE_ENABLE = yes +POINTING_DEVICE_DRIVER = custom diff --git a/tests/pointing/rotate180/test_rotate180.cpp b/tests/pointing/rotate180/test_rotate180.cpp new file mode 100644 index 0000000000..736cf9ea25 --- /dev/null +++ b/tests/pointing/rotate180/test_rotate180.cpp @@ -0,0 +1,55 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "gtest/gtest.h" +#include "mouse_report_util.hpp" +#include "test_common.hpp" +#include "test_pointing_device_driver.h" + +using testing::_; + +struct SimpleReport { + int16_t x; + int16_t y; + int16_t h; + int16_t v; +}; + +class Pointing : public TestFixture {}; +class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {}; + +TEST_P(PointingRotateParametrized, PointingRotateXY) { + TestDriver driver; + SimpleReport input = GetParam().first; + SimpleReport expectations = GetParam().second; + + pd_set_x(input.x); + pd_set_y(input.y); + pd_set_h(input.h); + pd_set_v(input.v); + + EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0)); + run_one_scan_loop(); + + // EXPECT_EMPTY_MOUSE_REPORT(driver); + pd_clear_movement(); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} +// clang-format off +INSTANTIATE_TEST_CASE_P( + Rotate180, + PointingRotateParametrized, + ::testing::Values( + // Input Expected + // Rotate Clockwise + std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // UP - DOWN + std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // DOWN - UP + std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{-1, 0, 0, 0}), // RIGHT - LEFT + std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 1, 0, 0, 0}) // LEFT - RIGHT + )); +// clang-format on diff --git a/tests/pointing/rotate270/config.h b/tests/pointing/rotate270/config.h new file mode 100644 index 0000000000..3977dd95e6 --- /dev/null +++ b/tests/pointing/rotate270/config.h @@ -0,0 +1,8 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" + +#define POINTING_DEVICE_ROTATION_270 diff --git a/tests/pointing/rotate270/test.mk b/tests/pointing/rotate270/test.mk new file mode 100644 index 0000000000..ba224d74f0 --- /dev/null +++ b/tests/pointing/rotate270/test.mk @@ -0,0 +1,2 @@ +POINTING_DEVICE_ENABLE = yes +POINTING_DEVICE_DRIVER = custom diff --git a/tests/pointing/rotate270/test_rotate270.cpp b/tests/pointing/rotate270/test_rotate270.cpp new file mode 100644 index 0000000000..6735f06248 --- /dev/null +++ b/tests/pointing/rotate270/test_rotate270.cpp @@ -0,0 +1,60 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "gtest/gtest.h" +#include "mouse_report_util.hpp" +#include "test_common.hpp" +#include "test_pointing_device_driver.h" + +using testing::_; + +struct SimpleReport { + int16_t x; + int16_t y; + int16_t h; + int16_t v; +}; + +class Pointing : public TestFixture {}; +class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {}; + +TEST_P(PointingRotateParametrized, PointingRotateXY) { + TestDriver driver; + SimpleReport input = GetParam().first; + SimpleReport expectations = GetParam().second; + + pd_set_x(input.x); + pd_set_y(input.y); + pd_set_h(input.h); + pd_set_v(input.v); + + EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0)); + run_one_scan_loop(); + + // EXPECT_EMPTY_MOUSE_REPORT(driver); + pd_clear_movement(); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} +// clang-format off +INSTANTIATE_TEST_CASE_P( + Rotate270, + PointingRotateParametrized, + ::testing::Values( + // Input Expected + // Actual Result - Rotate Anticlockwise + std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // UP - RIGHT + std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // DOWN - LEFT + std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // RIGHT - DOWN + std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}) // LEFT - UP + // Rotate Clockwise + // std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // UP - LEFT + // std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // DOWN - RIGHT + // std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // RIGHT - UP + // std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}) // LEFT - DOWN + )); +// clang-format on diff --git a/tests/pointing/rotate90/config.h b/tests/pointing/rotate90/config.h new file mode 100644 index 0000000000..3a18ec92e9 --- /dev/null +++ b/tests/pointing/rotate90/config.h @@ -0,0 +1,8 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "test_common.h" + +#define POINTING_DEVICE_ROTATION_90 diff --git a/tests/pointing/rotate90/test.mk b/tests/pointing/rotate90/test.mk new file mode 100644 index 0000000000..ba224d74f0 --- /dev/null +++ b/tests/pointing/rotate90/test.mk @@ -0,0 +1,2 @@ +POINTING_DEVICE_ENABLE = yes +POINTING_DEVICE_DRIVER = custom diff --git a/tests/pointing/rotate90/test_rotate90.cpp b/tests/pointing/rotate90/test_rotate90.cpp new file mode 100644 index 0000000000..5c44faad0a --- /dev/null +++ b/tests/pointing/rotate90/test_rotate90.cpp @@ -0,0 +1,60 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "gtest/gtest.h" +#include "mouse_report_util.hpp" +#include "test_common.hpp" +#include "test_pointing_device_driver.h" + +using testing::_; + +struct SimpleReport { + int16_t x; + int16_t y; + int16_t h; + int16_t v; +}; + +class Pointing : public TestFixture {}; +class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {}; + +TEST_P(PointingRotateParametrized, PointingRotateXY) { + TestDriver driver; + SimpleReport input = GetParam().first; + SimpleReport expectations = GetParam().second; + + pd_set_x(input.x); + pd_set_y(input.y); + pd_set_h(input.h); + pd_set_v(input.v); + + EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0)); + run_one_scan_loop(); + + // EXPECT_EMPTY_MOUSE_REPORT(driver); + pd_clear_movement(); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} +// clang-format off +INSTANTIATE_TEST_CASE_P( + Rotate90, + PointingRotateParametrized, + ::testing::Values( + // Input Expected + // Actual Result - Rotate Anticlockwise + std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // UP - LEFT + std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // DOWN - RIGHT + std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // RIGHT - UP + std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}) // LEFT - DOWN + // Rotate Clockwise + // std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // UP - RIGHT + // std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // DOWN - LEFT + // std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // RIGHT - DOWN + // std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}) // LEFT - UP + )); +// clang-format on diff --git a/tests/pointing/test.mk b/tests/pointing/test.mk new file mode 100644 index 0000000000..95fde21cb9 --- /dev/null +++ b/tests/pointing/test.mk @@ -0,0 +1,4 @@ +POINTING_DEVICE_ENABLE = yes +MOUSEKEY_ENABLE = no +POINTING_DEVICE_DRIVER = custom + diff --git a/tests/pointing/test_pointing.cpp b/tests/pointing/test_pointing.cpp new file mode 100644 index 0000000000..d59d014925 --- /dev/null +++ b/tests/pointing/test_pointing.cpp @@ -0,0 +1,166 @@ +// Copyright 2024 Dasky (@daskygit) +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "gtest/gtest.h" +#include "mouse_report_util.hpp" +#include "test_common.hpp" +#include "test_pointing_device_driver.h" +#include "mousekey.h" + +using testing::_; + +class Pointing : public TestFixture {}; +class PointingButtonsViaMousekeysParametrized : public ::testing::WithParamInterface<std::pair<KeymapKey, uint8_t>>, public Pointing {}; + +TEST_F(Pointing, SendMouseIsNotCalledWithNoInput) { + TestDriver driver; + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); +} + +TEST_F(Pointing, Xnegative) { + TestDriver driver; + + pd_set_x(-10); + EXPECT_MOUSE_REPORT(driver, (-10, 0, 0, 0, 0)); + run_one_scan_loop(); + + pd_clear_movement(); + // EXPECT_EMPTY_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Pointing, Xpositive) { + TestDriver driver; + + pd_set_x(10); + EXPECT_MOUSE_REPORT(driver, (10, 0, 0, 0, 0)); + run_one_scan_loop(); + + pd_clear_movement(); + // EXPECT_EMPTY_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Pointing, Ynegative) { + TestDriver driver; + + pd_set_y(-20); + EXPECT_MOUSE_REPORT(driver, (0, -20, 0, 0, 0)); + run_one_scan_loop(); + + pd_clear_movement(); + // EXPECT_EMPTY_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Pointing, Ypositive) { + TestDriver driver; + + pd_set_y(20); + EXPECT_MOUSE_REPORT(driver, (0, 20, 0, 0, 0)); + run_one_scan_loop(); + + pd_clear_movement(); + // EXPECT_EMPTY_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Pointing, XandY) { + TestDriver driver; + + pd_set_x(-50); + pd_set_y(100); + EXPECT_MOUSE_REPORT(driver, (-50, 100, 0, 0, 0)); + run_one_scan_loop(); + + pd_clear_movement(); + // EXPECT_EMPTY_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Pointing, CorrectButtonIsReportedWhenPressed) { + TestDriver driver; + + EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1)); + pd_press_button(POINTING_DEVICE_BUTTON1); + run_one_scan_loop(); + + EXPECT_EMPTY_MOUSE_REPORT(driver); + pd_release_button(POINTING_DEVICE_BUTTON1); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + pd_clear_all_buttons(); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_F(Pointing, CorrectButtonIsReportedWhenKeyPressed) { + TestDriver driver; + auto key = KeymapKey(0, 0, 0, KC_MS_BTN1); + set_keymap({key}); + + EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1)); + key.press(); + run_one_scan_loop(); + + EXPECT_EMPTY_MOUSE_REPORT(driver); + key.release(); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} + +TEST_P(PointingButtonsViaMousekeysParametrized, MouseKeysViaPointingDriver) { + TestDriver driver; + KeymapKey mouse_key = GetParam().first; + uint8_t button_mask = GetParam().second; + + set_keymap({mouse_key}); + + EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, button_mask)); + mouse_key.press(); + run_one_scan_loop(); + + EXPECT_EMPTY_MOUSE_REPORT(driver); + mouse_key.release(); + run_one_scan_loop(); + + EXPECT_NO_MOUSE_REPORT(driver); + run_one_scan_loop(); + + VERIFY_AND_CLEAR(driver); +} +// clang-format off +INSTANTIATE_TEST_CASE_P( + ButtonsOneToEight, + PointingButtonsViaMousekeysParametrized, + ::testing::Values( + // Key , Buttons Mask + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, 1), + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_2}, 2), + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_3}, 4), + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_4}, 8), + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_5}, 16), + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_6}, 32), + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_7}, 64), + std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_8}, 128) + )); +// clang-format on |