diff --git a/fake-gtest/src/fake-gtest.h b/fake-gtest/src/fake-gtest.h
deleted file mode 100644
index 1f2271c1..00000000
--- a/fake-gtest/src/fake-gtest.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma once
-// Fake file to trick arduino-builder into working.
diff --git a/fake-gtest/src/setup-googletest.h b/fake-gtest/src/setup-googletest.h
new file mode 100644
index 00000000..3ee6624a
--- /dev/null
+++ b/fake-gtest/src/setup-googletest.h
@@ -0,0 +1,33 @@
+/* -*- mode: c++ -*-
+ * Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+// Fake file to trick arduino-builder into working.
+
+#pragma once
+
+#undef min
+#undef max
+#undef T
+#undef U
+
+#include "gtest/gtest.h"
+
+#define SETUP_GOOGLETEST() \
+ void executeTestFunction() { \
+ setup(); /* setup Kaleidoscope */ \
+ testing::InitGoogleTest(); \
+ RUN_ALL_TESTS(); \
+ }
diff --git a/src/kaleidoscope/sim/Sim.cpp b/src/kaleidoscope/sim/Sim.cpp
new file mode 100644
index 00000000..8e78aa51
--- /dev/null
+++ b/src/kaleidoscope/sim/Sim.cpp
@@ -0,0 +1,23 @@
+/* kailedoscope::sim - Simulator for Unit Testing Kaleidoscope
+ * Copyright (C) 2020 epan
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#include "kaleidoscope/sim/Sim.h"
+
+namespace kaleidoscope {
+namespace sim {
+
+} // namespace sim
+} // namespace kaleidoscope
diff --git a/src/kaleidoscope/sim/Sim.h b/src/kaleidoscope/sim/Sim.h
new file mode 100644
index 00000000..74cd31b0
--- /dev/null
+++ b/src/kaleidoscope/sim/Sim.h
@@ -0,0 +1,32 @@
+/* kailedoscope::sim - Simulator for Unit Testing Kaleidoscope
+ * Copyright (C) 2020 epan
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#ifdef KALEIDOSCOPE_VIRTUAL_BUILD
+
+#pragma once
+
+namespace kaleidoscope {
+namespace sim {
+
+class Sim {
+ public:
+
+};
+
+} // namespace sim
+} // namespace kaleidoscope
+
+#endif // KALEIDOSCOPE_VIRTUAL_BUILD
diff --git a/testing/common/VirtualDeviceTest.h b/testing/common/VirtualDeviceTest.h
new file mode 100644
index 00000000..45453c77
--- /dev/null
+++ b/testing/common/VirtualDeviceTest.h
@@ -0,0 +1,78 @@
+/* -*- mode: c++ -*-
+ * Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#ifdef KALEIDOSCOPE_VIRTUAL_BUILD
+
+#pragma once
+
+#include "./Logging.h"
+
+#include "HID-Settings.h"
+
+namespace kaleidoscope {
+namespace testing {
+
+class VirtualDeviceTest : public ::testing::Test {
+ protected:
+ void SetUp() {
+ HIDReportObserver
+ }
+
+ void Press(uint8_t row, uint8_t, col) {
+ Kaleidoscope.device().keyScanner().setKeystate(
+ KeyAddr{row, col},
+ Kaleidoscope::Device::Props::keyScanner::KeyState::Pressed);
+ }
+
+ private:
+ template
+ void ProcessReport(const R& report) {
+ observer_RecordReport(report);
+ }
+
+ template
+ void RecordReport(const R& report);
+
+ template <>
+ void RecordReport(const MouseReport& report) {
+ mouse_reports_.push_back(report);
+ }
+
+ template <>
+ void RecordReport(const BootKeyboardReport& report) {
+ boot_keyboard_reports_.push_back(report);
+ }
+
+ template <>
+ void RecordReport(const AbsoluteMouseReport& report) {
+ absolute_mouse_reports_.push_back(report);
+ }
+
+ template <>
+ void RecordReport(const KeyboardReport& report) {
+ keyboard_reports_.push_back(report);
+ }
+
+ std::vector mouse_reports_;
+ std::vector boot_keyboard_reports_;
+ std::vector absolute_mouse_reports_;
+ std::vector keyboard_reports_;
+};
+
+} // namespace testing
+} // namespace kaleidoscope
+
+#endif // KALEIDOSCOPE_VIRTUAL_BUILD
diff --git a/testing/common/observer/Observer.h b/testing/common/observer/Observer.h
new file mode 100644
index 00000000..3d67f0eb
--- /dev/null
+++ b/testing/common/observer/Observer.h
@@ -0,0 +1,90 @@
+/* -*- mode: c++ -*-
+ * Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#ifdef KALEIDOSCOPE_VIRTUAL_BUILD
+
+#pragma once
+
+#include "./Logging.h"
+
+#include "HID-Settings.h"
+
+namespace kaleidoscope {
+namespace testing {
+
+class Observer {
+ public:
+ void ProcessHidReport(uint8_t id, const void* data, int len, int result) {
+ switch (id) {
+ case HID_REPORTID_MOUSE: {
+ ProcessReport(MouseReport{data});
+ break;
+ }
+ case HID_REPORTID_KEYBOARD: {
+ ProcessReport(BootKeyboardReport{data});
+ break;
+ }
+ case HID_REPORTID_GAMEPAD:
+ case HID_REPORTID_CONSUMERCONTROL:
+ case HID_REPORTID_SYSTEMCONTROL: {
+ // TODO: React appropriately to these.
+ LOG(INFO) << "Ignoring HID report with id = " << id;
+ break;
+ }
+ case HID_REPORTID_MOUSE_ABSOLUTE: {
+ ProcessReport(AbsoluteMouseReport{data});
+ break;
+ }
+ case HID_REPORTID_NKRO_KEYBOARD: {
+ ProcessReport(KeyboardReport{data});
+ break;
+ }
+ default:
+ LOG(ERROR) << "Encountered unknown HID report with id = " << id;
+ }
+ }
+
+ template
+ void RecordReport(const R& report);
+
+ template <>
+ void RecordReport(const MouseReport& report) {
+ mouse_reports_.push_back(report);
+ }
+
+ template <>
+ void RecordReport(const BootKeyboardReport& report) {
+ boot_keyboard_reports_.push_back(report);
+ }
+
+ template <>
+ void RecordReport(const AbsoluteMouseReport& report) {
+ absolute_mouse_reports_.push_back(report);
+ }
+
+ template <>
+ void RecordReport(const KeyboardReport& report) {
+ keyboard_reports_.push_back(report);
+ }
+
+ std::vector mouse_reports_;
+ std::vector boot_keyboard_reports_;
+ std::vector absolute_mouse_reports_;
+ std::vector keyboard_reports_;
+};
+
+} // namespace testing
+} // namespace kaleidoscope
diff --git a/testing/common/reports/KeyboardReport.h b/testing/common/reports/KeyboardReport.h
new file mode 100644
index 00000000..e67f99b1
--- /dev/null
+++ b/testing/common/reports/KeyboardReport.h
@@ -0,0 +1,21 @@
+/* -*- mode: c++ -*-
+ * Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#ifdef KALEIDOSCOPE_VIRTUAL_BUILD
+
+#pragma once
+
+#endif // KALEIDOSCOPE_VIRTUAL_BUILD
diff --git a/testing/hello-simulator/hello-simulator_test.h b/testing/hello-simulator/hello-simulator_test.h
index 7d4e7240..ff2a9e91 100644
--- a/testing/hello-simulator/hello-simulator_test.h
+++ b/testing/hello-simulator/hello-simulator_test.h
@@ -23,16 +23,11 @@
#undef T
#undef U
-#include "fake-gtest.h"
-#include "gtest/gtest.h"
+#include "setup-googletest.h"
#include "Kaleidoscope-Simulator.h"
-void executeTestFunction() {
- setup(); /* setup Kaleidoscope */
- testing::InitGoogleTest();
- RUN_ALL_TESTS();
-}
+SETUP_GOOGLETEST();
namespace kaleidoscope {
namespace simulator {
diff --git a/testing/kaleidoscope/kaleidoscope_test.h b/testing/kaleidoscope/kaleidoscope_test.h
new file mode 100644
index 00000000..0c63f401
--- /dev/null
+++ b/testing/kaleidoscope/kaleidoscope_test.h
@@ -0,0 +1,39 @@
+/* -*- mode: c++ -*-
+ * Copyright (C) 2020 Eric Paniagua (epaniagua@google.com)
+ *
+ * This program is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License as published by the Free Software
+ * Foundation, version 3.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ */
+
+#ifdef KALEIDOSCOPE_VIRTUAL_BUILD
+
+#pragma once
+
+#include "setup-googletest.h"
+
+SETUP_GOOGLETEST();
+
+namespace kaleidoscope {
+namespace testing {
+namespace {
+
+class KeyboardReports : public VirtualDeviceTest {};
+
+TEST_F(KeyboardReports, KeysActiveWhenPressed) {
+ Press(2, 1); // A
+}
+
+} // namespace
+} // namespace testing
+} // namespace kaleidoscope
+
+#endif // KALEIDOSCOPE_VIRTUAL_BUILD
diff --git a/testing/kaleidoscope/tests.h b/testing/kaleidoscope/tests.h
new file mode 100644
index 00000000..fb86bc07
--- /dev/null
+++ b/testing/kaleidoscope/tests.h
@@ -0,0 +1 @@
+#include "./kaleidoscope_test.h"