mirror of
https://github.com/brl/mutter.git
synced 2025-02-16 13:24:09 +00:00
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>
This commit is contained in:
parent
07384e18c5
commit
2f19a5f28d
@ -170,7 +170,8 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
g_autoptr (MetaContext) context = NULL;
|
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));
|
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
||||||
|
|
||||||
init_tests ();
|
init_tests ();
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
#include <gio/gio.h>
|
#include <gio/gio.h>
|
||||||
|
|
||||||
|
#include "core/main-private.h"
|
||||||
#include "tests/meta-backend-test.h"
|
#include "tests/meta-backend-test.h"
|
||||||
#include "tests/test-utils.h"
|
#include "tests/test-utils.h"
|
||||||
#include "wayland/meta-wayland.h"
|
#include "wayland/meta-wayland.h"
|
||||||
@ -49,6 +50,7 @@ struct _MetaContextTest
|
|||||||
GObject parent;
|
GObject parent;
|
||||||
|
|
||||||
MetaContextTestType type;
|
MetaContextTestType type;
|
||||||
|
MetaContextTestFlag flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT)
|
G_DEFINE_TYPE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT)
|
||||||
@ -59,6 +61,7 @@ meta_context_test_configure (MetaContext *context,
|
|||||||
char ***argv,
|
char ***argv,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
|
MetaContextTest *context_test = META_CONTEXT_TEST (context);
|
||||||
MetaContextClass *context_class =
|
MetaContextClass *context_class =
|
||||||
META_CONTEXT_CLASS (meta_context_test_parent_class);
|
META_CONTEXT_CLASS (meta_context_test_parent_class);
|
||||||
const char *plugin_name;
|
const char *plugin_name;
|
||||||
@ -69,7 +72,8 @@ meta_context_test_configure (MetaContext *context,
|
|||||||
g_test_init (argc, argv, NULL);
|
g_test_init (argc, argv, NULL);
|
||||||
g_test_bug_base ("https://gitlab.gnome.org/GNOME/mutter/issues/");
|
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_wayland_override_display_name ("mutter-test-display");
|
||||||
meta_xwayland_override_display_number (512);
|
meta_xwayland_override_display_number (512);
|
||||||
@ -224,7 +228,8 @@ meta_context_test_run_tests (MetaContextTest *context_test)
|
|||||||
}
|
}
|
||||||
|
|
||||||
MetaContext *
|
MetaContext *
|
||||||
meta_create_test_context (MetaContextTestType type)
|
meta_create_test_context (MetaContextTestType type,
|
||||||
|
MetaContextTestFlag flags)
|
||||||
{
|
{
|
||||||
MetaContextTest *context_test;
|
MetaContextTest *context_test;
|
||||||
|
|
||||||
@ -232,6 +237,12 @@ meta_create_test_context (MetaContextTestType type)
|
|||||||
"name", "Mutter Test",
|
"name", "Mutter Test",
|
||||||
NULL);
|
NULL);
|
||||||
context_test->type = type;
|
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);
|
return META_CONTEXT (context_test);
|
||||||
}
|
}
|
||||||
|
@ -31,12 +31,21 @@ typedef enum _MetaContextTestType
|
|||||||
META_CONTEXT_TEST_TYPE_NESTED,
|
META_CONTEXT_TEST_TYPE_NESTED,
|
||||||
} MetaContextTestType;
|
} 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 ())
|
#define META_TYPE_CONTEXT_TEST (meta_context_test_get_type ())
|
||||||
G_DECLARE_FINAL_TYPE (MetaContextTest, meta_context_test,
|
G_DECLARE_FINAL_TYPE (MetaContextTest, meta_context_test,
|
||||||
META, CONTEXT_TEST,
|
META, CONTEXT_TEST,
|
||||||
MetaContext)
|
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);
|
int meta_context_test_run_tests (MetaContextTest *context_test);
|
||||||
|
|
||||||
|
@ -37,7 +37,8 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
g_autoptr (MetaContext) context = NULL;
|
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));
|
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
||||||
|
|
||||||
init_tests ();
|
init_tests ();
|
||||||
|
@ -133,7 +133,8 @@ main (int argc,
|
|||||||
{
|
{
|
||||||
g_autoptr (MetaContext) context = NULL;
|
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));
|
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
||||||
|
|
||||||
init_ref_test_sanity_tests ();
|
init_ref_test_sanity_tests ();
|
||||||
|
@ -1161,7 +1161,8 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
g_autoptr (MetaContext) context = NULL;
|
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));
|
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
||||||
|
|
||||||
init_tests ();
|
init_tests ();
|
||||||
|
@ -1124,7 +1124,8 @@ main (int argc, char **argv)
|
|||||||
GPtrArray *tests;
|
GPtrArray *tests;
|
||||||
RunTestsInfo info;
|
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);
|
meta_context_add_option_entries (context, options, NULL);
|
||||||
|
|
||||||
|
@ -235,7 +235,8 @@ main (int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
g_autoptr (MetaContext) context = NULL;
|
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));
|
g_assert (meta_context_configure (context, &argc, &argv, NULL));
|
||||||
|
|
||||||
init_tests ();
|
init_tests ();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user