From 4f27512780b28aa5cd64c2daaea6798b55d987ff Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Wed, 5 Feb 2020 17:34:46 -0300 Subject: [PATCH] Some more tests --- tests/conftest.py | 4 + tests/fixtures/monitor_1.txt | 81 ++++++++++++ tests/fixtures/sample1.txt | 232 +++++++++++++++++++++++++++++++++++ tests/test_monitor.py | 18 ++- 4 files changed, 332 insertions(+), 3 deletions(-) create mode 100644 tests/conftest.py create mode 100644 tests/fixtures/monitor_1.txt create mode 100644 tests/fixtures/sample1.txt diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..f951162 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,4 @@ +from pathlib import Path +from fixtures import TestData + +TestData.BASE_PATH = Path(__file__).parent / "fixtures" diff --git a/tests/fixtures/monitor_1.txt b/tests/fixtures/monitor_1.txt new file mode 100644 index 0000000..e19982b --- /dev/null +++ b/tests/fixtures/monitor_1.txt @@ -0,0 +1,81 @@ +eDP connected primary 1920x1080+0+1080 (0x56) normal (normal left inverted right x axis y axis) 309mm x 173mm + Identifier: 0x53 + Timestamp: 52978498 + Subpixel: unknown + Gamma: 1.0:1.0:1.0 + Brightness: 1.0 + Clones: + CRTC: 0 + CRTCs: 0 1 2 3 + Transform: 1.000000 0.000000 0.000000 + 0.000000 1.000000 0.000000 + 0.000000 0.000000 1.000000 + filter: + EDID: + 00ffffffffffff000daed41400000000 + 241a0104a51f11780228659759548e27 + 1e505400000001010101010101010101 + 010101010101b43b804a71383440503c + 680035ad10000018000000fe004e3134 + 304843412d4541430a20000000fe0043 + 4d4e0a202020202020202020000000fe + 004e3134304843412d4541430a200005 + GAMMA_LUT_SIZE: 4096 + range: (0, -1) + DEGAMMA_LUT_SIZE: 4096 + range: (0, -1) + GAMMA_LUT: 0 + range: (0, 65535) + CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 + 0 1 + DEGAMMA_LUT: 0 + range: (0, 65535) + TearFree: auto + supported: off, on, auto + vrr_capable: 0 + range: (0, 1) + abm level: 0 + range: (0, 4) + max bpc: 8 + range: (8, 16) + underscan vborder: 0 + range: (0, 128) + underscan hborder: 0 + range: (0, 128) + underscan: off + supported: off, on, auto + scaling mode: None + supported: None, Full, Center, Full aspect + link-status: Good + supported: Good, Bad + CONNECTOR_ID: 64 + supported: 64 + non-desktop: 0 + range: (0, 1) + 1920x1080 (0x56) 152.840MHz -HSync -VSync *current +preferred + h: width 1920 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 1080 start 1086 end 1094 total 1132 clock 60.01Hz + 1680x1050 (0x57) 152.840MHz -HSync -VSync + h: width 1680 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 1050 start 1086 end 1094 total 1132 clock 60.01Hz + 1280x1024 (0x58) 152.840MHz -HSync -VSync + h: width 1280 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 1024 start 1086 end 1094 total 1132 clock 60.01Hz + 1440x900 (0x59) 152.840MHz -HSync -VSync + h: width 1440 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 900 start 1086 end 1094 total 1132 clock 60.01Hz + 1280x800 (0x5a) 152.840MHz -HSync -VSync + h: width 1280 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 800 start 1086 end 1094 total 1132 clock 60.01Hz + 1280x720 (0x5b) 152.840MHz -HSync -VSync + h: width 1280 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 720 start 1086 end 1094 total 1132 clock 60.01Hz + 1024x768 (0x5c) 152.840MHz -HSync -VSync + h: width 1024 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 768 start 1086 end 1094 total 1132 clock 60.01Hz + 800x600 (0x5d) 152.840MHz -HSync -VSync + h: width 800 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 600 start 1086 end 1094 total 1132 clock 60.01Hz + 640x480 (0x5e) 152.840MHz -HSync -VSync + h: width 640 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 480 start 1086 end 1094 total 1132 clock 60.01Hz diff --git a/tests/fixtures/sample1.txt b/tests/fixtures/sample1.txt new file mode 100644 index 0000000..fda10cd --- /dev/null +++ b/tests/fixtures/sample1.txt @@ -0,0 +1,232 @@ +Screen 0: minimum 320 x 200, current 1921 x 2160, maximum 16384 x 16384 +eDP connected primary 1920x1080+0+1080 (0x56) normal (normal left inverted right x axis y axis) 309mm x 173mm + Identifier: 0x53 + Timestamp: 52978498 + Subpixel: unknown + Gamma: 1.0:1.0:1.0 + Brightness: 1.0 + Clones: + CRTC: 0 + CRTCs: 0 1 2 3 + Transform: 1.000000 0.000000 0.000000 + 0.000000 1.000000 0.000000 + 0.000000 0.000000 1.000000 + filter: + EDID: + 00ffffffffffff000daed41400000000 + 241a0104a51f11780228659759548e27 + 1e505400000001010101010101010101 + 010101010101b43b804a71383440503c + 680035ad10000018000000fe004e3134 + 304843412d4541430a20000000fe0043 + 4d4e0a202020202020202020000000fe + 004e3134304843412d4541430a200005 + GAMMA_LUT_SIZE: 4096 + range: (0, -1) + DEGAMMA_LUT_SIZE: 4096 + range: (0, -1) + GAMMA_LUT: 0 + range: (0, 65535) + CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 + 0 1 + DEGAMMA_LUT: 0 + range: (0, 65535) + TearFree: auto + supported: off, on, auto + vrr_capable: 0 + range: (0, 1) + abm level: 0 + range: (0, 4) + max bpc: 8 + range: (8, 16) + underscan vborder: 0 + range: (0, 128) + underscan hborder: 0 + range: (0, 128) + underscan: off + supported: off, on, auto + scaling mode: None + supported: None, Full, Center, Full aspect + link-status: Good + supported: Good, Bad + CONNECTOR_ID: 64 + supported: 64 + non-desktop: 0 + range: (0, 1) + 1920x1080 (0x56) 152.840MHz -HSync -VSync *current +preferred + h: width 1920 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 1080 start 1086 end 1094 total 1132 clock 60.01Hz + 1680x1050 (0x57) 152.840MHz -HSync -VSync + h: width 1680 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 1050 start 1086 end 1094 total 1132 clock 60.01Hz + 1280x1024 (0x58) 152.840MHz -HSync -VSync + h: width 1280 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 1024 start 1086 end 1094 total 1132 clock 60.01Hz + 1440x900 (0x59) 152.840MHz -HSync -VSync + h: width 1440 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 900 start 1086 end 1094 total 1132 clock 60.01Hz + 1280x800 (0x5a) 152.840MHz -HSync -VSync + h: width 1280 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 800 start 1086 end 1094 total 1132 clock 60.01Hz + 1280x720 (0x5b) 152.840MHz -HSync -VSync + h: width 1280 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 720 start 1086 end 1094 total 1132 clock 60.01Hz + 1024x768 (0x5c) 152.840MHz -HSync -VSync + h: width 1024 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 768 start 1086 end 1094 total 1132 clock 60.01Hz + 800x600 (0x5d) 152.840MHz -HSync -VSync + h: width 800 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 600 start 1086 end 1094 total 1132 clock 60.01Hz + 640x480 (0x5e) 152.840MHz -HSync -VSync + h: width 640 start 2000 end 2060 total 2250 skew 0 clock 67.93KHz + v: height 480 start 1086 end 1094 total 1132 clock 60.01Hz +HDMI-A-0 connected 1920x1080+1+0 (0x5f) normal (normal left inverted right x axis y axis) 521mm x 293mm + Identifier: 0x54 + Timestamp: 52978498 + Subpixel: unknown + Gamma: 1.0:1.0:1.0 + Brightness: 1.0 + Clones: + CRTC: 1 + CRTCs: 0 1 2 3 + Transform: 1.000000 0.000000 0.000000 + 0.000000 1.000000 0.000000 + 0.000000 0.000000 1.000000 + filter: + EDID: + 00ffffffffffff004c2d200d47515a5a + 321c010380341d782a9315a655519c27 + 115054bfef80714f81c0810081809500 + a9c0b3000101023a801871382d40582c + 450009252100001e000000fd00324b1e + 5111000a202020202020000000fc0053 + 3234463335300a2020202020000000ff + 0048345a4b4330303436380a202001ae + 020311b14690041f13120365030c0010 + 00011d00bc52d01e20b8285540092521 + 00001e8c0ad090204031200c40550009 + 25210000188c0ad08a20e02d10103e96 + 00092521000018000000000000000000 + 00000000000000000000000000000000 + 00000000000000000000000000000000 + 00000000000000000000000000000051 + GAMMA_LUT_SIZE: 4096 + range: (0, -1) + DEGAMMA_LUT_SIZE: 4096 + range: (0, -1) + GAMMA_LUT: 0 + range: (0, 65535) + CTM: 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 + 0 1 + DEGAMMA_LUT: 0 + range: (0, 65535) + TearFree: auto + supported: off, on, auto + vrr_capable: 0 + range: (0, 1) + max bpc: 8 + range: (8, 16) + underscan vborder: 0 + range: (0, 128) + underscan hborder: 0 + range: (0, 128) + underscan: off + supported: off, on, auto + scaling mode: None + supported: None, Full, Center, Full aspect + link-status: Good + supported: Good, Bad + CONNECTOR_ID: 69 + supported: 69 + non-desktop: 0 + range: (0, 1) + 1920x1080 (0x5f) 148.500MHz +HSync +VSync *current +preferred + h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.50KHz + v: height 1080 start 1084 end 1089 total 1125 clock 60.00Hz + 1920x1080 (0x60) 148.500MHz +HSync +VSync + h: width 1920 start 2448 end 2492 total 2640 skew 0 clock 56.25KHz + v: height 1080 start 1084 end 1089 total 1125 clock 50.00Hz + 1920x1080 (0x61) 148.352MHz +HSync +VSync + h: width 1920 start 2008 end 2052 total 2200 skew 0 clock 67.43KHz + v: height 1080 start 1084 end 1089 total 1125 clock 59.94Hz + 1680x1050 (0x62) 119.000MHz +HSync -VSync + h: width 1680 start 1728 end 1760 total 1840 skew 0 clock 64.67KHz + v: height 1050 start 1053 end 1059 total 1080 clock 59.88Hz + 1600x900 (0x63) 108.000MHz +HSync +VSync + h: width 1600 start 1624 end 1704 total 1800 skew 0 clock 60.00KHz + v: height 900 start 901 end 904 total 1000 clock 60.00Hz + 1280x1024 (0x64) 135.000MHz +HSync +VSync + h: width 1280 start 1296 end 1440 total 1688 skew 0 clock 79.98KHz + v: height 1024 start 1025 end 1028 total 1066 clock 75.02Hz + 1280x1024 (0x65) 108.000MHz +HSync +VSync + h: width 1280 start 1328 end 1440 total 1688 skew 0 clock 63.98KHz + v: height 1024 start 1025 end 1028 total 1066 clock 60.02Hz + 1440x900 (0x66) 88.750MHz +HSync -VSync + h: width 1440 start 1488 end 1520 total 1600 skew 0 clock 55.47KHz + v: height 900 start 903 end 909 total 926 clock 59.90Hz + 1280x800 (0x67) 71.000MHz +HSync -VSync + h: width 1280 start 1328 end 1360 total 1440 skew 0 clock 49.31KHz + v: height 800 start 803 end 809 total 823 clock 59.91Hz + 1152x864 (0x68) 108.000MHz +HSync +VSync + h: width 1152 start 1216 end 1344 total 1600 skew 0 clock 67.50KHz + v: height 864 start 865 end 868 total 900 clock 75.00Hz + 1280x720 (0x69) 74.250MHz +HSync +VSync + h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 45.00KHz + v: height 720 start 725 end 730 total 750 clock 60.00Hz + 1280x720 (0x6a) 74.250MHz +HSync +VSync + h: width 1280 start 1720 end 1760 total 1980 skew 0 clock 37.50KHz + v: height 720 start 725 end 730 total 750 clock 50.00Hz + 1280x720 (0x6b) 74.176MHz +HSync +VSync + h: width 1280 start 1390 end 1430 total 1650 skew 0 clock 44.96KHz + v: height 720 start 725 end 730 total 750 clock 59.94Hz + 1024x768 (0x6c) 78.750MHz +HSync +VSync + h: width 1024 start 1040 end 1136 total 1312 skew 0 clock 60.02KHz + v: height 768 start 769 end 772 total 800 clock 75.03Hz + 1024x768 (0x6d) 75.000MHz -HSync -VSync + h: width 1024 start 1048 end 1184 total 1328 skew 0 clock 56.48KHz + v: height 768 start 771 end 777 total 806 clock 70.07Hz + 1024x768 (0x6e) 65.000MHz -HSync -VSync + h: width 1024 start 1048 end 1184 total 1344 skew 0 clock 48.36KHz + v: height 768 start 771 end 777 total 806 clock 60.00Hz + 832x624 (0x6f) 57.284MHz -HSync -VSync + h: width 832 start 864 end 928 total 1152 skew 0 clock 49.73KHz + v: height 624 start 625 end 628 total 667 clock 74.55Hz + 800x600 (0x70) 50.000MHz +HSync +VSync + h: width 800 start 856 end 976 total 1040 skew 0 clock 48.08KHz + v: height 600 start 637 end 643 total 666 clock 72.19Hz + 800x600 (0x71) 49.500MHz +HSync +VSync + h: width 800 start 816 end 896 total 1056 skew 0 clock 46.88KHz + v: height 600 start 601 end 604 total 625 clock 75.00Hz + 800x600 (0x72) 40.000MHz +HSync +VSync + h: width 800 start 840 end 968 total 1056 skew 0 clock 37.88KHz + v: height 600 start 601 end 605 total 628 clock 60.32Hz + 800x600 (0x73) 36.000MHz +HSync +VSync + h: width 800 start 824 end 896 total 1024 skew 0 clock 35.16KHz + v: height 600 start 601 end 603 total 625 clock 56.25Hz + 720x576 (0x74) 27.000MHz -HSync -VSync + h: width 720 start 732 end 796 total 864 skew 0 clock 31.25KHz + v: height 576 start 581 end 586 total 625 clock 50.00Hz + 720x480 (0x75) 27.027MHz -HSync -VSync + h: width 720 start 736 end 798 total 858 skew 0 clock 31.50KHz + v: height 480 start 489 end 495 total 525 clock 60.00Hz + 720x480 (0x76) 27.000MHz -HSync -VSync + h: width 720 start 736 end 798 total 858 skew 0 clock 31.47KHz + v: height 480 start 489 end 495 total 525 clock 59.94Hz + 640x480 (0x77) 31.500MHz -HSync -VSync + h: width 640 start 656 end 720 total 840 skew 0 clock 37.50KHz + v: height 480 start 481 end 484 total 500 clock 75.00Hz + 640x480 (0x78) 31.500MHz -HSync -VSync + h: width 640 start 664 end 704 total 832 skew 0 clock 37.86KHz + v: height 480 start 489 end 492 total 520 clock 72.81Hz + 640x480 (0x79) 30.240MHz -HSync -VSync + h: width 640 start 704 end 768 total 864 skew 0 clock 35.00KHz + v: height 480 start 483 end 486 total 525 clock 66.67Hz + 640x480 (0x7a) 25.200MHz -HSync -VSync + h: width 640 start 656 end 752 total 800 skew 0 clock 31.50KHz + v: height 480 start 490 end 492 total 525 clock 60.00Hz + 640x480 (0x7b) 25.175MHz -HSync -VSync + h: width 640 start 656 end 752 total 800 skew 0 clock 31.47KHz + v: height 480 start 490 end 492 total 525 clock 59.94Hz + 720x400 (0x7c) 28.320MHz -HSync +VSync + h: width 720 start 738 end 846 total 900 skew 0 clock 31.47KHz + v: height 400 start 412 end 414 total 449 clock 70.08Hz diff --git a/tests/test_monitor.py b/tests/test_monitor.py index 4fd723e..cb6798c 100644 --- a/tests/test_monitor.py +++ b/tests/test_monitor.py @@ -1,10 +1,22 @@ from xrandroll.monitor import Monitor +BASIC_HEADER = "eDP connected primary 1920x1080+0+1080 (0x56) normal (normal left inverted right x axis y axis) 309mm x 173mm" # noqa + def test_parse_pos(): - data = [ - "eDP connected primary 1920x1080+0+1080 (0x56) normal (normal left inverted right x axis y axis) 309mm x 173mm" - ] + data = [BASIC_HEADER] m = Monitor(data) assert m.pos_x == 0 assert m.pos_y == 1080 + + +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