1
0
Fork 0

monitor-unit-tests: Add basic tests for RGB range

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3535>
This commit is contained in:
Sebastian Wick 2024-01-17 17:25:06 +01:00 committed by Marge Bot
parent 926f7ea26d
commit 23b30267b5
6 changed files with 215 additions and 18 deletions

View file

@ -271,6 +271,7 @@ void meta_output_set_hdr_metadata (MetaOutput *output,
MetaOutputHdrMetadata * meta_output_peek_hdr_metadata (MetaOutput *output);
META_EXPORT_TEST
MetaOutputRGBRange meta_output_peek_rgb_range (MetaOutput *output);
void meta_output_add_possible_clone (MetaOutput *output,

View file

@ -388,6 +388,7 @@ meta_check_monitor_configuration (MetaContext *context,
MetaOutput *output = l_output->data;
uint64_t winsys_id = expect->monitors[i].outputs[j];
unsigned int output_max_bpc;
MetaOutputRGBRange rgb_range = META_OUTPUT_RGB_RANGE_AUTO;
g_assert (output == output_from_winsys_id (backend, winsys_id));
g_assert_cmpint (expect->monitors[i].is_underscanning,
@ -398,6 +399,10 @@ meta_check_monitor_configuration (MetaContext *context,
output_max_bpc = 0;
g_assert_cmpint (expect->monitors[i].max_bpc, ==, output_max_bpc);
if (expect->monitors[i].rgb_range)
rgb_range = expect->monitors[i].rgb_range;
g_assert_cmpint (rgb_range, ==, meta_output_peek_rgb_range (output));
}
meta_monitor_get_physical_dimensions (monitor, &width_mm, &height_mm);
@ -798,6 +803,7 @@ meta_create_monitor_test_setup (MetaBackend *backend,
.is_underscanning = setup->outputs[i].is_underscanning,
.has_max_bpc = !!setup->outputs[i].max_bpc,
.max_bpc = setup->outputs[i].max_bpc,
.rgb_range = setup->outputs[i].rgb_range,
};
meta_output_assign_crtc (output, crtc, &output_assignment);
}

View file

@ -106,6 +106,7 @@ typedef struct _MonitorTestCaseOutput
gboolean is_laptop_panel;
gboolean is_underscanning;
unsigned int max_bpc;
MetaOutputRGBRange rgb_range;
const char *serial;
MetaMonitorTransform panel_orientation_transform;
gboolean hotplug_mode;
@ -161,6 +162,7 @@ typedef struct _MonitorTestCaseMonitor
int height_mm;
gboolean is_underscanning;
unsigned int max_bpc;
MetaOutputRGBRange rgb_range;
} MonitorTestCaseMonitor;
typedef struct _MonitorTestCaseLogicalMonitor

View file

@ -0,0 +1,23 @@
<monitors version="2">
<configuration>
<logicalmonitor>
<x>0</x>
<y>0</y>
<primary>yes</primary>
<monitor>
<monitorspec>
<connector>DP-1</connector>
<vendor>MetaProduct&apos;s Inc.</vendor>
<product>MetaMonitor</product>
<serial>0x123456</serial>
</monitorspec>
<mode>
<width>1024</width>
<height>768</height>
<rate>60.000495910644531</rate>
</mode>
<rgbrange>limited</rgbrange>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View file

@ -49,6 +49,7 @@ typedef struct _MonitorStoreTestCaseMonitor
MonitorStoreTestCaseMonitorMode mode;
gboolean is_underscanning;
unsigned int max_bpc;
MetaOutputRGBRange rgb_range;
} MonitorStoreTestCaseMonitor;
typedef struct _MonitorStoreTestCaseLogicalMonitor
@ -203,6 +204,9 @@ check_monitor_store_configuration (MetaMonitorConfigStore *config_store,
g_assert_cmpint (monitor_config->max_bpc,
==,
test_monitor->max_bpc);
g_assert_cmpint (monitor_config->rgb_range,
==,
test_monitor->rgb_range);
}
}
}
@ -253,7 +257,8 @@ meta_test_monitor_store_single (void)
.width = 1920,
.height = 1080,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -297,7 +302,8 @@ meta_test_monitor_store_vertical (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -322,7 +328,8 @@ meta_test_monitor_store_vertical (void)
.width = 800,
.height = 600,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -366,7 +373,8 @@ meta_test_monitor_store_primary (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -391,7 +399,8 @@ meta_test_monitor_store_primary (void)
.width = 800,
.height = 600,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -436,7 +445,8 @@ meta_test_monitor_store_underscanning (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -481,7 +491,8 @@ meta_test_monitor_store_max_bpc (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -498,6 +509,51 @@ meta_test_monitor_store_max_bpc (void)
check_monitor_store_configurations (&expect);
}
static void
meta_test_monitor_store_rgb_range (void)
{
MonitorStoreTestExpect expect = {
.configurations = {
{
.logical_monitors = {
{
.layout = {
.x = 0,
.y = 0,
.width = 1024,
.height = 768
},
.scale = 1,
.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
},
.rgb_range = META_OUTPUT_RGB_RANGE_LIMITED,
}
},
.n_monitors = 1,
},
},
.n_logical_monitors = 1
}
},
.n_configurations = 1
};
meta_set_custom_monitor_config (test_context, "rgb-range.xml");
check_monitor_store_configurations (&expect);
}
static void
meta_test_monitor_store_scale (void)
{
@ -525,7 +581,8 @@ meta_test_monitor_store_scale (void)
.width = 1920,
.height = 1080,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -569,7 +626,8 @@ meta_test_monitor_store_fractional_scale (void)
.width = 1200,
.height = 900,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -613,7 +671,8 @@ meta_test_monitor_store_high_precision_fractional_scale (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -656,7 +715,8 @@ meta_test_monitor_store_mirrored (void)
.width = 800,
.height = 600,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
},
{
.connector = "DP-2",
@ -667,7 +727,8 @@ meta_test_monitor_store_mirrored (void)
.width = 800,
.height = 600,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 2,
@ -712,7 +773,8 @@ meta_test_monitor_store_first_rotated (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -738,7 +800,8 @@ meta_test_monitor_store_first_rotated (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -783,7 +846,8 @@ meta_test_monitor_store_second_rotated (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -809,7 +873,8 @@ meta_test_monitor_store_second_rotated (void)
.width = 1024,
.height = 768,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -854,7 +919,8 @@ meta_test_monitor_store_interlaced (void)
.height = 768,
.refresh_rate = 60.000495910644531,
.flags = META_CRTC_MODE_FLAG_INTERLACE,
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -898,7 +964,8 @@ meta_test_monitor_store_unknown_elements (void)
.width = 1920,
.height = 1080,
.refresh_rate = 60.000495910644531
}
},
.rgb_range = META_OUTPUT_RGB_RANGE_AUTO,
}
},
.n_monitors = 1,
@ -1049,6 +1116,8 @@ init_monitor_store_tests (void)
meta_test_monitor_store_underscanning);
g_test_add_func ("/backends/monitor-store/max-bpc",
meta_test_monitor_store_max_bpc);
g_test_add_func ("/backends/monitor-store/rgb-range",
meta_test_monitor_store_rgb_range);
g_test_add_func ("/backends/monitor-store/scale",
meta_test_monitor_store_scale);
g_test_add_func ("/backends/monitor-store/fractional-scale",

View file

@ -3348,6 +3348,100 @@ meta_test_monitor_max_bpc_config (void)
check_monitor_test_clients_state ();
}
static void
meta_test_monitor_rgb_range_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,
.rgb_range = META_OUTPUT_RGB_RANGE_FULL,
}
},
.n_outputs = 1,
.crtcs = {
{
.current_mode = 0
}
},
.n_crtcs = 1
},
.expect = {
.monitors = {
{
.outputs = { 0 },
.n_outputs = 1,
.modes = {
{
.width = 1024,
.height = 768,
.refresh_rate = 60.0,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 0
}
}
}
},
.n_modes = 1,
.current_mode = 0,
.width_mm = 222,
.height_mm = 125,
.rgb_range = META_OUTPUT_RGB_RANGE_FULL,
}
},
.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 = 1,
.crtcs = {
{
.current_mode = 0,
}
},
.n_crtcs = 1,
.screen_width = 1024,
.screen_height = 768
}
};
MetaMonitorTestSetup *test_setup;
test_setup = meta_create_monitor_test_setup (test_backend,
&test_case.setup,
MONITOR_TEST_FLAG_NO_STORED);
emulate_hotplug (test_setup);
META_TEST_LOG_CALL ("Checking monitor configuration",
meta_check_monitor_configuration (test_context,
&test_case.expect));
check_monitor_test_clients_state ();
}
static void
meta_test_monitor_preferred_non_first_mode (void)
{
@ -9626,6 +9720,8 @@ init_monitor_tests (void)
meta_test_monitor_underscanning_config);
add_monitor_test ("/backends/monitor/max-bpc-config",
meta_test_monitor_max_bpc_config);
add_monitor_test ("/backends/monitor/rgb-range-config",
meta_test_monitor_rgb_range_config);
add_monitor_test ("/backends/monitor/preferred-non-first-mode",
meta_test_monitor_preferred_non_first_mode);
add_monitor_test ("/backends/monitor/non-upright-panel",