summaryrefslogtreecommitdiff
path: root/app/tests
diff options
context:
space:
mode:
Diffstat (limited to 'app/tests')
-rw-r--r--app/tests/wpm/1-single_keypress/events.patterns2
-rw-r--r--app/tests/wpm/1-single_keypress/keycode_events.snapshot7
-rw-r--r--app/tests/wpm/1-single_keypress/native_posix.conf9
-rw-r--r--app/tests/wpm/1-single_keypress/native_posix.keymap10
-rw-r--r--app/tests/wpm/2-multiple_keypress/events.patterns2
-rw-r--r--app/tests/wpm/2-multiple_keypress/keycode_events.snapshot4
-rw-r--r--app/tests/wpm/2-multiple_keypress/native_posix.conf9
-rw-r--r--app/tests/wpm/2-multiple_keypress/native_posix.keymap15
-rw-r--r--app/tests/wpm/behavior_keymap.dtsi17
9 files changed, 75 insertions, 0 deletions
diff --git a/app/tests/wpm/1-single_keypress/events.patterns b/app/tests/wpm/1-single_keypress/events.patterns
new file mode 100644
index 0000000..c49e6c0
--- /dev/null
+++ b/app/tests/wpm/1-single_keypress/events.patterns
@@ -0,0 +1,2 @@
+s/.*wpm_work_handler: //p
+s/.*wpm_event_listener: //p \ No newline at end of file
diff --git a/app/tests/wpm/1-single_keypress/keycode_events.snapshot b/app/tests/wpm/1-single_keypress/keycode_events.snapshot
new file mode 100644
index 0000000..c86f323
--- /dev/null
+++ b/app/tests/wpm/1-single_keypress/keycode_events.snapshot
@@ -0,0 +1,7 @@
+key_pressed_count 1 keycode 5
+Raised WPM state changed 12 wpm_update_counter 1
+Raised WPM state changed 6 wpm_update_counter 2
+Raised WPM state changed 4 wpm_update_counter 3
+Raised WPM state changed 3 wpm_update_counter 4
+Raised WPM state changed 2 wpm_update_counter 5
+Raised WPM state changed 0 wpm_update_counter 1
diff --git a/app/tests/wpm/1-single_keypress/native_posix.conf b/app/tests/wpm/1-single_keypress/native_posix.conf
new file mode 100644
index 0000000..360e77d
--- /dev/null
+++ b/app/tests/wpm/1-single_keypress/native_posix.conf
@@ -0,0 +1,9 @@
+CONFIG_KSCAN=n
+CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
+CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
+CONFIG_GPIO=n
+CONFIG_ZMK_BLE=n
+CONFIG_LOG=y
+CONFIG_LOG_BACKEND_SHOW_COLOR=n
+CONFIG_ZMK_LOG_LEVEL_DBG=y
+CONFIG_ZMK_WPM=y \ No newline at end of file
diff --git a/app/tests/wpm/1-single_keypress/native_posix.keymap b/app/tests/wpm/1-single_keypress/native_posix.keymap
new file mode 100644
index 0000000..ec12a28
--- /dev/null
+++ b/app/tests/wpm/1-single_keypress/native_posix.keymap
@@ -0,0 +1,10 @@
+#include "../behavior_keymap.dtsi"
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ /* Wait for the worker to trigger and reset after 5 seconds, followed by a 0 at 6 seconds */
+ ZMK_MOCK_PRESS(0,0,6000)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/wpm/2-multiple_keypress/events.patterns b/app/tests/wpm/2-multiple_keypress/events.patterns
new file mode 100644
index 0000000..c49e6c0
--- /dev/null
+++ b/app/tests/wpm/2-multiple_keypress/events.patterns
@@ -0,0 +1,2 @@
+s/.*wpm_work_handler: //p
+s/.*wpm_event_listener: //p \ No newline at end of file
diff --git a/app/tests/wpm/2-multiple_keypress/keycode_events.snapshot b/app/tests/wpm/2-multiple_keypress/keycode_events.snapshot
new file mode 100644
index 0000000..a0e8f7a
--- /dev/null
+++ b/app/tests/wpm/2-multiple_keypress/keycode_events.snapshot
@@ -0,0 +1,4 @@
+key_pressed_count 1 keycode 5
+Raised WPM state changed 12 wpm_update_counter 1
+key_pressed_count 2 keycode 5
+Raised WPM state changed 8 wpm_update_counter 3
diff --git a/app/tests/wpm/2-multiple_keypress/native_posix.conf b/app/tests/wpm/2-multiple_keypress/native_posix.conf
new file mode 100644
index 0000000..f0e1a48
--- /dev/null
+++ b/app/tests/wpm/2-multiple_keypress/native_posix.conf
@@ -0,0 +1,9 @@
+CONFIG_KSCAN=n
+CONFIG_ZMK_KSCAN_MOCK_DRIVER=y
+CONFIG_ZMK_KSCAN_GPIO_DRIVER=n
+CONFIG_GPIO=n
+CONFIG_ZMK_BLE=n
+CONFIG_LOG=y
+CONFIG_LOG_BACKEND_SHOW_COLOR=n
+CONFIG_ZMK_LOG_LEVEL_DBG=y
+CONFIG_ZMK_WPM=y
diff --git a/app/tests/wpm/2-multiple_keypress/native_posix.keymap b/app/tests/wpm/2-multiple_keypress/native_posix.keymap
new file mode 100644
index 0000000..f4ba2df
--- /dev/null
+++ b/app/tests/wpm/2-multiple_keypress/native_posix.keymap
@@ -0,0 +1,15 @@
+#include "../behavior_keymap.dtsi"
+
+&kscan {
+ events = <
+ ZMK_MOCK_PRESS(0,0,10)
+ ZMK_MOCK_RELEASE(0,0,10)
+ //1st WPM worker call - 12wpm - 1 key press in 1 second
+ ZMK_MOCK_PRESS(0,0,1000)
+ ZMK_MOCK_RELEASE(0,0,10)
+ // 2nd WPM worker call - 12wpm - 2 key press in 2 second
+ // note there is no event for this as WPM hasn't changed
+ // 3rd WPM worker call - 8wpm - 2 key press in 3 seconds
+ ZMK_MOCK_PRESS(0,0,2000)
+ >;
+}; \ No newline at end of file
diff --git a/app/tests/wpm/behavior_keymap.dtsi b/app/tests/wpm/behavior_keymap.dtsi
new file mode 100644
index 0000000..f0c5d0c
--- /dev/null
+++ b/app/tests/wpm/behavior_keymap.dtsi
@@ -0,0 +1,17 @@
+#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 &none
+ &none &none
+ >;
+ };
+ };
+};