logo

qmk_firmware

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

test_rotate180.cpp (1699B)


  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 PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
  16. TEST_P(PointingRotateParametrized, PointingRotateXY) {
  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. Rotate180,
  36. PointingRotateParametrized,
  37. ::testing::Values(
  38. // Input Expected
  39. // Rotate Clockwise
  40. std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // UP - DOWN
  41. std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // DOWN - UP
  42. std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{-1, 0, 0, 0}), // RIGHT - LEFT
  43. std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 1, 0, 0, 0}) // LEFT - RIGHT
  44. ));
  45. // clang-format on