diff --git a/src/tests/monitor-configs/system/monitors.xml b/src/tests/monitor-configs/system/monitors.xml
new file mode 100644
index 000000000..4d2eafec1
--- /dev/null
+++ b/src/tests/monitor-configs/system/monitors.xml
@@ -0,0 +1,27 @@
+
+
+
+ system
+
+
+
+
+ 0
+ 0
+ yes
+
+
+ DP-1
+ MetaProduct's Inc.
+ MetaMonitor
+ 0x123456
+
+
+ 640
+ 480
+ 60
+
+
+
+
+
diff --git a/src/tests/monitor-configs/user/monitors.xml b/src/tests/monitor-configs/user/monitors.xml
new file mode 100644
index 000000000..f125972e0
--- /dev/null
+++ b/src/tests/monitor-configs/user/monitors.xml
@@ -0,0 +1,22 @@
+
+
+
+ 0
+ 0
+ yes
+
+
+ DP-1
+ 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 ca337ce7e..bec8184c8 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -8742,6 +8742,136 @@ meta_test_monitor_supported_fractional_scales (void)
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
test_case_setup (void **fixture,
const void *data)
@@ -8909,6 +9039,9 @@ init_monitor_tests (void)
meta_test_monitor_supported_integer_scales);
add_monitor_test ("/backends/monitor/suppported_scales/fractional",
meta_test_monitor_supported_fractional_scales);
+
+ add_monitor_test ("/backends/monitor/policy/system-only",
+ meta_test_monitor_policy_system_only);
}
static void
@@ -8928,11 +9061,27 @@ main (int argc,
char *argv[])
{
g_autoptr (MetaContext) context = NULL;
+ char *path;
context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED,
META_CONTEXT_TEST_FLAG_TEST_CLIENT);
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;
init_monitor_tests ();