From f1369120154e928c0d9f60ad93d47228c05d8045 Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Thu, 15 Apr 2021 13:22:00 -0500 Subject: [PATCH] Add testcases for Turbo plugin Signed-off-by: Michael Richters --- tests/plugins/Turbo/basic/basic.ino | 49 +++++++++++ tests/plugins/Turbo/basic/sketch.json | 6 ++ tests/plugins/Turbo/basic/test.ktest | 113 ++++++++++++++++++++++++++ 3 files changed, 168 insertions(+) create mode 100644 tests/plugins/Turbo/basic/basic.ino create mode 100644 tests/plugins/Turbo/basic/sketch.json create mode 100644 tests/plugins/Turbo/basic/test.ktest diff --git a/tests/plugins/Turbo/basic/basic.ino b/tests/plugins/Turbo/basic/basic.ino new file mode 100644 index 00000000..799484e0 --- /dev/null +++ b/tests/plugins/Turbo/basic/basic.ino @@ -0,0 +1,49 @@ +/* -*- 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 + ( + Key_Turbo, Key_RightGui, Key_LeftShift, ___, ___, ___, ___, + Key_A, Key_B, Key_C, Key_D, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +KALEIDOSCOPE_INIT_PLUGINS(Turbo); + +void setup() { + Kaleidoscope.setup(); +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/plugins/Turbo/basic/sketch.json b/tests/plugins/Turbo/basic/sketch.json new file mode 100644 index 00000000..8cc86922 --- /dev/null +++ b/tests/plugins/Turbo/basic/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} diff --git a/tests/plugins/Turbo/basic/test.ktest b/tests/plugins/Turbo/basic/test.ktest new file mode 100644 index 00000000..e1342728 --- /dev/null +++ b/tests/plugins/Turbo/basic/test.ktest @@ -0,0 +1,113 @@ +VERSION 1 + +KEYSWITCH TURBO 0 0 +KEYSWITCH R_GUI 0 1 +KEYSWITCH L_SHIFT 0 2 +KEYSWITCH A 1 0 +KEYSWITCH B 1 1 +KEYSWITCH C 1 2 +KEYSWITCH D 1 3 + +# ============================================================================== +NAME Turbo no regression + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report empty # report should be empty + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + +# ============================================================================== +NAME Turbo second + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 4 ms +PRESS TURBO +RUN 1 cycle + +RUN 1 ms +EXPECT keyboard-report empty # report should be empty +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 10 ms +RUN 1 ms +EXPECT keyboard-report empty # report should be empty +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 10 ms +RUN 1 ms +EXPECT keyboard-report empty # report should be empty +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 10 ms +RUN 1 ms +EXPECT keyboard-report empty # report should be empty +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 10 ms +RUN 1 ms +EXPECT keyboard-report empty # report should be empty +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 4 ms +RELEASE TURBO +RUN 1 cycle + +RUN 20 ms + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report empty # report should be empty + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports + +# ============================================================================== +NAME Turbo first + +RUN 4 ms +PRESS TURBO +RUN 1 cycle + +RUN 10 ms + +RUN 4 ms +PRESS A +RUN 1 cycle +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 7 ms +RUN 1 ms +EXPECT keyboard-report empty # report should be empty +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 10 ms +RUN 1 ms +EXPECT keyboard-report empty # report should be empty +EXPECT keyboard-report Key_A # report should contain `A` (0x04) + +RUN 4 ms +RELEASE A +RUN 1 cycle +EXPECT keyboard-report empty # report should be empty + +RUN 20 ms + +RUN 4 ms +RELEASE TURBO +RUN 1 cycle + +RUN 5 ms +EXPECT no keyboard-report # expect no more reports