Add basic OneShot testcases

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/986/head
Michael Richters 4 years ago
parent 0ccc3dcde0
commit 6858c0b030
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -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 <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <cstdint>
namespace kaleidoscope {
namespace testing {
} // namespace testing
} // namespace kaleidoscope

@ -0,0 +1,54 @@
/* -*- 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 <http://www.gnu.org/licenses/>.
*/
#include <Kaleidoscope.h>
#include <Kaleidoscope-OneShot.h>
#include "./common.h"
// *INDENT-OFF*
KEYMAPS(
[0] = KEYMAP_STACKED
(
OSM(LeftShift), ___, ___, ___, ___, ___, ___,
Key_A, Key_B, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___
),
)
// *INDENT-ON*
KALEIDOSCOPE_INIT_PLUGINS(OneShot);
void setup() {
Kaleidoscope.setup();
OneShot.time_out = 50;
OneShot.hold_time_out = 20;
OneShot.double_tap_time_out = 20;
}
void loop() {
Kaleidoscope.loop();
}

@ -0,0 +1,145 @@
VERSION 1
KEYSWITCH OS_shift 0 0
KEYSWITCH A 1 0
KEYSWITCH B 1 1
# ==============================================================================
NAME OneShot timeout
RUN 5 ms
PRESS OS_shift
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 5 ms
RELEASE OS_shift
RUN 45 ms
RUN 2 cycles
EXPECT keyboard-report empty # Report should be empty
# ==============================================================================
NAME OneShot next key
RUN 5 ms
PRESS OS_shift
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 5 ms
RELEASE OS_shift
RUN 10 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift Key_A # There should be `shift`+`A`
RUN 1 cycle
EXPECT keyboard-report Key_A # There should be only `A`
RUN 5 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report empty # Report should be empty
# ==============================================================================
NAME OneShot double tap
RUN 5 ms
PRESS OS_shift
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 5 ms
RELEASE OS_shift
RUN 5 ms
PRESS OS_shift
RUN 5 ms
RELEASE OS_shift
RUN 50 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift Key_A # There should be `shift`+`A`
RUN 5 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 10 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift Key_A # There should be `shift`+`A`
RUN 5 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 5 ms
PRESS OS_shift
RUN 1 cycle
EXPECT keyboard-report empty # Report should be empty
RUN 5 ms
RELEASE OS_shift
RUN 1 cycle
# ==============================================================================
NAME OneShot double tap timeout
RUN 5 ms
PRESS OS_shift
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 5 ms
RELEASE OS_shift
RUN 20 ms
PRESS OS_shift
RUN 5 ms
RELEASE OS_shift
RUN 1 cycle
EXPECT keyboard-report empty # Report should be empty
RUN 50 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_A # There should be only `A`
RUN 5 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report empty # Report should be empty
RUN 10 ms
# ==============================================================================
NAME OneShot hold timeout
RUN 5 ms
PRESS OS_shift
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 30 ms
RELEASE OS_shift
RUN 1 cycle
EXPECT keyboard-report empty # Report should be empty
# ==============================================================================
NAME OneShot rollover
RUN 5 ms
PRESS OS_shift
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # The report should contain `shift`
RUN 5 ms
PRESS A
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift Key_A # There should be `shift`+`A`
RUN 5 ms
RELEASE OS_shift
RUN 2 cycles # 2 cycles?
EXPECT keyboard-report Key_A # There should be only `A`
RUN 5 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report empty # Report should be empty
Loading…
Cancel
Save