diff --git a/tests/features/layers/use-cases/sketch.json b/tests/features/layers/use-cases/sketch.json new file mode 100644 index 00000000..43dc4c7e --- /dev/null +++ b/tests/features/layers/use-cases/sketch.json @@ -0,0 +1,6 @@ +{ + "cpu": { + "fqbn": "keyboardio:virtual:model01", + "port": "" + } +} \ No newline at end of file diff --git a/tests/features/layers/use-cases/test.ktest b/tests/features/layers/use-cases/test.ktest new file mode 100644 index 00000000..162f0dd4 --- /dev/null +++ b/tests/features/layers/use-cases/test.ktest @@ -0,0 +1,1218 @@ +VERSION 1 + +KEYSWITCH L0 0 0 +KEYSWITCH L1 0 1 +KEYSWITCH L2 0 2 + +KEYSWITCH L01 1 0 +KEYSWITCH L02 1 1 +KEYSWITCH L12 1 2 + +KEYSWITCH LAYER_SHIFT_0 2 0 +KEYSWITCH LAYER_SHIFT_1 2 1 +KEYSWITCH LAYER_SHIFT_2 2 2 + +KEYSWITCH OTHER_SHIFT_0 2 0 +KEYSWITCH OTHER_SHIFT_1 2 1 +KEYSWITCH OTHER_SHIFT_2 2 2 + +KEYSWITCH LAYER_LOCK_0 3 0 +KEYSWITCH LAYER_LOCK_1 3 1 +KEYSWITCH LAYER_LOCK_2 3 2 + +KEYSWITCH LAYER_MOVE_0 0 7 +KEYSWITCH LAYER_MOVE_1 1 7 +KEYSWITCH LAYER_MOVE_2 2 7 + +KEYSWITCH LAYER_SHIFT_NEXT 0 10 +KEYSWITCH LAYER_SHIFT_PREV 0 11 + +# ============================================================================== +NAME Startup layer state + +# ............................................................ +# verify layer 0 active +RUN 4 ms +PRESS L0 +RUN 1 cycle +EXPECT keyboard-report Key_0 # Report should contain only `0` + +RUN 4 ms +RELEASE L0 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ............................................................ +# verify layer 2 inactive +RUN 4 ms +PRESS L2 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L2 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME Layer shift 1 + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 active +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 0 active +RUN 4 ms +PRESS L0 +RUN 1 cycle +EXPECT keyboard-report Key_0 # Report should contain only `0` + +RUN 4 ms +RELEASE L0 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 1 on top +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME Layer lock 1 + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 active +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 0 active +RUN 4 ms +PRESS L0 +RUN 1 cycle +EXPECT keyboard-report Key_0 # Report should contain only `0` + +RUN 4 ms +RELEASE L0 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 1 on top +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME Reset from layer shift + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` (reset layer state) +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME Layer moves + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(1)` +RUN 4 ms +PRESS LAYER_MOVE_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 0 +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(2)` +RUN 4 ms +PRESS LAYER_MOVE_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_2 +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ............................................................ +# verify layer 2 active +RUN 4 ms +PRESS L2 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L2 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 2 on top of layer 0 +RUN 4 ms +PRESS L02 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L02 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ............................................................ +# verify layer 2 inactive +RUN 4 ms +PRESS L2 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L2 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME Layer lock promotion + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ............................................................ +# verify layer 2 on top of layer 1 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 1 active +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 2 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 2 active +RUN 4 ms +PRESS L2 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L2 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ............................................................ +# verify layer 2 on top of layer 1 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 1 active +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ............................................................ +# verify layer 2 inactive +RUN 4 ms +PRESS L2 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L2 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME Layer lock promote base layer + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(0)` +RUN 4 ms +PRESS LAYER_LOCK_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_0 +RUN 1 cycle + +# ............................................................ +# verify layer 0 on top of layer 1 +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_0 # Report should contain only `0` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + + + + + + + + +# ============================================================================== +NAME Scenario A + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ............................................................ +# verify layer 2 on top of layer 1 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 0 +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 2 inactive +RUN 4 ms +PRESS L2 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L2 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME Scenario B + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 0 +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 0 +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` (reset layer state) +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + +# ============================================================================== +NAME Scenario C + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 0 +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + +# ============================================================================== +NAME Scenario D + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 2 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 2 active +RUN 4 ms +PRESS L2 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L2 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` (reset layer state) +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + +# ============================================================================== +NAME Scenario E + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 2 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 2 on top of layer 1 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 1 active +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ............................................................ +# verify layer 1 active +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` (reset layer state) +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + +# ============================================================================== +NAME Scenario F + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 2 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 2 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 2 on top of layer 0 +RUN 4 ms +PRESS L02 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L02 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` (reset layer state) +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + +# ============================================================================== +NAME Scenario G + +# ---------------------------------------------------------------------- +# press & hold `ShiftToLayer(1)` +RUN 4 ms +PRESS LAYER_SHIFT_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# tap `LockLayer(1)` +RUN 4 ms +PRESS LAYER_LOCK_1 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_1 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# release `ShiftToLayer(1)` +RUN 4 ms +RELEASE LAYER_SHIFT_1 +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 2 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ............................................................ +# verify layer 2 on top of layer 0 +RUN 4 ms +PRESS L02 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L02 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` (reset layer state) +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME layer shift next + +# ---------------------------------------------------------------------- +# press & hold `Key_KeymapNext_Momentary` +RUN 4 ms +PRESS LAYER_SHIFT_NEXT +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 0 +RUN 4 ms +PRESS L01 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L01 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# release `Key_KeymapNext_Momentary` +RUN 4 ms +RELEASE LAYER_SHIFT_NEXT +RUN 1 cycle + +# ............................................................ +# verify layer 1 inactive +RUN 4 ms +PRESS L1 +RUN 1 cycle +EXPECT no keyboard-report + +RUN 4 ms +RELEASE L1 +RUN 1 cycle +EXPECT no keyboard-report + +# ---------------------------------------------------------------------- +RUN 5 ms + + +# ============================================================================== +NAME layer shift previous + +# ---------------------------------------------------------------------- +# tap `LockLayer(2)` +RUN 4 ms +PRESS LAYER_LOCK_2 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_LOCK_2 +RUN 1 cycle + +# ---------------------------------------------------------------------- +# press & hold `Key_KeymapPrevious_Momentary` +RUN 4 ms +PRESS LAYER_SHIFT_PREV +RUN 1 cycle + +# ............................................................ +# verify layer 1 on top of layer 2 +RUN 4 ms +PRESS L12 +RUN 1 cycle +EXPECT keyboard-report Key_1 # Report should contain only `1` + +RUN 4 ms +RELEASE L12 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# release `Key_KeymapPrevious_Momentary` +RUN 4 ms +RELEASE LAYER_SHIFT_PREV +RUN 1 cycle + +# ............................................................ +# verify layer 2 on top of layer 0 +RUN 4 ms +PRESS L02 +RUN 1 cycle +EXPECT keyboard-report Key_2 # Report should contain only `2` + +RUN 4 ms +RELEASE L02 +RUN 1 cycle +EXPECT keyboard-report empty # Report should be empty + +# ---------------------------------------------------------------------- +# tap `MoveToLayer(0)` +RUN 4 ms +PRESS LAYER_MOVE_0 +RUN 1 cycle + +RUN 4 ms +RELEASE LAYER_MOVE_0 +RUN 1 cycle + +# ---------------------------------------------------------------------- +RUN 5 ms diff --git a/tests/features/layers/use-cases/use-cases.ino b/tests/features/layers/use-cases/use-cases.ino new file mode 100644 index 00000000..a914dbac --- /dev/null +++ b/tests/features/layers/use-cases/use-cases.ino @@ -0,0 +1,80 @@ +/* -*- 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 . + */ + +#include + +// *INDENT-OFF* +KEYMAPS( + [0] = KEYMAP_STACKED + ( + Key_0, ___, ___, ___, ___, ___, ___, + Key_0, Key_0, ___, ___, ___, ___, ___, + ShiftToLayer(0), ShiftToLayer(1), ShiftToLayer(2), ___, ___, ___, + LockLayer(0), LockLayer(1), LockLayer(2), ___, ___, ___, ___, + MoveToLayer(0), MoveToLayer(1), MoveToLayer(2), ___, + ___, + + ___, Key_KeymapNext_Momentary, Key_KeymapPrevious_Momentary, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ShiftToLayer(0), ShiftToLayer(1), ShiftToLayer(2), ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), + [1] = KEYMAP_STACKED + ( + ___, Key_1, ___, ___, ___, ___, ___, + Key_1, ___, Key_1, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), + [2] = KEYMAP_STACKED + ( + ___, ___, Key_2, ___, ___, ___, ___, + ___, Key_2, Key_2, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___, + + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, ___, ___, ___, + ___, ___, ___, ___, + ___ + ), +) +// *INDENT-ON* + +//KALEIDOSCOPE_INIT_PLUGINS(); + +void setup() { + Kaleidoscope.setup(); +} + +void loop() { + Kaleidoscope.loop(); +}