diff --git a/tests/plugins/Cycle/basic/basic.ino b/tests/plugins/Cycle/basic/basic.ino new file mode 100644 index 0000000000..6f3706eb8a --- /dev/null +++ b/tests/plugins/Cycle/basic/basic.ino @@ -0,0 +1,60 @@ +/* -*- 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_A, Key_B, Key_C, Key_D, Key_Cycle, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + + +void cycleAction(Key previous_key, uint8_t cycle_count) { + if (previous_key == Key_A) { + Cycle.replace(Key_1); + } else if (previous_key == Key_B) { + cycleThrough(Key_B, Key_1, Key_2); + } +} + +KALEIDOSCOPE_INIT_PLUGINS(Cycle); + +void setup() { + Kaleidoscope.setup(); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/plugins/Cycle/basic/common.h b/tests/plugins/Cycle/basic/common.h new file mode 100644 index 0000000000..dcfcc35b25 --- /dev/null +++ b/tests/plugins/Cycle/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/Cycle/basic/sketch.json b/tests/plugins/Cycle/basic/sketch.json new file mode 100644 index 0000000000..43dc4c7e2d --- /dev/null +++ b/tests/plugins/Cycle/basic/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} \ No newline at end of file diff --git a/tests/plugins/Cycle/basic/sketch.yaml b/tests/plugins/Cycle/basic/sketch.yaml new file mode 100644 index 0000000000..4d94810065 --- /dev/null +++ b/tests/plugins/Cycle/basic/sketch.yaml @@ -0,0 +1 @@ +default_fqbn: keyboardio:virtual:model01 diff --git a/tests/plugins/Cycle/basic/test.ktest b/tests/plugins/Cycle/basic/test.ktest new file mode 100644 index 0000000000..c20282cbfb --- /dev/null +++ b/tests/plugins/Cycle/basic/test.ktest @@ -0,0 +1,72 @@ +VERSION 1 + +KEYSWITCH A 0 0 +KEYSWITCH B 0 1 +KEYSWITCH C 0 2 +KEYSWITCH D 0 3 +KEYSWITCH CYCLE 0 4 + +# ============================================================================== +NAME Cycle simple_replace +RUN 5 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_A # Report should contain A +RELEASE A +RUN 1 cycle +PRESS CYCLE +EXPECT keyboard-report empty # Report should be empty +RUN 1 cycle +RELEASE CYCLE +RUN 1 cycle +EXPECT keyboard-report Key_Backspace # Report should contain Backspace +EXPECT keyboard-report empty # Report should be empty after Backspace +EXPECT keyboard-report Key_1 # Report should contain 1 +EXPECT keyboard-report empty # Report should be empty after 1 + +NAME Cycle cycleThrough_with_loop +RUN 5 ms +PRESS B +RUN 1 cycle +EXPECT keyboard-report Key_B # Report should contain B +RELEASE B +RUN 1 cycle +PRESS CYCLE +EXPECT keyboard-report empty # Report should be empty +RUN 1 cycle +RELEASE CYCLE +RUN 1 cycle +EXPECT keyboard-report Key_Backspace # Report should contain Backspace for first key +EXPECT keyboard-report empty # Report should be empty after Backspace for first key +EXPECT keyboard-report Key_1 # Report should contain 1 +EXPECT keyboard-report empty # Report should be empty after 1 +RUN 1 cycle +PRESS CYCLE +RUN 1 cycle +RELEASE CYCLE +RUN 1 cycle +EXPECT keyboard-report Key_Backspace # Report should contain Backspace for second key +EXPECT keyboard-report empty # Report should be empty after Backspace for second key +EXPECT keyboard-report Key_2 # Report should contain 2 +EXPECT keyboard-report empty # Report should be empty after 2 +RUN 1 cycle +PRESS CYCLE +RUN 1 cycle +RELEASE CYCLE +RUN 1 cycle +EXPECT keyboard-report Key_Backspace # Report should contain Backspace for zeroth key +EXPECT keyboard-report empty # Report should be empty after Backspace for zeroth key +EXPECT keyboard-report Key_B # Report should contain B again +EXPECT keyboard-report empty # Report should be empty after B again + +NAME Cycle does_not_activate +RUN 5 ms +PRESS C +RUN 1 cycle +EXPECT keyboard-report Key_C # Report should contain C +RELEASE C +RUN 1 cycle +PRESS CYCLE +EXPECT keyboard-report empty # Report should be empty +RUN 1 cycle +RELEASE CYCLE