-
Notifications
You must be signed in to change notification settings - Fork 260
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1374 from justincmoy/cycle-tests
Add tests for the Cycle plugin
- Loading branch information
Showing
5 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* -*- 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-Cycle.h> | ||
|
||
#include "./common.h" | ||
|
||
// *INDENT-OFF* | ||
KEYMAPS( | ||
[0] = KEYMAP_STACKED | ||
( | ||
Key_A, Key_B, Key_C, Key_D, Key_Cycle, ___, ___, | ||
___, ___, ___, ___, ___, ___, ___, | ||
___, ___, ___, ___, ___, ___, | ||
___, ___, ___, ___, ___, ___, ___, | ||
___, ___, ___, ___, | ||
___, | ||
|
||
___, ___, ___, ___, ___, ___, ___, | ||
___, ___, ___, ___, ___, ___, ___, | ||
___, ___, ___, ___, ___, ___, | ||
___, ___, ___, ___, ___, ___, ___, | ||
___, ___, ___, ___, | ||
___ | ||
), | ||
) | ||
// *INDENT-ON* | ||
|
||
|
||
void cycleAction(Key previous_key, uint8_t cycle_count) { | ||
if (previous_key == Key_A) { | ||
Cycle.replace(Key_1); | ||
} else if (previous_key == Key_B) { | ||
cycleThrough(Key_B, Key_1, Key_2); | ||
} | ||
} | ||
|
||
KALEIDOSCOPE_INIT_PLUGINS(Cycle); | ||
|
||
void setup() { | ||
Kaleidoscope.setup(); | ||
} | ||
|
||
void loop() { | ||
Kaleidoscope.loop(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"cpu": { | ||
"fqbn": "keyboardio:virtual:model01", | ||
"port": "" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
default_fqbn: keyboardio:virtual:model01 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
VERSION 1 | ||
|
||
KEYSWITCH A 0 0 | ||
KEYSWITCH B 0 1 | ||
KEYSWITCH C 0 2 | ||
KEYSWITCH D 0 3 | ||
KEYSWITCH CYCLE 0 4 | ||
|
||
# ============================================================================== | ||
NAME Cycle simple_replace | ||
RUN 5 ms | ||
PRESS A | ||
RUN 1 cycle | ||
EXPECT keyboard-report Key_A # Report should contain A | ||
RELEASE A | ||
RUN 1 cycle | ||
PRESS CYCLE | ||
EXPECT keyboard-report empty # Report should be empty | ||
RUN 1 cycle | ||
RELEASE CYCLE | ||
RUN 1 cycle | ||
EXPECT keyboard-report Key_Backspace # Report should contain Backspace | ||
EXPECT keyboard-report empty # Report should be empty after Backspace | ||
EXPECT keyboard-report Key_1 # Report should contain 1 | ||
EXPECT keyboard-report empty # Report should be empty after 1 | ||
|
||
NAME Cycle cycleThrough_with_loop | ||
RUN 5 ms | ||
PRESS B | ||
RUN 1 cycle | ||
EXPECT keyboard-report Key_B # Report should contain B | ||
RELEASE B | ||
RUN 1 cycle | ||
PRESS CYCLE | ||
EXPECT keyboard-report empty # Report should be empty | ||
RUN 1 cycle | ||
RELEASE CYCLE | ||
RUN 1 cycle | ||
EXPECT keyboard-report Key_Backspace # Report should contain Backspace for first key | ||
EXPECT keyboard-report empty # Report should be empty after Backspace for first key | ||
EXPECT keyboard-report Key_1 # Report should contain 1 | ||
EXPECT keyboard-report empty # Report should be empty after 1 | ||
RUN 1 cycle | ||
PRESS CYCLE | ||
RUN 1 cycle | ||
RELEASE CYCLE | ||
RUN 1 cycle | ||
EXPECT keyboard-report Key_Backspace # Report should contain Backspace for second key | ||
EXPECT keyboard-report empty # Report should be empty after Backspace for second key | ||
EXPECT keyboard-report Key_2 # Report should contain 2 | ||
EXPECT keyboard-report empty # Report should be empty after 2 | ||
RUN 1 cycle | ||
PRESS CYCLE | ||
RUN 1 cycle | ||
RELEASE CYCLE | ||
RUN 1 cycle | ||
EXPECT keyboard-report Key_Backspace # Report should contain Backspace for zeroth key | ||
EXPECT keyboard-report empty # Report should be empty after Backspace for zeroth key | ||
EXPECT keyboard-report Key_B # Report should contain B again | ||
EXPECT keyboard-report empty # Report should be empty after B again | ||
|
||
NAME Cycle does_not_activate | ||
RUN 5 ms | ||
PRESS C | ||
RUN 1 cycle | ||
EXPECT keyboard-report Key_C # Report should contain C | ||
RELEASE C | ||
RUN 1 cycle | ||
PRESS CYCLE | ||
EXPECT keyboard-report empty # Report should be empty | ||
RUN 1 cycle | ||
RELEASE CYCLE |