diff --git a/src/tests/monitor-configs/primary.xml b/src/tests/monitor-configs/primary.xml new file mode 100644 index 000000000..7238b4fd8 --- /dev/null +++ b/src/tests/monitor-configs/primary.xml @@ -0,0 +1,40 @@ + + + + 0 + 0 + no + + + DP-1 + MetaProduct's Inc. + MetaMonitor + 0x123456 + + + 1024 + 768 + 60.000495910644531 + + + + + 1024 + 0 + yes + + + DP-2 + MetaProduct's Inc. + MetaMonitor + 0x123456 + + + 800 + 600 + 60.000495910644531 + + + + + diff --git a/src/tests/monitor-store-unit-tests.c b/src/tests/monitor-store-unit-tests.c index 516180992..78d1e8559 100644 --- a/src/tests/monitor-store-unit-tests.c +++ b/src/tests/monitor-store-unit-tests.c @@ -321,6 +321,79 @@ meta_test_monitor_store_vertical (void) check_monitor_configurations (&expect); } +static void +meta_test_monitor_store_primary (void) +{ + MonitorStoreTestExpect expect = { + .configurations = { + { + .logical_monitors = { + { + .layout = { + .x = 0, + .y = 0, + .width = 1024, + .height = 768 + }, + .is_primary = FALSE, + .is_presentation = FALSE, + .monitors = { + { + .connector = "DP-1", + .vendor = "MetaProduct's Inc.", + .product = "MetaMonitor", + .serial = "0x123456", + .mode = { + .width = 1024, + .height = 768, + .refresh_rate = 60.000495910644531 + } + } + }, + .n_monitors = 1, + }, + { + .layout = { + .x = 1024, + .y = 0, + .width = 800, + .height = 600 + }, + .is_primary = TRUE, + .is_presentation = FALSE, + .monitors = { + { + .connector = "DP-2", + .vendor = "MetaProduct's Inc.", + .product = "MetaMonitor", + .serial = "0x123456", + .mode = { + .width = 800, + .height = 600, + .refresh_rate = 60.000495910644531 + } + } + }, + .n_monitors = 1, + } + }, + .n_logical_monitors = 2 + } + }, + .n_configurations = 1 + }; + + if (!is_using_monitor_config_manager ()) + { + g_test_skip ("Not using MetaMonitorConfigManager"); + return; + } + + set_custom_monitor_config ("primary.xml"); + + check_monitor_configurations (&expect); +} + void init_monitor_store_tests (void) { @@ -328,4 +401,6 @@ init_monitor_store_tests (void) meta_test_monitor_store_single); g_test_add_func ("/backends/monitor-store/vertical", meta_test_monitor_store_vertical); + g_test_add_func ("/backends/monitor-store/primary", + meta_test_monitor_store_primary); } diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index 71e683421..03db5b656 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -1987,6 +1987,137 @@ meta_test_monitor_custom_vertical_config (void) check_monitor_configuration (&test_case); } +static void +meta_test_monitor_custom_primary_config (void) +{ + MonitorTestCase test_case = { + .setup = { + .modes = { + { + .width = 1024, + .height = 768, + .refresh_rate = 60.000495910644531 + }, + { + .width = 800, + .height = 600, + .refresh_rate = 60.000495910644531 + } + }, + .n_modes = 2, + .outputs = { + { + .crtc = 0, + .modes = { 0 }, + .n_modes = 1, + .preferred_mode = 0, + .possible_crtcs = { 0 }, + .n_possible_crtcs = 1, + .width_mm = 222, + .height_mm = 125 + }, + { + .crtc = 1, + .modes = { 1 }, + .n_modes = 1, + .preferred_mode = 1, + .possible_crtcs = { 1 }, + .n_possible_crtcs = 1, + .width_mm = 220, + .height_mm = 124 + } + }, + .n_outputs = 2, + .crtcs = { + { + .current_mode = 0 + }, + { + .current_mode = 0 + } + }, + .n_crtcs = 2 + }, + + .expect = { + .monitors = { + { + .outputs = { 0 }, + .n_outputs = 1, + .modes = { + { + .width = 1024, + .height = 768, + .crtc_modes = { + { + .output = 0, + .crtc_mode = 0 + } + } + } + }, + .n_modes = 1, + .current_mode = 0, + .width_mm = 222, + .height_mm = 125 + }, + { + .outputs = { 1 }, + .n_outputs = 1, + .modes = { + { + .width = 800, + .height = 600, + .crtc_modes = { + { + .output = 1, + .crtc_mode = 1 + } + } + } + }, + .n_modes = 1, + .current_mode = 0, + .width_mm = 220, + .height_mm = 124 + } + }, + .n_monitors = 2, + .logical_monitors = { + { + .layout = { .x = 0, .y = 0, .width = 1024, .height = 768 }, + .scale = 1 + }, + { + .layout = { .x = 1024, .y = 0, .width = 800, .height = 600 }, + .scale = 1 + } + }, + .n_logical_monitors = 2, + .primary_logical_monitor = 1, + .n_outputs = 2, + .n_crtcs = 2, + .n_tiled_monitors = 0, + .screen_width = 1024 + 800, + .screen_height = 768 + } + }; + MetaMonitorTestSetup *test_setup; + + if (!is_using_monitor_config_manager ()) + { + g_test_skip ("Not using MetaMonitorConfigManager"); + return; + } + + test_setup = create_monitor_test_setup (&test_case, + MONITOR_TEST_FLAG_NONE); + set_custom_monitor_config ("primary.xml"); + emulate_hotplug (test_setup); + + check_monitor_configuration (&test_case); +} + void init_monitor_tests (void) { @@ -2023,4 +2154,6 @@ init_monitor_tests (void) g_test_add_func ("/backends/monitor/custom/vertical-config", meta_test_monitor_custom_vertical_config); + g_test_add_func ("/backends/monitor/custom/primary-config", + meta_test_monitor_custom_primary_config); }