diff --git a/testing/SimHarness.cpp b/testing/SimHarness.cpp
index 090fada8..7c174c66 100644
--- a/testing/SimHarness.cpp
+++ b/testing/SimHarness.cpp
@@ -14,7 +14,6 @@
* this program. If not, see .
*/
-#include "Kaleidoscope.h"
#include "testing/SimHarness.h"
#include "testing/fix-macros.h"
@@ -31,17 +30,25 @@ void SimHarness::RunCycles(size_t n) {
for (size_t i = 0; i < n; ++i) RunCycle();
}
-void SimHarness::Press(uint8_t row, uint8_t col) {
+void SimHarness::Press(KeyAddr key_addr) {
Kaleidoscope.device().keyScanner().setKeystate(
- KeyAddr{row, col},
+ key_addr,
kaleidoscope::Device::Props::KeyScanner::KeyState::Pressed);
}
-void SimHarness::Release(uint8_t row, uint8_t col) {
+void SimHarness::Release(KeyAddr key_addr) {
Kaleidoscope.device().keyScanner().setKeystate(
- KeyAddr{row, col},
+ key_addr,
kaleidoscope::Device::Props::KeyScanner::KeyState::NotPressed);
}
+void SimHarness::Press(uint8_t row, uint8_t col) {
+ Press(KeyAddr{row, col});
+}
+
+void SimHarness::Release(uint8_t row, uint8_t col) {
+ Release(KeyAddr{row, col});
+}
+
} // namespace testing
} // namespace kaleidoscope
diff --git a/testing/SimHarness.h b/testing/SimHarness.h
index 06217eff..c850d671 100644
--- a/testing/SimHarness.h
+++ b/testing/SimHarness.h
@@ -19,6 +19,9 @@
#include
#include
+#include "Kaleidoscope.h"
+#include "testing/fix-macros.h"
+
namespace kaleidoscope {
namespace testing {
@@ -27,6 +30,8 @@ class SimHarness {
void RunCycle();
void RunCycles(size_t n);
+ void Press(KeyAddr key_addr);
+ void Release(KeyAddr key_addr);
void Press(uint8_t row, uint8_t col);
void Release(uint8_t row, uint8_t col);
};
diff --git a/tests/examples/basic-keypress/test/testcase.cpp b/tests/examples/basic-keypress/test/testcase.cpp
index e9b06723..5c0a6cb8 100644
--- a/tests/examples/basic-keypress/test/testcase.cpp
+++ b/tests/examples/basic-keypress/test/testcase.cpp
@@ -15,6 +15,7 @@
*/
#include "testing/setup-googletest.h"
+#include "Kaleidoscope.h"
SETUP_GOOGLETEST();
@@ -22,12 +23,14 @@ namespace kaleidoscope {
namespace testing {
namespace {
+constexpr KeyAddr key_addr_A{2, 1};
+
using ::testing::IsEmpty;
class KeyboardReports : public VirtualDeviceTest {};
TEST_F(KeyboardReports, KeysActiveWhenPressed) {
- sim_.Press(2, 1); // A
+ sim_.Press(key_addr_A); // A
auto state = RunCycle();
ASSERT_EQ(state->HIDReports()->Keyboard().size(), 1);
@@ -35,7 +38,7 @@ TEST_F(KeyboardReports, KeysActiveWhenPressed) {
state->HIDReports()->Keyboard(0).ActiveKeycodes(),
Contains(Key_A));
- sim_.Release(2, 1); // A
+ sim_.Release(key_addr_A); // A
state = RunCycle();
ASSERT_EQ(state->HIDReports()->Keyboard().size(), 1);