Diff
1diff --git a/tests/housekeeping/config.h b/tests/housekeeping/config.h
2new file mode 100644
3index 0000000000000000000000000000000000000000..bf1f8cd27fb1b187890a3967ec352b706ec72e5b
4--- /dev/null
5+++ b/tests/housekeeping/config.h
6@@ -0,0 +1,19 @@
7+/* Copyright 2024 leep-frog
8+ *
9+ * This program is free software: you can redistribute it and/or modify
10+ * it under the terms of the GNU General Public License as published by
11+ * the Free Software Foundation, either version 2 of the License, or
12+ * (at your option) any later version.
13+ *
14+ * This program is distributed in the hope that it will be useful,
15+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
16+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17+ * GNU General Public License for more details.
18+ *
19+ * You should have received a copy of the GNU General Public License
20+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
21+ */
22+
23+#pragma once
24+
25+#include "test_common.h"
26diff --git a/tests/housekeeping/test.mk b/tests/housekeeping/test.mk
27new file mode 100644
28index 0000000000000000000000000000000000000000..bf46b735ce88faa2540f0876809d1bd607c5c002
29--- /dev/null
30+++ b/tests/housekeeping/test.mk
31@@ -0,0 +1,18 @@
32+# Copyright 2024 leep-frog
33+#
34+# This program is free software: you can redistribute it and/or modify
35+# it under the terms of the GNU General Public License as published by
36+# the Free Software Foundation, either version 2 of the License, or
37+# (at your option) any later version.
38+#
39+# This program is distributed in the hope that it will be useful,
40+# but WITHOUT ANY WARRANTY; without even the implied warranty of
41+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
42+# GNU General Public License for more details.
43+#
44+# You should have received a copy of the GNU General Public License
45+# along with this program. If not, see <http://www.gnu.org/licenses/>.
46+
47+# --------------------------------------------------------------------------------
48+# Keep this file, even if it is empty, as a marker that this folder contains tests
49+# --------------------------------------------------------------------------------
50diff --git a/tests/housekeeping/test_housekeeping.cpp b/tests/housekeeping/test_housekeeping.cpp
51new file mode 100644
52index 0000000000000000000000000000000000000000..6f1e6a62841d7ad4228f5f27f5675d4eff23f2dd
53--- /dev/null
54+++ b/tests/housekeeping/test_housekeeping.cpp
55@@ -0,0 +1,68 @@
56+/* Copyright 2024 leep-frog
57+ *
58+ * This program is free software: you can redistribute it and/or modify
59+ * it under the terms of the GNU General Public License as published by
60+ * the Free Software Foundation, either version 2 of the License, or
61+ * (at your option) any later version.
62+ *
63+ * This program is distributed in the hope that it will be useful,
64+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
65+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
66+ * GNU General Public License for more details.
67+ *
68+ * You should have received a copy of the GNU General Public License
69+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
70+ */
71+
72+#include "keyboard_report_util.hpp"
73+#include "keycode.h"
74+#include "test_common.hpp"
75+#include "action_tapping.h"
76+#include "test_keymap_key.hpp"
77+
78+using testing::_;
79+
80+class HousekeepingMock {
81+ public:
82+ virtual ~HousekeepingMock() {}
83+
84+ // mock methods
85+ MOCK_METHOD0(housekeeping_task_kb, void(void));
86+ MOCK_METHOD0(housekeeping_task_user, void(void));
87+};
88+
89+class Housekeeping : public TestFixture {
90+ public:
91+ Housekeeping() {
92+ _housekeepingMock.reset(new ::testing::NiceMock<HousekeepingMock>());
93+ }
94+ virtual ~Housekeeping() {
95+ _housekeepingMock.reset();
96+ }
97+
98+ static std::unique_ptr<HousekeepingMock> _housekeepingMock;
99+};
100+
101+std::unique_ptr<HousekeepingMock> Housekeeping::_housekeepingMock;
102+
103+extern "C" {
104+void housekeeping_task_kb(void) {
105+ if (Housekeeping::_housekeepingMock) {
106+ Housekeeping::_housekeepingMock->housekeeping_task_kb();
107+ }
108+}
109+
110+void housekeeping_task_user(void) {
111+ if (Housekeeping::_housekeepingMock) {
112+ Housekeeping::_housekeepingMock->housekeeping_task_user();
113+ }
114+}
115+}
116+
117+TEST_F(Housekeeping, Works) {
118+ TestDriver driver;
119+
120+ EXPECT_CALL(*_housekeepingMock, housekeeping_task_kb()).Times(1);
121+ EXPECT_CALL(*_housekeepingMock, housekeeping_task_user()).Times(1);
122+ run_one_scan_loop();
123+}
124diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
125index 72763d0bc08cb5018526047a004c2cb612e7bc18..3cfb2cb4c29235c499bf2c18fbefb5d8406215bd 100644
126--- a/tests/test_common/test_fixture.cpp
127+++ b/tests/test_common/test_fixture.cpp
128@@ -58,7 +58,8 @@ void TestFixture::TearDownTestCase() {}
129 TestFixture::TestFixture() {
130 m_this = this;
131 timer_clear();
132- test_logger.info() << "tapping term is " << +GET_TAPPING_TERM(KC_TRANSPARENT, &(keyrecord_t){}) << "ms" << std::endl;
133+ keyrecord_t empty_keyrecord = {0};
134+ test_logger.info() << "tapping term is " << +GET_TAPPING_TERM(KC_TRANSPARENT, &empty_keyrecord) << "ms" << std::endl;
135 }
136
137 TestFixture::~TestFixture() {
138@@ -175,6 +176,7 @@ void TestFixture::idle_for(unsigned time) {
139 test_logger.trace() << +time << " keyboard task " << (time > 1 ? "loops" : "loop") << std::endl;
140 for (unsigned i = 0; i < time; i++) {
141 keyboard_task();
142+ housekeeping_task();
143 advance_time(1);
144 }
145 }