logo

qmk_firmware

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

test_housekeeping.cpp (1957B)


  1. /* Copyright 2024 leep-frog
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include "keyboard_report_util.hpp"
  17. #include "keycode.h"
  18. #include "test_common.hpp"
  19. #include "action_tapping.h"
  20. #include "test_keymap_key.hpp"
  21. using testing::_;
  22. class HousekeepingMock {
  23. public:
  24. virtual ~HousekeepingMock() {}
  25. // mock methods
  26. MOCK_METHOD0(housekeeping_task_kb, void(void));
  27. MOCK_METHOD0(housekeeping_task_user, void(void));
  28. };
  29. class Housekeeping : public TestFixture {
  30. public:
  31. Housekeeping() {
  32. _housekeepingMock.reset(new ::testing::NiceMock<HousekeepingMock>());
  33. }
  34. virtual ~Housekeeping() {
  35. _housekeepingMock.reset();
  36. }
  37. static std::unique_ptr<HousekeepingMock> _housekeepingMock;
  38. };
  39. std::unique_ptr<HousekeepingMock> Housekeeping::_housekeepingMock;
  40. extern "C" {
  41. void housekeeping_task_kb(void) {
  42. if (Housekeeping::_housekeepingMock) {
  43. Housekeeping::_housekeepingMock->housekeeping_task_kb();
  44. }
  45. }
  46. void housekeeping_task_user(void) {
  47. if (Housekeeping::_housekeepingMock) {
  48. Housekeeping::_housekeepingMock->housekeeping_task_user();
  49. }
  50. }
  51. }
  52. TEST_F(Housekeeping, Works) {
  53. TestDriver driver;
  54. EXPECT_CALL(*_housekeepingMock, housekeeping_task_kb()).Times(1);
  55. EXPECT_CALL(*_housekeepingMock, housekeeping_task_user()).Times(1);
  56. run_one_scan_loop();
  57. }