Skip to content

Commit 2423001

Browse files
committed
test(hooks): pin _connected_device on MacOSThumbButtonTests for TomBadash#185 integration
``MacOSThumbButtonTests._make_hook`` previously left ``hook._connected_device`` unset. The thumb-button dispatch path runs unconditionally on this branch, so the test passes; but TomBadash#185 adds an early-return at the top of the CGEventTap callback gated on ``_should_intercept_events`` (which is ``self._connected_device is not None``), and once both PRs are integrated that gate fires before ``btn=6`` reaches the thumb-button handler and the assertions about ``THUMB_BUTTON_DOWN`` / ``THUMB_BUTTON_UP`` / ``XBUTTON1_DOWN`` start failing. Pin a stub ``SimpleNamespace`` device on the hook in ``_make_hook``. This is also semantically more truthful: btn=6 / btn=3 only originate from a connected MX Master mouse in production, so the test should model that state rather than the "no Logitech bound" cold-start state the dispatch path was never designed for. No-op against current master (the early-return does not yet exist); becomes load-bearing as soon as TomBadash#185 lands.
1 parent eefea69 commit 2423001

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

tests/test_mouse_hook.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,20 @@ def _make_hook(self):
909909
hook._running = True
910910
hook._tap = MagicMock(name="tap")
911911
hook._enqueue_dispatch_event = MagicMock(name="enqueue")
912+
# Pin a stub ``_connected_device`` so this test class stays
913+
# truthful (btn=6 / btn=3 only originate from a connected MX
914+
# Master in production) and so it composes with the top-level
915+
# ``_should_intercept_events`` early-return that lands in
916+
# #185 (``fix(hooks): pass through OS mouse events when no
917+
# Logitech is connected``). On this branch the gate is not yet
918+
# consulted at the top of the CGEventTap callback, so this is a
919+
# no-op against current master; it becomes load-bearing once
920+
# #185 is integrated.
921+
hook._connected_device = SimpleNamespace(
922+
key="mx_master_4",
923+
thumb_button_via_hid=False,
924+
gesture_via_sense_panel=False,
925+
)
912926
return hook
913927

914928
def _mock_field(self, button_number):

0 commit comments

Comments
 (0)