From 80fb4d40a506a51a44551e02d6fc53120e6f1e13 Mon Sep 17 00:00:00 2001 From: Jake Ob Date: Thu, 9 Feb 2023 21:22:34 +0200 Subject: [PATCH] Add unit test to assert devices in reflect mode --- tests/fixtures/generic/xrandr_simple.json | 1 + tests/test_xrandr.py | 26 +++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/tests/fixtures/generic/xrandr_simple.json b/tests/fixtures/generic/xrandr_simple.json index e03e79c8..0f1ebe49 100644 --- a/tests/fixtures/generic/xrandr_simple.json +++ b/tests/fixtures/generic/xrandr_simple.json @@ -44,6 +44,7 @@ "is_primary": true, "device_name": "eDP1", "rotation": "normal", + "reflection": "normal", "resolution_width": 1920, "resolution_height": 1080, "offset_width": 0, diff --git a/tests/test_xrandr.py b/tests/test_xrandr.py index 8fce69b7..dea94f71 100644 --- a/tests/test_xrandr.py +++ b/tests/test_xrandr.py @@ -32,6 +32,8 @@ class XrandrTests(unittest.TestCase): "eDP1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 310mm x 170mm", "eDP-1 connected primary 1920x1080+0+0 (normal left inverted right x axis y axis) 309mm x 174mm", "HDMI-0 connected 2160x3840+3840+0 right (normal left inverted right x axis y axis) 609mm x 349mm", + "LVDS-1 connected primary 1366x768+0+0 normal X axis (normal left inverted right x axis y axis) 609mm x 349mm", + "VGA-1 connected 1280x1024+0+0 left X and Y axis (normal left inverted right x axis y axis) 609mm x 349mm", ] for device in devices: self.assertIsNotNone(re.match(_device_pattern, device)) @@ -118,6 +120,30 @@ class XrandrTests(unittest.TestCase): 59.94, device["associated_modes"][12]["frequencies"][4]["frequency"] ) + def test_device_with_reflect(self): + sample = "VGA-1 connected primary 1920x1080+0+0 left X and Y axis (normal left inverted right x axis y axis) 310mm x 170mm" + actual: Optional[Device] = _parse_device([sample]) + + expected = { + "device_name": "VGA-1", + "is_connected": True, + "is_primary": True, + "resolution_width": 1920, + "resolution_height": 1080, + "offset_width": 0, + "offset_height": 0, + "dimension_width": 310, + "dimension_height": 170, + "rotation": "left", + "reflection": "X and Y axis", + } + + self.assertIsNotNone(actual) + + if actual: + for k, v in expected.items(): + self.assertEqual(v, actual[k], f"Devices regex failed on {k}") + def test_mode(self): sample_1 = "1920x1080 60.03*+ 59.93" expected = {