Add testcases for Leader plugin

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

@ -0,0 +1,66 @@
/* -*- 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 <http://www.gnu.org/licenses/>.
*/
#include <Kaleidoscope.h>
#include <Kaleidoscope-Leader.h>
#include <Kaleidoscope-Macros.h>
// *INDENT-OFF*
KEYMAPS(
[0] = KEYMAP_STACKED
(
LEAD(0), ___, ___, ___, ___, ___, ___,
Key_A, Key_B, Key_C, Key_D, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___
),
)
// *INDENT-ON*
KALEIDOSCOPE_INIT_PLUGINS(Leader);
static void leaderBC(uint8_t id) {
Macros.type(PSTR("x"));
}
static void leaderAC(uint8_t id) {
Macros.type(PSTR("xyz"));
}
// *INDENT-OFF*
static const kaleidoscope::plugin::Leader::dictionary_t leader_dictionary[] PROGMEM =
LEADER_DICT( {LEADER_SEQ(LEAD(0), Key_B, Key_C), leaderBC},
{LEADER_SEQ(LEAD(0), Key_A, Key_C), leaderAC} );
// *INDENT-ON*
void setup() {
Kaleidoscope.setup();
Leader.time_out = 20;
Leader.dictionary = leader_dictionary;
}
void loop() {
Kaleidoscope.loop();
}

@ -0,0 +1,6 @@
{
"cpu": {
"fqbn": "keyboardio:virtual:model01",
"port": ""
}
}

@ -0,0 +1,107 @@
VERSION 1
KEYSWITCH LEAD_0 0 0
KEYSWITCH A 1 0
KEYSWITCH B 1 1
KEYSWITCH C 1 2
KEYSWITCH D 1 3
# ==============================================================================
NAME Leader sequence AC
RUN 4 ms
PRESS LEAD_0
RUN 1 cycle
RUN 4 ms
RELEASE LEAD_0
RUN 1 cycle
RUN 4 ms
PRESS A
RUN 1 cycle
RUN 4 ms
RELEASE A
RUN 1 cycle
RUN 4 ms
PRESS C
RUN 1 cycle
EXPECT keyboard-report Key_X # report should contain `X` (0x1b)
EXPECT keyboard-report empty # report should be empty
EXPECT keyboard-report Key_Y # report should contain `Y` (0x1c)
EXPECT keyboard-report empty # report should be empty
EXPECT keyboard-report Key_Z # report should contain `Z` (0x1d)
EXPECT keyboard-report empty # report should be empty
RUN 4 ms
RELEASE C
RUN 1 cycle
RUN 5 ms
EXPECT no keyboard-report # expect no more reports
# ==============================================================================
NAME Leader sequence BC
RUN 4 ms
PRESS LEAD_0
RUN 1 cycle
RUN 4 ms
RELEASE LEAD_0
RUN 1 cycle
RUN 4 ms
PRESS B
RUN 1 cycle
RUN 4 ms
RELEASE B
RUN 1 cycle
RUN 4 ms
PRESS C
RUN 1 cycle
EXPECT keyboard-report Key_X # report should contain `X` (0x1b)
EXPECT keyboard-report empty # report should be empty
RUN 4 ms
RELEASE C
RUN 1 cycle
RUN 5 ms
EXPECT no keyboard-report # expect no more reports
# ==============================================================================
NAME Leader sequence timeout
RUN 4 ms
PRESS LEAD_0
RUN 1 cycle
RUN 4 ms
RELEASE LEAD_0
RUN 1 cycle
RUN 4 ms
PRESS B
RUN 1 cycle
RUN 24 ms
RELEASE B
RUN 1 cycle
RUN 4 ms
PRESS C
RUN 1 cycle
EXPECT keyboard-report Key_C # report should contain `C` (0x06)
RUN 4 ms
RELEASE C
RUN 1 cycle
EXPECT keyboard-report empty # report should be empty
RUN 5 ms
EXPECT no keyboard-report # expect no more reports
Loading…
Cancel
Save