Skip to content

Commit

Permalink
Add a simple testcase for the focus version command
Browse files Browse the repository at this point in the history
  • Loading branch information
obra committed Dec 17, 2024
1 parent e22493f commit 3da1142
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/simulator/serial/focus_version/focus_version.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// -*- mode: c++ -*-
// Copyright 2016 Keyboardio, inc. <[email protected]>
// 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();
}
6 changes: 6 additions & 0 deletions tests/simulator/serial/focus_version/sketch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cpu": {
"fqbn": "keyboardio:virtual:model01",
"port": ""
}
}
1 change: 1 addition & 0 deletions tests/simulator/serial/focus_version/sketch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_fqbn: keyboardio:virtual:model01
28 changes: 28 additions & 0 deletions tests/simulator/serial/focus_version/test/testcase.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "testing/setup-googletest.h"
#include "Kaleidoscope.h"
#include <iostream>
#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

0 comments on commit 3da1142

Please sign in to comment.