From e42206cc43586e215721cc9e0d959e9682faf703 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Fri, 9 Jun 2017 16:05:27 +0800 Subject: [PATCH] tests: Add non-precise fractional scaling test https://bugzilla.gnome.org/show_bug.cgi?id=765011 --- .../high-precision-fractional-scale.xml | 23 ++++ src/tests/monitor-store-unit-tests.c | 58 ++++++++++ src/tests/monitor-unit-tests.c | 104 ++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 src/tests/monitor-configs/high-precision-fractional-scale.xml diff --git a/src/tests/monitor-configs/high-precision-fractional-scale.xml b/src/tests/monitor-configs/high-precision-fractional-scale.xml new file mode 100644 index 000000000..8fe66477d --- /dev/null +++ b/src/tests/monitor-configs/high-precision-fractional-scale.xml @@ -0,0 +1,23 @@ + + + + 0 + 0 + yes + 1.3763440847396851 + + + DP-1 + MetaProduct's Inc. + MetaMonitor + 0x123456 + + + 1024 + 768 + 60.000495910644531 + + + + + diff --git a/src/tests/monitor-store-unit-tests.c b/src/tests/monitor-store-unit-tests.c index ea6fa509d..18e4fa52f 100644 --- a/src/tests/monitor-store-unit-tests.c +++ b/src/tests/monitor-store-unit-tests.c @@ -577,6 +577,62 @@ meta_test_monitor_store_fractional_scale (void) check_monitor_configurations (&expect); } +static void +meta_test_monitor_store_high_precision_fractional_scale (void) +{ + MonitorStoreTestExpect expect = { + .configurations = { + { + .logical_monitors = { + { + .layout = { + .x = 0, + .y = 0, + .width = 744, + .height = 558 + }, + .scale = 1.3763440847396851, + .is_primary = TRUE, + .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, + } + }, + .n_logical_monitors = 1 + } + }, + .n_configurations = 1 + }; + + if (!is_using_monitor_config_manager ()) + { + g_test_skip ("Not using MetaMonitorConfigManager"); + return; + } + + if (!meta_is_stage_views_enabled ()) + { + g_test_skip ("Not using stage views"); + return; + } + + set_custom_monitor_config ("high-precision-fractional-scale.xml"); + + check_monitor_configurations (&expect); +} + static void meta_test_monitor_store_mirrored (void) { @@ -806,6 +862,8 @@ init_monitor_store_tests (void) meta_test_monitor_store_scale); g_test_add_func ("/backends/monitor-store/fractional-scale", meta_test_monitor_store_fractional_scale); + g_test_add_func ("/backends/monitor-store/high-precision-fractional-scale", + meta_test_monitor_store_high_precision_fractional_scale); g_test_add_func ("/backends/monitor-store/mirrored", meta_test_monitor_store_mirrored); g_test_add_func ("/backends/monitor-store/first-rotated", diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c index f3563cd8c..00d4e8e38 100644 --- a/src/tests/monitor-unit-tests.c +++ b/src/tests/monitor-unit-tests.c @@ -3111,6 +3111,108 @@ meta_test_monitor_custom_fractional_scale_config (void) check_monitor_configuration (&test_case); } +static void +meta_test_monitor_custom_high_precision_fractional_scale_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, + } + }, + .n_monitors = 1, + .logical_monitors = { + { + .monitors = { 0 }, + .n_monitors = 1, + .layout = { .x = 0, .y = 0, .width = 744, .height = 558 }, + .scale = 1024.0/744.0 /* 1.3763440847396851 */ + } + }, + .n_logical_monitors = 1, + .primary_logical_monitor = 0, + .n_outputs = 1, + .crtcs = { + { + .current_mode = 0, + } + }, + .n_crtcs = 1, + .n_tiled_monitors = 0, + .screen_width = 744, + .screen_height = 558 + } + }; + MetaMonitorTestSetup *test_setup; + + if (!is_using_monitor_config_manager ()) + { + g_test_skip ("Not using MetaMonitorConfigManager"); + return; + } + + if (!meta_is_stage_views_enabled ()) + { + g_test_skip ("Not using stage views"); + return; + } + + test_setup = create_monitor_test_setup (&test_case, + MONITOR_TEST_FLAG_NONE); + set_custom_monitor_config ("high-precision-fractional-scale.xml"); + emulate_hotplug (test_setup); + + check_monitor_configuration (&test_case); +} + static void meta_test_monitor_custom_tiled_config (void) { @@ -4392,6 +4494,8 @@ init_monitor_tests (void) meta_test_monitor_custom_scale_config); g_test_add_func ("/backends/monitor/custom/fractional-scale-config", meta_test_monitor_custom_fractional_scale_config); + g_test_add_func ("/backends/monitor/custom/high-precision-fractional-scale-config", + meta_test_monitor_custom_high_precision_fractional_scale_config); g_test_add_func ("/backends/monitor/custom/tiled-config", meta_test_monitor_custom_tiled_config); g_test_add_func ("/backends/monitor/custom/tiled-custom-resolution-config",