logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

test_invertxy.cpp (1552B)


  1. // Copyright 2024 Dasky (@daskygit)
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #include "gtest/gtest.h"
  4. #include "mouse_report_util.hpp"
  5. #include "test_common.hpp"
  6. #include "test_pointing_device_driver.h"
  7. using testing::_;
  8. struct SimpleReport {
  9. int16_t x;
  10. int16_t y;
  11. int16_t h;
  12. int16_t v;
  13. };
  14. class Pointing : public TestFixture {};
  15. class PointingInvertXYParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
  16. TEST_P(PointingInvertXYParametrized, PointingInvertXY) {
  17. TestDriver driver;
  18. SimpleReport input = GetParam().first;
  19. SimpleReport expectations = GetParam().second;
  20. pd_set_x(input.x);
  21. pd_set_y(input.y);
  22. pd_set_h(input.h);
  23. pd_set_v(input.v);
  24. EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
  25. run_one_scan_loop();
  26. // EXPECT_EMPTY_MOUSE_REPORT(driver);
  27. pd_clear_movement();
  28. run_one_scan_loop();
  29. EXPECT_NO_MOUSE_REPORT(driver);
  30. run_one_scan_loop();
  31. VERIFY_AND_CLEAR(driver);
  32. }
  33. // clang-format off
  34. INSTANTIATE_TEST_CASE_P(
  35. X_Y_XY,
  36. PointingInvertXYParametrized,
  37. ::testing::Values(
  38. // Input Expected
  39. std::make_pair(SimpleReport{ 33, 0, 0, 0}, SimpleReport{ -33, 0, 0, 0}),
  40. std::make_pair(SimpleReport{ 0, -127, 0, 0}, SimpleReport{ 0, 127, 0, 0}),
  41. std::make_pair(SimpleReport{ 10, -20, 0, 0}, SimpleReport{ -10, 20, 0, 0})
  42. ));
  43. // clang-format on