2021-03-02 03:43:02 -05:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2021 Red Hat Inc.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation; either version 2 of the
|
|
|
|
* License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
|
|
|
|
* 02111-1307, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include "tests/meta-context-test.h"
|
|
|
|
|
2021-03-02 04:49:43 -05:00
|
|
|
#include <glib.h>
|
|
|
|
#include <gio/gio.h>
|
|
|
|
|
|
|
|
#include "tests/meta-backend-test.h"
|
2021-03-02 04:44:02 -05:00
|
|
|
#include "tests/test-utils.h"
|
|
|
|
#include "wayland/meta-wayland.h"
|
|
|
|
#include "wayland/meta-xwayland.h"
|
|
|
|
|
2021-03-02 04:49:43 -05:00
|
|
|
#ifdef HAVE_NATIVE_BACKEND
|
|
|
|
#include "backends/native/meta-backend-native.h"
|
|
|
|
#endif
|
|
|
|
|
2021-03-02 03:43:02 -05:00
|
|
|
struct _MetaContextTest
|
|
|
|
{
|
|
|
|
GObject parent;
|
2021-03-02 04:46:43 -05:00
|
|
|
|
|
|
|
MetaContextTestType type;
|
2021-03-02 03:43:02 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT)
|
|
|
|
|
2021-03-02 04:35:38 -05:00
|
|
|
static gboolean
|
|
|
|
meta_context_test_configure (MetaContext *context,
|
|
|
|
int *argc,
|
|
|
|
char ***argv,
|
|
|
|
GError **error)
|
|
|
|
{
|
2021-03-02 05:48:22 -05:00
|
|
|
const char *plugin_name;
|
|
|
|
|
2021-03-02 04:44:02 -05:00
|
|
|
g_test_init (argc, argv, NULL);
|
|
|
|
g_test_bug_base ("https://gitlab.gnome.org/GNOME/mutter/issues/");
|
|
|
|
|
|
|
|
meta_ensure_test_client_path (*argc, *argv);
|
|
|
|
|
|
|
|
meta_wayland_override_display_name ("mutter-test-display");
|
|
|
|
meta_xwayland_override_display_number (512);
|
|
|
|
|
2021-03-02 05:48:22 -05:00
|
|
|
plugin_name = g_getenv ("MUTTER_TEST_PLUGIN_PATH");
|
|
|
|
if (!plugin_name)
|
|
|
|
plugin_name = "libdefault";
|
|
|
|
meta_context_set_plugin_name (context, plugin_name);
|
|
|
|
|
2021-03-02 04:35:38 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static MetaCompositorType
|
|
|
|
meta_context_test_get_compositor_type (MetaContext *context)
|
|
|
|
{
|
|
|
|
return META_COMPOSITOR_TYPE_WAYLAND;
|
|
|
|
}
|
|
|
|
|
2021-03-02 05:41:34 -05:00
|
|
|
static gboolean
|
|
|
|
meta_context_test_setup (MetaContext *context,
|
|
|
|
GError **error)
|
|
|
|
{
|
2021-03-02 06:02:51 -05:00
|
|
|
MetaBackend *backend;
|
|
|
|
MetaSettings *settings;
|
|
|
|
|
2021-03-02 05:41:34 -05:00
|
|
|
if (!META_CONTEXT_CLASS (meta_context_test_parent_class)->setup (context,
|
|
|
|
error))
|
|
|
|
return FALSE;
|
|
|
|
|
2021-03-02 06:02:51 -05:00
|
|
|
backend = meta_get_backend ();
|
|
|
|
settings = meta_backend_get_settings (backend);
|
|
|
|
meta_settings_override_experimental_features (settings);
|
|
|
|
meta_settings_enable_experimental_feature (
|
|
|
|
settings,
|
|
|
|
META_EXPERIMENTAL_FEATURE_SCALE_MONITOR_FRAMEBUFFER);
|
|
|
|
|
2021-03-02 06:04:03 -05:00
|
|
|
meta_set_syncing (!!g_getenv ("MUTTER_SYNC"));
|
|
|
|
|
2021-03-02 05:41:34 -05:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2021-03-02 04:49:43 -05:00
|
|
|
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 ();
|
|
|
|
}
|
|
|
|
|
2021-03-02 03:43:02 -05:00
|
|
|
MetaContext *
|
2021-03-02 04:46:43 -05:00
|
|
|
meta_create_test_context (MetaContextTestType type)
|
2021-03-02 03:43:02 -05:00
|
|
|
{
|
|
|
|
MetaContextTest *context_test;
|
|
|
|
|
|
|
|
context_test = g_object_new (META_TYPE_CONTEXT_TEST,
|
|
|
|
"name", "Mutter Test",
|
|
|
|
NULL);
|
2021-03-02 04:46:43 -05:00
|
|
|
context_test->type = type;
|
2021-03-02 03:43:02 -05:00
|
|
|
|
|
|
|
return META_CONTEXT (context_test);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_context_test_class_init (MetaContextTestClass *klass)
|
|
|
|
{
|
2021-03-02 04:35:38 -05:00
|
|
|
MetaContextClass *context_class = META_CONTEXT_CLASS (klass);
|
|
|
|
|
|
|
|
context_class->configure = meta_context_test_configure;
|
|
|
|
context_class->get_compositor_type = meta_context_test_get_compositor_type;
|
2021-03-02 05:41:34 -05:00
|
|
|
context_class->setup = meta_context_test_setup;
|
2021-03-02 04:49:43 -05:00
|
|
|
context_class->create_backend = meta_context_test_create_backend;
|
2021-03-02 03:43:02 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
meta_context_test_init (MetaContextTest *context_test)
|
|
|
|
{
|
|
|
|
}
|