From e2f710abee42be75e06502e1af2baf43263c7edb Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 13 May 2021 12:19:13 -0500 Subject: [PATCH] Add testcase for issue 1032 Signed-off-by: Michael Richters --- tests/issues/1032/1032.ino | 69 ++++++++++++++++++++ tests/issues/1032/sketch.json | 6 ++ tests/issues/1032/test.ktest | 115 ++++++++++++++++++++++++++++++++++ 3 files changed, 190 insertions(+) create mode 100644 tests/issues/1032/1032.ino create mode 100644 tests/issues/1032/sketch.json create mode 100644 tests/issues/1032/test.ktest diff --git a/tests/issues/1032/1032.ino b/tests/issues/1032/1032.ino new file mode 100644 index 00000000..13f4a086 --- /dev/null +++ b/tests/issues/1032/1032.ino @@ -0,0 +1,69 @@ +/* -*- mode: c++ -*- + * Copyright (C) 2021 Keyboard.io, Inc. + * + * 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 + +#include + +// *INDENT-OFF* +KEYMAPS( + [0] = KEYMAP_STACKED + ( + SYSTER, ___, ___, ___, ___, ___, ___, + Key_A, Key_B, Key_C, ___, ___, ___, ___, + Key_0, Key_1, ___, ___, ___, ___, + Key_Spacebar, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +void systerAction(kaleidoscope::plugin::Syster::action_t action, const char *symbol) { + switch (action) { + case kaleidoscope::plugin::Syster::StartAction: + break; + case kaleidoscope::plugin::Syster::EndAction: + break; + case kaleidoscope::plugin::Syster::SymbolAction: + if (strcmp(symbol, "abc") == 0) { + Kaleidoscope.handleKeyEvent(KeyEvent(KeyAddr::none(), INJECTED | IS_PRESSED, Key_X)); + Kaleidoscope.handleKeyEvent(KeyEvent(KeyAddr::none(), INJECTED | WAS_PRESSED, Key_X)); + } + if (strcmp(symbol, "a0") == 0) { + Kaleidoscope.handleKeyEvent(KeyEvent(KeyAddr::none(), INJECTED | IS_PRESSED, Key_Y)); + Kaleidoscope.handleKeyEvent(KeyEvent(KeyAddr::none(), INJECTED | WAS_PRESSED, Key_Y)); + } + break; + } +} + +KALEIDOSCOPE_INIT_PLUGINS(Syster); + +void setup() { + Kaleidoscope.setup(); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/issues/1032/sketch.json b/tests/issues/1032/sketch.json new file mode 100644 index 00000000..8cc86922 --- /dev/null +++ b/tests/issues/1032/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} diff --git a/tests/issues/1032/test.ktest b/tests/issues/1032/test.ktest new file mode 100644 index 00000000..87b14861 --- /dev/null +++ b/tests/issues/1032/test.ktest @@ -0,0 +1,115 @@ +VERSION 1 + +KEYSWITCH SYSTER 0 0 +KEYSWITCH A 1 0 +KEYSWITCH B 1 1 +KEYSWITCH C 1 2 +KEYSWITCH ZERO 2 0 +KEYSWITCH ONE 2 1 +KEYSWITCH SPACE 3 0 + +# ============================================================================== +NAME Syster sequence without zero + +RUN 4 ms +PRESS SYSTER +RUN 1 cycle + +RUN 4 ms +RELEASE SYSTER +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_A # The report should contain only `A` + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report empty # The report should be empty + +RUN 4 ms +PRESS B +RUN 1 cycle +EXPECT keyboard-report Key_B # The report should contain only `B` + +RUN 4 ms +RELEASE B +RUN 1 cycle +EXPECT keyboard-report empty # The report should be empty + +RUN 4 ms +PRESS C +RUN 1 cycle +EXPECT keyboard-report Key_C # The report should contain only `C` + +RUN 4 ms +RELEASE C +RUN 1 cycle +EXPECT keyboard-report empty # The report should be empty + +RUN 4 ms +PRESS SPACE +RUN 1 cycle +EXPECT keyboard-report Key_Backspace # The report should contain `backspace` +EXPECT keyboard-report empty # The report should be empty +EXPECT keyboard-report Key_Backspace # The report should contain `backspace` +EXPECT keyboard-report empty # The report should be empty +EXPECT keyboard-report Key_Backspace # The report should contain `backspace` +EXPECT keyboard-report empty # The report should be empty +EXPECT keyboard-report Key_X # The report should contain `X` +EXPECT keyboard-report empty # The report should be empty + +RUN 4 ms +RELEASE SPACE +RUN 1 cycle + +RUN 10 ms + +# ============================================================================== +NAME Syster sequence with zero + +RUN 4 ms +PRESS SYSTER +RUN 1 cycle + +RUN 4 ms +RELEASE SYSTER +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_A # The report should contain only `A` + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report empty # The report should be empty + +RUN 4 ms +PRESS ZERO +RUN 1 cycle +EXPECT keyboard-report Key_0 # The report should contain only `0` + +RUN 4 ms +RELEASE ZERO +RUN 1 cycle +EXPECT keyboard-report empty # The report should be empty + +RUN 4 ms +PRESS SPACE +RUN 1 cycle +EXPECT keyboard-report Key_Backspace # The report should contain `backspace` +EXPECT keyboard-report empty # The report should be empty +EXPECT keyboard-report Key_Backspace # The report should contain `backspace` +EXPECT keyboard-report empty # The report should be empty +EXPECT keyboard-report Key_Y # The report should contain `Y` +EXPECT keyboard-report empty # The report should be empty + +RUN 4 ms +RELEASE SPACE +RUN 1 cycle + +RUN 10 ms