Browse Source

feat(test): add tests for toggle layer

xmkb
Cody McGinnis 4 years ago
parent
commit
a722cbcea3
  1. 28
      app/tests/toggle-layer/behavior_keymap.dtsi
  2. 2
      app/tests/toggle-layer/early-key-release/events.patterns
  3. 6
      app/tests/toggle-layer/early-key-release/keycode_events.snapshot
  4. 9
      app/tests/toggle-layer/early-key-release/native_posix.keymap
  5. 2
      app/tests/toggle-layer/normal/events.patterns
  6. 4
      app/tests/toggle-layer/normal/keycode_events.snapshot
  7. 8
      app/tests/toggle-layer/normal/native_posix.keymap

28
app/tests/toggle-layer/behavior_keymap.dtsi

@ -0,0 +1,28 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
/ {
keymap {
compatible = "zmk,keymap";
label ="Default keymap";
default_layer {
bindings = <
&kp B &tog 1
&kp D &kp G>;
};
lower_layer {
bindings = <
&cp M_NEXT &trans
&kp L &kp J>;
};
raise_layer {
bindings = <
&kp W &kp U
&kp X &kp M>;
};
};
};

2
app/tests/toggle-layer/early-key-release/events.patterns

@ -0,0 +1,2 @@
s/.*hid_listener_keycode/kp/p
s/.*tog_keymap_binding/tog/p

6
app/tests/toggle-layer/early-key-release/keycode_events.snapshot

@ -0,0 +1,6 @@
kp_pressed: usage_page 0x07 keycode 0x05
tog_pressed: position 1 layer 1
kp_released: usage_page 0x07 keycode 0x05
tog_released: position 1 layer 1
kp_pressed: usage_page 0x0c keycode 0xb5
kp_released: usage_page 0x0c keycode 0xb5

9
app/tests/toggle-layer/early-key-release/native_posix.keymap

@ -0,0 +1,9 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
#include "../behavior_keymap.dtsi"
&kscan {
events = <ZMK_MOCK_PRESS(0,0,10) ZMK_MOCK_PRESS(0,1,10) ZMK_MOCK_RELEASE(0,0,10) ZMK_MOCK_RELEASE(0,1,10)
ZMK_MOCK_PRESS(0,0,10) ZMK_MOCK_RELEASE(0,0,10)>;
};

2
app/tests/toggle-layer/normal/events.patterns

@ -0,0 +1,2 @@
s/.*hid_listener_keycode/kp/p
s/.*tog_keymap_binding/tog/p

4
app/tests/toggle-layer/normal/keycode_events.snapshot

@ -0,0 +1,4 @@
tog_pressed: position 1 layer 1
tog_released: position 1 layer 1
kp_pressed: usage_page 0x0c keycode 0xb5
kp_released: usage_page 0x0c keycode 0xb5

8
app/tests/toggle-layer/normal/native_posix.keymap

@ -0,0 +1,8 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan-mock.h>
#include "../behavior_keymap.dtsi"
&kscan {
events = <ZMK_MOCK_PRESS(0,1,10) ZMK_MOCK_RELEASE(0,1,10) ZMK_MOCK_PRESS(0,0,10) ZMK_MOCK_RELEASE(0,0,10)>;
};
Loading…
Cancel
Save