tests: Split out monitor configuration tests to its own test case

This makes it easier to run without having to run all the other tests,
and it will allow us to be more particular with its setup.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2030>
This commit is contained in:
Jonas Ådahl 2021-09-30 14:47:51 +02:00 committed by Marge Bot
parent 67425bf653
commit d8a66a3892
5 changed files with 51 additions and 51 deletions

View File

@ -143,9 +143,20 @@ unit_tests = executable('mutter-test-unit-tests',
'monitor-test-utils.h', 'monitor-test-utils.h',
'monitor-transform-tests.c', 'monitor-transform-tests.c',
'monitor-transform-tests.h', 'monitor-transform-tests.h',
'monitor-unit-tests.c',
'orientation-manager-unit-tests.c', 'orientation-manager-unit-tests.c',
'monitor-unit-tests.h', ],
include_directories: tests_includes,
c_args: tests_c_args,
dependencies: libmutter_test_dep,
install: have_installed_tests,
install_dir: mutter_installed_tests_libexecdir,
)
monitor_unit_tests = executable('mutter-monitor-unit-tests',
sources: [
'monitor-test-utils.c',
'monitor-test-utils.h',
'monitor-unit-tests.c',
], ],
include_directories: tests_includes, include_directories: tests_includes,
c_args: tests_c_args, c_args: tests_c_args,
@ -374,6 +385,13 @@ test('normal', unit_tests,
timeout: 60, timeout: 60,
) )
test('monitors', monitor_unit_tests,
suite: ['core', 'mutter/unit'],
env: test_env,
is_parallel: false,
timeout: 60,
)
test('headless-start', headless_start_test, test('headless-start', headless_start_test,
suite: ['core', 'mutter/unit'], suite: ['core', 'mutter/unit'],
env: test_env, env: test_env,

View File

@ -191,11 +191,11 @@ typedef struct _MonitorTestCaseExpect
int screen_height; int screen_height;
} MonitorTestCaseExpect; } MonitorTestCaseExpect;
struct _MonitorTestCase typedef struct _MonitorTestCase
{ {
MonitorTestCaseSetup setup; MonitorTestCaseSetup setup;
MonitorTestCaseExpect expect; MonitorTestCaseExpect expect;
}; } MonitorTestCase;
MetaGpu * test_get_gpu (void); MetaGpu * test_get_gpu (void);

View File

@ -19,8 +19,6 @@
#include "config.h" #include "config.h"
#include "tests/monitor-unit-tests.h"
#include "backends/meta-backend-private.h" #include "backends/meta-backend-private.h"
#include "backends/meta-crtc.h" #include "backends/meta-crtc.h"
#include "backends/meta-logical-monitor.h" #include "backends/meta-logical-monitor.h"
@ -31,13 +29,15 @@
#include "backends/meta-output.h" #include "backends/meta-output.h"
#include "core/window-private.h" #include "core/window-private.h"
#include "meta-backend-test.h" #include "meta-backend-test.h"
#include "meta-test/meta-context-test.h"
#include "tests/meta-monitor-manager-test.h" #include "tests/meta-monitor-manager-test.h"
#include "tests/meta-sensors-proxy-mock.h" #include "tests/meta-sensors-proxy-mock.h"
#include "tests/monitor-test-utils.h" #include "tests/monitor-test-utils.h"
#include "tests/meta-test-utils.h" #include "tests/meta-test-utils.h"
#include "tests/unit-tests.h"
#include "x11/meta-x11-display-private.h" #include "x11/meta-x11-display-private.h"
static MetaContext *test_context;
static MonitorTestCase initial_test_case = { static MonitorTestCase initial_test_case = {
.setup = { .setup = {
.modes = { .modes = {
@ -8776,7 +8776,7 @@ create_initial_test_setup (void)
MONITOR_TEST_FLAG_NO_STORED); MONITOR_TEST_FLAG_NO_STORED);
} }
void static void
init_monitor_tests (void) init_monitor_tests (void)
{ {
meta_monitor_manager_test_init_test_setup (create_initial_test_setup); meta_monitor_manager_test_init_test_setup (create_initial_test_setup);
@ -8911,14 +8911,37 @@ init_monitor_tests (void)
meta_test_monitor_supported_fractional_scales); meta_test_monitor_supported_fractional_scales);
} }
void static void
pre_run_monitor_tests (MetaContext *context) pre_run_monitor_tests (MetaContext *context)
{ {
create_monitor_test_clients (context); create_monitor_test_clients (context);
} }
void static void
finish_monitor_tests (void) finish_monitor_tests (void)
{ {
destroy_monitor_test_clients (); destroy_monitor_test_clients ();
} }
int
main (int argc,
char *argv[])
{
g_autoptr (MetaContext) context = NULL;
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));
test_context = context;
init_monitor_tests ();
g_signal_connect (context, "before-tests",
G_CALLBACK (pre_run_monitor_tests), NULL);
g_signal_connect (context, "after-tests",
G_CALLBACK (finish_monitor_tests), NULL);
return meta_context_test_run_tests (META_CONTEXT_TEST (context),
META_TEST_RUN_FLAG_NONE);
}

View File

@ -1,34 +0,0 @@
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
/*
* Copyright (C) 2016 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, see <http://www.gnu.org/licenses/>.
*/
#ifndef MONITOR_UNIT_TESTS_H
#define MONITOR_UNIT_TESTS_H
#include "core/util-private.h"
#include "tests/monitor-test-utils.h"
typedef struct _MonitorTestCase MonitorTestCase;
void init_monitor_tests (void);
void pre_run_monitor_tests (MetaContext *context);
void finish_monitor_tests (void);
#endif /* MONITOR_UNIT_TESTS_H */

View File

@ -32,7 +32,6 @@
#include "meta/meta-context.h" #include "meta/meta-context.h"
#include "tests/boxes-tests.h" #include "tests/boxes-tests.h"
#include "tests/monitor-config-migration-unit-tests.h" #include "tests/monitor-config-migration-unit-tests.h"
#include "tests/monitor-unit-tests.h"
#include "tests/monitor-store-unit-tests.h" #include "tests/monitor-store-unit-tests.h"
#include "tests/monitor-transform-tests.h" #include "tests/monitor-transform-tests.h"
#include "tests/meta-test-utils.h" #include "tests/meta-test-utils.h"
@ -229,7 +228,6 @@ init_tests (void)
init_monitor_store_tests (); init_monitor_store_tests ();
init_monitor_config_migration_tests (); init_monitor_config_migration_tests ();
init_monitor_tests ();
init_boxes_tests (); init_boxes_tests ();
init_monitor_transform_tests (); init_monitor_transform_tests ();
init_orientation_manager_tests (); init_orientation_manager_tests ();
@ -250,11 +248,6 @@ main (int argc, char *argv[])
init_tests (); init_tests ();
g_signal_connect (context, "before-tests",
G_CALLBACK (pre_run_monitor_tests), NULL);
g_signal_connect (context, "after-tests",
G_CALLBACK (finish_monitor_tests), NULL);
return meta_context_test_run_tests (META_CONTEXT_TEST (context), return meta_context_test_run_tests (META_CONTEXT_TEST (context),
META_TEST_RUN_FLAG_NONE); META_TEST_RUN_FLAG_NONE);
} }