From e9a82086070314c17a31ed7e922f02bb6da7bb4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Tue, 17 Jan 2017 11:34:23 +0800 Subject: [PATCH] tests: Add monitor store and config test for output underscanning https://bugzilla.gnome.org/show_bug.cgi?id=777732 --- src/tests/meta-monitor-manager-test.c | 1 + src/tests/monitor-configs/underscanning.xml | 23 +++ src/tests/monitor-store-unit-tests.c | 55 ++++++ src/tests/monitor-unit-tests.c | 184 +++++++++++++++++++- 4 files changed, 262 insertions(+), 1 deletion(-) create mode 100644 src/tests/monitor-configs/underscanning.xml diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c index 0ae5fc9ab..d7b01fa69 100644 --- a/src/tests/meta-monitor-manager-test.c +++ b/src/tests/meta-monitor-manager-test.c @@ -182,6 +182,7 @@ apply_crtc_assignments (MetaMonitorManager *manager, output->is_primary = output_info->is_primary; output->is_presentation = output_info->is_presentation; + output->is_underscanning = output_info->is_underscanning; } /* Disable CRTCs not mentioned in the list */ diff --git a/src/tests/monitor-configs/underscanning.xml b/src/tests/monitor-configs/underscanning.xml new file mode 100644 index 000000000..7bcd6e75a --- /dev/null +++ b/src/tests/monitor-configs/underscanning.xml @@ -0,0 +1,23 @@ + + + + 0 + 0 + yes + + + DP-1 + MetaProduct's Inc. + MetaMonitor + 0x123456 + + + 1024 + 768 + 60.000495910644531 + + yes + + + + diff --git a/src/tests/monitor-store-unit-tests.c b/src/tests/monitor-store-unit-tests.c index 78d1e8559..2d48990e1 100644 --- a/src/tests/monitor-store-unit-tests.c +++ b/src/tests/monitor-store-unit-tests.c @@ -176,6 +176,9 @@ check_monitor_configuration (MetaMonitorConfigStore *config_store, g_assert_cmpfloat (monitor_config->mode_spec->refresh_rate, ==, test_monitor->mode.refresh_rate); + g_assert_cmpint (monitor_config->is_underscanning, + ==, + test_monitor->is_underscanning); } } } @@ -394,6 +397,56 @@ meta_test_monitor_store_primary (void) check_monitor_configurations (&expect); } +static void +meta_test_monitor_store_underscanning (void) +{ + MonitorStoreTestExpect expect = { + .configurations = { + { + .logical_monitors = { + { + .layout = { + .x = 0, + .y = 0, + .width = 1024, + .height = 768 + }, + .is_primary = TRUE, + .is_presentation = FALSE, + .monitors = { + { + .connector = "DP-1", + .vendor = "MetaProduct's Inc.", + .product = "MetaMonitor", + .serial = "0x123456", + .is_underscanning = TRUE, + .mode = { + .width = 1024, + .height = 768, + .refresh_rate = 60.000495910644531 + } + } + }, + .n_monitors = 1, + }, + }, + .n_logical_monitors = 1 + } + }, + .n_configurations = 1 + }; + + if (!is_using_monitor_config_manager ()) + { + g_test_skip ("Not using MetaMonitorConfigManager"); + return; + } + + set_custom_monitor_config ("underscanning.xml"); + + check_monitor_configurations (&expect); +} + void init_monitor_store_tests (void) { @@ -403,4 +456,6 @@ init_monitor_store_tests (void) meta_test_monitor_store_vertical); g_test_add_func ("/backends/monitor-store/primary", meta_test_monitor_store_primary); + g_test_add_func ("/backends/monitor-store/underscanning", + meta_test_monitor_store_underscanning); } diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index 03db5b656..e66695678 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -104,6 +104,7 @@ typedef struct _MonitorTestCaseOutput MetaTileInfo tile_info; int scale; gboolean is_laptop_panel; + gboolean is_underscanning; } MonitorTestCaseOutput; typedef struct _MonitorTestCaseCrtc @@ -145,6 +146,7 @@ typedef struct _MonitorTestCaseMonitor int current_mode; int width_mm; int height_mm; + gboolean is_underscanning; } MonitorTestCaseMonitor; typedef struct _MonitorTestCaseLogicalMonitor @@ -391,6 +393,9 @@ check_monitor_configuration (MonitorTestCase *test_case) g_assert (output == output_from_winsys_id (monitor_manager, winsys_id)); + g_assert_cmpint (test_case->expect.monitors[i].is_underscanning, + ==, + output->is_underscanning); } meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm); @@ -661,7 +666,8 @@ create_monitor_test_setup (MonitorTestCase *test_case, .connector_type = (is_laptop_panel ? META_CONNECTOR_TYPE_eDP : META_CONNECTOR_TYPE_DisplayPort), .tile_info = test_case->setup.outputs[i].tile_info, - .scale = scale + .scale = scale, + .is_underscanning = test_case->setup.outputs[i].is_underscanning }; } @@ -1856,6 +1862,88 @@ meta_test_monitor_no_outputs (void) check_monitor_configuration (&test_case); } +static void +meta_test_monitor_underscanning_config (void) +{ + MonitorTestCase test_case = { + .setup = { + .modes = { + { + .width = 1024, + .height = 768, + .refresh_rate = 60.0 + } + }, + .n_modes = 1, + .outputs = { + { + .crtc = 0, + .modes = { 0 }, + .n_modes = 1, + .preferred_mode = 0, + .possible_crtcs = { 0 }, + .n_possible_crtcs = 1, + .width_mm = 222, + .height_mm = 125, + .is_underscanning = TRUE, + } + }, + .n_outputs = 1, + .crtcs = { + { + .current_mode = 0 + } + }, + .n_crtcs = 1 + }, + + .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, + .is_underscanning = TRUE, + } + }, + .n_monitors = 1, + .logical_monitors = { + { + .layout = { .x = 0, .y = 0, .width = 1024, .height = 768 }, + .scale = 1 + } + }, + .n_logical_monitors = 1, + .primary_logical_monitor = 0, + .n_outputs = 1, + .n_crtcs = 1, + .screen_width = 1024, + .screen_height = 768 + } + }; + MetaMonitorTestSetup *test_setup; + + 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_custom_vertical_config (void) { @@ -2118,6 +2206,96 @@ meta_test_monitor_custom_primary_config (void) check_monitor_configuration (&test_case); } +static void +meta_test_monitor_custom_underscanning_config (void) +{ + MonitorTestCase test_case = { + .setup = { + .modes = { + { + .width = 1024, + .height = 768, + .refresh_rate = 60.000495910644531 + } + }, + .n_modes = 1, + .outputs = { + { + .crtc = 0, + .modes = { 0 }, + .n_modes = 1, + .preferred_mode = 0, + .possible_crtcs = { 0 }, + .n_possible_crtcs = 1, + .width_mm = 222, + .height_mm = 125 + }, + }, + .n_outputs = 1, + .crtcs = { + { + .current_mode = 0 + }, + }, + .n_crtcs = 1 + }, + + .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, + .is_underscanning = TRUE, + } + }, + .n_monitors = 1, + .logical_monitors = { + { + .layout = { .x = 0, .y = 0, .width = 1024, .height = 768 }, + .scale = 1 + } + }, + .n_logical_monitors = 1, + .primary_logical_monitor = 0, + .n_outputs = 1, + .n_crtcs = 1, + .n_tiled_monitors = 0, + .screen_width = 1024, + .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 ("underscanning.xml"); + emulate_hotplug (test_setup); + + check_monitor_configuration (&test_case); +} + void init_monitor_tests (void) { @@ -2151,9 +2329,13 @@ init_monitor_tests (void) meta_test_monitor_lid_closed_no_external); g_test_add_func ("/backends/monitor/no-outputs", meta_test_monitor_no_outputs); + g_test_add_func ("/backends/monitor/underscanning-config", + meta_test_monitor_underscanning_config); 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); + g_test_add_func ("/backends/monitor/custom/underscanning-config", + meta_test_monitor_custom_underscanning_config); }