xrandroll/tests/test_monitor.py

43 lines
1.2 KiB
Python
Raw Normal View History

2020-02-05 20:22:37 +00:00
from xrandroll.monitor import Monitor
2020-02-05 20:34:46 +00:00
BASIC_HEADER = "eDP connected primary 1920x1080+0+1080 (0x56) normal (normal left inverted right x axis y axis) 309mm x 173mm" # noqa
2020-02-05 20:22:37 +00:00
def test_parse_pos():
2020-02-05 20:34:46 +00:00
data = [BASIC_HEADER]
2020-02-05 20:22:37 +00:00
m = Monitor(data)
assert m.pos_x == 0
assert m.pos_y == 1080
2020-02-05 20:34:46 +00:00
def test_parse_output():
data = [BASIC_HEADER]
m = Monitor(data)
assert m.output == "eDP"
def test_parse_modes(test_data):
data = test_data.read("monitor_1.txt", deserialize=False).splitlines()
m = Monitor(data)
assert len(m.modes) == 9
2022-06-08 13:27:34 +00:00
assert "0x56" in m.modes
2022-06-08 15:46:51 +00:00
assert str(m.modes["0x56"]) == "1920x1080 60Hz (0x56)"
assert m.modes["0x56"].frequency == 60.01
2020-02-05 21:21:32 +00:00
assert m.enabled
2020-02-05 21:36:32 +00:00
assert m.primary
2020-02-05 22:17:02 +00:00
assert m.orientation == "normal"
2020-02-05 21:21:32 +00:00
def test_disabled_monitor(test_data):
data = test_data.read("disabled_monitor.txt", deserialize=False).splitlines()
m = Monitor(data)
assert m.enabled is False
2020-02-05 21:36:32 +00:00
assert m.primary is False
2020-02-05 22:17:02 +00:00
def test_parse_orientation(test_data):
data = test_data.read("monitor_1.txt", deserialize=False).splitlines()
data[0] = data[0].replace("normal (", "left (")
m = Monitor(data)
assert m.orientation == "left"