[mutter] tests: Move monitor test utils into libmutter-test.so



commit afca97440596c2c8de116383467a9696d967ccf3
Author: Jonas Ã…dahl <jadahl gmail com>
Date:   Fri Jan 28 16:28:32 2022 +0100

    tests: Move monitor test utils into libmutter-test.so
    
    It already was built into it without any symbols exported, but also
    duplicated in test cases that used it. Make it so that the built in
    functions are exported, with prefixes, and make all tests use the
    exported functions. While at it, make things go via MetaContext or
    MetaBackend depending on how early in initialization things are run.
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2262>

 src/tests/headless-start-test.c                    |   4 +-
 src/tests/meson.build                              |  10 +-
 src/tests/meta-monitor-manager-test.c              | 105 ++--
 src/tests/meta-monitor-manager-test.h              |   4 +-
 ...itor-test-utils.c => meta-monitor-test-utils.c} |  51 +-
 ...itor-test-utils.h => meta-monitor-test-utils.h} |  34 +-
 src/tests/meta-test-utils.c                        |   6 +-
 src/tests/meta-test-utils.h                        |   6 +-
 src/tests/monitor-config-migration-unit-tests.c    |   6 +-
 src/tests/monitor-store-unit-tests.c               |  43 +-
 src/tests/monitor-unit-tests.c                     | 685 +++++++++++++--------
 src/tests/native-pointer-constraints.c             |   4 +-
 src/tests/orientation-manager-unit-tests.c         |   2 +-
 src/tests/stage-view-tests.c                       |  75 ++-
 14 files changed, 613 insertions(+), 422 deletions(-)
---
diff --git a/src/tests/headless-start-test.c b/src/tests/headless-start-test.c
index 4ddabf7f91..b563be3d47 100644
--- a/src/tests/headless-start-test.c
+++ b/src/tests/headless-start-test.c
@@ -148,7 +148,7 @@ meta_test_headless_monitor_connect (void)
 }
 
 static MetaMonitorTestSetup *
-create_headless_test_setup (void)
+create_headless_test_setup (MetaBackend *backend)
 {
   return g_new0 (MetaMonitorTestSetup, 1);
 }
