[mutter] context/test: Add 'no-x11' and 'test-client' constructor flags
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter] context/test: Add 'no-x11' and 'test-client' constructor flags
- Date: Thu, 15 Jul 2021 12:40:54 +0000 (UTC)
commit 2f19a5f28d217091d6df0e860e7c57a07d773e75
Author: Jonas Ã…dahl <jadahl gmail com>
Date: Wed Mar 3 10:42:26 2021 +0100
context/test: Add 'no-x11' and 'test-client' constructor flags
The 'no-x11' one will inhibit Xwayland from starting, and 'test-client'
will make sure the test client path is properly discovered.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
src/tests/headless-start-test.c | 3 ++-
src/tests/meta-context-test.c | 15 +++++++++++++--
src/tests/meta-context-test.h | 11 ++++++++++-
src/tests/native-headless.c | 3 ++-
src/tests/ref-test-sanity.c | 3 ++-
src/tests/stage-view-tests.c | 3 ++-
src/tests/test-runner.c | 3 ++-
src/tests/unit-tests.c | 3 ++-
8 files changed, 35 insertions(+), 9 deletions(-)
---
diff --git a/src/tests/headless-start-test.c b/src/tests/headless-start-test.c
index e0b8be0fc3..fb64ca13fc 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 0a490913a3..e15ac3257c 100644
--- a/src/tests/meta-context-test.c
+++ b/src/tests/meta-context-test.c
@@ -25,6 +25,7 @@
#include <glib.h>
#include <gio/gio.h>
+#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 b7931b075b..187ea85dcc 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 47689b8631..06d456574d 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 af7b0185a1..5815e36cec 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 4e839e76e1..c16d1b2ab5 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 aa83dd5570..4112966d4b 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 c7c9943e69..0ef5aff020 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 ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]