diff --git a/src/tests/headless-start-test.c b/src/tests/headless-start-test.c index e0b8be0fc..fb64ca13f 100644 --- a/src/tests/headless-start-test.c +++ b/src/tests/headless-start-test.c @@ -170,7 +170,8 @@ main (int argc, char *argv[]) { g_autoptr (MetaContext) context = NULL; - context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED); + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED, + META_CONTEXT_TEST_FLAG_NO_X11); g_assert (meta_context_configure (context, &argc, &argv, NULL)); init_tests (); diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c index 0a490913a..e15ac3257 100644 --- a/src/tests/meta-context-test.c +++ b/src/tests/meta-context-test.c @@ -25,6 +25,7 @@ #include #include +#include "core/main-private.h" #include "tests/meta-backend-test.h" #include "tests/test-utils.h" #include "wayland/meta-wayland.h" @@ -49,6 +50,7 @@ struct _MetaContextTest GObject parent; MetaContextTestType type; + MetaContextTestFlag flags; }; G_DEFINE_TYPE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT) @@ -59,6 +61,7 @@ meta_context_test_configure (MetaContext *context, char ***argv, GError **error) { + MetaContextTest *context_test = META_CONTEXT_TEST (context); MetaContextClass *context_class = META_CONTEXT_CLASS (meta_context_test_parent_class); const char *plugin_name; @@ -69,7 +72,8 @@ meta_context_test_configure (MetaContext *context, g_test_init (argc, argv, NULL); g_test_bug_base ("https://gitlab.gnome.org/GNOME/mutter/issues/"); - meta_ensure_test_client_path (*argc, *argv); + if (context_test->flags & META_CONTEXT_TEST_FLAG_TEST_CLIENT) + meta_ensure_test_client_path (*argc, *argv); meta_wayland_override_display_name ("mutter-test-display"); meta_xwayland_override_display_number (512); @@ -224,7 +228,8 @@ meta_context_test_run_tests (MetaContextTest *context_test) } MetaContext * -meta_create_test_context (MetaContextTestType type) +meta_create_test_context (MetaContextTestType type, + MetaContextTestFlag flags) { MetaContextTest *context_test; @@ -232,6 +237,12 @@ meta_create_test_context (MetaContextTestType type) "name", "Mutter Test", NULL); context_test->type = type; + context_test->flags = flags; + + /* NOTE: This will be removed in a follow up commit, but is needed + * until the override method is replaced. */ + if (flags & META_CONTEXT_TEST_FLAG_NO_X11) + meta_override_x11_display_policy (META_X11_DISPLAY_POLICY_DISABLED); return META_CONTEXT (context_test); } diff --git a/src/tests/meta-context-test.h b/src/tests/meta-context-test.h index b7931b075..187ea85dc 100644 --- a/src/tests/meta-context-test.h +++ b/src/tests/meta-context-test.h @@ -31,12 +31,21 @@ typedef enum _MetaContextTestType META_CONTEXT_TEST_TYPE_NESTED, } MetaContextTestType; +typedef enum _MetaContextTestFlag +{ + META_CONTEXT_TEST_FLAG_NONE = 0, + META_CONTEXT_TEST_FLAG_TEST_CLIENT = 1 << 0, + META_CONTEXT_TEST_FLAG_NO_X11 = 1 << 1, +} MetaContextTestFlag; + #define META_TYPE_CONTEXT_TEST (meta_context_test_get_type ()) G_DECLARE_FINAL_TYPE (MetaContextTest, meta_context_test, META, CONTEXT_TEST, MetaContext) -MetaContext * meta_create_test_context (MetaContextTestType type); +MetaContext * meta_create_test_context (MetaContextTestType type, + MetaContextTestFlag flags); + int meta_context_test_run_tests (MetaContextTest *context_test); diff --git a/src/tests/native-headless.c b/src/tests/native-headless.c index 47689b863..06d456574 100644 --- a/src/tests/native-headless.c +++ b/src/tests/native-headless.c @@ -37,7 +37,8 @@ main (int argc, { g_autoptr (MetaContext) context = NULL; - context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS); + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS, + META_CONTEXT_TEST_FLAG_NO_X11); g_assert (meta_context_configure (context, &argc, &argv, NULL)); init_tests (); diff --git a/src/tests/ref-test-sanity.c b/src/tests/ref-test-sanity.c index af7b0185a..5815e36ce 100644 --- a/src/tests/ref-test-sanity.c +++ b/src/tests/ref-test-sanity.c @@ -133,7 +133,8 @@ main (int argc, { g_autoptr (MetaContext) context = NULL; - context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS); + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_HEADLESS, + META_CONTEXT_TEST_FLAG_NO_X11); g_assert (meta_context_configure (context, &argc, &argv, NULL)); init_ref_test_sanity_tests (); diff --git a/src/tests/stage-view-tests.c b/src/tests/stage-view-tests.c index 4e839e76e..c16d1b2ab 100644 --- a/src/tests/stage-view-tests.c +++ b/src/tests/stage-view-tests.c @@ -1161,7 +1161,8 @@ main (int argc, char *argv[]) { g_autoptr (MetaContext) context = NULL; - context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED); + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED, + META_CONTEXT_TEST_FLAG_NO_X11); g_assert (meta_context_configure (context, &argc, &argv, NULL)); init_tests (); diff --git a/src/tests/test-runner.c b/src/tests/test-runner.c index aa83dd557..4112966d4 100644 --- a/src/tests/test-runner.c +++ b/src/tests/test-runner.c @@ -1124,7 +1124,8 @@ main (int argc, char **argv) GPtrArray *tests; RunTestsInfo info; - context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED); + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED, + META_CONTEXT_TEST_FLAG_TEST_CLIENT); meta_context_add_option_entries (context, options, NULL); diff --git a/src/tests/unit-tests.c b/src/tests/unit-tests.c index c7c9943e6..0ef5aff02 100644 --- a/src/tests/unit-tests.c +++ b/src/tests/unit-tests.c @@ -235,7 +235,8 @@ main (int argc, char *argv[]) { g_autoptr (MetaContext) context = NULL; - context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED); + context = meta_create_test_context (META_CONTEXT_TEST_TYPE_NESTED, + META_CONTEXT_TEST_FLAG_TEST_CLIENT); g_assert (meta_context_configure (context, &argc, &argv, NULL)); init_tests ();