summaryrefslogtreecommitdiff
path: root/tests/pointing/rotate270
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pointing/rotate270')
-rw-r--r--tests/pointing/rotate270/config.h8
-rw-r--r--tests/pointing/rotate270/test.mk2
-rw-r--r--tests/pointing/rotate270/test_rotate270.cpp60
3 files changed, 70 insertions, 0 deletions
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 @@
1// Copyright 2024 Dasky (@daskygit)
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "test_common.h"
7
8#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 @@
1POINTING_DEVICE_ENABLE = yes
2POINTING_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 @@
1// Copyright 2024 Dasky (@daskygit)
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "gtest/gtest.h"
5#include "mouse_report_util.hpp"
6#include "test_common.hpp"
7#include "test_pointing_device_driver.h"
8
9using testing::_;
10
11struct SimpleReport {
12 int16_t x;
13 int16_t y;
14 int16_t h;
15 int16_t v;
16};
17
18class Pointing : public TestFixture {};
19class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
20
21TEST_P(PointingRotateParametrized, PointingRotateXY) {
22 TestDriver driver;
23 SimpleReport input = GetParam().first;
24 SimpleReport expectations = GetParam().second;
25
26 pd_set_x(input.x);
27 pd_set_y(input.y);
28 pd_set_h(input.h);
29 pd_set_v(input.v);
30
31 EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
32 run_one_scan_loop();
33
34 // EXPECT_EMPTY_MOUSE_REPORT(driver);
35 pd_clear_movement();
36 run_one_scan_loop();
37
38 EXPECT_NO_MOUSE_REPORT(driver);
39 run_one_scan_loop();
40
41 VERIFY_AND_CLEAR(driver);
42}
43// clang-format off
44INSTANTIATE_TEST_CASE_P(
45 Rotate270,
46 PointingRotateParametrized,
47 ::testing::Values(
48 // Input Expected
49 // Actual Result - Rotate Anticlockwise
50 std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // UP - RIGHT
51 std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // DOWN - LEFT
52 std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // RIGHT - DOWN
53 std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}) // LEFT - UP
54 // Rotate Clockwise
55 // std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // UP - LEFT
56 // std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // DOWN - RIGHT
57 // std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // RIGHT - UP
58 // std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}) // LEFT - DOWN
59 ));
60// clang-format on