From d9b6101b15992267e54b638190895c505b4ea2a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Wed, 21 Aug 2024 22:49:13 +0200 Subject: [PATCH] tests: Split up 'native-unit' test It had three different parts that deserve their own actual test cases * virtual monitors * screen casting * bezier Part-of: --- src/tests/meson.build | 21 +++++++---- src/tests/native-bezier-tests.c | 22 +++++++++--- src/tests/native-bezier-tests.h | 21 ----------- src/tests/native-headless.c | 48 -------------------------- src/tests/native-kms-cursor-hotplug.c | 2 -- src/tests/native-pointer-constraints.c | 2 -- src/tests/native-screen-cast.c | 23 +++++++++--- src/tests/native-screen-cast.h | 21 ----------- src/tests/native-virtual-monitor.c | 23 +++++++++--- src/tests/native-virtual-monitor.h | 23 ------------ 10 files changed, 71 insertions(+), 135 deletions(-) delete mode 100644 src/tests/native-bezier-tests.h delete mode 100644 src/tests/native-headless.c delete mode 100644 src/tests/native-screen-cast.h delete mode 100644 src/tests/native-virtual-monitor.h diff --git a/src/tests/meson.build b/src/tests/meson.build index f1cb3b836..3569713fc 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -353,21 +353,30 @@ test_cases += [ 'sources': [ 'kms-utils-unit-tests.c', ], }, { - 'name': 'native-unit', + 'name': 'native-virtual-monitor', 'suite': 'backends/native', 'sources': [ - 'native-headless.c', - 'native-screen-cast.c', - 'native-screen-cast.h', 'native-virtual-monitor.c', - 'native-virtual-monitor.h', - 'native-bezier-tests.c', + ], + }, + { + 'name': 'native-screen-cast', + 'suite': 'backends/native', + 'sources': [ + 'native-screen-cast.c', ], 'depends': [ screen_cast_client, ], 'launch': [ 'pipewire', 'wireplumber' ], }, + { + 'name': 'bezier', + 'suite': 'backends/native', + 'sources': [ + 'native-bezier-tests.c', + ], + }, { 'name': 'pointer-constraints', 'suite': 'backends/native', diff --git a/src/tests/native-bezier-tests.c b/src/tests/native-bezier-tests.c index 06eae1cd2..ccf0425a7 100644 --- a/src/tests/native-bezier-tests.c +++ b/src/tests/native-bezier-tests.c @@ -18,9 +18,8 @@ #include "config.h" -#include "native-bezier-tests.h" - #include "backends/native/meta-bezier.h" +#include "tests/meta-test/meta-context-test.h" static void meta_test_bezier_linear (void) @@ -116,8 +115,8 @@ meta_test_bezier_snake (void) } } -void -init_bezier_tests (void) +static void +init_tests (void) { g_test_add_func ("/backends/bezier/linear", meta_test_bezier_linear); g_test_add_func ("/backends/bezier/steep", meta_test_bezier_steep); @@ -125,3 +124,18 @@ init_bezier_tests (void) g_test_add_func ("/backends/bezier/snake", meta_test_bezier_snake); } +int +main (int argc, + char **argv) +{ + g_autoptr (MetaContext) context = NULL; + + 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)); + + init_tests (); + + return meta_context_test_run_tests (META_CONTEXT_TEST (context), + META_TEST_RUN_FLAG_NONE); +} diff --git a/src/tests/native-bezier-tests.h b/src/tests/native-bezier-tests.h deleted file mode 100644 index 2a4a362b2..000000000 --- a/src/tests/native-bezier-tests.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2023 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 . - * - */ - -#pragma once - -void init_bezier_tests (void); diff --git a/src/tests/native-headless.c b/src/tests/native-headless.c deleted file mode 100644 index 39393fc44..000000000 --- a/src/tests/native-headless.c +++ /dev/null @@ -1,48 +0,0 @@ -/* - * 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, see . - * - */ - -#include "config.h" - -#include "meta-test/meta-context-test.h" -#include "tests/native-bezier-tests.h" -#include "tests/native-screen-cast.h" -#include "tests/native-virtual-monitor.h" - -static void -init_tests (MetaContext *context) -{ - init_virtual_monitor_tests (context); - init_screen_cast_tests (); - init_bezier_tests (); -} - -int -main (int argc, - char **argv) -{ - g_autoptr (MetaContext) context = NULL; - - 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)); - - init_tests (context); - - return meta_context_test_run_tests (META_CONTEXT_TEST (context), - META_TEST_RUN_FLAG_NONE); -} diff --git a/src/tests/native-kms-cursor-hotplug.c b/src/tests/native-kms-cursor-hotplug.c index df3b6f163..6165bd18f 100644 --- a/src/tests/native-kms-cursor-hotplug.c +++ b/src/tests/native-kms-cursor-hotplug.c @@ -31,8 +31,6 @@ #include "tests/meta-test-utils.h" #include "tests/meta-wayland-test-driver.h" #include "tests/meta-wayland-test-utils.h" -#include "tests/native-screen-cast.h" -#include "tests/native-virtual-monitor.h" #include "wayland/meta-cursor-sprite-wayland.h" #include "wayland/meta-wayland-private.h" #include "wayland/meta-wayland-seat.h" diff --git a/src/tests/native-pointer-constraints.c b/src/tests/native-pointer-constraints.c index 0031a20fe..87810cc5d 100644 --- a/src/tests/native-pointer-constraints.c +++ b/src/tests/native-pointer-constraints.c @@ -24,8 +24,6 @@ #include "meta-test/meta-context-test.h" #include "meta/meta-backend.h" #include "tests/meta-test-utils.h" -#include "tests/native-screen-cast.h" -#include "tests/native-virtual-monitor.h" static MetaContext *test_context; diff --git a/src/tests/native-screen-cast.c b/src/tests/native-screen-cast.c index 2b40ba79c..5a8304540 100644 --- a/src/tests/native-screen-cast.c +++ b/src/tests/native-screen-cast.c @@ -18,13 +18,12 @@ #include "config.h" -#include "tests/native-screen-cast.h" - #include #include #include #include "meta/util.h" +#include "tests/meta-test/meta-context-test.h" static void test_client_exited (GObject *source_object, @@ -82,9 +81,25 @@ meta_test_screen_cast_record_virtual (void) meta_remove_verbose_topic (META_DEBUG_SCREEN_CAST); } -void -init_screen_cast_tests (void) +static void +init_tests (void) { g_test_add_func ("/backends/native/screen-cast/record-virtual", meta_test_screen_cast_record_virtual); } + +int +main (int argc, + char **argv) +{ + g_autoptr (MetaContext) context = NULL; + + 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)); + + init_tests (); + + return meta_context_test_run_tests (META_CONTEXT_TEST (context), + META_TEST_RUN_FLAG_NONE); +} diff --git a/src/tests/native-screen-cast.h b/src/tests/native-screen-cast.h deleted file mode 100644 index a60ef3898..000000000 --- a/src/tests/native-screen-cast.h +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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, see . - * - */ - -#pragma once - -void init_screen_cast_tests (void); diff --git a/src/tests/native-virtual-monitor.c b/src/tests/native-virtual-monitor.c index a384bf20a..d9a89541f 100644 --- a/src/tests/native-virtual-monitor.c +++ b/src/tests/native-virtual-monitor.c @@ -18,14 +18,13 @@ #include "config.h" -#include "tests/native-virtual-monitor.h" - #include "backends/meta-backend-private.h" #include "backends/meta-logical-monitor.h" #include "backends/meta-monitor-config-manager.h" #include "backends/meta-virtual-monitor.h" #include "backends/native/meta-renderer-native.h" #include "tests/meta-ref-test.h" +#include "tests/meta-test/meta-context-test.h" static MetaContext *test_context; @@ -127,11 +126,27 @@ meta_test_virtual_monitor_create (void) clutter_actor_destroy (actor); } -void -init_virtual_monitor_tests (MetaContext *context) +static void +init_tests (MetaContext *context) { test_context = context; g_test_add_func ("/backends/native/virtual-monitor/create", meta_test_virtual_monitor_create); } + +int +main (int argc, + char **argv) +{ + g_autoptr (MetaContext) context = NULL; + + 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)); + + init_tests (context); + + return meta_context_test_run_tests (META_CONTEXT_TEST (context), + META_TEST_RUN_FLAG_NONE); +} diff --git a/src/tests/native-virtual-monitor.h b/src/tests/native-virtual-monitor.h deleted file mode 100644 index 68eda981d..000000000 --- a/src/tests/native-virtual-monitor.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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, see . - * - */ - -#pragma once - -typedef struct _MetaContext MetaContext; - -void init_virtual_monitor_tests (MetaContext *context);