1
0
Fork 0

monitor-config-store: Add test for monitor configuration policy

The test aims to verify that setting the following policy

    <policy>
      <stores>
        <store>system</store>
      </stores>
    </policy>

only applies monitor configurations from the system level.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
This commit is contained in:
Jonas Ådahl 2021-09-30 17:32:31 +02:00 committed by Marge Bot
parent d8a66a3892
commit 3d4a6875e6
3 changed files with 198 additions and 0 deletions

View file

@ -0,0 +1,27 @@
<monitors version="2">
<policy>
<stores>
<store>system</store>
</stores>
</policy>
<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>640</width>
<height>480</height>
<rate>60</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View file

@ -0,0 +1,22 @@
<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>800</width>
<height>600</height>
<rate>60</rate>
</mode>
</monitor>
</logicalmonitor>
</configuration>
</monitors>

View file

@ -8742,6 +8742,136 @@ meta_test_monitor_supported_fractional_scales (void)
META_MONITOR_SCALES_CONSTRAINT_NONE)); META_MONITOR_SCALES_CONSTRAINT_NONE));
} }
static void
meta_test_monitor_policy_system_only (void)
{
MetaMonitorTestSetup *test_setup;
MonitorTestCase test_case = {
.setup = {
.modes = {
{
.width = 1024,
.height = 768,
.refresh_rate = 60.0
},
{
.width = 800,
.height = 600,
.refresh_rate = 60.0
},
{
.width = 640,
.height = 480,
.refresh_rate = 60.0
}
},
.n_modes = 3,
.outputs = {
{
.crtc = 0,
.modes = { 0, 1, 2 },
.n_modes = 3,
.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,
.refresh_rate = 60.0,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 0
}
}
},
{
.width = 800,
.height = 600,
.refresh_rate = 60.0,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 1
}
}
},
{
.width = 640,
.height = 480,
.refresh_rate = 60.0,
.crtc_modes = {
{
.output = 0,
.crtc_mode = 2
}
}
}
},
.n_modes = 3,
.current_mode = 2,
.width_mm = 222,
.height_mm = 125
},
},
.n_monitors = 1,
.logical_monitors = {
{
.monitors = { 0 },
.n_monitors = 1,
.layout = { .x = 0, .y = 0, .width = 640, .height = 480 },
.scale = 1
},
},
.n_logical_monitors = 1,
.primary_logical_monitor = 0,
.n_outputs = 1,
.crtcs = {
{
.current_mode = 2,
.x = 0,
}
},
.n_crtcs = 1,
.screen_width = 640,
.screen_height = 480,
}
};
MetaBackend *backend = meta_context_get_backend (test_context);
MetaMonitorManager *monitor_manager =
meta_backend_get_monitor_manager (backend);
MetaMonitorConfigManager *config_manager = monitor_manager->config_manager;
MetaMonitorConfigStore *config_store =
meta_monitor_config_manager_get_store (config_manager);
test_setup = create_monitor_test_setup (&test_case.setup,
MONITOR_TEST_FLAG_NONE);
meta_monitor_config_store_reset (config_store);
emulate_hotplug (test_setup);
META_TEST_LOG_CALL ("Checking monitor configuration",
check_monitor_configuration (&test_case.expect));
}
static void static void
test_case_setup (void **fixture, test_case_setup (void **fixture,
const void *data) const void *data)
@ -8909,6 +9039,9 @@ init_monitor_tests (void)
meta_test_monitor_supported_integer_scales); meta_test_monitor_supported_integer_scales);
add_monitor_test ("/backends/monitor/suppported_scales/fractional", add_monitor_test ("/backends/monitor/suppported_scales/fractional",
meta_test_monitor_supported_fractional_scales); meta_test_monitor_supported_fractional_scales);
add_monitor_test ("/backends/monitor/policy/system-only",
meta_test_monitor_policy_system_only);
} }
static void static void
@ -8928,11 +9061,27 @@ main (int argc,
char *argv[]) char *argv[])
{ {
g_autoptr (MetaContext) context = NULL; g_autoptr (MetaContext) context = NULL;
char *path;
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED, context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
META_CONTEXT_TEST_FLAG_TEST_CLIENT); META_CONTEXT_TEST_FLAG_TEST_CLIENT);
g_assert (meta_context_configure (context, &argc, &argv, NULL)); g_assert (meta_context_configure (context, &argc, &argv, NULL));
path = g_test_build_filename (G_TEST_DIST,
"tests",
"monitor-configs",
"system",
NULL);
g_setenv ("XDG_CONFIG_DIRS", path, TRUE);
g_free (path);
path = g_test_build_filename (G_TEST_DIST,
"tests",
"monitor-configs",
"user",
NULL);
g_setenv ("XDG_CONFIG_HOME", path, TRUE);
g_free (path);
test_context = context; test_context = context;
init_monitor_tests (); init_monitor_tests ();