-
Notifications
You must be signed in to change notification settings - Fork 426
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from logitech_receiver import diversion | ||
from logitech_receiver.diversion import Key | ||
from logitech_receiver.diversion import KeyPress | ||
from logitech_receiver.diversion import Rule | ||
|
||
|
||
def test_diversion_rule(): | ||
args = [ | ||
{ | ||
"Rule": [ # Implement problematic keys for Craft and MX Master | ||
{"Rule": [{"Key": ["Brightness Down", "pressed"]}, {"KeyPress": "XF86_MonBrightnessDown"}]}, | ||
{"Rule": [{"Key": ["Brightness Up", "pressed"]}, {"KeyPress": "XF86_MonBrightnessUp"}]}, | ||
] | ||
}, | ||
] | ||
|
||
rule = diversion.Rule(args) | ||
|
||
assert len(rule.components) == 1 | ||
root_rule = rule.components[0] | ||
assert isinstance(root_rule, Rule) | ||
|
||
assert len(root_rule.components) == 2 | ||
for component in root_rule.components: | ||
assert isinstance(component, Rule) | ||
assert len(component.components) == 2 | ||
|
||
key = component.components[0] | ||
assert isinstance(key, Key) | ||
key = component.components[1] | ||
assert isinstance(key, KeyPress) | ||
|
||
|
||
def test_keysym_to_keycode(): | ||
expected_keycode = 56 | ||
expected_level = 0 | ||
keysym_shift_l = 65505 | ||
|
||
keycode, level = diversion.keysym_to_keycode(keysym_shift_l, None) | ||
|
||
assert keycode == expected_keycode | ||
assert level == expected_level |