From 56cafeb9fde73e58500c8e18080cbc1595c3353e Mon Sep 17 00:00:00 2001 From: Michael Richters Date: Sat, 21 Nov 2020 12:32:51 -0600 Subject: [PATCH] Add basic Escape-OneShot testcases Signed-off-by: Michael Richters --- tests/plugins/Escape-OneShot/basic/common.h | 27 +++++++++ tests/plugins/Escape-OneShot/basic/sketch.ino | 55 +++++++++++++++++++ tests/plugins/Escape-OneShot/basic/test.ktest | 48 ++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 tests/plugins/Escape-OneShot/basic/common.h create mode 100644 tests/plugins/Escape-OneShot/basic/sketch.ino create mode 100644 tests/plugins/Escape-OneShot/basic/test.ktest diff --git a/tests/plugins/Escape-OneShot/basic/common.h b/tests/plugins/Escape-OneShot/basic/common.h new file mode 100644 index 00000000..dcfcc35b --- /dev/null +++ b/tests/plugins/Escape-OneShot/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/Escape-OneShot/basic/sketch.ino b/tests/plugins/Escape-OneShot/basic/sketch.ino new file mode 100644 index 00000000..372adca6 --- /dev/null +++ b/tests/plugins/Escape-OneShot/basic/sketch.ino @@ -0,0 +1,55 @@ +/* -*- 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 + +#include "./common.h" + +// *INDENT-OFF* +KEYMAPS( + [0] = KEYMAP_STACKED + ( + OSM(LeftShift), OSM(LeftAlt), ___, ___, ___, ___, ___, + Key_Escape, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +KALEIDOSCOPE_INIT_PLUGINS(OneShot, EscapeOneShot); + +void setup() { + Kaleidoscope.setup(); + OneShot.time_out = 50; + OneShot.hold_time_out = 20; + OneShot.double_tap_time_out = 20; +} + +void loop() { + Kaleidoscope.loop(); +} diff --git a/tests/plugins/Escape-OneShot/basic/test.ktest b/tests/plugins/Escape-OneShot/basic/test.ktest new file mode 100644 index 00000000..1ab61288 --- /dev/null +++ b/tests/plugins/Escape-OneShot/basic/test.ktest @@ -0,0 +1,48 @@ +VERSION 1 + +KEYSWITCH OSM_0 0 0 # left shift +KEYSWITCH OSM_1 0 1 # left alt +KEYSWITCH ESC 1 0 + +# ============================================================================== +NAME EscapeOneShot cancel temporary + +RUN 5 ms +PRESS OSM_0 +RUN 1 cycle +EXPECT keyboard-report Key_LeftShift # The report should contain `shift` +RUN 5 ms +RELEASE OSM_0 +RUN 10 ms +PRESS ESC +RUN 2 cycles +EXPECT keyboard-report empty # Report should be empty +RUN 5 ms +RELEASE ESC +RUN 1 cycle + +# ============================================================================== +# The testcases below are commented out because they are currently failing. + +# # ============================================================================== +# NAME EscapeOneShot cancel sticky + +# RUN 5 ms +# PRESS OSM_0 +# RUN 1 cycle +# EXPECT keyboard-report Key_LeftShift # The report should contain `shift` +# RUN 5 ms +# RELEASE OSM_0 + +# RUN 5 ms +# PRESS OSM_0 +# RUN 5 ms +# RELEASE OSM_0 + +# RUN 50 ms +# PRESS ESC +# RUN 2 cycles +# EXPECT keyboard-report empty # Report should be empty +# RUN 5 ms +# RELEASE ESC +# RUN 1 cycle