diff --git a/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml b/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml new file mode 100644 index 000000000..8ee2abf09 --- /dev/null +++ b/src/tests/monitor-configs/non-preferred-tiled-custom-resolution.xml @@ -0,0 +1,22 @@ + + + + 0 + 0 + yes + + + DP-2 + MetaProduct's Inc. + MetaMonitor + 0x123456 + + + 800 + 600 + 60 + + + + + diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index 2134c685b..ae592bb8b 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -1343,6 +1343,182 @@ meta_test_monitor_tiled_linear_config (void) check_monitor_configuration (&test_case); } +static void +meta_test_monitor_tiled_non_preferred_linear_config (void) +{ + MonitorTestCase test_case = { + .setup = { + .modes = { + { + .width = 640, + .height = 480, + .refresh_rate = 60.0 + }, + { + .width = 800, + .height = 600, + .refresh_rate = 60.0 + }, + { + .width = 512, + .height = 768, + .refresh_rate = 120.0 + }, + { + .width = 1024, + .height = 768, + .refresh_rate = 60.0 + }, + }, + .n_modes = 4, + .outputs = { + { + .crtc = -1, + .modes = { 0, 2 }, + .n_modes = 2, + .preferred_mode = 1, + .possible_crtcs = { 0 }, + .n_possible_crtcs = 1, + .width_mm = 222, + .height_mm = 125, + .tile_info = { + .group_id = 1, + .max_h_tiles = 2, + .max_v_tiles = 1, + .loc_h_tile = 0, + .loc_v_tile = 0, + .tile_w = 512, + .tile_h = 768 + } + }, + { + .crtc = -1, + .modes = { 1, 2, 3 }, + .n_modes = 3, + .preferred_mode = 0, + .possible_crtcs = { 1 }, + .n_possible_crtcs = 1, + .width_mm = 222, + .height_mm = 125, + .tile_info = { + .group_id = 1, + .max_h_tiles = 2, + .max_v_tiles = 1, + .loc_h_tile = 1, + .loc_v_tile = 0, + .tile_w = 512, + .tile_h = 768 + } + } + }, + .n_outputs = 2, + .crtcs = { + { + .current_mode = -1 + }, + { + .current_mode = -1 + } + }, + .n_crtcs = 2 + }, + + .expect = { + .monitors = { + { + .outputs = { 0, 1 }, + .n_outputs = 2, + .modes = { + { + .width = 1024, + .height = 768, + .crtc_modes = { + { + .output = 0, + .crtc_mode = 2 + }, + { + .output = 1, + .crtc_mode = 2, + } + } + }, + { + .width = 800, + .height = 600, + .crtc_modes = { + { + .output = 0, + .crtc_mode = -1 + }, + { + .output = 1, + .crtc_mode = 1, + } + } + }, + { + .width = 1024, + .height = 768, + .crtc_modes = { + { + .output = 0, + .crtc_mode = -1 + }, + { + .output = 1, + .crtc_mode = 3, + } + } + }, + }, + .n_modes = 3, + .current_mode = 0, + .width_mm = 222, + .height_mm = 125, + } + }, + .n_monitors = 1, + .logical_monitors = { + { + .monitors = { 0 }, + .n_monitors = 1, + .layout = { .x = 0, .y = 0, .width = 1024, .height = 768 }, + .scale = 1 + }, + }, + .n_logical_monitors = 1, + .primary_logical_monitor = 0, + .n_outputs = 2, + .crtcs = { + { + .current_mode = 2, + }, + { + .current_mode = 2, + .x = 512 + } + }, + .n_crtcs = 2, + .n_tiled_monitors = 1, + .screen_width = 1024, + .screen_height = 768, + } + }; + MetaMonitorTestSetup *test_setup; + + if (!is_using_monitor_config_manager ()) + { + g_test_skip ("Only the new monitor config manager handles this case."); + return; + } + + test_setup = create_monitor_test_setup (&test_case, + MONITOR_TEST_FLAG_NO_STORED); + emulate_hotplug (test_setup); + check_monitor_configuration (&test_case); +} + static void meta_test_monitor_hidpi_linear_config (void) { @@ -3136,6 +3312,183 @@ meta_test_monitor_custom_tiled_custom_resolution_config (void) check_monitor_configuration (&test_case); } +static void +meta_test_monitor_custom_tiled_non_preferred_config (void) +{ + MonitorTestCase test_case = { + .setup = { + .modes = { + { + .width = 640, + .height = 480, + .refresh_rate = 60.0 + }, + { + .width = 800, + .height = 600, + .refresh_rate = 60.0 + }, + { + .width = 512, + .height = 768, + .refresh_rate = 120.0 + }, + { + .width = 1024, + .height = 768, + .refresh_rate = 60.0 + }, + }, + .n_modes = 4, + .outputs = { + { + .crtc = -1, + .modes = { 0, 2 }, + .n_modes = 2, + .preferred_mode = 1, + .possible_crtcs = { 0 }, + .n_possible_crtcs = 1, + .width_mm = 222, + .height_mm = 125, + .tile_info = { + .group_id = 1, + .max_h_tiles = 2, + .max_v_tiles = 1, + .loc_h_tile = 0, + .loc_v_tile = 0, + .tile_w = 512, + .tile_h = 768 + } + }, + { + .crtc = -1, + .modes = { 1, 2, 3 }, + .n_modes = 3, + .preferred_mode = 0, + .possible_crtcs = { 1 }, + .n_possible_crtcs = 1, + .width_mm = 222, + .height_mm = 125, + .tile_info = { + .group_id = 1, + .max_h_tiles = 2, + .max_v_tiles = 1, + .loc_h_tile = 1, + .loc_v_tile = 0, + .tile_w = 512, + .tile_h = 768 + } + } + }, + .n_outputs = 2, + .crtcs = { + { + .current_mode = -1 + }, + { + .current_mode = -1 + } + }, + .n_crtcs = 2 + }, + + .expect = { + .monitors = { + { + .outputs = { 0, 1 }, + .n_outputs = 2, + .modes = { + { + .width = 1024, + .height = 768, + .crtc_modes = { + { + .output = 0, + .crtc_mode = 2 + }, + { + .output = 1, + .crtc_mode = 2, + } + } + }, + { + .width = 800, + .height = 600, + .crtc_modes = { + { + .output = 0, + .crtc_mode = -1 + }, + { + .output = 1, + .crtc_mode = 1, + } + } + }, + { + .width = 1024, + .height = 768, + .crtc_modes = { + { + .output = 0, + .crtc_mode = -1 + }, + { + .output = 1, + .crtc_mode = 3, + } + } + }, + }, + .n_modes = 3, + .current_mode = 1, + .width_mm = 222, + .height_mm = 125, + } + }, + .n_monitors = 1, + .logical_monitors = { + { + .monitors = { 0 }, + .n_monitors = 1, + .layout = { .x = 0, .y = 0, .width = 800, .height = 600 }, + .scale = 1 + }, + }, + .n_logical_monitors = 1, + .primary_logical_monitor = 0, + .n_outputs = 2, + .crtcs = { + { + .current_mode = -1, + }, + { + .current_mode = 1, + } + }, + .n_crtcs = 2, + .n_tiled_monitors = 1, + .screen_width = 800, + .screen_height = 600, + } + }; + MetaMonitorTestSetup *test_setup; + + if (!is_using_monitor_config_manager ()) + { + g_test_skip ("Only the new monitor config manager handles this case."); + return; + } + + test_setup = create_monitor_test_setup (&test_case, + MONITOR_TEST_FLAG_NONE); + set_custom_monitor_config ("non-preferred-tiled-custom-resolution.xml"); + emulate_hotplug (test_setup); + + check_monitor_configuration (&test_case); +} + static void meta_test_monitor_custom_mirrored_config (void) { @@ -3908,6 +4261,8 @@ init_monitor_tests (void) meta_test_monitor_preferred_linear_config); g_test_add_func ("/backends/monitor/tiled-linear-config", meta_test_monitor_tiled_linear_config); + g_test_add_func ("/backends/monitor/tiled-non-preferred-linear-config", + meta_test_monitor_tiled_non_preferred_linear_config); g_test_add_func ("/backends/monitor/hidpi-linear-config", meta_test_monitor_hidpi_linear_config); g_test_add_func ("/backends/monitor/suggested-config", @@ -3937,6 +4292,8 @@ init_monitor_tests (void) meta_test_monitor_custom_tiled_config); g_test_add_func ("/backends/monitor/custom/tiled-custom-resolution-config", meta_test_monitor_custom_tiled_custom_resolution_config); + g_test_add_func ("/backends/monitor/custom/tiled-non-preferred-config", + meta_test_monitor_custom_tiled_non_preferred_config); g_test_add_func ("/backends/monitor/custom/mirrored-config", meta_test_monitor_custom_mirrored_config); g_test_add_func ("/backends/monitor/custom/first-rotated-config",