From b84d82bdb163ebcae9e11d94dce6e58d08c82875 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 26 May 2021 20:20:01 -0500 Subject: [PATCH 1/4] Add Leader testcases, including for issue #407 Signed-off-by: Michael Richters --- tests/plugins/Leader/basic/basic.ino | 25 ++- tests/plugins/Leader/basic/test.ktest | 262 ++++++++++++++++++++++++++ 2 files changed, 282 insertions(+), 5 deletions(-) diff --git a/tests/plugins/Leader/basic/basic.ino b/tests/plugins/Leader/basic/basic.ino index febdf47e..9995a663 100644 --- a/tests/plugins/Leader/basic/basic.ino +++ b/tests/plugins/Leader/basic/basic.ino @@ -23,7 +23,7 @@ KEYMAPS( [0] = KEYMAP_STACKED ( LEAD(0), ___, ___, ___, ___, ___, ___, - Key_A, Key_B, Key_C, Key_D, ___, ___, ___, + Key_A, Key_B, Key_C, Key_D, Key_C, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, @@ -41,18 +41,33 @@ KEYMAPS( KALEIDOSCOPE_INIT_PLUGINS(Leader); -static void leaderBC(uint8_t id) { - Macros.type(PSTR("x")); +static void leaderAB(uint8_t id) { + Macros.type(PSTR("z")); } static void leaderAC(uint8_t id) { Macros.type(PSTR("xyz")); } +static void leaderBA(uint8_t id) { + Macros.type(PSTR("y")); +} + +static void leaderBC(uint8_t id) { + Macros.type(PSTR("x")); +} + +static void leaderC(uint8_t id) { + Macros.type(PSTR("q")); +} + // *INDENT-OFF* static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM = - LEADER_DICT( {LEADER_SEQ(LEAD(0), Key_B, Key_C), leaderBC}, - {LEADER_SEQ(LEAD(0), Key_A, Key_C), leaderAC} ); + LEADER_DICT( {LEADER_SEQ(LEAD(0), Key_A, Key_B), leaderAB}, + {LEADER_SEQ(LEAD(0), Key_A, Key_C), leaderAC}, + {LEADER_SEQ(LEAD(0), Key_B, Key_A), leaderBA}, + {LEADER_SEQ(LEAD(0), Key_B, Key_C), leaderBC}, + {LEADER_SEQ(LEAD(0), Key_C), leaderC } ); // *INDENT-ON* void setup() { diff --git a/tests/plugins/Leader/basic/test.ktest b/tests/plugins/Leader/basic/test.ktest index 62cfa2f6..32ee6380 100644 --- a/tests/plugins/Leader/basic/test.ktest +++ b/tests/plugins/Leader/basic/test.ktest @@ -5,6 +5,70 @@ KEYSWITCH A 1 0 KEYSWITCH B 1 1 KEYSWITCH C 1 2 KEYSWITCH D 1 3 +KEYSWITCH C2 1 4 + +# ============================================================================== +NAME Leader sequence abort + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle + +RUN 4 ms +RELEASE A +RUN 1 cycle + +RUN 4 ms +PRESS D +RUN 1 cycle +EXPECT keyboard-report Key_D # report: { 7 } + +RUN 4 ms +RELEASE D +RUN 1 cycle +EXPECT keyboard-report empty # report: { } + +RUN 5 ms + +# ============================================================================== +NAME Leader sequence AB + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle + +RUN 4 ms +RELEASE A +RUN 1 cycle + +RUN 4 ms +PRESS B +RUN 1 cycle +EXPECT keyboard-report Key_Z # report should contain `Z` (0x1d) +EXPECT keyboard-report empty # report should be empty + +RUN 4 ms +RELEASE B +RUN 1 cycle + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports # ============================================================================== NAME Leader sequence AC @@ -42,6 +106,38 @@ RUN 1 cycle RUN 5 ms EXPECT no keyboard-report # expect no more reports +# ============================================================================== +NAME Leader sequence BA + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS B +RUN 1 cycle + +RUN 4 ms +RELEASE B +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_Y # report should contain `Y` (0x1c) +EXPECT keyboard-report empty # report should be empty + +RUN 4 ms +RELEASE A +RUN 1 cycle + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + # ============================================================================== NAME Leader sequence BC @@ -74,6 +170,172 @@ RUN 1 cycle RUN 5 ms EXPECT no keyboard-report # expect no more reports +# ============================================================================== +NAME Leader sequence C + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS C +RUN 1 cycle +EXPECT keyboard-report Key_Q # report should contain `Q` (0x13) +EXPECT keyboard-report empty # report should be empty + +RUN 4 ms +RELEASE C +RUN 1 cycle + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + +# ============================================================================== +NAME Leader sequence BA rollover + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS B +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_Y # report should contain `Y` (0x1c) +EXPECT keyboard-report empty # report should be empty + +RUN 4 ms +RELEASE B +RUN 1 cycle + +RUN 4 ms +RELEASE A +RUN 1 cycle + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + +# ============================================================================== +NAME Leader sequence C rollover + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS C +RUN 1 cycle +EXPECT keyboard-report Key_Q # report should contain `Q` (0x13) +EXPECT keyboard-report empty # report should be empty + +RUN 4 ms +PRESS D +RUN 1 cycle +EXPECT keyboard-report Key_D # report should contain `D` (0x07) + +RUN 4 ms +RELEASE C +RUN 1 cycle + +RUN 4 ms +RELEASE D +RUN 1 cycle +EXPECT keyboard-report empty # report should be empty + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + +# ============================================================================== +NAME Leader sequence C2 rollover + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS C2 +RUN 1 cycle +EXPECT keyboard-report Key_Q # report should contain `Q` (0x13) +EXPECT keyboard-report empty # report should be empty + +RUN 4 ms +PRESS D +RUN 1 cycle +EXPECT keyboard-report Key_D # report should contain `D` (0x07) + +RUN 4 ms +RELEASE C2 +RUN 1 cycle + +RUN 4 ms +RELEASE D +RUN 1 cycle +EXPECT keyboard-report empty # report should be empty + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + +# ============================================================================== +NAME Leader sequence ABD rollover + +RUN 4 ms +PRESS LEAD_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LEAD_0 +RUN 1 cycle + +RUN 4 ms +PRESS A +RUN 1 cycle + +RUN 4 ms +RELEASE A +RUN 1 cycle + +RUN 4 ms +PRESS B +RUN 1 cycle +EXPECT keyboard-report Key_Z # report should contain `Z` (0x1d) +EXPECT keyboard-report empty # report should be empty + +RUN 4 ms +PRESS D +RUN 1 cycle +EXPECT keyboard-report Key_D # report should contain `D` (0x07) + +RUN 4 ms +RELEASE B +RUN 1 cycle + +RUN 4 ms +RELEASE D +RUN 1 cycle +EXPECT keyboard-report empty # report should be empty + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + # ============================================================================== NAME Leader sequence timeout From 5b45092221b14fd730de9ac4937baeca3e122481 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 26 May 2021 20:40:59 -0500 Subject: [PATCH 2/4] Add SpaceCadet testcase for issue #484 Signed-off-by: Michael Richters --- tests/plugins/SpaceCadet/basic/basic.ino | 2 +- tests/plugins/SpaceCadet/basic/test.ktest | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/tests/plugins/SpaceCadet/basic/basic.ino b/tests/plugins/SpaceCadet/basic/basic.ino index aba9a916..ea934f33 100644 --- a/tests/plugins/SpaceCadet/basic/basic.ino +++ b/tests/plugins/SpaceCadet/basic/basic.ino @@ -23,7 +23,7 @@ KEYMAPS( [0] = KEYMAP_STACKED ( - Key_LeftShift, Key_RightShift, ___, ___, ___, ___, ___, + Key_LeftShift, Key_RightShift, Key_RightGui, ___, ___, ___, ___, Key_A, Key_B, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, ___, diff --git a/tests/plugins/SpaceCadet/basic/test.ktest b/tests/plugins/SpaceCadet/basic/test.ktest index f3edaae8..581069ce 100644 --- a/tests/plugins/SpaceCadet/basic/test.ktest +++ b/tests/plugins/SpaceCadet/basic/test.ktest @@ -2,6 +2,7 @@ VERSION 1 KEYSWITCH LSHIFT 0 0 KEYSWITCH RSHIFT 0 1 +KEYSWITCH RGUI 0 2 KEYSWITCH A 1 0 KEYSWITCH B 1 1 @@ -123,3 +124,28 @@ RUN 3 ms RELEASE RSHIFT RUN 1 cycle EXPECT keyboard-report empty # Report should be empty + +# ============================================================================== +NAME SpaceCadet interrupt with modifier + +RUN 5 ms +PRESS LSHIFT +RUN 1 cycle + +RUN 3 ms +PRESS RGUI +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift # report: { e1 } +EXPECT keyboard-report Key_LeftShift Key_RightGui # report: { e1 e7 } + +RUN 5 ms +RELEASE LSHIFT +RUN 1 cycle +EXPECT keyboard-report Key_RightGui # report: { e7 } + +RUN 3 ms +RELEASE RGUI +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +RUN 5 ms From 1416bdb4c8d9124ed811c6498f77119f627715a8 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 26 May 2021 12:20:57 -0500 Subject: [PATCH 3/4] Add testcase for issue #571 Signed-off-by: Michael Richters --- tests/issues/571/571.ino | 66 ++++++++++++++++++++++++++++++++++++ tests/issues/571/sketch.json | 6 ++++ tests/issues/571/test.ktest | 49 ++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 tests/issues/571/571.ino create mode 100644 tests/issues/571/sketch.json create mode 100644 tests/issues/571/test.ktest diff --git a/tests/issues/571/571.ino b/tests/issues/571/571.ino new file mode 100644 index 00000000..b99310fb --- /dev/null +++ b/tests/issues/571/571.ino @@ -0,0 +1,66 @@ +/* -*- 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 + ( + TD(0), ___, ___, ___, ___, ___, ___, + Key_Tab, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *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_LeftControl, LGUI(Key_LeftBracket)); + case 1: + return tapDanceActionKeys(tap_count, tap_dance_action, + Key_RightControl, LGUI(Key_RightBracket)); + default: + break; + } +} + +KALEIDOSCOPE_INIT_PLUGINS(TapDance); + +void setup() { + Kaleidoscope.setup(); + TapDance.time_out = 25; +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/issues/571/sketch.json b/tests/issues/571/sketch.json new file mode 100644 index 00000000..43dc4c7e --- /dev/null +++ b/tests/issues/571/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} \ No newline at end of file diff --git a/tests/issues/571/test.ktest b/tests/issues/571/test.ktest new file mode 100644 index 00000000..2492dc2a --- /dev/null +++ b/tests/issues/571/test.ktest @@ -0,0 +1,49 @@ +VERSION 1 + +KEYSWITCH TD_0 0 0 +KEYSWITCH TAB 1 0 + +# ============================================================================== +NAME Issue 571 + +RUN 4 ms +PRESS TD_0 +RUN 1 cycle + +RUN 4 ms +PRESS TAB +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl # report: e0 +EXPECT keyboard-report Key_LeftControl Key_Tab # report: e0, 2b + +RUN 19 ms +RELEASE TAB +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl # report: e0 + +RUN 4 ms +RELEASE TD_0 +RUN 1 cycle +EXPECT keyboard-report empty # report: - + +RUN 10 ms + +RUN 4 ms +PRESS TD_0 +RUN 1 cycle + +RUN 4 ms +PRESS TAB +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl # report: e0 +EXPECT keyboard-report Key_LeftControl Key_Tab # report: e0, 2b + +RUN 19 ms +RELEASE TAB +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl # report: e0 + +RUN 4 ms +RELEASE TD_0 +RUN 1 cycle +EXPECT keyboard-report empty # report: - From c60dd9526df3b835fb8b2d57d65d625ea4e3db85 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Wed, 26 May 2021 13:01:37 -0500 Subject: [PATCH 4/4] Add testcase for issue #673 Signed-off-by: Michael Richters --- tests/issues/673/673.ino | 52 +++++++++++++++++++++++++++++++ tests/issues/673/sketch.json | 6 ++++ tests/issues/673/test.ktest | 59 ++++++++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+) create mode 100644 tests/issues/673/673.ino create mode 100644 tests/issues/673/sketch.json create mode 100644 tests/issues/673/test.ktest diff --git a/tests/issues/673/673.ino b/tests/issues/673/673.ino new file mode 100644 index 00000000..9b0943fe --- /dev/null +++ b/tests/issues/673/673.ino @@ -0,0 +1,52 @@ +/* -*- 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 + ( + OSM(LeftShift), OSM(LeftControl), ___, ___, ___, ___, ___, + Key_A, Key_B, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +KALEIDOSCOPE_INIT_PLUGINS(OneShot); + +void setup() { + Kaleidoscope.setup(); + OneShot.setTimeout(50); + OneShot.setHoldTimeout(20); + OneShot.setDoubleTapTimeout(20); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/issues/673/sketch.json b/tests/issues/673/sketch.json new file mode 100644 index 00000000..43dc4c7e --- /dev/null +++ b/tests/issues/673/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} \ No newline at end of file diff --git a/tests/issues/673/test.ktest b/tests/issues/673/test.ktest new file mode 100644 index 00000000..ec6f9b85 --- /dev/null +++ b/tests/issues/673/test.ktest @@ -0,0 +1,59 @@ +VERSION 1 + +KEYSWITCH OS_SFT 0 0 +KEYSWITCH OS_CTL 0 1 +KEYSWITCH A 1 0 +KEYSWITCH B 1 1 + +# ============================================================================== +NAME Issue 673 + +RUN 4 ms +PRESS OS_CTL +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl # report: { e0 } + +RUN 4 ms +RELEASE OS_CTL +RUN 1 cycle + +RUN 4 ms +PRESS OS_CTL +RUN 1 cycle + +RUN 4 ms +RELEASE OS_CTL +RUN 1 cycle + +RUN 100 ms + +RUN 4 ms +PRESS OS_SFT +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl Key_LeftShift # report: { e0 e1 } + +RUN 4 ms +RELEASE OS_SFT +RUN 1 cycle + +RUN 4 ms +PRESS OS_SFT +RUN 1 cycle + +RUN 4 ms +RELEASE OS_SFT +RUN 1 cycle + +RUN 100 ms + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl Key_LeftShift Key_A # report: { 4 e0 e1 } + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report Key_LeftControl Key_LeftShift # report: { e0 e1 } + +RUN 5 ms