From c9a98ecb261e77fbd137bda754dc648ac158427f Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 26 May 2021 19:28:25 -0500 Subject: [PATCH] Add testcases for issue #423 Signed-off-by: Michael Richters --- tests/issues/423/423.ino | 64 ++++++++++++++++++ tests/issues/423/sketch.json | 6 ++ tests/issues/423/test.ktest | 125 +++++++++++++++++++++++++++++++++++ 3 files changed, 195 insertions(+) create mode 100644 tests/issues/423/423.ino create mode 100644 tests/issues/423/sketch.json create mode 100644 tests/issues/423/test.ktest diff --git a/tests/issues/423/423.ino b/tests/issues/423/423.ino new file mode 100644 index 00000000..dcf02840 --- /dev/null +++ b/tests/issues/423/423.ino @@ -0,0 +1,64 @@ +/* -*- 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 +#include + +// *INDENT-OFF* +KEYMAPS( + [0] = KEYMAP_STACKED + ( + Key_Spacebar, Key_A, ___, ___, ___, ___, ___, + TD(0), OSM(LeftShift), ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +void tapDanceAction(uint8_t tap_dance_index, + KeyAddr key_addr, + uint8_t tap_count, + kaleidoscope::plugin::TapDance::ActionType tap_dance_action) { + switch (tap_dance_index) { + case 0: + return tapDanceActionKeys(tap_count, tap_dance_action, + Key_Period, LSHIFT(Key_1)); + default: + break; + } +} + +KALEIDOSCOPE_INIT_PLUGINS(OneShot, TapDance); + +void setup() { + Kaleidoscope.setup(); + TapDance.time_out = 25; +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/issues/423/sketch.json b/tests/issues/423/sketch.json new file mode 100644 index 00000000..43dc4c7e --- /dev/null +++ b/tests/issues/423/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} \ No newline at end of file diff --git a/tests/issues/423/test.ktest b/tests/issues/423/test.ktest new file mode 100644 index 00000000..c734e0e9 --- /dev/null +++ b/tests/issues/423/test.ktest @@ -0,0 +1,125 @@ +VERSION 1 + +KEYSWITCH SPACE 0 0 +KEYSWITCH A 0 1 +KEYSWITCH TD_0 1 0 +KEYSWITCH OS_SHIFT 1 1 + +# ============================================================================== +NAME Back and forth + +RUN 4 ms +PRESS TD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE TD_0 +RUN 1 cycle + +RUN 4 ms +PRESS OS_SHIFT +RUN 1 cycle +EXPECT keyboard-report Key_Period # report: { 37 } +EXPECT keyboard-report empty +EXPECT keyboard-report Key_LeftShift # report: { e1 } + +RUN 4 ms +RELEASE OS_SHIFT +RUN 1 cycle + +RUN 4 ms +PRESS TD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE TD_0 +RUN 1 cycle + +# ------------------------------------------------------------------------------ +# Next, we press `space`, triggering both the resolution of the TapDance key and +# the release of the OneShot key, in that order. +RUN 4 ms +PRESS SPACE +RUN 1 cycle +# First, the TapDance key is resolved, adding `.` to the report. This event also +# triggers the release of the OneShot key, which shouldn't happen until after +# the `.` press is processed. +EXPECT keyboard-report Key_LeftShift Key_Period # report: { 37 e1 } +# Now the OneShot key is released, removing `shift` from the report. +EXPECT keyboard-report Key_Period # report: { 37 } +# The TapDance `.` key has been released, so its release comes next. +EXPECT keyboard-report empty # report: { } +# Finally, we get the report for the press of the `space` key. +EXPECT keyboard-report Key_Spacebar # report: { 2c } + +RUN 4 ms +RELEASE SPACE +RUN 1 cycle +EXPECT keyboard-report empty + +RUN 4 ms +PRESS OS_SHIFT +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift # report: { e1 } + +RUN 4 ms +RELEASE OS_SHIFT +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift Key_A # report: { 4 e1 } +EXPECT keyboard-report Key_A # report: { 4 } + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report empty + +RUN 5 ms + +# ============================================================================== +NAME Single rollover + +RUN 4 ms +PRESS TD_0 +RUN 1 cycle + +RUN 4 ms +PRESS SPACE +RUN 1 cycle +EXPECT keyboard-report Key_Period # report: { 37 } +EXPECT keyboard-report Key_Period Key_Spacebar # report: { 37 2c } + +RUN 4 ms +PRESS OS_SHIFT +RUN 1 cycle +EXPECT keyboard-report Key_Period Key_Spacebar Key_LeftShift # report: { 2c 37 e1 } + +RUN 4 ms +RELEASE TD_0 +RUN 1 cycle +EXPECT keyboard-report Key_Spacebar Key_LeftShift # report: { 2c e1 } + +RUN 4 ms +RELEASE SPACE +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift # report: { e1 } + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift Key_A # report: { 4 e1 } + +RUN 4 ms +RELEASE OS_SHIFT +RUN 1 cycle +EXPECT keyboard-report Key_A # report: { 4 } + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report empty + +RUN 5 ms