tests: Introduce MetaContextTest

This introduces a MetaContext implementation aimed to be used for test
cases, with as little boiler plate as possible needed in the test.

It currently doesn't do anything, just fills out the GObject boiler
plate and sets a name.

Build it into every core test, for compilation, even though it isn't
used anywhere yet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1861>
This commit is contained in:
Jonas Ådahl 2021-03-02 09:43:02 +01:00
parent e020fdfddf
commit e17bf88d5e
3 changed files with 96 additions and 0 deletions

View File

@ -42,6 +42,11 @@ test_env.set('G_TEST_SRCDIR', join_paths(meson.source_root(), 'src'))
test_env.set('G_TEST_BUILDDIR', meson.build_root()) test_env.set('G_TEST_BUILDDIR', meson.build_root())
test_env.set('MUTTER_TEST_PLUGIN_PATH', '@0@'.format(default_plugin.full_path())) test_env.set('MUTTER_TEST_PLUGIN_PATH', '@0@'.format(default_plugin.full_path()))
test_context_sources = [
'meta-context-test.c',
'meta-context-test.h',
]
test_client = executable('mutter-test-client', test_client = executable('mutter-test-client',
sources: ['test-client.c'], sources: ['test-client.c'],
include_directories: tests_includepath, include_directories: tests_includepath,
@ -71,6 +76,7 @@ test_runner = executable('mutter-test-runner',
unit_tests = executable('mutter-test-unit-tests', unit_tests = executable('mutter-test-unit-tests',
sources: [ sources: [
test_context_sources,
'test-utils.c', 'test-utils.c',
'test-utils.h', 'test-utils.h',
'unit-tests.c', 'unit-tests.c',
@ -108,6 +114,7 @@ unit_tests = executable('mutter-test-unit-tests',
headless_start_test = executable('mutter-headless-start-test', headless_start_test = executable('mutter-headless-start-test',
sources: [ sources: [
test_context_sources,
'headless-start-test.c', 'headless-start-test.c',
'meta-backend-test.c', 'meta-backend-test.c',
'meta-backend-test.h', 'meta-backend-test.h',
@ -127,6 +134,7 @@ headless_start_test = executable('mutter-headless-start-test',
stage_view_tests = executable('mutter-stage-view-tests', stage_view_tests = executable('mutter-stage-view-tests',
sources: [ sources: [
test_context_sources,
'meta-backend-test.c', 'meta-backend-test.c',
'meta-backend-test.h', 'meta-backend-test.h',
'meta-gpu-test.c', 'meta-gpu-test.c',
@ -176,6 +184,7 @@ if have_native_tests
native_headless_tests = executable('mutter-native-headless-tests', native_headless_tests = executable('mutter-native-headless-tests',
sources: [ sources: [
test_context_sources,
'native-headless.c', 'native-headless.c',
'native-screen-cast.c', 'native-screen-cast.c',
'native-screen-cast.h', 'native-screen-cast.h',
@ -194,6 +203,7 @@ if have_native_tests
ref_test_sanity = executable('mutter-ref-test-sanity', ref_test_sanity = executable('mutter-ref-test-sanity',
sources: [ sources: [
test_context_sources,
'ref-test-sanity.c', 'ref-test-sanity.c',
'test-utils.c', 'test-utils.c',
'test-utils.h', 'test-utils.h',
@ -224,6 +234,7 @@ if have_native_tests
native_persistent_virtual_monitor = executable( native_persistent_virtual_monitor = executable(
'mutter-persistent-virtual-monitor', 'mutter-persistent-virtual-monitor',
sources: [ sources: [
test_context_sources,
'native-persistent-virtual-monitor.c', 'native-persistent-virtual-monitor.c',
'test-utils.c', 'test-utils.c',
'test-utils.h', 'test-utils.h',

View File

@ -0,0 +1,52 @@
/*
* 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"
struct _MetaContextTest
{
GObject parent;
};
G_DEFINE_TYPE (MetaContextTest, meta_context_test, META_TYPE_CONTEXT)
MetaContext *
meta_create_test_context (void)
{
MetaContextTest *context_test;
context_test = g_object_new (META_TYPE_CONTEXT_TEST,
"name", "Mutter Test",
NULL);
return META_CONTEXT (context_test);
}
static void
meta_context_test_class_init (MetaContextTestClass *klass)
{
}
static void
meta_context_test_init (MetaContextTest *context_test)
{
}

View File

@ -0,0 +1,33 @@
/*
* 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.
*
*/
#ifndef META_CONTEXT_TEST_H
#define META_CONTEXT_TEST_H
#include "core/meta-context-private.h"
#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 (void);
#endif /* META_CONTEXT_TEST_H */