diff --git a/src/core/meta-context-private.h b/src/core/meta-context-private.h index 76f0675e1..3046476f9 100644 --- a/src/core/meta-context-private.h +++ b/src/core/meta-context-private.h @@ -21,6 +21,7 @@ #ifndef META_CONTEXT_PRIVATE_H #define META_CONTEXT_PRIVATE_H +#include "meta/meta-backend.h" #include "meta/meta-context.h" #include "meta/meta-enums.h" @@ -34,6 +35,9 @@ struct _MetaContextClass GError **error); MetaCompositorType (* get_compositor_type) (MetaContext *context); + + MetaBackend * (* create_backend) (MetaContext *context, + GError **error); }; #endif /* META_CONTEXT_PRIVATE_H */ diff --git a/src/tests/meson.build b/src/tests/meson.build index bf9d63190..a7c05fb71 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -43,8 +43,16 @@ test_env.set('G_TEST_BUILDDIR', meson.build_root()) test_env.set('MUTTER_TEST_PLUGIN_PATH', '@0@'.format(default_plugin.full_path())) test_context_sources = [ + 'meta-backend-test.c', + 'meta-backend-test.h', 'meta-context-test.c', 'meta-context-test.h', + 'meta-gpu-test.c', + 'meta-gpu-test.h', + 'meta-monitor-manager-test.c', + 'meta-monitor-manager-test.h', + 'monitor-test-utils.c', + 'monitor-test-utils.h', 'test-utils.c', 'test-utils.h', ] @@ -82,12 +90,6 @@ unit_tests = executable('mutter-test-unit-tests', 'unit-tests.c', 'boxes-tests.c', 'boxes-tests.h', - 'meta-backend-test.c', - 'meta-backend-test.h', - 'meta-gpu-test.c', - 'meta-gpu-test.h', - 'meta-monitor-manager-test.c', - 'meta-monitor-manager-test.h', 'meta-wayland-test-driver.c', 'meta-wayland-test-driver.h', 'monitor-config-migration-unit-tests.c', @@ -116,12 +118,6 @@ headless_start_test = executable('mutter-headless-start-test', sources: [ test_context_sources, 'headless-start-test.c', - 'meta-backend-test.c', - 'meta-backend-test.h', - 'meta-gpu-test.c', - 'meta-gpu-test.h', - 'meta-monitor-manager-test.c', - 'meta-monitor-manager-test.h', ], include_directories: tests_includepath, c_args: tests_c_args, @@ -133,12 +129,6 @@ headless_start_test = executable('mutter-headless-start-test', stage_view_tests = executable('mutter-stage-view-tests', sources: [ test_context_sources, - 'meta-backend-test.c', - 'meta-backend-test.h', - 'meta-gpu-test.c', - 'meta-gpu-test.h', - 'meta-monitor-manager-test.c', - 'meta-monitor-manager-test.h', 'monitor-test-utils.c', 'monitor-test-utils.h', 'stage-view-tests.c', diff --git a/src/tests/meta-context-test.c b/src/tests/meta-context-test.c index 936808f53..01376b61e 100644 --- a/src/tests/meta-context-test.c +++ b/src/tests/meta-context-test.c @@ -22,10 +22,18 @@ #include "tests/meta-context-test.h" +#include +#include + +#include "tests/meta-backend-test.h" #include "tests/test-utils.h" #include "wayland/meta-wayland.h" #include "wayland/meta-xwayland.h" +#ifdef HAVE_NATIVE_BACKEND +#include "backends/native/meta-backend-native.h" +#endif + struct _MetaContextTest { GObject parent; @@ -58,6 +66,46 @@ meta_context_test_get_compositor_type (MetaContext *context) return META_COMPOSITOR_TYPE_WAYLAND; } +static MetaBackend * +create_nested_backend (MetaContext *context, + GError **error) +{ + return g_initable_new (META_TYPE_BACKEND_TEST, + NULL, error, + NULL); +} + +#ifdef HAVE_NATIVE_BACKEND +static MetaBackend * +create_headless_backend (MetaContext *context, + GError **error) +{ + return g_initable_new (META_TYPE_BACKEND_NATIVE, + NULL, error, + "headless", TRUE, + NULL); +} +#endif /* HAVE_NATIVE_BACKEND */ + +static MetaBackend * +meta_context_test_create_backend (MetaContext *context, + GError **error) +{ + MetaContextTest *context_test = META_CONTEXT_TEST (context); + + switch (context_test->type) + { + case META_CONTEXT_TEST_TYPE_NESTED: + return create_nested_backend (context, error); +#ifdef HAVE_NATIVE_BACKEND + case META_CONTEXT_TEST_TYPE_HEADLESS: + return create_headless_backend (context, error); +#endif /* HAVE_NATIVE_BACKEND */ + } + + g_assert_not_reached (); +} + MetaContext * meta_create_test_context (MetaContextTestType type) { @@ -78,6 +126,7 @@ meta_context_test_class_init (MetaContextTestClass *klass) context_class->configure = meta_context_test_configure; context_class->get_compositor_type = meta_context_test_get_compositor_type; + context_class->create_backend = meta_context_test_create_backend; } static void