mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-24 18:11:14 +00:00
move mousekey tests
This commit is contained in:
parent
0fe775fdf9
commit
8716256fba
1
tests/mousekeys/test.mk
Normal file
1
tests/mousekeys/test.mk
Normal file
@ -0,0 +1 @@
|
|||||||
|
MOUSEKEY_ENABLE = yes
|
@ -4,7 +4,6 @@
|
|||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "mouse_report_util.hpp"
|
#include "mouse_report_util.hpp"
|
||||||
#include "test_common.hpp"
|
#include "test_common.hpp"
|
||||||
#include "test_pointing_device_driver.h"
|
|
||||||
|
|
||||||
using testing::_;
|
using testing::_;
|
||||||
|
|
||||||
@ -16,10 +15,55 @@ struct MouseKeyExpectations {
|
|||||||
uint16_t button_mask;
|
uint16_t button_mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Pointing : public TestFixture {};
|
class Mousekey : public TestFixture {};
|
||||||
class PointingKeycodesParametrizedTestFixture : public ::testing::WithParamInterface<std::pair<KeymapKey, MouseKeyExpectations>>, public Pointing {};
|
class MousekeyParametrized : public ::testing::WithParamInterface<std::pair<KeymapKey, MouseKeyExpectations>>, 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;
|
TestDriver driver;
|
||||||
KeymapKey mouse_key = GetParam().first;
|
KeymapKey mouse_key = GetParam().first;
|
||||||
MouseKeyExpectations expectations = GetParam().second;
|
MouseKeyExpectations expectations = GetParam().second;
|
||||||
@ -41,8 +85,8 @@ TEST_P(PointingKeycodesParametrizedTestFixture, PointingMouseKeysViaPointingDriv
|
|||||||
}
|
}
|
||||||
// clang-format off
|
// clang-format off
|
||||||
INSTANTIATE_TEST_CASE_P(
|
INSTANTIATE_TEST_CASE_P(
|
||||||
PointingMouseKeysOnlyTests,
|
Keys,
|
||||||
PointingKeycodesParametrizedTestFixture,
|
MousekeyParametrized,
|
||||||
::testing::Values(
|
::testing::Values(
|
||||||
// Key , X, Y, H, V, Buttons Mask
|
// Key , X, Y, H, V, Buttons Mask
|
||||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, MouseKeyExpectations{ 0, 0, 0, 0, 1}),
|
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, MouseKeyExpectations{ 0, 0, 0, 0, 1}),
|
@ -1,5 +0,0 @@
|
|||||||
POINTING_DEVICE_ENABLE = no
|
|
||||||
MOUSEKEY_ENABLE = yes
|
|
||||||
POINTING_DEVICE_DRIVER = custom
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user