aboutsummaryrefslogtreecommitdiff
path: root/tests/pointing/rotate180/test_rotate180.cpp
diff options
context:
space:
mode:
authorNick Brassel <[email protected]>2024-11-27 21:29:12 +1100
committerNick Brassel <[email protected]>2024-11-27 21:29:12 +1100
commit9f76541b29056150cf57d69569a14a59e13995c7 (patch)
tree66c7398d873fcda88aebe3090603aefe045ff52e /tests/pointing/rotate180/test_rotate180.cpp
parent57be4871616ee9a8fe042f6186010d436ec7d4b1 (diff)
parenteb04b94eecbb9b3e64ca9c74f937b5f762440b17 (diff)
downloadqmk_firmware-9f76541b29056150cf57d69569a14a59e13995c7.tar.gz
qmk_firmware-9f76541b29056150cf57d69569a14a59e13995c7.zip
Merge branch 'develop'0.27.0
Diffstat (limited to 'tests/pointing/rotate180/test_rotate180.cpp')
-rw-r--r--tests/pointing/rotate180/test_rotate180.cpp55
1 files changed, 55 insertions, 0 deletions
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