Skip to content

Commit

Permalink
Add tests for AutoShift explicit configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Marco Herrn <[email protected]>
  • Loading branch information
hupfdule committed Apr 13, 2023
1 parent 7722673 commit 88fc500
Show file tree
Hide file tree
Showing 4 changed files with 113 additions and 0 deletions.
54 changes: 54 additions & 0 deletions tests/plugins/AutoShift/explicit-config/explicit-config.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/* -*- 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-AutoShift.h>

// *INDENT-OFF*
KEYMAPS(
[0] = KEYMAP_STACKED
(
Key_LeftShift, Key_RightShift, ___, ___, ___, ___, ___,
Key_A, Key_B, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___,

___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___,
___, ___, ___, ___, ___, ___, ___,
___, ___, ___, ___,
___
),
)
// *INDENT-ON*

KALEIDOSCOPE_INIT_PLUGINS(AutoShift);

void setup() {
Kaleidoscope.setup();
AutoShift.setTimeout(20);

AUTOSHIFT(
kaleidoscope::plugin::LongPress(Key_A, Key_C),
)
}

void loop() {
Kaleidoscope.loop();
}
6 changes: 6 additions & 0 deletions tests/plugins/AutoShift/explicit-config/sketch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"cpu": {
"fqbn": "keyboardio:virtual:model01",
"port": ""
}
}
1 change: 1 addition & 0 deletions tests/plugins/AutoShift/explicit-config/sketch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
default_fqbn: keyboardio:virtual:model01
52 changes: 52 additions & 0 deletions tests/plugins/AutoShift/explicit-config/test.ktest
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
VERSION 1

KEYSWITCH LSHIFT 0 0
KEYSWITCH RSHIFT 0 1
KEYSWITCH A 1 0
KEYSWITCH B 1 1

# ==============================================================================
NAME AutoShift explicit config

RUN 4 ms
PRESS A
RUN 1 cycle

# Timeout is 20ms
RUN 20 ms
EXPECT keyboard-report Key_C # report: { 6 }

RUN 4 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report empty

RUN 5 ms

# ==============================================================================
NAME AutoShift explicit config shifted

RUN 4 ms
PRESS LSHIFT
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # report: { e1 }

RUN 4 ms
PRESS A
RUN 1 cycle

# Timeout is 20ms
RUN 20 ms
EXPECT keyboard-report Key_LeftShift Key_C # report: { 6 e1 }

RUN 4 ms
RELEASE A
RUN 1 cycle
EXPECT keyboard-report Key_LeftShift # report: { e1 }

RUN 4 ms
RELEASE LSHIFT
RUN 1 cycle
EXPECT keyboard-report empty

RUN 5 ms

0 comments on commit 88fc500

Please sign in to comment.