mirror of
https://github.com/qmk/qmk_firmware.git
synced 2024-11-22 03:19:24 +00:00
check invert and rotate ordering
This commit is contained in:
parent
ab0029e2b8
commit
4bc3014fa6
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
|
Loading…
Reference in New Issue
Block a user