Merge remote-tracking branch 'origin/develop' into xap
This commit is contained in:
commit
2d9bfa2a3b
29 changed files with 917 additions and 0 deletions
|
|
@ -21,8 +21,10 @@ $(TEST_OUTPUT)_SRC := \
|
|||
$(SRC) \
|
||||
$(QUANTUM_PATH)/keymap_introspection.c \
|
||||
tests/test_common/matrix.c \
|
||||
tests/test_common/pointing_device_driver.c \
|
||||
tests/test_common/test_driver.cpp \
|
||||
tests/test_common/keyboard_report_util.cpp \
|
||||
tests/test_common/mouse_report_util.cpp \
|
||||
tests/test_common/keycode_util.cpp \
|
||||
tests/test_common/keycode_table.cpp \
|
||||
tests/test_common/test_fixture.cpp \
|
||||
|
|
|
|||
6
tests/mousekeys/config.h
Normal file
6
tests/mousekeys/config.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright 2024 Dasky (@daskygit)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
||||
1
tests/mousekeys/test.mk
Normal file
1
tests/mousekeys/test.mk
Normal file
|
|
@ -0,0 +1 @@
|
|||
MOUSEKEY_ENABLE = yes
|
||||
109
tests/mousekeys/test_mousekeys.cpp
Normal file
109
tests/mousekeys/test_mousekeys.cpp
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
// 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"
|
||||
|
||||
using testing::_;
|
||||
|
||||
struct MouseKeyExpectations {
|
||||
int16_t x;
|
||||
int16_t y;
|
||||
int16_t h;
|
||||
int16_t v;
|
||||
uint16_t button_mask;
|
||||
};
|
||||
|
||||
class Mousekey : public TestFixture {};
|
||||
class MousekeyParametrized : public ::testing::WithParamInterface<std::pair<KeymapKey, MouseKeyExpectations>>, public Mousekey {};
|
||||
|
||||
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;
|
||||
|
||||
set_keymap({mouse_key});
|
||||
|
||||
EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, expectations.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(
|
||||
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}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_2}, MouseKeyExpectations{ 0, 0, 0, 0, 2}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_3}, MouseKeyExpectations{ 0, 0, 0, 0, 4}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_4}, MouseKeyExpectations{ 0, 0, 0, 0, 8}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_5}, MouseKeyExpectations{ 0, 0, 0, 0, 16}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_6}, MouseKeyExpectations{ 0, 0, 0, 0, 32}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_7}, MouseKeyExpectations{ 0, 0, 0, 0, 64}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_8}, MouseKeyExpectations{ 0, 0, 0, 0, 128}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_UP}, MouseKeyExpectations{ 0,-8, 0, 0, 0}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_DOWN}, MouseKeyExpectations{ 0, 8, 0, 0, 0}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_LEFT}, MouseKeyExpectations{-8, 0, 0, 0, 0}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_RIGHT}, MouseKeyExpectations{ 8, 0, 0, 0, 0}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_UP}, MouseKeyExpectations{ 0, 0, 0, 1, 0}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_DOWN}, MouseKeyExpectations{ 0, 0, 0,-1, 0}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_LEFT}, MouseKeyExpectations{ 0, 0,-1, 0, 0}),
|
||||
std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_RIGHT}, MouseKeyExpectations{ 0, 0, 1, 0, 0})
|
||||
));
|
||||
// clang-format on
|
||||
6
tests/pointing/config.h
Normal file
6
tests/pointing/config.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// Copyright 2024 Dasky (@daskygit)
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "test_common.h"
|
||||
9
tests/pointing/invertandrotate/config.h
Normal file
9
tests/pointing/invertandrotate/config.h
Normal file
|
|
@ -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
|
||||
2
tests/pointing/invertandrotate/test.mk
Normal file
2
tests/pointing/invertandrotate/test.mk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
POINTING_DEVICE_ENABLE = yes
|
||||
POINTING_DEVICE_DRIVER = custom
|
||||
59
tests/pointing/invertandrotate/test_invertandrotate.cpp
Normal file
59
tests/pointing/invertandrotate/test_invertandrotate.cpp
Normal file
|
|
@ -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
|
||||
9
tests/pointing/invertxy/config.h
Normal file
9
tests/pointing/invertxy/config.h
Normal file
|
|
@ -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
|
||||
2
tests/pointing/invertxy/test.mk
Normal file
2
tests/pointing/invertxy/test.mk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
POINTING_DEVICE_ENABLE = yes
|
||||
POINTING_DEVICE_DRIVER = custom
|
||||
53
tests/pointing/invertxy/test_invertxy.cpp
Normal file
53
tests/pointing/invertxy/test_invertxy.cpp
Normal file
|
|
@ -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
|
||||
8
tests/pointing/rotate180/config.h
Normal file
8
tests/pointing/rotate180/config.h
Normal file
|
|
@ -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
|
||||
2
tests/pointing/rotate180/test.mk
Normal file
2
tests/pointing/rotate180/test.mk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
POINTING_DEVICE_ENABLE = yes
|
||||
POINTING_DEVICE_DRIVER = custom
|
||||
55
tests/pointing/rotate180/test_rotate180.cpp
Normal file
55
tests/pointing/rotate180/test_rotate180.cpp
Normal file
|
|
@ -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
|
||||
8
tests/pointing/rotate270/config.h
Normal file
8
tests/pointing/rotate270/config.h
Normal file
|
|
@ -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
|
||||
2
tests/pointing/rotate270/test.mk
Normal file
2
tests/pointing/rotate270/test.mk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
POINTING_DEVICE_ENABLE = yes
|
||||
POINTING_DEVICE_DRIVER = custom
|
||||
60
tests/pointing/rotate270/test_rotate270.cpp
Normal file
60
tests/pointing/rotate270/test_rotate270.cpp
Normal file
|
|
@ -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
|
||||
8
tests/pointing/rotate90/config.h
Normal file
8
tests/pointing/rotate90/config.h
Normal file
|
|
@ -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
|
||||
2
tests/pointing/rotate90/test.mk
Normal file
2
tests/pointing/rotate90/test.mk
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
POINTING_DEVICE_ENABLE = yes
|
||||
POINTING_DEVICE_DRIVER = custom
|
||||
60
tests/pointing/rotate90/test_rotate90.cpp
Normal file
60
tests/pointing/rotate90/test_rotate90.cpp
Normal file
|
|
@ -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
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue