From 3da11427a54fc0a59345df45dac846e31c49860e Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Tue, 17 Dec 2024 11:39:06 -0800 Subject: [PATCH] Add a simple testcase for the focus version command --- .../serial/focus_version/focus_version.ino | 44 +++++++++++++++++++ .../serial/focus_version/sketch.json | 6 +++ .../serial/focus_version/sketch.yaml | 1 + .../serial/focus_version/test/testcase.cpp | 28 ++++++++++++ 4 files changed, 79 insertions(+) create mode 100644 tests/simulator/serial/focus_version/focus_version.ino create mode 100644 tests/simulator/serial/focus_version/sketch.json create mode 100644 tests/simulator/serial/focus_version/sketch.yaml create mode 100644 tests/simulator/serial/focus_version/test/testcase.cpp diff --git a/tests/simulator/serial/focus_version/focus_version.ino b/tests/simulator/serial/focus_version/focus_version.ino new file mode 100644 index 0000000000..bc15fbb67e --- /dev/null +++ b/tests/simulator/serial/focus_version/focus_version.ino @@ -0,0 +1,44 @@ +// -*- mode: c++ -*- +// Copyright 2016 Keyboardio, inc. +// See "LICENSE" for license details + +#include "Kaleidoscope.h" +#include "Kaleidoscope-FocusSerial.h" + +#define KALEIDOSCOPE_FIRMWARE_VERSION "0.1.2" + +#include "Kaleidoscope-FirmwareVersion.h" +// *INDENT-OFF* +// *INDENT-OFF* + +KEYMAPS( + [0] = KEYMAP_STACKED + ( + XXX ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX + ,XXX + + ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX ,XXX + ,XXX ,XXX ,XXX ,XXX + ,XXX + ) +) // KEYMAPS( + +// *INDENT-ON* + + +KALEIDOSCOPE_INIT_PLUGINS(Focus, FirmwareVersion); + +void setup() { + Kaleidoscope.setup(); +} + +void loop() { + Kaleidoscope.loop(); +} \ No newline at end of file diff --git a/tests/simulator/serial/focus_version/sketch.json b/tests/simulator/serial/focus_version/sketch.json new file mode 100644 index 0000000000..9931687ee5 --- /dev/null +++ b/tests/simulator/serial/focus_version/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} \ No newline at end of file diff --git a/tests/simulator/serial/focus_version/sketch.yaml b/tests/simulator/serial/focus_version/sketch.yaml new file mode 100644 index 0000000000..4d94810065 --- /dev/null +++ b/tests/simulator/serial/focus_version/sketch.yaml @@ -0,0 +1 @@ +default_fqbn: keyboardio:virtual:model01 diff --git a/tests/simulator/serial/focus_version/test/testcase.cpp b/tests/simulator/serial/focus_version/test/testcase.cpp new file mode 100644 index 0000000000..896385ec22 --- /dev/null +++ b/tests/simulator/serial/focus_version/test/testcase.cpp @@ -0,0 +1,28 @@ +#include "testing/setup-googletest.h" +#include "Kaleidoscope.h" +#include +#include "gmock/gmock.h" // For matchers like Eq() + +SETUP_GOOGLETEST(); + +namespace kaleidoscope { +namespace testing { +namespace { + +class FocusVersionCommand : public VirtualDeviceTest {}; + +TEST_F(FocusVersionCommand, SendVersionCommand) { + // Run a cycle to initialize + RunCycle(); + + // Send version command and get response using new helper + auto response = sim_.SendFocusCommand("version"); + + // Response should be exactly the version number + EXPECT_THAT(response, ::testing::Eq("0.1.2")) + << "Expected version response '0.1.2', got: '" << response << "'"; +} + +} // namespace +} // namespace testing +} // namespace kaleidoscope \ No newline at end of file