From 0c03d19c64fab05295f61a55ee3af24adf07a8f2 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Sat, 21 Nov 2020 23:19:08 -0600 Subject: [PATCH] Add basic ShapeShifter testcases Signed-off-by: Michael Richters --- tests/plugins/ShapeShifter/basic/common.h | 27 ++++++++++ tests/plugins/ShapeShifter/basic/sketch.ino | 59 +++++++++++++++++++++ tests/plugins/ShapeShifter/basic/test.ktest | 38 +++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 tests/plugins/ShapeShifter/basic/common.h create mode 100644 tests/plugins/ShapeShifter/basic/sketch.ino create mode 100644 tests/plugins/ShapeShifter/basic/test.ktest diff --git a/tests/plugins/ShapeShifter/basic/common.h b/tests/plugins/ShapeShifter/basic/common.h new file mode 100644 index 00000000..dcfcc35b --- /dev/null +++ b/tests/plugins/ShapeShifter/basic/common.h @@ -0,0 +1,27 @@ +// -*- mode: c++ -*- + +/* Kaleidoscope - Firmware for computer input devices + * Copyright (C) 2020 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 . + */ + +#pragma once + +#include + +namespace kaleidoscope { +namespace testing { + +} // namespace testing +} // namespace kaleidoscope diff --git a/tests/plugins/ShapeShifter/basic/sketch.ino b/tests/plugins/ShapeShifter/basic/sketch.ino new file mode 100644 index 00000000..546af5c4 --- /dev/null +++ b/tests/plugins/ShapeShifter/basic/sketch.ino @@ -0,0 +1,59 @@ +/* -*- mode: c++ -*- + * Copyright (C) 2020 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 "./common.h" + +// *INDENT-OFF* +KEYMAPS( + [0] = KEYMAP_STACKED + ( + Key_1, Key_2, Key_3, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + Key_LeftShift, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +static const kaleidoscope::plugin::ShapeShifter::dictionary_t shape_shifter_dictionary[] PROGMEM = { + {Key_1, Key_2}, + {Key_2, Key_1}, + {Key_3, Key_4}, + {Key_NoKey, Key_NoKey}, +}; + +KALEIDOSCOPE_INIT_PLUGINS(ShapeShifter); + +void setup() { + Kaleidoscope.setup(); + ShapeShifter.dictionary = shape_shifter_dictionary; +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/plugins/ShapeShifter/basic/test.ktest b/tests/plugins/ShapeShifter/basic/test.ktest new file mode 100644 index 00000000..649f37fe --- /dev/null +++ b/tests/plugins/ShapeShifter/basic/test.ktest @@ -0,0 +1,38 @@ +VERSION 1 + +KEYSWITCH K1 0 0 +KEYSWITCH K2 0 1 +KEYSWITCH K3 0 2 +KEYSWITCH LSHIFT 2 0 + +# ============================================================================== +NAME ShapeShifter without shift + +RUN 5 ms +PRESS K1 +RUN 1 cycle +EXPECT keyboard-report Key_1 # The report should contain only `1` +RUN 5 ms +RELEASE K1 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ============================================================================== +NAME ShapeShifter full overlap + +RUN 5 ms +PRESS LSHIFT +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift # The report should contain `shift` +RUN 5 ms +PRESS K1 +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift Key_2 # The report should contain `shift` + `2` +RUN 5 ms +RELEASE K1 +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift # The report should contain `shift` +RUN 5 ms +RELEASE LSHIFT +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty