keyboard stuff
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 Rotate180,
46 PointingRotateParametrized,
47 ::testing::Values(
48 // Input Expected
49 // Rotate Clockwise
50 std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // UP - DOWN
51 std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // DOWN - UP
52 std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{-1, 0, 0, 0}), // RIGHT - LEFT
53 std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 1, 0, 0, 0}) // LEFT - RIGHT
54 ));
55// clang-format on