aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/combo/combo_repress/config.h10
-rw-r--r--tests/combo/combo_repress/test.mk6
-rw-r--r--tests/combo/combo_repress/test_combo.cpp158
-rw-r--r--tests/combo/combo_repress/test_combos_repress.c43
-rw-r--r--tests/layer_lock/config.h8
-rw-r--r--tests/layer_lock/test.mk8
-rw-r--r--tests/layer_lock/test_layer_lock.cpp284
-rw-r--r--tests/mousekeys/config.h6
-rw-r--r--tests/mousekeys/test.mk1
-rw-r--r--tests/mousekeys/test_mousekeys.cpp109
-rw-r--r--tests/pointing/config.h6
-rw-r--r--tests/pointing/invertandrotate/config.h9
-rw-r--r--tests/pointing/invertandrotate/test.mk2
-rw-r--r--tests/pointing/invertandrotate/test_invertandrotate.cpp59
-rw-r--r--tests/pointing/invertxy/config.h9
-rw-r--r--tests/pointing/invertxy/test.mk2
-rw-r--r--tests/pointing/invertxy/test_invertxy.cpp53
-rw-r--r--tests/pointing/rotate180/config.h8
-rw-r--r--tests/pointing/rotate180/test.mk2
-rw-r--r--tests/pointing/rotate180/test_rotate180.cpp55
-rw-r--r--tests/pointing/rotate270/config.h8
-rw-r--r--tests/pointing/rotate270/test.mk2
-rw-r--r--tests/pointing/rotate270/test_rotate270.cpp60
-rw-r--r--tests/pointing/rotate90/config.h8
-rw-r--r--tests/pointing/rotate90/test.mk2
-rw-r--r--tests/pointing/rotate90/test_rotate90.cpp60
-rw-r--r--tests/pointing/test.mk4
-rw-r--r--tests/pointing/test_pointing.cpp166
-rw-r--r--tests/test_common/keyboard_report_util.cpp2
-rw-r--r--tests/test_common/keycode_table.cpp19
-rw-r--r--tests/test_common/keycode_util.cpp2
-rw-r--r--tests/test_common/mouse_report_util.cpp58
-rw-r--r--tests/test_common/mouse_report_util.hpp38
-rw-r--r--tests/test_common/pointing_device_driver.c109
-rw-r--r--tests/test_common/test_driver.cpp1
-rw-r--r--tests/test_common/test_driver.hpp42
-rw-r--r--tests/test_common/test_fixture.cpp4
-rw-r--r--tests/test_common/test_pointing_device_driver.h32
38 files changed, 1450 insertions, 5 deletions
diff --git a/tests/combo/combo_repress/config.h b/tests/combo/combo_repress/config.h
new file mode 100644
index 0000000000..61ba58177e
--- /dev/null
+++ b/tests/combo/combo_repress/config.h
@@ -0,0 +1,10 @@
+// Copyright 2024 @Filios92
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
+
+#define TAPPING_TERM 200
+
+#define COMBO_PROCESS_KEY_REPRESS
diff --git a/tests/combo/combo_repress/test.mk b/tests/combo/combo_repress/test.mk
new file mode 100644
index 0000000000..cc3f482f4b
--- /dev/null
+++ b/tests/combo/combo_repress/test.mk
@@ -0,0 +1,6 @@
+# Copyright 2024 @Filios92
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+COMBO_ENABLE = yes
+
+INTROSPECTION_KEYMAP_C = test_combos_repress.c
diff --git a/tests/combo/combo_repress/test_combo.cpp b/tests/combo/combo_repress/test_combo.cpp
new file mode 100644
index 0000000000..1488d5c1bd
--- /dev/null
+++ b/tests/combo/combo_repress/test_combo.cpp
@@ -0,0 +1,158 @@
+// Copyright 2024 @Filios92
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "keyboard_report_util.hpp"
+#include "quantum.h"
+#include "keycode.h"
+#include "test_common.h"
+#include "test_driver.hpp"
+#include "test_fixture.hpp"
+#include "test_keymap_key.hpp"
+
+using testing::_;
+using testing::InSequence;
+
+class ComboRepress : public TestFixture {};
+
+TEST_F(ComboRepress, combo_repress_tapped) {
+ TestDriver driver;
+ KeymapKey key_f(0, 0, 0, KC_F);
+ KeymapKey key_g(0, 0, 1, KC_G);
+ set_keymap({key_f, key_g});
+
+ EXPECT_REPORT(driver, (KC_LEFT_ALT)).Times(2);
+ EXPECT_REPORT(driver, (KC_TAB, KC_LEFT_ALT));
+ EXPECT_EMPTY_REPORT(driver);
+ tap_combo({key_f, key_g}, 20);
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(ComboRepress, combo_repress_held_released_one_key_and_repressed) {
+ TestDriver driver;
+ KeymapKey key_f(0, 0, 0, KC_F);
+ KeymapKey key_g(0, 0, 1, KC_G);
+ KeymapKey key_h(0, 0, 2, KC_H);
+ KeymapKey key_j(0, 0, 3, KC_J);
+ set_keymap({key_f, key_g, key_h, key_j});
+
+ /* Press combo F+G */
+ EXPECT_REPORT(driver, (KC_LEFT_ALT)).Times(2);
+ EXPECT_REPORT(driver, (KC_TAB, KC_LEFT_ALT));
+ key_f.press();
+ run_one_scan_loop();
+ key_g.press();
+ run_one_scan_loop();
+ idle_for(COMBO_TERM + 1);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release G */
+ EXPECT_NO_REPORT(driver);
+ key_g.release();
+ idle_for(80);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Tap G */
+ EXPECT_REPORT(driver, (KC_TAB, KC_LEFT_ALT));
+ EXPECT_REPORT(driver, (KC_LEFT_ALT));
+ tap_key(key_g, TAPPING_TERM + 1);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Tap G, but hold for longer */
+ EXPECT_REPORT(driver, (KC_TAB, KC_LEFT_ALT));
+ EXPECT_REPORT(driver, (KC_LEFT_ALT));
+ tap_key(key_g, TAPPING_TERM * 2);
+ VERIFY_AND_CLEAR(driver);
+
+ idle_for(500);
+
+ /* Tap other combo while holding F */
+ EXPECT_REPORT(driver, (KC_ESCAPE, KC_LEFT_ALT));
+ EXPECT_REPORT(driver, (KC_LEFT_ALT));
+ tap_combo({key_h, key_j}, TAPPING_TERM + 1);
+ VERIFY_AND_CLEAR(driver);
+
+ /* G press and hold */
+ EXPECT_REPORT(driver, (KC_TAB, KC_LEFT_ALT));
+ EXPECT_REPORT(driver, (KC_LEFT_ALT));
+ key_g.press();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* F release and tap */
+ EXPECT_REPORT(driver, (KC_LEFT_ALT, KC_LEFT_SHIFT)).Times(2);
+ EXPECT_REPORT(driver, (KC_TAB, KC_LEFT_ALT, KC_LEFT_SHIFT));
+ EXPECT_REPORT(driver, (KC_LEFT_ALT));
+ key_f.release();
+ run_one_scan_loop();
+ tap_key(key_f);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release G */
+ EXPECT_EMPTY_REPORT(driver);
+ key_g.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(ComboRepress, combo_repress_normal_combo) {
+ TestDriver driver;
+ KeymapKey key_f(0, 0, 0, KC_F);
+ KeymapKey key_g(0, 0, 1, KC_G);
+ KeymapKey key_h(0, 0, 2, KC_H);
+ KeymapKey key_j(0, 0, 3, KC_J);
+ set_keymap({key_f, key_g, key_h, key_j});
+
+ /* Press combo H+J */
+ EXPECT_REPORT(driver, (KC_ESCAPE));
+ key_h.press();
+ run_one_scan_loop();
+ key_j.press();
+ run_one_scan_loop();
+ idle_for(COMBO_TERM + 10);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release H */
+ EXPECT_NO_REPORT(driver);
+ key_h.release();
+ idle_for(80);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Tap H */
+ EXPECT_REPORT(driver, (KC_H, KC_ESCAPE));
+ EXPECT_REPORT(driver, (KC_ESCAPE));
+ tap_key(key_h);
+ VERIFY_AND_CLEAR(driver);
+
+ /* Tap H, but hold for longer */
+ EXPECT_REPORT(driver, (KC_H, KC_ESCAPE));
+ EXPECT_REPORT(driver, (KC_ESCAPE));
+ tap_key(key_h, TAPPING_TERM + 1);
+ VERIFY_AND_CLEAR(driver);
+
+ idle_for(500);
+
+ /* Tap other combo while holding K */
+ EXPECT_REPORT(driver, (KC_ESCAPE, KC_LEFT_ALT)).Times(2);
+ EXPECT_REPORT(driver, (KC_ESCAPE, KC_TAB, KC_LEFT_ALT));
+ EXPECT_REPORT(driver, (KC_ESCAPE));
+ tap_combo({key_f, key_g}, TAPPING_TERM + 1);
+ VERIFY_AND_CLEAR(driver);
+
+ /* H press and hold */
+ EXPECT_REPORT(driver, (KC_H, KC_ESCAPE));
+ key_h.press();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* J release and tap */
+ EXPECT_REPORT(driver, (KC_H));
+ key_j.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+
+ /* Release G */
+ EXPECT_EMPTY_REPORT(driver);
+ key_h.release();
+ run_one_scan_loop();
+ VERIFY_AND_CLEAR(driver);
+}
diff --git a/tests/combo/combo_repress/test_combos_repress.c b/tests/combo/combo_repress/test_combos_repress.c
new file mode 100644
index 0000000000..73fa77b0aa
--- /dev/null
+++ b/tests/combo/combo_repress/test_combos_repress.c
@@ -0,0 +1,43 @@
+// Copyright 2024 @Filios92
+// SPDX-License-Identifier: GPL-2.0-or-later
+#include "quantum.h"
+
+enum combos { alttab, esc };
+
+uint16_t const alttab_combo[] = {KC_F, KC_G, COMBO_END};
+uint16_t const esc_combo[] = {KC_H, KC_J, COMBO_END};
+
+// clang-format off
+combo_t key_combos[] = {
+ [alttab] = COMBO(alttab_combo, KC_NO),
+ [esc] = COMBO(esc_combo, KC_ESC)
+};
+// clang-format on
+
+void process_combo_event(uint16_t combo_index, bool pressed) {
+ switch (combo_index) {
+ case alttab:
+ if (pressed) {
+ register_mods(MOD_LALT);
+ tap_code(KC_TAB);
+ } else {
+ unregister_mods(MOD_LALT);
+ }
+ break;
+ }
+}
+
+bool process_combo_key_repress(uint16_t combo_index, combo_t *combo, uint8_t key_index, uint16_t keycode) {
+ switch (combo_index) {
+ case alttab:
+ switch (keycode) {
+ case KC_F:
+ tap_code16(S(KC_TAB));
+ return true;
+ case KC_G:
+ tap_code(KC_TAB);
+ return true;
+ }
+ }
+ return false;
+}
diff --git a/tests/layer_lock/config.h b/tests/layer_lock/config.h
new file mode 100644
index 0000000000..25d0b20c0e
--- /dev/null
+++ b/tests/layer_lock/config.h
@@ -0,0 +1,8 @@
+// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <[email protected]>
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
+
+#define LAYER_LOCK_IDLE_TIMEOUT 1000
diff --git a/tests/layer_lock/test.mk b/tests/layer_lock/test.mk
new file mode 100644
index 0000000000..05771e4dbf
--- /dev/null
+++ b/tests/layer_lock/test.mk
@@ -0,0 +1,8 @@
+# Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <[email protected]>
+# SPDX-License-Identifier: GPL-2.0-or-later
+
+# --------------------------------------------------------------------------------
+# Keep this file, even if it is empty, as a marker that this folder contains tests
+# --------------------------------------------------------------------------------
+
+LAYER_LOCK_ENABLE = yes
diff --git a/tests/layer_lock/test_layer_lock.cpp b/tests/layer_lock/test_layer_lock.cpp
new file mode 100644
index 0000000000..00742c3b43
--- /dev/null
+++ b/tests/layer_lock/test_layer_lock.cpp
@@ -0,0 +1,284 @@
+// Copyright 2021 Christopher Courtney, aka Drashna Jael're (@drashna) <[email protected]>
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "keycodes.h"
+#include "test_common.hpp"
+
+using testing::_;
+
+class LayerLock : public TestFixture {};
+
+TEST_F(LayerLock, LayerLockState) {
+ TestDriver driver;
+ KeymapKey key_a = KeymapKey(0, 0, 0, KC_A);
+ KeymapKey key_b = KeymapKey(1, 0, 0, KC_B);
+ KeymapKey key_c = KeymapKey(2, 0, 0, KC_C);
+ KeymapKey key_d = KeymapKey(3, 0, 0, KC_C);
+
+ set_keymap({key_a, key_b, key_c, key_d});
+
+ EXPECT_FALSE(is_layer_locked(1));
+ EXPECT_FALSE(is_layer_locked(2));
+ EXPECT_FALSE(is_layer_locked(3));
+
+ layer_lock_invert(1); // Layer 1: unlocked -> locked
+ layer_lock_on(2); // Layer 2: unlocked -> locked
+ layer_lock_off(3); // Layer 3: stays unlocked
+
+ // Layers 1 and 2 are now on.
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(layer_state_is(2));
+ // Layers 1 and 2 are now locked.
+ EXPECT_TRUE(is_layer_locked(1));
+ EXPECT_TRUE(is_layer_locked(2));
+ EXPECT_FALSE(is_layer_locked(3));
+
+ layer_lock_invert(1); // Layer 1: locked -> unlocked
+ layer_lock_on(2); // Layer 2: stays locked
+ layer_lock_on(3); // Layer 3: unlocked -> locked
+
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_TRUE(layer_state_is(2));
+ EXPECT_TRUE(layer_state_is(3));
+ EXPECT_FALSE(is_layer_locked(1));
+ EXPECT_TRUE(is_layer_locked(2));
+ EXPECT_TRUE(is_layer_locked(3));
+
+ layer_lock_invert(1); // Layer 1: unlocked -> locked
+ layer_lock_off(2); // Layer 2: locked -> unlocked
+
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_FALSE(layer_state_is(2));
+ EXPECT_TRUE(layer_state_is(3));
+ EXPECT_TRUE(is_layer_locked(1));
+ EXPECT_FALSE(is_layer_locked(2));
+ EXPECT_TRUE(is_layer_locked(3));
+
+ layer_lock_all_off(); // Layers 1 and 3: locked -> unlocked
+
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(layer_state_is(2));
+ EXPECT_FALSE(layer_state_is(3));
+ EXPECT_FALSE(is_layer_locked(1));
+ EXPECT_FALSE(is_layer_locked(2));
+ EXPECT_FALSE(is_layer_locked(3));
+}
+
+TEST_F(LayerLock, LayerLockMomentaryTest) {
+ TestDriver driver;
+ KeymapKey key_layer = KeymapKey(0, 0, 0, MO(1));
+ KeymapKey key_a = KeymapKey(0, 1, 0, KC_A);
+ KeymapKey key_trns = KeymapKey(1, 0, 0, KC_TRNS);
+ KeymapKey key_ll = KeymapKey(1, 1, 0, QK_LAYER_LOCK);
+
+ set_keymap({key_layer, key_a, key_trns, key_ll});
+
+ EXPECT_NO_REPORT(driver);
+ key_layer.press();
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ tap_key(key_ll);
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ key_layer.release();
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ // Pressing Layer Lock again unlocks the lock.
+ EXPECT_NO_REPORT(driver);
+ key_ll.press();
+ run_one_scan_loop();
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(LayerLock, LayerLockLayerTapTest) {
+ TestDriver driver;
+ KeymapKey key_layer = KeymapKey(0, 0, 0, LT(1, KC_B));
+ KeymapKey key_a = KeymapKey(0, 1, 0, KC_A);
+ KeymapKey key_trns = KeymapKey(1, 0, 0, KC_TRNS);
+ KeymapKey key_ll = KeymapKey(1, 1, 0, QK_LAYER_LOCK);
+
+ set_keymap({key_layer, key_a, key_trns, key_ll});
+
+ EXPECT_NO_REPORT(driver);
+ key_layer.press();
+ idle_for(TAPPING_TERM);
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ tap_key(key_ll);
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ // Pressing Layer Lock again unlocks the lock.
+ EXPECT_NO_REPORT(driver);
+ key_ll.press();
+ run_one_scan_loop();
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(LayerLock, LayerLockOneshotTapTest) {
+ TestDriver driver;
+ KeymapKey key_layer = KeymapKey(0, 0, 0, OSL(1));
+ KeymapKey key_a = KeymapKey(0, 1, 0, KC_A);
+ KeymapKey key_trns = KeymapKey(1, 0, 0, KC_TRNS);
+ KeymapKey key_ll = KeymapKey(1, 1, 0, QK_LAYER_LOCK);
+
+ set_keymap({key_layer, key_a, key_trns, key_ll});
+
+ EXPECT_NO_REPORT(driver);
+ tap_key(key_layer);
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ tap_key(key_ll);
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ // Pressing Layer Lock again unlocks the lock.
+ EXPECT_NO_REPORT(driver);
+ key_ll.press();
+ run_one_scan_loop();
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(LayerLock, LayerLockOneshotHoldTest) {
+ TestDriver driver;
+ KeymapKey key_layer = KeymapKey(0, 0, 0, OSL(1));
+ KeymapKey key_a = KeymapKey(0, 1, 0, KC_A);
+ KeymapKey key_trns = KeymapKey(1, 0, 0, KC_TRNS);
+ KeymapKey key_ll = KeymapKey(1, 1, 0, QK_LAYER_LOCK);
+
+ set_keymap({key_layer, key_a, key_trns, key_ll});
+
+ EXPECT_NO_REPORT(driver);
+ key_layer.press();
+ idle_for(TAPPING_TERM);
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ tap_key(key_ll);
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ key_layer.release();
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ // Pressing Layer Lock again unlocks the lock.
+ EXPECT_NO_REPORT(driver);
+ key_ll.press();
+ run_one_scan_loop();
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(LayerLock, LayerLockTimeoutTest) {
+ TestDriver driver;
+ KeymapKey key_layer = KeymapKey(0, 0, 0, MO(1));
+ KeymapKey key_a = KeymapKey(0, 1, 0, KC_A);
+ KeymapKey key_trns = KeymapKey(1, 0, 0, KC_TRNS);
+ KeymapKey key_ll = KeymapKey(1, 1, 0, QK_LAYER_LOCK);
+
+ set_keymap({key_layer, key_a, key_trns, key_ll});
+
+ EXPECT_NO_REPORT(driver);
+ key_layer.press();
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ tap_key(key_ll);
+ EXPECT_TRUE(layer_state_is(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ key_layer.release();
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ idle_for(LAYER_LOCK_IDLE_TIMEOUT);
+ run_one_scan_loop();
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(LayerLock, ToKeyOverridesLayerLock) {
+ TestDriver driver;
+ KeymapKey key_layer = KeymapKey(0, 0, 0, MO(1));
+ KeymapKey key_to0 = KeymapKey(1, 0, 0, TO(0));
+ KeymapKey key_ll = KeymapKey(1, 1, 0, QK_LAYER_LOCK);
+
+ set_keymap({key_layer, key_to0, key_ll});
+
+ EXPECT_NO_REPORT(driver);
+ layer_lock_on(1);
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_NO_REPORT(driver);
+ tap_key(key_to0); // TO(0) overrides Layer Lock and unlocks layer 1.
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(LayerLock, LayerClearOverridesLayerLock) {
+ TestDriver driver;
+ KeymapKey key_layer = KeymapKey(0, 0, 0, MO(1));
+ KeymapKey key_a = KeymapKey(0, 1, 0, KC_A);
+ KeymapKey key_ll = KeymapKey(1, 1, 0, QK_LAYER_LOCK);
+
+ set_keymap({key_layer, key_a, key_ll});
+
+ EXPECT_NO_REPORT(driver);
+ layer_lock_on(1);
+ run_one_scan_loop();
+ EXPECT_TRUE(layer_state_is(1));
+ EXPECT_TRUE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+
+ EXPECT_REPORT(driver, (KC_A));
+ layer_clear(); // layer_clear() overrides Layer Lock and unlocks layer 1.
+ key_a.press();
+ run_one_scan_loop();
+ EXPECT_FALSE(layer_state_is(1));
+ EXPECT_FALSE(is_layer_locked(1));
+ VERIFY_AND_CLEAR(driver);
+}
diff --git a/tests/mousekeys/config.h b/tests/mousekeys/config.h
new file mode 100644
index 0000000000..76bbbe8dae
--- /dev/null
+++ b/tests/mousekeys/config.h
@@ -0,0 +1,6 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
diff --git a/tests/mousekeys/test.mk b/tests/mousekeys/test.mk
new file mode 100644
index 0000000000..6c605daecf
--- /dev/null
+++ b/tests/mousekeys/test.mk
@@ -0,0 +1 @@
+MOUSEKEY_ENABLE = yes
diff --git a/tests/mousekeys/test_mousekeys.cpp b/tests/mousekeys/test_mousekeys.cpp
new file mode 100644
index 0000000000..a1b8e06cf7
--- /dev/null
+++ b/tests/mousekeys/test_mousekeys.cpp
@@ -0,0 +1,109 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "gtest/gtest.h"
+#include "mouse_report_util.hpp"
+#include "test_common.hpp"
+
+using testing::_;
+
+struct MouseKeyExpectations {
+ int16_t x;
+ int16_t y;
+ int16_t h;
+ int16_t v;
+ uint16_t button_mask;
+};
+
+class Mousekey : public TestFixture {};
+class MousekeyParametrized : public ::testing::WithParamInterface<std::pair<KeymapKey, MouseKeyExpectations>>, public Mousekey {};
+
+TEST_F(Mousekey, SendMouseNotCalledWhenNoKeyIsPressed) {
+ TestDriver driver;
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(Mousekey, PressAndHoldCursorUpIsCorrectlyReported) {
+ TestDriver driver;
+ KeymapKey mouse_key = KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_UP};
+
+ set_keymap({mouse_key});
+
+ EXPECT_MOUSE_REPORT(driver, (0, -8, 0, 0, 0));
+ mouse_key.press();
+ run_one_scan_loop();
+
+ EXPECT_MOUSE_REPORT(driver, (0, -2, 0, 0, 0));
+ idle_for(MOUSEKEY_INTERVAL);
+
+ EXPECT_EMPTY_MOUSE_REPORT(driver);
+ mouse_key.release();
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Mousekey, PressAndHoldButtonOneCorrectlyReported) {
+ TestDriver driver;
+ KeymapKey mouse_key = KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1};
+
+ set_keymap({mouse_key});
+
+ EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1));
+ mouse_key.press();
+ run_one_scan_loop();
+
+ idle_for(MOUSEKEY_INTERVAL);
+
+ EXPECT_EMPTY_MOUSE_REPORT(driver);
+ mouse_key.release();
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_P(MousekeyParametrized, PressAndReleaseIsCorrectlyReported) {
+ TestDriver driver;
+ KeymapKey mouse_key = GetParam().first;
+ MouseKeyExpectations expectations = GetParam().second;
+
+ set_keymap({mouse_key});
+
+ EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, expectations.button_mask));
+ mouse_key.press();
+ run_one_scan_loop();
+
+ EXPECT_EMPTY_MOUSE_REPORT(driver);
+ mouse_key.release();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ Keys,
+ MousekeyParametrized,
+ ::testing::Values(
+ // Key , X, Y, H, V, Buttons Mask
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, MouseKeyExpectations{ 0, 0, 0, 0, 1}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_2}, MouseKeyExpectations{ 0, 0, 0, 0, 2}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_3}, MouseKeyExpectations{ 0, 0, 0, 0, 4}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_4}, MouseKeyExpectations{ 0, 0, 0, 0, 8}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_5}, MouseKeyExpectations{ 0, 0, 0, 0, 16}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_6}, MouseKeyExpectations{ 0, 0, 0, 0, 32}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_7}, MouseKeyExpectations{ 0, 0, 0, 0, 64}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_8}, MouseKeyExpectations{ 0, 0, 0, 0, 128}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_UP}, MouseKeyExpectations{ 0,-8, 0, 0, 0}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_DOWN}, MouseKeyExpectations{ 0, 8, 0, 0, 0}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_LEFT}, MouseKeyExpectations{-8, 0, 0, 0, 0}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_CURSOR_RIGHT}, MouseKeyExpectations{ 8, 0, 0, 0, 0}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_UP}, MouseKeyExpectations{ 0, 0, 0, 1, 0}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_DOWN}, MouseKeyExpectations{ 0, 0, 0,-1, 0}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_LEFT}, MouseKeyExpectations{ 0, 0,-1, 0, 0}),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_WHEEL_RIGHT}, MouseKeyExpectations{ 0, 0, 1, 0, 0})
+ ));
+// clang-format on
diff --git a/tests/pointing/config.h b/tests/pointing/config.h
new file mode 100644
index 0000000000..76bbbe8dae
--- /dev/null
+++ b/tests/pointing/config.h
@@ -0,0 +1,6 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
diff --git a/tests/pointing/invertandrotate/config.h b/tests/pointing/invertandrotate/config.h
new file mode 100644
index 0000000000..a3f3df7a54
--- /dev/null
+++ b/tests/pointing/invertandrotate/config.h
@@ -0,0 +1,9 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
+
+#define POINTING_DEVICE_INVERT_X
+#define POINTING_DEVICE_ROTATION_90
diff --git a/tests/pointing/invertandrotate/test.mk b/tests/pointing/invertandrotate/test.mk
new file mode 100644
index 0000000000..ba224d74f0
--- /dev/null
+++ b/tests/pointing/invertandrotate/test.mk
@@ -0,0 +1,2 @@
+POINTING_DEVICE_ENABLE = yes
+POINTING_DEVICE_DRIVER = custom
diff --git a/tests/pointing/invertandrotate/test_invertandrotate.cpp b/tests/pointing/invertandrotate/test_invertandrotate.cpp
new file mode 100644
index 0000000000..b47739f415
--- /dev/null
+++ b/tests/pointing/invertandrotate/test_invertandrotate.cpp
@@ -0,0 +1,59 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "gtest/gtest.h"
+#include "mouse_report_util.hpp"
+#include "test_common.hpp"
+#include "test_pointing_device_driver.h"
+
+using testing::_;
+
+struct SimpleReport {
+ int16_t x;
+ int16_t y;
+ int16_t h;
+ int16_t v;
+};
+
+class Pointing : public TestFixture {};
+class PointingInvertAndRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
+
+TEST_P(PointingInvertAndRotateParametrized, PointingInvertAndRotateOrder) {
+ TestDriver driver;
+ SimpleReport input = GetParam().first;
+ SimpleReport expectations = GetParam().second;
+
+ pd_set_x(input.x);
+ pd_set_y(input.y);
+ pd_set_h(input.h);
+ pd_set_v(input.v);
+
+ EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
+ run_one_scan_loop();
+
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ pd_clear_movement();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ InvertAndRotate,
+ PointingInvertAndRotateParametrized,
+ ::testing::Values(
+ // Input Expected // Actual Result - Rotate 90 then Invert X
+ std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // LEFT - DOWN
+ std::make_pair(SimpleReport{ 0, -1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // UP - RIGHT
+ std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0, -1, 0, 0}), // RIGHT - UP
+ std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ -1, 0, 0, 0}) // DOWN - LEFT
+ // Input Expected // Invert X then Rotate 90
+ // std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, -1, 0, 0}), // LEFT - UP
+ // std::make_pair(SimpleReport{ 0, -1, 0, 0}, SimpleReport{ -1, 0, 0, 0}), // UP - LEFT
+ // std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // RIGHT - DOWN
+ // std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 1, 0, 0, 0}) // DOWN - RIGHT
+ ));
+// clang-format on
diff --git a/tests/pointing/invertxy/config.h b/tests/pointing/invertxy/config.h
new file mode 100644
index 0000000000..6b29185d37
--- /dev/null
+++ b/tests/pointing/invertxy/config.h
@@ -0,0 +1,9 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
+
+#define POINTING_DEVICE_INVERT_X
+#define POINTING_DEVICE_INVERT_Y
diff --git a/tests/pointing/invertxy/test.mk b/tests/pointing/invertxy/test.mk
new file mode 100644
index 0000000000..ba224d74f0
--- /dev/null
+++ b/tests/pointing/invertxy/test.mk
@@ -0,0 +1,2 @@
+POINTING_DEVICE_ENABLE = yes
+POINTING_DEVICE_DRIVER = custom
diff --git a/tests/pointing/invertxy/test_invertxy.cpp b/tests/pointing/invertxy/test_invertxy.cpp
new file mode 100644
index 0000000000..014f6f3cd0
--- /dev/null
+++ b/tests/pointing/invertxy/test_invertxy.cpp
@@ -0,0 +1,53 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "gtest/gtest.h"
+#include "mouse_report_util.hpp"
+#include "test_common.hpp"
+#include "test_pointing_device_driver.h"
+
+using testing::_;
+
+struct SimpleReport {
+ int16_t x;
+ int16_t y;
+ int16_t h;
+ int16_t v;
+};
+
+class Pointing : public TestFixture {};
+class PointingInvertXYParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
+
+TEST_P(PointingInvertXYParametrized, PointingInvertXY) {
+ TestDriver driver;
+ SimpleReport input = GetParam().first;
+ SimpleReport expectations = GetParam().second;
+
+ pd_set_x(input.x);
+ pd_set_y(input.y);
+ pd_set_h(input.h);
+ pd_set_v(input.v);
+
+ EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
+ run_one_scan_loop();
+
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ pd_clear_movement();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ X_Y_XY,
+ PointingInvertXYParametrized,
+ ::testing::Values(
+ // Input Expected
+ std::make_pair(SimpleReport{ 33, 0, 0, 0}, SimpleReport{ -33, 0, 0, 0}),
+ std::make_pair(SimpleReport{ 0, -127, 0, 0}, SimpleReport{ 0, 127, 0, 0}),
+ std::make_pair(SimpleReport{ 10, -20, 0, 0}, SimpleReport{ -10, 20, 0, 0})
+ ));
+// clang-format on
diff --git a/tests/pointing/rotate180/config.h b/tests/pointing/rotate180/config.h
new file mode 100644
index 0000000000..a80f5482fd
--- /dev/null
+++ b/tests/pointing/rotate180/config.h
@@ -0,0 +1,8 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
+
+#define POINTING_DEVICE_ROTATION_180
diff --git a/tests/pointing/rotate180/test.mk b/tests/pointing/rotate180/test.mk
new file mode 100644
index 0000000000..ba224d74f0
--- /dev/null
+++ b/tests/pointing/rotate180/test.mk
@@ -0,0 +1,2 @@
+POINTING_DEVICE_ENABLE = yes
+POINTING_DEVICE_DRIVER = custom
diff --git a/tests/pointing/rotate180/test_rotate180.cpp b/tests/pointing/rotate180/test_rotate180.cpp
new file mode 100644
index 0000000000..736cf9ea25
--- /dev/null
+++ b/tests/pointing/rotate180/test_rotate180.cpp
@@ -0,0 +1,55 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "gtest/gtest.h"
+#include "mouse_report_util.hpp"
+#include "test_common.hpp"
+#include "test_pointing_device_driver.h"
+
+using testing::_;
+
+struct SimpleReport {
+ int16_t x;
+ int16_t y;
+ int16_t h;
+ int16_t v;
+};
+
+class Pointing : public TestFixture {};
+class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
+
+TEST_P(PointingRotateParametrized, PointingRotateXY) {
+ TestDriver driver;
+ SimpleReport input = GetParam().first;
+ SimpleReport expectations = GetParam().second;
+
+ pd_set_x(input.x);
+ pd_set_y(input.y);
+ pd_set_h(input.h);
+ pd_set_v(input.v);
+
+ EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
+ run_one_scan_loop();
+
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ pd_clear_movement();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ Rotate180,
+ PointingRotateParametrized,
+ ::testing::Values(
+ // Input Expected
+ // Rotate Clockwise
+ std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // UP - DOWN
+ std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // DOWN - UP
+ std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{-1, 0, 0, 0}), // RIGHT - LEFT
+ std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 1, 0, 0, 0}) // LEFT - RIGHT
+ ));
+// clang-format on
diff --git a/tests/pointing/rotate270/config.h b/tests/pointing/rotate270/config.h
new file mode 100644
index 0000000000..3977dd95e6
--- /dev/null
+++ b/tests/pointing/rotate270/config.h
@@ -0,0 +1,8 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
+
+#define POINTING_DEVICE_ROTATION_270
diff --git a/tests/pointing/rotate270/test.mk b/tests/pointing/rotate270/test.mk
new file mode 100644
index 0000000000..ba224d74f0
--- /dev/null
+++ b/tests/pointing/rotate270/test.mk
@@ -0,0 +1,2 @@
+POINTING_DEVICE_ENABLE = yes
+POINTING_DEVICE_DRIVER = custom
diff --git a/tests/pointing/rotate270/test_rotate270.cpp b/tests/pointing/rotate270/test_rotate270.cpp
new file mode 100644
index 0000000000..6735f06248
--- /dev/null
+++ b/tests/pointing/rotate270/test_rotate270.cpp
@@ -0,0 +1,60 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "gtest/gtest.h"
+#include "mouse_report_util.hpp"
+#include "test_common.hpp"
+#include "test_pointing_device_driver.h"
+
+using testing::_;
+
+struct SimpleReport {
+ int16_t x;
+ int16_t y;
+ int16_t h;
+ int16_t v;
+};
+
+class Pointing : public TestFixture {};
+class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
+
+TEST_P(PointingRotateParametrized, PointingRotateXY) {
+ TestDriver driver;
+ SimpleReport input = GetParam().first;
+ SimpleReport expectations = GetParam().second;
+
+ pd_set_x(input.x);
+ pd_set_y(input.y);
+ pd_set_h(input.h);
+ pd_set_v(input.v);
+
+ EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
+ run_one_scan_loop();
+
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ pd_clear_movement();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ Rotate270,
+ PointingRotateParametrized,
+ ::testing::Values(
+ // Input Expected
+ // Actual Result - Rotate Anticlockwise
+ std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // UP - RIGHT
+ std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // DOWN - LEFT
+ std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}), // RIGHT - DOWN
+ std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}) // LEFT - UP
+ // Rotate Clockwise
+ // std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // UP - LEFT
+ // std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // DOWN - RIGHT
+ // std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // RIGHT - UP
+ // std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}) // LEFT - DOWN
+ ));
+// clang-format on
diff --git a/tests/pointing/rotate90/config.h b/tests/pointing/rotate90/config.h
new file mode 100644
index 0000000000..3a18ec92e9
--- /dev/null
+++ b/tests/pointing/rotate90/config.h
@@ -0,0 +1,8 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#include "test_common.h"
+
+#define POINTING_DEVICE_ROTATION_90
diff --git a/tests/pointing/rotate90/test.mk b/tests/pointing/rotate90/test.mk
new file mode 100644
index 0000000000..ba224d74f0
--- /dev/null
+++ b/tests/pointing/rotate90/test.mk
@@ -0,0 +1,2 @@
+POINTING_DEVICE_ENABLE = yes
+POINTING_DEVICE_DRIVER = custom
diff --git a/tests/pointing/rotate90/test_rotate90.cpp b/tests/pointing/rotate90/test_rotate90.cpp
new file mode 100644
index 0000000000..5c44faad0a
--- /dev/null
+++ b/tests/pointing/rotate90/test_rotate90.cpp
@@ -0,0 +1,60 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "gtest/gtest.h"
+#include "mouse_report_util.hpp"
+#include "test_common.hpp"
+#include "test_pointing_device_driver.h"
+
+using testing::_;
+
+struct SimpleReport {
+ int16_t x;
+ int16_t y;
+ int16_t h;
+ int16_t v;
+};
+
+class Pointing : public TestFixture {};
+class PointingRotateParametrized : public ::testing::WithParamInterface<std::pair<SimpleReport, SimpleReport>>, public Pointing {};
+
+TEST_P(PointingRotateParametrized, PointingRotateXY) {
+ TestDriver driver;
+ SimpleReport input = GetParam().first;
+ SimpleReport expectations = GetParam().second;
+
+ pd_set_x(input.x);
+ pd_set_y(input.y);
+ pd_set_h(input.h);
+ pd_set_v(input.v);
+
+ EXPECT_MOUSE_REPORT(driver, (expectations.x, expectations.y, expectations.h, expectations.v, 0));
+ run_one_scan_loop();
+
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ pd_clear_movement();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ Rotate90,
+ PointingRotateParametrized,
+ ::testing::Values(
+ // Input Expected
+ // Actual Result - Rotate Anticlockwise
+ std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // UP - LEFT
+ std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // DOWN - RIGHT
+ std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // RIGHT - UP
+ std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}) // LEFT - DOWN
+ // Rotate Clockwise
+ // std::make_pair(SimpleReport{ 0,-1, 0, 0}, SimpleReport{ 1, 0, 0, 0}), // UP - RIGHT
+ // std::make_pair(SimpleReport{ 0, 1, 0, 0}, SimpleReport{-1, 0, 0, 0}), // DOWN - LEFT
+ // std::make_pair(SimpleReport{ 1, 0, 0, 0}, SimpleReport{ 0,-1, 0, 0}), // RIGHT - DOWN
+ // std::make_pair(SimpleReport{ -1, 0, 0, 0}, SimpleReport{ 0, 1, 0, 0}) // LEFT - UP
+ ));
+// clang-format on
diff --git a/tests/pointing/test.mk b/tests/pointing/test.mk
new file mode 100644
index 0000000000..95fde21cb9
--- /dev/null
+++ b/tests/pointing/test.mk
@@ -0,0 +1,4 @@
+POINTING_DEVICE_ENABLE = yes
+MOUSEKEY_ENABLE = no
+POINTING_DEVICE_DRIVER = custom
+
diff --git a/tests/pointing/test_pointing.cpp b/tests/pointing/test_pointing.cpp
new file mode 100644
index 0000000000..d59d014925
--- /dev/null
+++ b/tests/pointing/test_pointing.cpp
@@ -0,0 +1,166 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "gtest/gtest.h"
+#include "mouse_report_util.hpp"
+#include "test_common.hpp"
+#include "test_pointing_device_driver.h"
+#include "mousekey.h"
+
+using testing::_;
+
+class Pointing : public TestFixture {};
+class PointingButtonsViaMousekeysParametrized : public ::testing::WithParamInterface<std::pair<KeymapKey, uint8_t>>, public Pointing {};
+
+TEST_F(Pointing, SendMouseIsNotCalledWithNoInput) {
+ TestDriver driver;
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+}
+
+TEST_F(Pointing, Xnegative) {
+ TestDriver driver;
+
+ pd_set_x(-10);
+ EXPECT_MOUSE_REPORT(driver, (-10, 0, 0, 0, 0));
+ run_one_scan_loop();
+
+ pd_clear_movement();
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Pointing, Xpositive) {
+ TestDriver driver;
+
+ pd_set_x(10);
+ EXPECT_MOUSE_REPORT(driver, (10, 0, 0, 0, 0));
+ run_one_scan_loop();
+
+ pd_clear_movement();
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Pointing, Ynegative) {
+ TestDriver driver;
+
+ pd_set_y(-20);
+ EXPECT_MOUSE_REPORT(driver, (0, -20, 0, 0, 0));
+ run_one_scan_loop();
+
+ pd_clear_movement();
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Pointing, Ypositive) {
+ TestDriver driver;
+
+ pd_set_y(20);
+ EXPECT_MOUSE_REPORT(driver, (0, 20, 0, 0, 0));
+ run_one_scan_loop();
+
+ pd_clear_movement();
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Pointing, XandY) {
+ TestDriver driver;
+
+ pd_set_x(-50);
+ pd_set_y(100);
+ EXPECT_MOUSE_REPORT(driver, (-50, 100, 0, 0, 0));
+ run_one_scan_loop();
+
+ pd_clear_movement();
+ // EXPECT_EMPTY_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Pointing, CorrectButtonIsReportedWhenPressed) {
+ TestDriver driver;
+
+ EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1));
+ pd_press_button(POINTING_DEVICE_BUTTON1);
+ run_one_scan_loop();
+
+ EXPECT_EMPTY_MOUSE_REPORT(driver);
+ pd_release_button(POINTING_DEVICE_BUTTON1);
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ pd_clear_all_buttons();
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_F(Pointing, CorrectButtonIsReportedWhenKeyPressed) {
+ TestDriver driver;
+ auto key = KeymapKey(0, 0, 0, KC_MS_BTN1);
+ set_keymap({key});
+
+ EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 1));
+ key.press();
+ run_one_scan_loop();
+
+ EXPECT_EMPTY_MOUSE_REPORT(driver);
+ key.release();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+
+TEST_P(PointingButtonsViaMousekeysParametrized, MouseKeysViaPointingDriver) {
+ TestDriver driver;
+ KeymapKey mouse_key = GetParam().first;
+ uint8_t button_mask = GetParam().second;
+
+ set_keymap({mouse_key});
+
+ EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, button_mask));
+ mouse_key.press();
+ run_one_scan_loop();
+
+ EXPECT_EMPTY_MOUSE_REPORT(driver);
+ mouse_key.release();
+ run_one_scan_loop();
+
+ EXPECT_NO_MOUSE_REPORT(driver);
+ run_one_scan_loop();
+
+ VERIFY_AND_CLEAR(driver);
+}
+// clang-format off
+INSTANTIATE_TEST_CASE_P(
+ ButtonsOneToEight,
+ PointingButtonsViaMousekeysParametrized,
+ ::testing::Values(
+ // Key , Buttons Mask
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_1}, 1),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_2}, 2),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_3}, 4),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_4}, 8),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_5}, 16),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_6}, 32),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_7}, 64),
+ std::make_pair(KeymapKey{0, 0, 0, QK_MOUSE_BUTTON_8}, 128)
+ ));
+// clang-format on
diff --git a/tests/test_common/keyboard_report_util.cpp b/tests/test_common/keyboard_report_util.cpp
index 5676483539..18e0574277 100644
--- a/tests/test_common/keyboard_report_util.cpp
+++ b/tests/test_common/keyboard_report_util.cpp
@@ -29,8 +29,6 @@ std::vector<uint8_t> get_keys(const report_keyboard_t& report) {
std::vector<uint8_t> result;
#if defined(NKRO_ENABLE)
# error NKRO support not implemented yet
-#elif defined(RING_BUFFERED_6KRO_REPORT_ENABLE)
-# error 6KRO support not implemented yet
#else
for (size_t i = 0; i < KEYBOARD_REPORT_KEYS; i++) {
if (report.keys[i]) {
diff --git a/tests/test_common/keycode_table.cpp b/tests/test_common/keycode_table.cpp
index 4c28ab4d20..ae1a9edcd0 100644
--- a/tests/test_common/keycode_table.cpp
+++ b/tests/test_common/keycode_table.cpp
@@ -562,6 +562,21 @@ std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {
{QK_MACRO_29, "QK_MACRO_29"},
{QK_MACRO_30, "QK_MACRO_30"},
{QK_MACRO_31, "QK_MACRO_31"},
+ {QK_OUTPUT_AUTO, "QK_OUTPUT_AUTO"},
+ {QK_OUTPUT_NEXT, "QK_OUTPUT_NEXT"},
+ {QK_OUTPUT_PREV, "QK_OUTPUT_PREV"},
+ {QK_OUTPUT_NONE, "QK_OUTPUT_NONE"},
+ {QK_OUTPUT_USB, "QK_OUTPUT_USB"},
+ {QK_OUTPUT_2P4GHZ, "QK_OUTPUT_2P4GHZ"},
+ {QK_OUTPUT_BLUETOOTH, "QK_OUTPUT_BLUETOOTH"},
+ {QK_BLUETOOTH_PROFILE_NEXT, "QK_BLUETOOTH_PROFILE_NEXT"},
+ {QK_BLUETOOTH_PROFILE_PREV, "QK_BLUETOOTH_PROFILE_PREV"},
+ {QK_BLUETOOTH_UNPAIR, "QK_BLUETOOTH_UNPAIR"},
+ {QK_BLUETOOTH_PROFILE1, "QK_BLUETOOTH_PROFILE1"},
+ {QK_BLUETOOTH_PROFILE2, "QK_BLUETOOTH_PROFILE2"},
+ {QK_BLUETOOTH_PROFILE3, "QK_BLUETOOTH_PROFILE3"},
+ {QK_BLUETOOTH_PROFILE4, "QK_BLUETOOTH_PROFILE4"},
+ {QK_BLUETOOTH_PROFILE5, "QK_BLUETOOTH_PROFILE5"},
{QK_BACKLIGHT_ON, "QK_BACKLIGHT_ON"},
{QK_BACKLIGHT_OFF, "QK_BACKLIGHT_OFF"},
{QK_BACKLIGHT_TOGGLE, "QK_BACKLIGHT_TOGGLE"},
@@ -632,9 +647,6 @@ std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {
{QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN, "QK_SPACE_CADET_LEFT_ALT_PARENTHESIS_OPEN"},
{QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE, "QK_SPACE_CADET_RIGHT_ALT_PARENTHESIS_CLOSE"},
{QK_SPACE_CADET_RIGHT_SHIFT_ENTER, "QK_SPACE_CADET_RIGHT_SHIFT_ENTER"},
- {QK_OUTPUT_AUTO, "QK_OUTPUT_AUTO"},
- {QK_OUTPUT_USB, "QK_OUTPUT_USB"},
- {QK_OUTPUT_BLUETOOTH, "QK_OUTPUT_BLUETOOTH"},
{QK_UNICODE_MODE_NEXT, "QK_UNICODE_MODE_NEXT"},
{QK_UNICODE_MODE_PREVIOUS, "QK_UNICODE_MODE_PREVIOUS"},
{QK_UNICODE_MODE_MACOS, "QK_UNICODE_MODE_MACOS"},
@@ -687,6 +699,7 @@ std::map<uint16_t, std::string> KEYCODE_ID_TABLE = {
{QK_TRI_LAYER_UPPER, "QK_TRI_LAYER_UPPER"},
{QK_REPEAT_KEY, "QK_REPEAT_KEY"},
{QK_ALT_REPEAT_KEY, "QK_ALT_REPEAT_KEY"},
+ {QK_LAYER_LOCK, "QK_LAYER_LOCK"},
{QK_KB_0, "QK_KB_0"},
{QK_KB_1, "QK_KB_1"},
{QK_KB_2, "QK_KB_2"},
diff --git a/tests/test_common/keycode_util.cpp b/tests/test_common/keycode_util.cpp
index 9f88d40ec7..539cab819a 100644
--- a/tests/test_common/keycode_util.cpp
+++ b/tests/test_common/keycode_util.cpp
@@ -94,6 +94,8 @@ std::string generate_identifier(uint16_t kc) {
s << "MO(" << +QK_MOMENTARY_GET_LAYER(kc) << ")";
} else if (IS_QK_DEF_LAYER(kc)) {
s << "DF(" << +QK_DEF_LAYER_GET_LAYER(kc) << ")";
+ } else if (IS_QK_PERSISTENT_DEF_LAYER(kc)) {
+ s << "PDF(" << +QK_PERSISTENT_DEF_LAYER_GET_LAYER(kc) << ")";
} else if (IS_QK_TOGGLE_LAYER(kc)) {
s << "TG(" << +QK_TOGGLE_LAYER_GET_LAYER(kc) << ")";
} else if (IS_QK_LAYER_TAP_TOGGLE(kc)) {
diff --git a/tests/test_common/mouse_report_util.cpp b/tests/test_common/mouse_report_util.cpp
new file mode 100644
index 0000000000..60cdeced24
--- /dev/null
+++ b/tests/test_common/mouse_report_util.cpp
@@ -0,0 +1,58 @@
+/* Copyright 2017 Fred Sundvik
+ *
+ * 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, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 "mouse_report_util.hpp"
+#include <cstdint>
+#include <vector>
+#include <algorithm>
+
+using namespace testing;
+
+bool operator==(const report_mouse_t& lhs, const report_mouse_t& rhs) {
+ return lhs.x == rhs.x && lhs.y == rhs.y && lhs.h == rhs.h && lhs.v == rhs.v && lhs.buttons == rhs.buttons;
+}
+
+std::ostream& operator<<(std::ostream& os, const report_mouse_t& report) {
+ os << std::setw(10) << std::left << "mouse report: ";
+
+ if (report.x == 0 && report.y == 0 && report.h == 0 && report.v == 0 && report.buttons == 0) {
+ return os << "empty" << std::endl;
+ }
+
+ os << "(X:" << (int)report.x << ", Y:" << (int)report.y << ", H:" << (int)report.h << ", V:" << (int)report.v << ", B:" << (int)report.buttons << ")";
+ return os << std::endl;
+}
+
+MouseReportMatcher::MouseReportMatcher(int16_t x, int16_t y, int8_t h, int8_t v, uint8_t button_mask) {
+ memset(&m_report, 0, sizeof(report_mouse_t));
+ m_report.x = x;
+ m_report.y = y;
+ m_report.h = h;
+ m_report.v = v;
+ m_report.buttons = button_mask;
+}
+
+bool MouseReportMatcher::MatchAndExplain(report_mouse_t& report, MatchResultListener* listener) const {
+ return m_report == report;
+}
+
+void MouseReportMatcher::DescribeTo(::std::ostream* os) const {
+ *os << "is equal to " << m_report;
+}
+
+void MouseReportMatcher::DescribeNegationTo(::std::ostream* os) const {
+ *os << "is not equal to " << m_report;
+}
diff --git a/tests/test_common/mouse_report_util.hpp b/tests/test_common/mouse_report_util.hpp
new file mode 100644
index 0000000000..645f6aa58c
--- /dev/null
+++ b/tests/test_common/mouse_report_util.hpp
@@ -0,0 +1,38 @@
+/* Copyright 2017 Fred Sundvik
+ *
+ * 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, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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 "report.h"
+#include <ostream>
+#include "gmock/gmock.h"
+
+bool operator==(const report_mouse_t& lhs, const report_mouse_t& rhs);
+std::ostream& operator<<(std::ostream& stream, const report_mouse_t& value);
+
+class MouseReportMatcher : public testing::MatcherInterface<report_mouse_t&> {
+ public:
+ MouseReportMatcher(int16_t x, int16_t y, int8_t h, int8_t v, uint8_t button_mask);
+ virtual bool MatchAndExplain(report_mouse_t& report, testing::MatchResultListener* listener) const override;
+ virtual void DescribeTo(::std::ostream* os) const override;
+ virtual void DescribeNegationTo(::std::ostream* os) const override;
+
+ private:
+ report_mouse_t m_report;
+};
+
+inline testing::Matcher<report_mouse_t&> MouseReport(int16_t x, int16_t y, int8_t h, int8_t v, uint8_t button_mask) {
+ return testing::MakeMatcher(new MouseReportMatcher(x, y, h, v, button_mask));
+}
diff --git a/tests/test_common/pointing_device_driver.c b/tests/test_common/pointing_device_driver.c
new file mode 100644
index 0000000000..b64dbad506
--- /dev/null
+++ b/tests/test_common/pointing_device_driver.c
@@ -0,0 +1,109 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include "report.h"
+#include "test_pointing_device_driver.h"
+#include <string.h>
+
+typedef struct {
+ bool pressed;
+ bool dirty;
+} pd_button_state_t;
+
+typedef struct {
+ int16_t x;
+ int16_t y;
+ int16_t h;
+ int16_t v;
+ pd_button_state_t button_state[8];
+ uint16_t cpi;
+ bool initiated;
+} pd_config_t;
+
+static pd_config_t pd_config = {0};
+
+void pointing_device_driver_init(void) {
+ pd_set_init(true);
+}
+
+report_mouse_t pointing_device_driver_get_report(report_mouse_t mouse_report) {
+ for (uint8_t i = 0; i < 8; i++) {
+ if (pd_config.button_state[i].dirty) {
+ pd_config.button_state[i].dirty = false;
+ if (pd_config.button_state[i].pressed) {
+ mouse_report.buttons |= 1 << (i);
+ } else {
+ mouse_report.buttons &= ~(1 << (i));
+ }
+ }
+ }
+ mouse_report.x = pd_config.x;
+ mouse_report.y = pd_config.y;
+ mouse_report.h = pd_config.h;
+ mouse_report.v = pd_config.v;
+ return mouse_report;
+}
+
+__attribute__((weak)) uint16_t pointing_device_driver_get_cpi(void) {
+ return pd_config.cpi;
+}
+
+__attribute__((weak)) void pointing_device_driver_set_cpi(uint16_t cpi) {
+ pd_config.cpi = cpi;
+}
+
+void pd_press_button(uint8_t btn) {
+ pd_config.button_state[btn].dirty = true;
+ pd_config.button_state[btn].pressed = true;
+}
+void pd_release_button(uint8_t btn) {
+ pd_config.button_state[btn].dirty = true;
+ pd_config.button_state[btn].pressed = false;
+}
+
+void pd_clear_all_buttons(void) {
+ for (uint8_t i = 0; i < 8; i++) {
+ pd_config.button_state[i].dirty = true;
+ pd_config.button_state[i].pressed = false;
+ }
+}
+
+void pd_set_x(int16_t x) {
+ pd_config.x = x;
+}
+
+void pd_clear_x(void) {
+ pd_set_x(0);
+}
+
+void pd_set_y(int16_t y) {
+ pd_config.y = y;
+}
+void pd_clear_y(void) {
+ pd_set_y(0);
+}
+
+void pd_set_h(int16_t h) {
+ pd_config.h = h;
+}
+void pd_clear_h(void) {
+ pd_set_h(0);
+}
+
+void pd_set_v(int16_t v) {
+ pd_config.v = v;
+}
+void pd_clear_v(void) {
+ pd_set_v(0);
+}
+
+void pd_clear_movement(void) {
+ pd_set_x(0);
+ pd_set_y(0);
+ pd_set_h(0);
+ pd_set_v(0);
+}
+
+void pd_set_init(bool success) {
+ pd_config.initiated = success;
+}
diff --git a/tests/test_common/test_driver.cpp b/tests/test_common/test_driver.cpp
index d410b225f9..70b920ac86 100644
--- a/tests/test_common/test_driver.cpp
+++ b/tests/test_common/test_driver.cpp
@@ -54,6 +54,7 @@ void TestDriver::send_nkro(report_nkro_t* report) {
}
void TestDriver::send_mouse(report_mouse_t* report) {
+ test_logger.trace() << std::setw(10) << std::left << "send_mouse: (X:" << (int)report->x << ", Y:" << (int)report->y << ", H:" << (int)report->h << ", V:" << (int)report->v << ", B:" << (int)report->buttons << ")" << std::endl;
m_this->send_mouse_mock(*report);
}
diff --git a/tests/test_common/test_driver.hpp b/tests/test_common/test_driver.hpp
index ec75d3fff2..fea8225953 100644
--- a/tests/test_common/test_driver.hpp
+++ b/tests/test_common/test_driver.hpp
@@ -67,6 +67,25 @@ class TestDriver {
#define EXPECT_REPORT(driver, report) EXPECT_CALL((driver), send_keyboard_mock(KeyboardReport report))
/**
+ * @brief Sets gmock expectation that a mouse report of `report` will be sent.
+ * For this macro to parse correctly, the `report` arg must be surrounded by
+ * parentheses ( ). For instance,
+ *
+ * // Expect that a report of "X:-10 Y:0 H:0 V:10 BTN:1 " is sent to the host.
+ * EXPECT_REPORT(driver, (-10, 0, 0, 0, 1));
+ *
+ * is shorthand for
+ *
+ * EXPECT_CALL(driver, send_mouse_mock(MouseReport(-10, 0, 0, 0, 1)));
+ *
+ * It is possible to use .Times() and other gmock APIS with EXPECT_REPORT, for instance,
+ * allow only single report to be sent:
+ *
+ * EXPECT_REPORT(driver, (-10, 0, 0, 0, 1)).Times(1);
+ */
+#define EXPECT_MOUSE_REPORT(driver, report) EXPECT_CALL((driver), send_mouse_mock(MouseReport report))
+
+/**
* @brief Sets gmock expectation that Unicode `code_point` is sent with UNICODE_MODE_LINUX input
* mode. For instance for U+2013,
*
@@ -88,6 +107,15 @@ class TestDriver {
#define EXPECT_EMPTY_REPORT(driver) EXPECT_REPORT(driver, ())
/**
+ * @brief Sets gmock expectation that a empty keyboard report will be sent.
+ * It is possible to use .Times() and other gmock APIS with EXPECT_EMPTY_MOUSE_REPORT, for instance,
+ * allow any number of empty reports with:
+ *
+ * EXPECT_EMPTY_MOUSE_REPORT(driver).Times(AnyNumber());
+ */
+#define EXPECT_EMPTY_MOUSE_REPORT(driver) EXPECT_MOUSE_REPORT(driver, (0, 0, 0, 0, 0))
+
+/**
* @brief Sets gmock expectation that a keyboard report will be sent, without matching its content.
* It is possible to use .Times() and other gmock APIS with EXPECT_ANY_REPORT, for instance,
* allow a single arbitrary report with:
@@ -97,10 +125,24 @@ class TestDriver {
#define EXPECT_ANY_REPORT(driver) EXPECT_CALL((driver), send_keyboard_mock(_))
/**
+ * @brief Sets gmock expectation that a mouse report will be sent, without matching its content.
+ * It is possible to use .Times() and other gmock APIS with EXPECT_ANY_MOUSE_REPORT, for instance,
+ * allow a single arbitrary report with:
+ *
+ * EXPECT_ANY_MOUSE_REPORT(driver).Times(1);
+ */
+#define EXPECT_ANY_MOUSE_REPORT(driver) EXPECT_CALL((driver), send_mouse_mock(_))
+
+/**
* @brief Sets gmock expectation that no keyboard report will be sent at all.
*/
#define EXPECT_NO_REPORT(driver) EXPECT_ANY_REPORT(driver).Times(0)
+/**
+ * @brief Sets gmock expectation that no keyboard report will be sent at all.
+ */
+#define EXPECT_NO_MOUSE_REPORT(driver) EXPECT_ANY_MOUSE_REPORT(driver).Times(0)
+
/** @brief Tests whether keycode `actual` is equal to `expected`. */
#define EXPECT_KEYCODE_EQ(actual, expected) EXPECT_THAT((actual), KeycodeEq((expected)))
diff --git a/tests/test_common/test_fixture.cpp b/tests/test_common/test_fixture.cpp
index 3cfb2cb4c2..81806b0e6d 100644
--- a/tests/test_common/test_fixture.cpp
+++ b/tests/test_common/test_fixture.cpp
@@ -7,6 +7,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
#include "keyboard_report_util.hpp"
+#include "mouse_report_util.hpp"
#include "keycode.h"
#include "test_driver.hpp"
#include "test_logger.hpp"
@@ -69,6 +70,9 @@ TestFixture::~TestFixture() {
/* Reset keyboard state. */
clear_all_keys();
+#ifdef MOUSEKEY_ENABLE
+ EXPECT_EMPTY_MOUSE_REPORT(driver);
+#endif
clear_keyboard();
clear_oneshot_mods();
diff --git a/tests/test_common/test_pointing_device_driver.h b/tests/test_common/test_pointing_device_driver.h
new file mode 100644
index 0000000000..ae136b21cd
--- /dev/null
+++ b/tests/test_common/test_pointing_device_driver.h
@@ -0,0 +1,32 @@
+// Copyright 2024 Dasky (@daskygit)
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void pd_press_button(uint8_t btn);
+void pd_release_button(uint8_t btn);
+void pd_clear_all_buttons(void);
+
+void pd_set_x(int16_t x);
+void clear_x(void);
+
+void pd_set_y(int16_t y);
+void pd_clear_y(void);
+
+void pd_set_h(int16_t h);
+void pd_clear_h(void);
+
+void pd_set_v(int16_t v);
+void pd_clear_v(void);
+
+void pd_clear_movement(void);
+
+void pd_set_init(bool success);
+
+#ifdef __cplusplus
+}
+#endif