@@ -156,7 +156,7 @@ create_headless_test_setup (void)
 static void
 init_tests (void)
 {
-  meta_monitor_manager_test_init_test_setup (create_headless_test_setup);
+  meta_init_monitor_test_setup (create_headless_test_setup);
 
   g_test_add_func ("/headless-start/start", meta_test_headless_start);
   g_test_add_func ("/headless-start/monitor-getters",
diff --git a/src/tests/meson.build b/src/tests/meson.build
index 9485af9b09..50ae3d4368 100644
--- a/src/tests/meson.build
+++ b/src/tests/meson.build
@@ -6,14 +6,14 @@ mutter_test_sources = [
   'meta-gpu-test.h',
   'meta-monitor-manager-test.c',
   'meta-monitor-manager-test.h',
+  'meta-monitor-test-utils.c',
+  'meta-monitor-test-utils.h',
   'meta-ref-test.c',
   'meta-ref-test.h',
   'meta-sensors-proxy-mock.c',
   'meta-sensors-proxy-mock.h',
   'meta-test-utils.c',
   'meta-test-utils.h',
-  'monitor-test-utils.c',
-  'monitor-test-utils.h',
 ]
 
 libmutter_test_name = 'mutter-test-' + libmutter_api_version
@@ -139,8 +139,6 @@ unit_tests = executable('mutter-test-unit-tests',
     'monitor-config-migration-unit-tests.h',
     'monitor-store-unit-tests.c',
     'monitor-store-unit-tests.h',
-    'monitor-test-utils.c',
-    'monitor-test-utils.h',
     'monitor-transform-tests.c',
     'monitor-transform-tests.h',
     'orientation-manager-unit-tests.c',
@@ -154,8 +152,6 @@ unit_tests = executable('mutter-test-unit-tests',
 
 monitor_unit_tests = executable('mutter-monitor-unit-tests',
   sources: [
-    'monitor-test-utils.c',
-    'monitor-test-utils.h',
     'monitor-unit-tests.c',
   ],
   include_directories: tests_includes,
@@ -178,8 +174,6 @@ headless_start_test = executable('mutter-headless-start-test',
 
 stage_view_tests = executable('mutter-stage-view-tests',
   sources: [
-    'monitor-test-utils.c',
-    'monitor-test-utils.h',
     'stage-view-tests.c',
   ],
   include_directories: tests_includes,
diff --git a/src/tests/meta-monitor-manager-test.c b/src/tests/meta-monitor-manager-test.c
index efff2361cd..fe435288ab 100644
--- a/src/tests/meta-monitor-manager-test.c
+++ b/src/tests/meta-monitor-manager-test.c
@@ -27,7 +27,7 @@
 #include "backends/meta-monitor-config-manager.h"
 #include "backends/meta-output.h"
 #include "tests/meta-backend-test.h"
-#include "tests/monitor-test-utils.h"
+#include "tests/meta-monitor-test-utils.h"
 
 G_DEFINE_TYPE (MetaCrtcTest, meta_crtc_test, META_TYPE_CRTC)
 G_DEFINE_TYPE (MetaOutputTest, meta_output_test, META_TYPE_OUTPUT)
@@ -46,10 +46,49 @@ struct _MetaMonitorManagerTest
 G_DEFINE_TYPE (MetaMonitorManagerTest, meta_monitor_manager_test,
                META_TYPE_MONITOR_MANAGER)
 
-static CreateTestSetupFunc initial_setup_func;
+static MetaCreateTestSetupFunc initial_setup_func;
+
+static MonitorTestCaseSetup default_test_case_setup = {
+  .modes = {
+    {
+      .width = 800,
+      .height = 600,
+      .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
+    },
+
+  },
+  .n_outputs = 1,
+  .crtcs = {
+    {
+      .current_mode = 0
+    },
+  },
+  .n_crtcs = 1,
+};
+
+static MetaMonitorTestSetup *
+create_default_test_setup (MetaBackend *backend)
+{
+  return meta_create_monitor_test_setup (backend,
+                                         &default_test_case_setup,
+                                         MONITOR_TEST_FLAG_NO_STORED);
+}
 
 void
-meta_monitor_manager_test_init_test_setup (CreateTestSetupFunc func)
+meta_init_monitor_test_setup (MetaCreateTestSetupFunc func)
 {
   initial_setup_func = func;
 }
@@ -382,64 +421,28 @@ meta_monitor_manager_test_get_default_layout_mode (MetaMonitorManager *manager)
 }
 
 static void
-meta_monitor_manager_test_dispose (GObject *object)
+meta_monitor_manager_test_constructed (GObject *object)
 {
   MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (object);
+  MetaMonitorManager *manager = META_MONITOR_MANAGER (manager_test);
+  MetaBackend *backend = meta_monitor_manager_get_backend (manager);
 
-  g_clear_pointer (&manager_test->test_setup, g_free);
-
-  G_OBJECT_CLASS (meta_monitor_manager_test_parent_class)->dispose (object);
-}
-
-static MonitorTestCaseSetup default_test_case_setup = {
-  .modes = {
-    {
-      .width = 800,
-      .height = 600,
-      .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
-    },
-
-  },
-  .n_outputs = 1,
-  .crtcs = {
-    {
-      .current_mode = 0
-    },
-  },
-  .n_crtcs = 1,
-};
+  if (initial_setup_func)
+    manager_test->test_setup = initial_setup_func (backend);
+  else
+    manager_test->test_setup = create_default_test_setup (backend);
 
-static MetaMonitorTestSetup *
-create_default_test_setup (void)
-{
-  return create_monitor_test_setup (&default_test_case_setup,
-                                    MONITOR_TEST_FLAG_NO_STORED);
+  G_OBJECT_CLASS (meta_monitor_manager_test_parent_class)->constructed (object);
 }
 
 static void
-meta_monitor_manager_test_constructed (GObject *object)
+meta_monitor_manager_test_dispose (GObject *object)
 {
   MetaMonitorManagerTest *manager_test = META_MONITOR_MANAGER_TEST (object);
 
-  if (initial_setup_func)
-    manager_test->test_setup = initial_setup_func ();
-  else
-    manager_test->test_setup = create_default_test_setup ();
+  g_clear_pointer (&manager_test->test_setup, g_free);
 
-  G_OBJECT_CLASS (meta_monitor_manager_test_parent_class)->constructed (object);
+  G_OBJECT_CLASS (meta_monitor_manager_test_parent_class)->dispose (object);
 }
 
 static void
@@ -454,8 +457,8 @@ meta_monitor_manager_test_class_init (MetaMonitorManagerTestClass *klass)
   GObjectClass *object_class = G_OBJECT_CLASS (klass);
   MetaMonitorManagerClass *manager_class = META_MONITOR_MANAGER_CLASS (klass);
 
-  object_class->dispose = meta_monitor_manager_test_dispose;
   object_class->constructed = meta_monitor_manager_test_constructed;
+  object_class->dispose = meta_monitor_manager_test_dispose;
 
   manager_class->ensure_initial_config = meta_monitor_manager_test_ensure_initial_config;
   manager_class->apply_monitors_config = meta_monitor_manager_test_apply_monitors_config;
diff --git a/src/tests/meta-monitor-manager-test.h b/src/tests/meta-monitor-manager-test.h
index d95ee2978c..c339ec5bee 100644
--- a/src/tests/meta-monitor-manager-test.h
+++ b/src/tests/meta-monitor-manager-test.h
@@ -44,7 +44,7 @@ struct _MetaOutputTest
   float scale;
 };
 
-typedef MetaMonitorTestSetup * (* CreateTestSetupFunc) (void);
+typedef MetaMonitorTestSetup * (* MetaCreateTestSetupFunc) (MetaBackend *backend);
 
 #define META_TYPE_CRTC_TEST (meta_crtc_test_get_type ())
 META_EXPORT
@@ -64,7 +64,7 @@ G_DECLARE_FINAL_TYPE (MetaMonitorManagerTest, meta_monitor_manager_test,
                       META, MONITOR_MANAGER_TEST, MetaMonitorManager)
 
 META_EXPORT
-void meta_monitor_manager_test_init_test_setup (CreateTestSetupFunc func);
+void meta_init_monitor_test_setup (MetaCreateTestSetupFunc func);
 
 META_EXPORT
 void meta_monitor_manager_test_read_current (MetaMonitorManager *manager);
diff --git a/src/tests/monitor-test-utils.c b/src/tests/meta-monitor-test-utils.c
similarity index 95%
rename from src/tests/monitor-test-utils.c
rename to src/tests/meta-monitor-test-utils.c
index dd4d16f8ee..aab9e18589 100644
--- a/src/tests/monitor-test-utils.c
+++ b/src/tests/meta-monitor-test-utils.c
@@ -19,7 +19,7 @@
 
 #include "config.h"
 
-#include "tests/monitor-test-utils.h"
+#include "tests/meta-monitor-test-utils.h"
 
 #include <float.h>
 
@@ -33,33 +33,31 @@
 #include "meta-backend-test.h"
 
 MetaGpu *
-test_get_gpu (void)
+meta_test_get_gpu (MetaBackend *backend)
 {
-  return META_GPU (meta_backend_get_gpus (meta_get_backend ())->data);
-}
-
-static void
-set_custom_monitor_config_common (const char             *filename,
-                                  MetaMonitorsConfigFlag  configs_flags)
-{
-  meta_set_custom_monitor_config (meta_get_backend (), filename, configs_flags);
+  return META_GPU (meta_backend_get_gpus (backend)->data);
 }
 
 void
-set_custom_monitor_config (const char *filename)
+meta_set_custom_monitor_config (MetaContext *context,
+                                const char  *filename)
 {
-  set_custom_monitor_config_common (filename, META_MONITORS_CONFIG_FLAG_NONE);
+  meta_set_custom_monitor_config_full (meta_context_get_backend (context),
+                                       filename,
+                                       META_MONITORS_CONFIG_FLAG_NONE);
 }
 
 void
-set_custom_monitor_system_config (const char *filename)
+meta_set_custom_monitor_system_config (MetaContext *context,
+                                       const char  *filename)
 {
-  set_custom_monitor_config_common (filename,
-                                    META_MONITORS_CONFIG_FLAG_SYSTEM_CONFIG);
+  meta_set_custom_monitor_config_full (meta_context_get_backend (context),
+                                       filename,
+                                       META_MONITORS_CONFIG_FLAG_SYSTEM_CONFIG);
 }
 
 char *
-read_file (const char *file_path)
+meta_read_file (const char *file_path)
 {
   g_autoptr (GFile) file = NULL;
   g_autoptr (GFileInputStream) input_stream = NULL;
@@ -322,9 +320,10 @@ check_logical_monitor (MetaMonitorManager             *monitor_manager,
 }
 
 void
-check_monitor_configuration (MonitorTestCaseExpect *expect)
+meta_check_monitor_configuration (MetaContext           *context,
+                                  MonitorTestCaseExpect *expect)
 {
-  MetaBackend *backend = meta_get_backend ();
+  MetaBackend *backend = meta_context_get_backend (context);
   MetaRenderer *renderer = meta_backend_get_renderer (backend);
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
@@ -621,8 +620,9 @@ check_monitor_configuration (MonitorTestCaseExpect *expect)
 }
 
 MetaMonitorTestSetup *
-create_monitor_test_setup (MonitorTestCaseSetup *setup,
-                           MonitorTestFlag       flags)
+meta_create_monitor_test_setup (MetaBackend          *backend,
+                                MonitorTestCaseSetup *setup,
+                                MonitorTestFlag       flags)
 {
   MetaMonitorTestSetup *test_setup;
   int i;
@@ -658,7 +658,7 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
 
       crtc = g_object_new (META_TYPE_CRTC_TEST,
                            "id", (uint64_t) i + 1,
-                           "gpu", test_get_gpu (),
+                           "gpu", meta_test_get_gpu (backend),
                            NULL);
 
       test_setup->crtcs = g_list_append (test_setup->crtcs, crtc);
@@ -765,7 +765,7 @@ create_monitor_test_setup (MonitorTestCaseSetup *setup,
 
       output = g_object_new (META_TYPE_OUTPUT_TEST,
                              "id", (uint64_t) i,
-                             "gpu", test_get_gpu (),
+                             "gpu", meta_test_get_gpu (backend),
                              "info", output_info,
                              NULL);
 
@@ -828,12 +828,13 @@ check_expected_scales (MetaMonitor                 *monitor,
     }
 }
 
-void check_monitor_scales (MonitorTestCaseExpect       *expect,
+void
+meta_check_monitor_scales (MetaContext                 *context,
+                           MonitorTestCaseExpect       *expect,
                            MetaMonitorScalesConstraint  scales_constraints)
 {
-  MetaBackend *backend = meta_get_backend ();
   MetaMonitorManager *monitor_manager =
-    meta_backend_get_monitor_manager (backend);
+    meta_backend_get_monitor_manager (meta_context_get_backend (context));
 
   GList *monitors;
   GList *l;
diff --git a/src/tests/monitor-test-utils.h b/src/tests/meta-monitor-test-utils.h
similarity index 84%
rename from src/tests/monitor-test-utils.h
rename to src/tests/meta-monitor-test-utils.h
index 3f2f757d01..988a4115e8 100644
--- a/src/tests/monitor-test-utils.h
+++ b/src/tests/meta-monitor-test-utils.h
@@ -197,27 +197,43 @@ typedef struct _MonitorTestCase
   MonitorTestCaseExpect expect;
 } MonitorTestCase;
 
-MetaGpu * test_get_gpu (void);
+META_EXPORT
+MetaGpu * meta_test_get_gpu (MetaBackend *backend);
 
-void set_custom_monitor_config (const char *filename);
+META_EXPORT
+void meta_set_custom_monitor_config (MetaContext *context,
+                                     const char  *filename);
 
-void set_custom_monitor_system_config (const char *filename);
+META_EXPORT
+void meta_set_custom_monitor_system_config (MetaContext *context,
+                                            const char  *filename);
 
-char * read_file (const char *file_path);
+META_EXPORT
+char * meta_read_file (const char *file_path);
 
-void check_monitor_configuration (MonitorTestCaseExpect *expect);
-void check_monitor_scales (MonitorTestCaseExpect       *expect,
-                           MetaMonitorScalesConstraint  scales_constraints);
+META_EXPORT
+void meta_check_monitor_configuration (MetaContext           *context,
+                                       MonitorTestCaseExpect *expect);
 
-MetaMonitorTestSetup * create_monitor_test_setup (MonitorTestCaseSetup *setup,
-                                                  MonitorTestFlag       flags);
+META_EXPORT
+void meta_check_monitor_scales (MetaContext                 *context,
+                                MonitorTestCaseExpect       *expect,
+                                MetaMonitorScalesConstraint  scales_constraints);
 
+META_EXPORT
+MetaMonitorTestSetup * meta_create_monitor_test_setup (MetaBackend          *backend,
+                                                       MonitorTestCaseSetup *setup,
+                                                       MonitorTestFlag       flags);
+
+META_EXPORT
 const char * meta_orientation_to_string (MetaOrientation orientation);
 
+META_EXPORT
 void meta_wait_for_orientation (MetaOrientationManager *orientation_manager,
                                 MetaOrientation         orientation,
                                 unsigned int           *times_signalled_out);
 
+META_EXPORT
 void meta_wait_for_possible_orientation_change (MetaOrientationManager *orientation_manager,
                                                 unsigned int           *times_signalled_out);
 
diff --git a/src/tests/meta-test-utils.c b/src/tests/meta-test-utils.c
index c70886a6b8..261d2c4191 100644
--- a/src/tests/meta-test-utils.c
+++ b/src/tests/meta-test-utils.c
@@ -596,9 +596,9 @@ meta_test_get_plugin_name (void)
 }
 
 void
-meta_set_custom_monitor_config (MetaBackend            *backend,
-                                const char             *filename,
-                                MetaMonitorsConfigFlag  configs_flags)
+meta_set_custom_monitor_config_full (MetaBackend            *backend,
+                                     const char             *filename,
+                                     MetaMonitorsConfigFlag  configs_flags)
 {
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
diff --git a/src/tests/meta-test-utils.h b/src/tests/meta-test-utils.h
index 423f96c491..fe0bde766f 100644
--- a/src/tests/meta-test-utils.h
+++ b/src/tests/meta-test-utils.h
@@ -114,9 +114,9 @@ META_EXPORT
 const char * meta_test_get_plugin_name (void);
 
 META_EXPORT
-void meta_set_custom_monitor_config (MetaBackend            *backend,
-                                     const char             *filename,
-                                     MetaMonitorsConfigFlag  configs_flags);
+void meta_set_custom_monitor_config_full (MetaBackend            *backend,
+                                          const char             *filename,
+                                          MetaMonitorsConfigFlag  configs_flags);
 
 META_EXPORT
 void meta_wait_for_paint (MetaContext *context);
diff --git a/src/tests/monitor-config-migration-unit-tests.c b/src/tests/monitor-config-migration-unit-tests.c
index df22ee3a8d..402427031f 100644
--- a/src/tests/monitor-config-migration-unit-tests.c
+++ b/src/tests/monitor-config-migration-unit-tests.c
@@ -29,7 +29,7 @@
 #include "backends/meta-monitor-config-store.h"
 #include "backends/meta-monitor-manager-private.h"
 #include "backends/meta-monitor-config-migration.h"
-#include "tests/monitor-test-utils.h"
+#include "tests/meta-monitor-test-utils.h"
 
 static void
 test_migration (const char *old_config,
@@ -70,8 +70,8 @@ test_migration (const char *old_config,
   expected_path = g_test_get_filename (G_TEST_DIST, "tests", "migration",
                                        new_config, NULL);
 
-  expected_data = read_file (expected_path);
-  migrated_data = read_file (migrated_path);
+  expected_data = meta_read_file (expected_path);
+  migrated_data = meta_read_file (migrated_path);
 
   g_assert_nonnull (expected_data);
   g_assert_nonnull (migrated_data);
diff --git a/src/tests/monitor-store-unit-tests.c b/src/tests/monitor-store-unit-tests.c
index 9ccf101ea1..004d466c9d 100644
--- a/src/tests/monitor-store-unit-tests.c
+++ b/src/tests/monitor-store-unit-tests.c
@@ -25,7 +25,7 @@
 #include "backends/meta-monitor-config-store.h"
 #include "backends/meta-monitor-config-manager.h"
 #include "backends/meta-monitor-manager-private.h"
-#include "tests/monitor-test-utils.h"
+#include "tests/meta-monitor-test-utils.h"
 #include "tests/unit-tests.h"
 
 #define MAX_N_MONITORS 10
@@ -258,7 +258,7 @@ meta_test_monitor_store_single (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("single.xml");
+  meta_set_custom_monitor_config (test_context, "single.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -327,7 +327,7 @@ meta_test_monitor_store_vertical (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("vertical.xml");
+  meta_set_custom_monitor_config (test_context, "vertical.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -396,7 +396,7 @@ meta_test_monitor_store_primary (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("primary.xml");
+  meta_set_custom_monitor_config (test_context, "primary.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -441,7 +441,7 @@ meta_test_monitor_store_underscanning (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("underscanning.xml");
+  meta_set_custom_monitor_config (test_context, "underscanning.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -491,7 +491,7 @@ meta_test_monitor_store_scale (void)
       return;
     }
 
-  set_custom_monitor_config ("scale.xml");
+  meta_set_custom_monitor_config (test_context, "scale.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -541,7 +541,7 @@ meta_test_monitor_store_fractional_scale (void)
       return;
     }
 
-  set_custom_monitor_config ("fractional-scale.xml");
+  meta_set_custom_monitor_config (test_context, "fractional-scale.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -591,7 +591,7 @@ meta_test_monitor_store_high_precision_fractional_scale (void)
       return;
     }
 
-  set_custom_monitor_config ("high-precision-fractional-scale.xml");
+  meta_set_custom_monitor_config (test_context, "high-precision-fractional-scale.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -645,7 +645,7 @@ meta_test_monitor_store_mirrored (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("mirrored.xml");
+  meta_set_custom_monitor_config (test_context, "mirrored.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -716,7 +716,7 @@ meta_test_monitor_store_first_rotated (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("first-rotated.xml");
+  meta_set_custom_monitor_config (test_context, "first-rotated.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -787,7 +787,7 @@ meta_test_monitor_store_second_rotated (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("second-rotated.xml");
+  meta_set_custom_monitor_config (test_context, "second-rotated.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -832,7 +832,7 @@ meta_test_monitor_store_interlaced (void)
     .n_configurations = 1
   };
 
-  set_custom_monitor_config ("interlaced.xml");
+  meta_set_custom_monitor_config (test_context, "interlaced.xml");
 
   check_monitor_store_configurations (&expect);
 }
@@ -885,7 +885,7 @@ meta_test_monitor_store_unknown_elements (void)
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "Unknown element <unknownunderlogicalmonitor> "
                          "under <logicalmonitor>, ignoring");
-  set_custom_monitor_config ("unknown-elements.xml");
+  meta_set_custom_monitor_config (test_context, "unknown-elements.xml");
   g_test_assert_expected_messages ();
 
   check_monitor_store_configurations (&expect);
@@ -897,7 +897,7 @@ meta_test_monitor_store_policy_not_allowed (void)
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "*Policy can only be defined in system level "
                          "configurations*");
-  set_custom_monitor_config ("policy.xml");
+  meta_set_custom_monitor_config (test_context, "policy.xml");
   g_test_assert_expected_messages ();
 }
 
@@ -912,7 +912,7 @@ meta_test_monitor_store_policy (void)
     meta_monitor_config_manager_get_store (config_manager);
   GList *stores_policy;
 
-  set_custom_monitor_system_config ("policy.xml");
+  meta_set_custom_monitor_system_config (test_context, "policy.xml");
   stores_policy = meta_monitor_config_store_get_stores_policy (config_store);
   g_assert_cmpuint (g_list_length (stores_policy), ==, 1);
   g_assert_cmpint (GPOINTER_TO_INT (stores_policy->data),
@@ -925,7 +925,7 @@ meta_test_monitor_store_policy_empty (void)
 {
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "*Invalid store*");
-  set_custom_monitor_system_config ("policy-empty.xml");
+  meta_set_custom_monitor_system_config (test_context, "policy-empty.xml");
   g_test_assert_expected_messages ();
 }
 
@@ -934,7 +934,7 @@ meta_test_monitor_store_policy_duplicate (void)
 {
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "*Multiple identical stores*");
-  set_custom_monitor_system_config ("policy-duplicate.xml");
+  meta_set_custom_monitor_system_config (test_context, "policy-duplicate.xml");
   g_test_assert_expected_messages ();
 }
 
@@ -943,7 +943,7 @@ meta_test_monitor_store_policy_invalid (void)
 {
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "*Invalid store*");
-  set_custom_monitor_system_config ("policy-invalid.xml");
+  meta_set_custom_monitor_system_config (test_context, "policy-invalid.xml");
   g_test_assert_expected_messages ();
 }
 
@@ -952,7 +952,7 @@ meta_test_monitor_store_policy_multiple (void)
 {
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "*Multiple stores elements under policy*");
-  set_custom_monitor_system_config ("policy-multiple.xml");
+  meta_set_custom_monitor_system_config (test_context, "policy-multiple.xml");
   g_test_assert_expected_messages ();
 }
 
@@ -972,7 +972,7 @@ meta_test_monitor_store_policy_dbus (void)
   g_assert_nonnull (policy);
   g_assert_cmpint (policy->enable_dbus, ==, TRUE);
 
-  set_custom_monitor_system_config ("policy-dbus.xml");
+  meta_set_custom_monitor_system_config (test_context, "policy-dbus.xml");
 
   policy = meta_monitor_config_store_get_policy (config_store);
   g_assert_nonnull (policy);
@@ -993,7 +993,8 @@ meta_test_monitor_store_policy_dbus_invalid (void)
 
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "*Multiple dbus elements under policy*");
-  set_custom_monitor_system_config ("policy-dbus-invalid.xml");
+  meta_set_custom_monitor_system_config (test_context,
+                                         "policy-dbus-invalid.xml");
   g_test_assert_expected_messages ();
 
   policy = meta_monitor_config_store_get_policy (config_store);
diff --git a/src/tests/monitor-unit-tests.c b/src/tests/monitor-unit-tests.c
index bec8184c82..7a19ca1134 100644
--- a/src/tests/monitor-unit-tests.c
+++ b/src/tests/monitor-unit-tests.c
@@ -31,12 +31,13 @@
 #include "meta-backend-test.h"
 #include "meta-test/meta-context-test.h"
 #include "tests/meta-monitor-manager-test.h"
+#include "tests/meta-monitor-test-utils.h"
 #include "tests/meta-sensors-proxy-mock.h"
-#include "tests/monitor-test-utils.h"
 #include "tests/meta-test-utils.h"
 #include "x11/meta-x11-display-private.h"
 
 static MetaContext *test_context;
+static MetaBackend *test_backend;
 
 static MonitorTestCase initial_test_case = {
   .setup = {
@@ -267,7 +268,8 @@ static void
 meta_test_monitor_initial_linear_config (void)
 {
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&initial_test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &initial_test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -678,11 +680,13 @@ meta_test_monitor_one_disconnected_linear_config (void)
     .screen_height = 768
   };
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -798,11 +802,13 @@ meta_test_monitor_one_off_linear_config (void)
     .screen_height = 768
   };
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -920,11 +926,13 @@ meta_test_monitor_preferred_linear_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -1051,11 +1059,13 @@ meta_test_monitor_tiled_linear_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -1226,11 +1236,13 @@ meta_test_monitor_tiled_non_preferred_linear_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -1377,11 +1389,13 @@ meta_test_monitor_tiled_non_main_origin_linear_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -1525,11 +1539,13 @@ meta_test_monitor_hidpi_linear_config (void)
       return;
     }
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -1676,12 +1692,14 @@ meta_test_monitor_suggested_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -1830,8 +1848,9 @@ meta_test_monitor_suggested_config_overlapping (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
 
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "Suggested monitor config has overlapping region, "
@@ -1840,7 +1859,8 @@ meta_test_monitor_suggested_config_overlapping (void)
   g_test_assert_expected_messages ();
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
 }
 
 static void
@@ -1987,8 +2007,9 @@ meta_test_monitor_suggested_config_not_adjacent (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
 
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "Suggested monitor config has monitors with no "
@@ -1997,7 +2018,8 @@ meta_test_monitor_suggested_config_not_adjacent (void)
   g_test_assert_expected_messages ();
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
 }
 
 static void
@@ -2143,8 +2165,9 @@ meta_test_monitor_suggested_config_multi_dpi (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
 
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "Suggested monitor config has monitors with no "
@@ -2153,7 +2176,8 @@ meta_test_monitor_suggested_config_multi_dpi (void)
   g_test_assert_expected_messages();
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
 }
 
 static void
@@ -2270,8 +2294,9 @@ meta_test_monitor_limited_crtcs (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
 
   g_test_expect_message (G_LOG_DOMAIN, G_LOG_LEVEL_WARNING,
                          "Failed to use linear *");
@@ -2280,7 +2305,8 @@ meta_test_monitor_limited_crtcs (void)
   g_test_assert_expected_messages ();
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -2415,11 +2441,13 @@ meta_test_monitor_lid_switch_config (void)
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
@@ -2438,7 +2466,8 @@ meta_test_monitor_lid_switch_config (void)
   test_case.expect.crtcs[1].x = 0;
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
@@ -2460,7 +2489,8 @@ meta_test_monitor_lid_switch_config (void)
   test_case.expect.crtcs[1].x = 1024;
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -2594,13 +2624,15 @@ meta_test_monitor_lid_opened_config (void)
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
 
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
@@ -2615,7 +2647,8 @@ meta_test_monitor_lid_opened_config (void)
   test_case.expect.crtcs[1].x = 0;
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -2704,13 +2737,15 @@ meta_test_monitor_lid_closed_no_external (void)
   MetaMonitorTestSetup *test_setup;
   MetaBackend *backend = meta_get_backend ();
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
 
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -2849,13 +2884,15 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
    *  3) Close lid
    */
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
 
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   g_test_message ("External monitor connected");
@@ -2867,11 +2904,13 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
   test_case.expect.crtcs[1].x = 1024;
   test_case.expect.screen_width = 1024 * 2;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   g_test_message ("Lid closed");
@@ -2882,12 +2921,14 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
   test_case.expect.crtcs[1].x = 0;
   test_case.expect.screen_width = 1024;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   /*
@@ -2907,12 +2948,14 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
   test_case.expect.crtcs[1].x = 1024;
   test_case.expect.screen_width = 1024 * 2;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   g_test_message ("External monitor disconnected");
@@ -2923,11 +2966,13 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
   test_case.expect.crtcs[1].current_mode = -1;
   test_case.expect.screen_width = 1024;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   g_test_message ("Lid closed");
@@ -2935,21 +2980,25 @@ meta_test_monitor_lid_closed_with_hotplugged_external (void)
   test_case.expect.n_logical_monitors = 1;
   test_case.expect.screen_width = 1024;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   g_test_message ("Lid opened");
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -3046,26 +3095,30 @@ meta_test_monitor_lid_scaled_closed_opened (void)
       return;
     }
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("lid-scale.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "lid-scale.xml");
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
   meta_monitor_manager_lid_is_closed_changed (monitor_manager);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   meta_monitor_manager_lid_is_closed_changed (monitor_manager);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -3093,12 +3146,14 @@ meta_test_monitor_no_outputs (void)
   MetaMonitorTestSetup *test_setup;
   GError *error = NULL;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   if (!meta_test_client_do (x11_monitor_test_client, &error,
@@ -3116,12 +3171,14 @@ meta_test_monitor_no_outputs (void)
   check_monitor_test_clients_state ();
 
   /* Also check that we handle going headless -> headless */
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -3209,11 +3266,13 @@ meta_test_monitor_underscanning_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -3306,11 +3365,13 @@ meta_test_monitor_preferred_non_first_mode (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -3341,11 +3402,13 @@ meta_test_monitor_non_upright_panel (void)
   test_case.expect.crtcs[0].current_mode = 1;
   test_case.expect.crtcs[0].transform = META_MONITOR_TRANSFORM_90;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -3481,16 +3544,19 @@ meta_test_monitor_switch_external_without_external (void)
   MetaMonitorManager *monitor_manager =
     meta_backend_get_monitor_manager (backend);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
 
   meta_monitor_manager_switch_config (monitor_manager,
                                       META_MONITOR_SWITCH_CONFIG_EXTERNAL);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
 
   check_monitor_test_clients_state ();
 }
@@ -3548,7 +3614,8 @@ check_monitor_configuration_per_orientation (MonitorTestCase *test_case,
         expect.screen_height = bottom_edge;
     }
 
-  check_monitor_configuration (&expect);
+  meta_check_monitor_configuration (test_context,
+                                    &expect);
   check_monitor_test_clients_state ();
 }
 
@@ -3691,14 +3758,16 @@ meta_test_monitor_orientation_is_managed (void)
   g_autoptr (ClutterAutoRemoveInputDevice) touch_device = NULL;
   g_autoptr (MetaSensorsProxyAutoResetMock) orientation_mock = NULL;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
 
   g_assert_false (
     meta_monitor_manager_get_panel_orientation_managed (monitor_manager));
 
   emulate_hotplug (test_setup);
-  check_monitor_configuration (&test_case.expect);
+  meta_check_monitor_configuration (test_context,
+                                    &test_case.expect);
   check_monitor_test_clients_state ();
 
   g_assert_false (
@@ -3706,8 +3775,9 @@ meta_test_monitor_orientation_is_managed (void)
 
   g_assert_null (meta_monitor_manager_get_laptop_panel (monitor_manager));
   test_case.setup.outputs[0].is_laptop_panel = TRUE;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
   g_assert_nonnull (meta_monitor_manager_get_laptop_panel (monitor_manager));
 
@@ -3739,16 +3809,18 @@ meta_test_monitor_orientation_is_managed (void)
     meta_monitor_manager_get_panel_orientation_managed (monitor_manager));
 
   test_case.setup.outputs[0].is_laptop_panel = FALSE;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
   g_assert_null (meta_monitor_manager_get_laptop_panel (monitor_manager));
   g_assert_false (
     meta_monitor_manager_get_panel_orientation_managed (monitor_manager));
 
   test_case.setup.outputs[0].is_laptop_panel = TRUE;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
   g_assert_nonnull (meta_monitor_manager_get_laptop_panel (monitor_manager));
   g_assert_true (
@@ -3892,8 +3964,9 @@ meta_test_monitor_orientation_initial_rotated (void)
                              &times_signalled);
   g_assert_cmpuint (times_signalled, <=, 1);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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 configuration per orientation",
@@ -3999,8 +4072,9 @@ meta_test_monitor_orientation_initial_rotated_no_touch_mode (void)
                              &times_signalled);
   g_assert_cmpuint (times_signalled, <=, 1);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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 configuration per orientation",
@@ -4116,9 +4190,10 @@ meta_test_monitor_orientation_initial_stored_rotated (void)
                              &times_signalled);
   g_assert_cmpuint (times_signalled, <=, 1);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("lid-scale.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "lid-scale.xml");
   emulate_hotplug (test_setup);
 
 
@@ -4273,12 +4348,12 @@ meta_test_monitor_orientation_initial_stored_rotated_no_touch (void)
                              &times_signalled);
   g_assert_cmpuint (times_signalled, <=, 1);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("lid-scale.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "lid-scale.xml");
   emulate_hotplug (test_setup);
 
-
   META_TEST_LOG_CALL ("Checking configuration per orientation",
                       check_monitor_configuration_per_orientation (
                         &test_case, 0, META_ORIENTATION_NORMAL,
@@ -4395,8 +4470,9 @@ meta_test_monitor_orientation_changes (void)
   g_test_message ("%s", G_STRFUNC);
   orientation_mock = meta_sensors_proxy_mock_get ();
   touch_device = meta_test_add_touch_device (backend);
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
 
   g_set_object (&previous_config,
@@ -4591,8 +4667,9 @@ meta_test_monitor_orientation_changes_for_transformed_panel (void)
   g_test_message ("%s", G_STRFUNC);
   orientation_mock = meta_sensors_proxy_mock_get ();
   touch_device = meta_test_add_touch_device (backend);
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
 
   g_set_object (&previous_config,
@@ -4854,12 +4931,14 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
    *  5) Close lid
    */
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
 
   emulate_hotplug (test_setup);
-  check_monitor_configuration (&test_case.expect);
+  meta_check_monitor_configuration (test_context,
+                                    &test_case.expect);
 
   for (i = META_N_ORIENTATIONS - 1; i > META_ORIENTATION_UNDEFINED; i--)
     {
@@ -4877,7 +4956,8 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
   meta_wait_for_orientation (orientation_manager, META_ORIENTATION_NORMAL,
                              &times_signalled);
   g_assert_cmpuint (times_signalled, <=, 1);
-  check_monitor_configuration (&test_case.expect);
+  meta_check_monitor_configuration (test_context,
+                                    &test_case.expect);
 
   g_test_message ("External monitor connected");
   test_case.setup.n_outputs = 2;
@@ -4888,10 +4968,12 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
   test_case.expect.crtcs[1].x = 1024;
   test_case.expect.screen_width = 1024 * 2;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
-  check_monitor_configuration (&test_case.expect);
+  meta_check_monitor_configuration (test_context,
+                                    &test_case.expect);
 
   /* Rotate the monitor in all the directions */
   for (i = META_N_ORIENTATIONS - 1; i > META_ORIENTATION_UNDEFINED; i--)
@@ -4910,7 +4992,8 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
   meta_wait_for_orientation (orientation_manager, META_ORIENTATION_NORMAL,
                              &times_signalled);
   g_assert_cmpuint (times_signalled, <=, 1);
-  check_monitor_configuration (&test_case.expect);
+  meta_check_monitor_configuration (test_context,
+                                    &test_case.expect);
 
   g_test_message ("Lid closed");
   test_case.expect.monitors[0].current_mode = -1;
@@ -4920,8 +5003,9 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
   test_case.expect.crtcs[1].x = 0;
   test_case.expect.screen_width = 1024;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
   emulate_hotplug (test_setup);
 
@@ -4931,7 +5015,8 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
       meta_sensors_proxy_mock_set_orientation (orientation_mock, i);
       meta_wait_for_orientation (orientation_manager, i, &times_signalled);
       g_assert_cmpuint (times_signalled, <=, 1);
-      check_monitor_configuration (&test_case.expect);
+      meta_check_monitor_configuration (test_context,
+                                        &test_case.expect);
     }
 
   meta_sensors_proxy_mock_set_orientation (orientation_mock,
@@ -4958,11 +5043,13 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
   test_case.expect.crtcs[1].x = 1024;
   test_case.expect.screen_width = 1024 * 2;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
   emulate_hotplug (test_setup);
-  check_monitor_configuration (&test_case.expect);
+  meta_check_monitor_configuration (test_context,
+                                    &test_case.expect);
 
   for (i = META_N_ORIENTATIONS - 1; i > META_ORIENTATION_UNDEFINED; i--)
     {
@@ -4974,8 +5061,9 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
       test_case.expect.crtcs[1].x = 0;
       test_case.expect.screen_width = 1024;
 
-      test_setup = create_monitor_test_setup (&test_case.setup,
-                                              MONITOR_TEST_FLAG_NO_STORED);
+      test_setup = meta_create_monitor_test_setup (test_backend,
+                                                   &test_case.setup,
+                                                   MONITOR_TEST_FLAG_NO_STORED);
       meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
       emulate_hotplug (test_setup);
 
@@ -4983,7 +5071,8 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
       meta_sensors_proxy_mock_set_orientation (orientation_mock, i);
       meta_wait_for_orientation (orientation_manager, i, &times_signalled);
       g_assert_cmpuint (times_signalled, <=, 1);
-      check_monitor_configuration (&test_case.expect);
+      meta_check_monitor_configuration (test_context,
+                                        &test_case.expect);
 
       g_test_message ("Opening lid");
       test_case.expect.monitors[0].current_mode = 0;
@@ -4993,8 +5082,9 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
       test_case.expect.crtcs[0].current_mode = 0;
       test_case.expect.crtcs[1].x = 1024;
 
-      test_setup = create_monitor_test_setup (&test_case.setup,
-                                              MONITOR_TEST_FLAG_NO_STORED);
+      test_setup = meta_create_monitor_test_setup (test_backend,
+                                                   &test_case.setup,
+                                                   MONITOR_TEST_FLAG_NO_STORED);
       meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
       emulate_hotplug (test_setup);
 
@@ -5016,8 +5106,9 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
       test_case.expect.n_logical_monitors = 1;
       test_case.expect.crtcs[1].current_mode = -1;
 
-      test_setup = create_monitor_test_setup (&test_case.setup,
-                                              MONITOR_TEST_FLAG_NO_STORED);
+      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 configuration per orientation",
                           check_monitor_configuration_per_orientation (
@@ -5031,8 +5122,9 @@ meta_test_monitor_orientation_changes_with_hotplugging (void)
       test_case.expect.crtcs[1].current_mode = 0;
       test_case.expect.crtcs[1].x = 1024;
 
-      test_setup = create_monitor_test_setup (&test_case.setup,
-                                              MONITOR_TEST_FLAG_NO_STORED);
+      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 configuration per orientation",
                           check_monitor_configuration_per_orientation (
@@ -5178,13 +5270,15 @@ meta_test_monitor_custom_vertical_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("vertical.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "vertical.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -5320,13 +5414,15 @@ meta_test_monitor_custom_primary_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("primary.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "primary.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -5414,13 +5510,15 @@ meta_test_monitor_custom_underscanning_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("underscanning.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "underscanning.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -5513,13 +5611,15 @@ meta_test_monitor_custom_scale_config (void)
       return;
     }
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("scale.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "scale.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -5612,13 +5712,15 @@ meta_test_monitor_custom_fractional_scale_config (void)
       return;
     }
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("fractional-scale.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "fractional-scale.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -5711,13 +5813,16 @@ meta_test_monitor_custom_high_precision_fractional_scale_config (void)
       return;
     }
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("high-precision-fractional-scale.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context,
+                                  "high-precision-fractional-scale.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -5850,13 +5955,15 @@ meta_test_monitor_custom_tiled_config (void)
       return;
     }
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("tiled.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "tiled.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -6009,13 +6116,15 @@ meta_test_monitor_custom_tiled_custom_resolution_config (void)
       return;
     }
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("tiled-custom-resolution.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "tiled-custom-resolution.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -6185,13 +6294,16 @@ meta_test_monitor_custom_tiled_non_preferred_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("non-preferred-tiled-custom-resolution.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context,
+                                  "non-preferred-tiled-custom-resolution.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -6315,13 +6427,15 @@ meta_test_monitor_custom_mirrored_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("mirrored.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "mirrored.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -6453,12 +6567,14 @@ meta_test_monitor_custom_first_rotated_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("first-rotated.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "first-rotated.xml");
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -6591,12 +6707,14 @@ meta_test_monitor_custom_second_rotated_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("second-rotated.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "second-rotated.xml");
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -6785,12 +6903,14 @@ meta_test_monitor_custom_second_rotated_tiled_config (void)
   meta_monitor_manager_test_set_handles_transforms (monitor_manager_test,
                                                     TRUE);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("second-rotated-tiled.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "second-rotated-tiled.xml");
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -6979,12 +7099,14 @@ meta_test_monitor_custom_second_rotated_nonnative_tiled_config (void)
   meta_monitor_manager_test_set_handles_transforms (monitor_manager_test,
                                                     FALSE);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("second-rotated-tiled.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "second-rotated-tiled.xml");
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -7131,12 +7253,14 @@ meta_test_monitor_custom_second_rotated_nonnative_config (void)
   meta_monitor_manager_test_set_handles_transforms (monitor_manager_test,
                                                     FALSE);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("second-rotated.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "second-rotated.xml");
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -7242,13 +7366,15 @@ meta_test_monitor_custom_interlaced_config (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("interlaced.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "interlaced.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -7373,13 +7499,15 @@ meta_test_monitor_custom_oneoff (void)
   };
   MetaMonitorTestSetup *test_setup;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("oneoff.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "oneoff.xml");
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -7512,12 +7640,14 @@ meta_test_monitor_custom_lid_switch_config (void)
   MetaMonitorTestSetup *test_setup;
   MetaBackend *backend = meta_get_backend ();
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
-  set_custom_monitor_config ("lid-switch.xml");
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
+  meta_set_custom_monitor_config (test_context, "lid-switch.xml");
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   /* External monitor connected */
@@ -7536,11 +7666,13 @@ meta_test_monitor_custom_lid_switch_config (void)
   test_case.expect.n_logical_monitors = 2;
   test_case.expect.screen_width = 1024 + 768;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   /* Lid was closed */
@@ -7557,11 +7689,13 @@ meta_test_monitor_custom_lid_switch_config (void)
   test_case.expect.screen_width = 768;
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), TRUE);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   /* Lid was opened */
@@ -7581,11 +7715,13 @@ meta_test_monitor_custom_lid_switch_config (void)
   test_case.expect.screen_width = 1024 + 768;
   meta_backend_test_set_is_lid_closed (META_BACKEND_TEST (backend), FALSE);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
   emulate_hotplug (test_setup);
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 }
 
@@ -7687,8 +7823,9 @@ meta_test_monitor_migrated_rotated (void)
   g_autofree char *expected_data = NULL;
   g_autoptr (GFile) migrated_file = NULL;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
 
   migrated_path = g_build_filename (g_get_tmp_dir (),
                                     "test-finished-migrated-monitors.xml",
@@ -7713,15 +7850,16 @@ meta_test_monitor_migrated_rotated (void)
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   expected_path = g_test_get_filename (G_TEST_DIST,
                                        "tests", "migration",
                                        "rotated-new-finished.xml",
                                        NULL);
-  expected_data = read_file (expected_path);
-  migrated_data = read_file (migrated_path);
+  expected_data = meta_read_file (expected_path);
+  migrated_data = meta_read_file (migrated_path);
 
   g_assert_nonnull (expected_data);
   g_assert_nonnull (migrated_data);
@@ -7830,8 +7968,9 @@ meta_test_monitor_migrated_wiggle_discard (void)
   g_autofree char *expected_data = NULL;
   g_autoptr (GFile) migrated_file = NULL;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
 
   migrated_path = g_build_filename (g_get_tmp_dir (),
                                     "test-finished-migrated-monitors.xml",
@@ -7860,15 +7999,16 @@ meta_test_monitor_migrated_wiggle_discard (void)
   g_test_assert_expected_messages ();
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   expected_path = g_test_get_filename (G_TEST_DIST,
                                        "tests", "migration",
                                        "wiggle-new-discarded.xml",
                                        NULL);
-  expected_data = read_file (expected_path);
-  migrated_data = read_file (migrated_path);
+  expected_data = meta_read_file (expected_path);
+  migrated_data = meta_read_file (migrated_path);
 
   g_assert_nonnull (expected_data);
   g_assert_nonnull (migrated_data);
@@ -7936,8 +8076,9 @@ meta_test_monitor_wm_tiling (void)
   g_autoptr (GError) error = NULL;
   MetaTestClient *test_client;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
 
   /*
@@ -7968,12 +8109,14 @@ meta_test_monitor_wm_tiling (void)
   check_test_client_state (test_client);
 
   test_case.setup.n_outputs = 0;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
   test_case.setup.n_outputs = 1;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
 
   dispatch ();
@@ -7987,16 +8130,18 @@ meta_test_monitor_wm_tiling (void)
    */
 
   test_case.setup.n_outputs = 2;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
 
   meta_window_move_to_monitor (test_window, 1);
   meta_window_tile (test_window, META_TILE_NONE);
 
   test_case.setup.n_outputs = 1;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   emulate_hotplug (test_setup);
 
   meta_window_tile (test_window, META_TILE_MAXIMIZED);
@@ -8102,8 +8247,9 @@ meta_test_monitor_migrated_wiggle (void)
   g_autofree char *expected_data = NULL;
   g_autoptr (GFile) migrated_file = NULL;
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case.setup,
+                                               MONITOR_TEST_FLAG_NONE);
 
   migrated_path = g_build_filename (g_get_tmp_dir (),
                                     "test-finished-migrated-monitors.xml",
@@ -8128,15 +8274,16 @@ meta_test_monitor_migrated_wiggle (void)
   emulate_hotplug (test_setup);
 
   META_TEST_LOG_CALL ("Checking monitor configuration",
-                      check_monitor_configuration (&test_case.expect));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
   check_monitor_test_clients_state ();
 
   expected_path = g_test_get_filename (G_TEST_DIST,
                                        "tests", "migration",
                                        "wiggle-new-finished.xml",
                                        NULL);
-  expected_data = read_file (expected_path);
-  migrated_data = read_file (migrated_path);
+  expected_data = meta_read_file (expected_path);
+  migrated_data = meta_read_file (migrated_path);
 
   g_assert_nonnull (expected_data);
   g_assert_nonnull (migrated_data);
@@ -8422,12 +8569,14 @@ meta_test_monitor_supported_integer_scales (void)
   };
 
   MetaMonitorTestSetup *test_setup;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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 scaling values",
-                      check_monitor_scales (&test_case.expect,
-                                            META_MONITOR_SCALES_CONSTRAINT_NO_FRAC));
+                      meta_check_monitor_scales (test_context,
+                                                 &test_case.expect,
+                                                 META_MONITOR_SCALES_CONSTRAINT_NO_FRAC));
 }
 
 static void
@@ -8734,12 +8883,14 @@ meta_test_monitor_supported_fractional_scales (void)
   };
 
   MetaMonitorTestSetup *test_setup;
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  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 scaling values",
-                      check_monitor_scales (&test_case.expect,
-                                            META_MONITOR_SCALES_CONSTRAINT_NONE));
+                      meta_check_monitor_scales (test_context,
+                                                 &test_case.expect,
+                                                 META_MONITOR_SCALES_CONSTRAINT_NONE));
 }
 
 static void
@@ -8863,13 +9014,15 @@ meta_test_monitor_policy_system_only (void)
   MetaMonitorConfigStore *config_store =
     meta_monitor_config_manager_get_store (config_manager);
 
-  test_setup = create_monitor_test_setup (&test_case.setup,
-                                          MONITOR_TEST_FLAG_NONE);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &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));
+                      meta_check_monitor_configuration (test_context,
+                                                        &test_case.expect));
 }
 
 static void
@@ -8900,16 +9053,17 @@ add_monitor_test (const char *test_path,
 }
 
 static MetaMonitorTestSetup *
-create_initial_test_setup (void)
+create_initial_test_setup (MetaBackend *backend)
 {
-  return create_monitor_test_setup (&initial_test_case.setup,
-                                    MONITOR_TEST_FLAG_NO_STORED);
+  return meta_create_monitor_test_setup (backend,
+                                         &initial_test_case.setup,
+                                         MONITOR_TEST_FLAG_NO_STORED);
 }
 
 static void
 init_monitor_tests (void)
 {
-  meta_monitor_manager_test_init_test_setup (create_initial_test_setup);
+  meta_init_monitor_test_setup (create_initial_test_setup);
 
   add_monitor_test ("/backends/monitor/config-store/set_current-on-empty",
                     meta_test_monitor_config_store_set_current_on_empty);
@@ -9047,6 +9201,7 @@ init_monitor_tests (void)
 static void
 pre_run_monitor_tests (MetaContext *context)
 {
+  test_backend = meta_context_get_backend (context);
   create_monitor_test_clients (context);
 }
 
diff --git a/src/tests/native-pointer-constraints.c b/src/tests/native-pointer-constraints.c
index 027c51a046..656fefa6d8 100644
--- a/src/tests/native-pointer-constraints.c
+++ b/src/tests/native-pointer-constraints.c
@@ -66,8 +66,8 @@ meta_test_warp_on_hotplug (void)
   virtual_pointer = clutter_seat_create_virtual_device (seat,
                                                         CLUTTER_POINTER_DEVICE);
 
-  meta_set_custom_monitor_config (backend, "pointer-constraint.xml",
-                                  META_MONITORS_CONFIG_FLAG_NONE);
+  meta_set_custom_monitor_config_full (backend, "pointer-constraint.xml",
+                                       META_MONITORS_CONFIG_FLAG_NONE);
 
   monitor_info1 = meta_virtual_monitor_info_new (100, 100, 60.0,
                                                  "MetaTestVendor",
diff --git a/src/tests/orientation-manager-unit-tests.c b/src/tests/orientation-manager-unit-tests.c
index c7fc1d7cfb..518ee59878 100644
--- a/src/tests/orientation-manager-unit-tests.c
+++ b/src/tests/orientation-manager-unit-tests.c
@@ -22,8 +22,8 @@
 
 #include "orientation-manager-unit-tests.h"
 
+#include "tests/meta-monitor-test-utils.h"
 #include "tests/meta-sensors-proxy-mock.h"
-#include "tests/monitor-test-utils.h"
 
 static void
 meta_test_orientation_manager_no_daemon (void)
diff --git a/src/tests/stage-view-tests.c b/src/tests/stage-view-tests.c
index 008b8557ca..4ce1a70f9f 100644
--- a/src/tests/stage-view-tests.c
+++ b/src/tests/stage-view-tests.c
@@ -23,14 +23,15 @@
 #include "meta-test/meta-context-test.h"
 #include "meta/meta-window-actor.h"
 #include "tests/meta-backend-test.h"
+#include "tests/meta-monitor-test-utils.h"
 #include "tests/meta-test-utils.h"
-#include "tests/monitor-test-utils.h"
 #include "x11/meta-x11-display-private.h"
 
 #define X11_TEST_CLIENT_NAME "x11_test_client"
 #define X11_TEST_CLIENT_WINDOW "window1"
 
 static MetaContext *test_context;
+static MetaBackend *test_backend;
 
 static MonitorTestCaseSetup initial_test_case_setup = {
   .modes = {
@@ -480,10 +481,11 @@ meta_test_actor_stage_views_hide_parent (void)
 }
 
 static MetaMonitorTestSetup *
-create_stage_view_test_setup (void)
+create_stage_view_test_setup (MetaBackend *backend)
 {
-  return create_monitor_test_setup (&initial_test_case_setup,
-                                    MONITOR_TEST_FLAG_NO_STORED);
+  return meta_create_monitor_test_setup (backend,
+                                         &initial_test_case_setup,
+                                         MONITOR_TEST_FLAG_NO_STORED);
 }
 
 static void
@@ -546,8 +548,9 @@ meta_test_actor_stage_views_hot_plug (void)
   prev_stage_views = g_list_copy_deep (stage_views,
                                        (GCopyFunc) g_object_ref, NULL);
 
-  test_setup = create_monitor_test_setup (&hotplug_test_case_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &hotplug_test_case_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   stage_views = clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
@@ -596,8 +599,9 @@ meta_test_actor_stage_views_frame_clock (void)
   frame_clock_test_setup.n_modes = 2;
   frame_clock_test_setup.outputs[1].modes[0] = 1;
   frame_clock_test_setup.outputs[1].preferred_mode = 1;
-  test_setup = create_monitor_test_setup (&frame_clock_test_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &frame_clock_test_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   stage_views = clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
@@ -740,8 +744,9 @@ meta_test_actor_stage_views_timeline (void)
   frame_clock_test_setup.n_modes = 2;
   frame_clock_test_setup.outputs[1].modes[0] = 1;
   frame_clock_test_setup.outputs[1].preferred_mode = 1;
-  test_setup = create_monitor_test_setup (&frame_clock_test_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &frame_clock_test_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   stage_views = clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
@@ -819,8 +824,9 @@ meta_test_actor_stage_views_parent_views_rebuilt (void)
   frame_clock_test_setup = initial_test_case_setup;
   frame_clock_test_setup.n_outputs = 1;
   frame_clock_test_setup.n_crtcs = 1;
-  test_setup = create_monitor_test_setup (&frame_clock_test_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &frame_clock_test_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   stage_views = clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
@@ -856,8 +862,9 @@ meta_test_actor_stage_views_parent_views_rebuilt (void)
   old_frame_clock =
     g_object_ref (clutter_stage_view_get_frame_clock (old_stage_view));
 
-  test_setup = create_monitor_test_setup (&frame_clock_test_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &frame_clock_test_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
   wait_for_paint (stage);
 
@@ -900,8 +907,9 @@ meta_test_actor_stage_views_parent_views_changed (void)
   stage = meta_backend_get_stage (backend);
 
   frame_clock_test_setup = initial_test_case_setup;
-  test_setup = create_monitor_test_setup (&frame_clock_test_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &frame_clock_test_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   stage_views = clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
@@ -1043,8 +1051,9 @@ meta_test_actor_stage_views_and_frame_clocks_freed (void)
   frame_clock_test_setup = initial_test_case_setup;
   frame_clock_test_setup.n_outputs = 0;
   frame_clock_test_setup.n_crtcs = 0;
-  test_setup = create_monitor_test_setup (&frame_clock_test_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &frame_clock_test_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   timeline_frame_clock = clutter_timeline_get_frame_clock (timeline);
@@ -1075,8 +1084,9 @@ ensure_view_count (int n_views)
   test_case_setup = initial_test_case_setup;
   test_case_setup.n_outputs = n_views;
   test_case_setup.n_crtcs = n_views;
-  test_setup = create_monitor_test_setup (&test_case_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &test_case_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   stage_views = clutter_stage_peek_stage_views (CLUTTER_STAGE (stage));
@@ -1148,8 +1158,9 @@ meta_test_actor_stage_views_queue_frame_drawn (void)
   /* Make sure we have a single output. */
   hotplug_test_case_setup.n_outputs = 1;
   hotplug_test_case_setup.n_crtcs = 1;
-  test_setup = create_monitor_test_setup (&hotplug_test_case_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &hotplug_test_case_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
   wait_for_paint (stage);
   g_assert_cmpint (g_list_length (clutter_actor_peek_stage_views (stage)),
@@ -1171,8 +1182,9 @@ meta_test_actor_stage_views_queue_frame_drawn (void)
   meta_window_actor_queue_frame_drawn (META_WINDOW_ACTOR (window_actor), TRUE);
 
   /* Hotplug to rebuild the views, will clear the window actor view list. */
-  test_setup = create_monitor_test_setup (&hotplug_test_case_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &hotplug_test_case_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
   g_assert_null (clutter_actor_peek_stage_views (window_actor));
 
@@ -1183,8 +1195,9 @@ meta_test_actor_stage_views_queue_frame_drawn (void)
 
   /* Hotplug again to re-rebuild the views, will again clear the window actor
    * view list, which will be a no-op. */
-  test_setup = create_monitor_test_setup (&hotplug_test_case_setup,
-                                          MONITOR_TEST_FLAG_NO_STORED);
+  test_setup = meta_create_monitor_test_setup (test_backend,
+                                               &hotplug_test_case_setup,
+                                               MONITOR_TEST_FLAG_NO_STORED);
   meta_monitor_manager_test_emulate_hotplug (monitor_manager_test, test_setup);
 
   /* Make sure we're not using some old frame clock when queuing another
@@ -1306,10 +1319,16 @@ meta_test_timeline_actor_tree_clear (void)
   clutter_actor_destroy (container2);
 }
 
+static void
+on_before_tests (MetaContext *context)
+{
+  test_backend = meta_context_get_backend (context);
+}
+
 static void
 init_tests (void)
 {
-  meta_monitor_manager_test_init_test_setup (create_stage_view_test_setup);
+  meta_init_monitor_test_setup (create_stage_view_test_setup);
 
   g_test_add_func ("/stage-view/stage-views-exist",
                    meta_test_stage_views_exist);
@@ -1356,6 +1375,8 @@ main (int argc, char *argv[])
 
   init_tests ();
 
+  g_signal_connect (context, "before-tests",
+                    G_CALLBACK (on_before_tests), NULL);
   return meta_context_test_run_tests (META_CONTEXT_TEST (context),
                                       META_TEST_RUN_FLAG_NONE);
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]