Tests updated. Attempt to fix remaining problems with forward keypress and numlock reporting.

This commit is contained in:
Storm Dragon
2026-05-12 02:32:26 -04:00
parent 38ef1c2d72
commit 878eef5c5b
5 changed files with 171 additions and 10 deletions
+32 -5
View File
@@ -167,23 +167,50 @@ def test_x11_build_passive_grabs_for_fenrir_keys_and_shortcuts():
input_manager = Mock(convert_event_name=lambda key: key)
x11.env = {
"input": {
"fenrir_key": ["KEY_KP0", "KEY_CAPSLOCK"],
"fenrir_key": ["KEY_KP0", "KEY_META"],
"script_key": [],
},
"rawBindings": {
"fenrir_combo": [1, ["KEY_FENRIR", "KEY_KP8"]],
"bare_keypad": [1, ["KEY_KP5"]],
"ctrl_keypad": [1, ["KEY_CTRL", "KEY_KP2"]],
"meta_combo": [1, ["KEY_FENRIR", "KEY_BACKSPACE"]],
},
"runtime": {"InputManager": input_manager},
}
grabs = x11.build_passive_grabs()
assert ("KEY_KP0", 0) in grabs
assert ("KEY_CAPSLOCK", 0) in grabs
assert ("KEY_KP5", 0) in grabs
assert ("KEY_KP2", X.ControlMask) in grabs
assert ("KEY_KP0", 0, True) in grabs
assert ("KEY_META", 0, True) in grabs
assert ("KEY_NUMLOCK", 0, True) in grabs
assert ("KEY_KP5", 0, False) in grabs
assert ("KEY_KP2", X.ControlMask, False) in grabs
assert ("KEY_BACKSPACE", X.Mod4Mask, True) in grabs
@pytest.mark.unit
def test_x11_optional_modifier_masks_can_exclude_numlock():
x11 = X11Driver()
x11.num_lock_mask = X.Mod2Mask
masks = x11.optional_modifier_masks(0, include_num_lock=False)
assert X.Mod2Mask not in masks
assert X.Mod2Mask | X.LockMask not in masks
@pytest.mark.unit
def test_x11_get_led_state_reads_lock_modifiers_from_pointer_mask():
x11 = X11Driver()
x11.num_lock_mask = X.Mod2Mask
pointer = Mock(mask=X.Mod2Mask | X.LockMask)
x11.root = Mock()
x11.root.query_pointer.return_value = pointer
assert x11.get_led_state(0) is True
assert x11.get_led_state(1) is True
assert x11.get_led_state(2) is False
@pytest.mark.unit