From cc7e843c44c30475b9519c2a1ed8d6fcef130036 Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 3 Jul 2019 13:43:25 +0200 Subject: [PATCH] tests: Move clutter-test-utils.[ch] to src/tests And add the necessary glue so those initialize a X11 clutter backend. This should get Clutter tests that are dependent on windowing to work again, thus they were enabled back again. https://gitlab.gnome.org/GNOME/mutter/merge_requests/672 --- clutter/clutter/clutter-private.h | 1 + clutter/clutter/clutter.h | 1 - clutter/clutter/meson.build | 2 -- .../tests}/clutter-test-utils.c | 11 +------ .../tests}/clutter-test-utils.h | 29 +++++++++++++++---- src/tests/clutter/conform/actor-anchors.c | 2 ++ src/tests/clutter/conform/actor-destroy.c | 2 ++ src/tests/clutter/conform/actor-graph.c | 2 ++ src/tests/clutter/conform/actor-invariants.c | 2 ++ src/tests/clutter/conform/actor-iter.c | 2 ++ src/tests/clutter/conform/actor-layout.c | 2 ++ src/tests/clutter/conform/actor-meta.c | 2 ++ .../conform/actor-offscreen-redirect.c | 2 ++ .../clutter/conform/actor-paint-opacity.c | 2 ++ src/tests/clutter/conform/actor-pick.c | 2 ++ .../clutter/conform/actor-shader-effect.c | 2 ++ src/tests/clutter/conform/actor-size.c | 2 ++ src/tests/clutter/conform/behaviours.c | 8 +++++ src/tests/clutter/conform/binding-pool.c | 2 ++ src/tests/clutter/conform/color.c | 2 ++ src/tests/clutter/conform/group.c | 2 ++ src/tests/clutter/conform/interval.c | 2 ++ src/tests/clutter/conform/meson.build | 4 ++- src/tests/clutter/conform/rectangle.c | 2 ++ src/tests/clutter/conform/script-parser.c | 2 ++ src/tests/clutter/conform/text.c | 2 ++ src/tests/clutter/conform/texture.c | 2 ++ src/tests/clutter/conform/units.c | 2 ++ src/tests/meson.build | 11 +++++-- 29 files changed, 86 insertions(+), 23 deletions(-) rename {clutter/clutter => src/tests}/clutter-test-utils.c (98%) rename {clutter/clutter => src/tests}/clutter-test-utils.h (87%) diff --git a/clutter/clutter/clutter-private.h b/clutter/clutter/clutter-private.h index 63b8a5e03..ac44edadc 100644 --- a/clutter/clutter/clutter-private.h +++ b/clutter/clutter/clutter-private.h @@ -204,6 +204,7 @@ guint _clutter_pixel_to_id (guchar pixel[4]); void _clutter_id_to_color (guint id, ClutterColor *col); +CLUTTER_EXPORT void _clutter_set_sync_to_vblank (gboolean sync_to_vblank); /* use this function as the accumulator if you have a signal with diff --git a/clutter/clutter/clutter.h b/clutter/clutter/clutter.h index ec846910f..320fdf7e8 100644 --- a/clutter/clutter/clutter.h +++ b/clutter/clutter/clutter.h @@ -103,7 +103,6 @@ #include "clutter-stage-manager.h" #include "clutter-stage-view.h" #include "clutter-tap-action.h" -#include "clutter-test-utils.h" #include "clutter-texture.h" #include "clutter-text.h" #include "clutter-timeline.h" diff --git a/clutter/clutter/meson.build b/clutter/clutter/meson.build index 7a247632d..44ee1a315 100644 --- a/clutter/clutter/meson.build +++ b/clutter/clutter/meson.build @@ -77,7 +77,6 @@ clutter_headers = [ 'clutter-stage-manager.h', 'clutter-stage-view.h', 'clutter-tap-action.h', - 'clutter-test-utils.h', 'clutter-texture.h', 'clutter-text.h', 'clutter-text-buffer.h', @@ -168,7 +167,6 @@ clutter_sources = [ 'clutter-stage-view.c', 'clutter-stage-window.c', 'clutter-tap-action.c', - 'clutter-test-utils.c', 'clutter-text.c', 'clutter-text-buffer.c', 'clutter-transition-group.c', diff --git a/clutter/clutter/clutter-test-utils.c b/src/tests/clutter-test-utils.c similarity index 98% rename from clutter/clutter/clutter-test-utils.c rename to src/tests/clutter-test-utils.c index edc413e96..3bd99989e 100644 --- a/clutter/clutter/clutter-test-utils.c +++ b/src/tests/clutter-test-utils.c @@ -1,17 +1,8 @@ -#include "clutter-build-config.h" - #include "clutter-test-utils.h" #include #include - -#include "clutter-actor.h" -#include "clutter-color.h" -#include "clutter-event.h" -#include "clutter-keysyms.h" -#include "clutter-main.h" -#include "clutter-private.h" -#include "clutter-stage.h" +#include typedef struct { ClutterActor *stage; diff --git a/clutter/clutter/clutter-test-utils.h b/src/tests/clutter-test-utils.h similarity index 87% rename from clutter/clutter/clutter-test-utils.h rename to src/tests/clutter-test-utils.h index 6078533c2..1c4be6495 100644 --- a/clutter/clutter/clutter-test-utils.h +++ b/src/tests/clutter-test-utils.h @@ -19,16 +19,23 @@ * License along with this library. If not, see . */ +#include "config.h" + #ifndef __CLUTTER_TEST_UTILS_H__ #define __CLUTTER_TEST_UTILS_H__ -#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION) -#error "Only can be included directly." -#endif +#define __CLUTTER_H_INSIDE__ -#include -#include -#include +#include "clutter/clutter-types.h" +#include "clutter/clutter-actor.h" +#include "clutter/clutter-color.h" +#include "clutter/clutter-private.h" +#include "core/main-private.h" +#include "meta/common.h" +#include "meta/main.h" +#include "backends/x11/nested/meta-backend-x11-nested.h" +#include "wayland/meta-wayland.h" +#include "wayland/meta-xwayland.h" G_BEGIN_DECLS @@ -79,12 +86,22 @@ G_BEGIN_DECLS int \ main (int argc, char *argv[]) \ { \ + char *display_name = g_strdup ("mutter-test-display-XXXXXX");\ + int fd = g_mkstemp (display_name);\ + meta_wayland_override_display_name (display_name);\ + meta_override_compositor_configuration (META_COMPOSITOR_TYPE_WAYLAND,\ + META_TYPE_BACKEND_X11_NESTED);\ +\ + meta_init ();\ +\ clutter_test_init (&argc, &argv); \ \ { \ units \ } \ \ + close (fd);\ + g_free (display_name);\ return clutter_test_run (); \ } diff --git a/src/tests/clutter/conform/actor-anchors.c b/src/tests/clutter/conform/actor-anchors.c index 55395880b..842379818 100644 --- a/src/tests/clutter/conform/actor-anchors.c +++ b/src/tests/clutter/conform/actor-anchors.c @@ -4,6 +4,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + #define NOTIFY_ANCHOR_X (1 << 0) #define NOTIFY_ANCHOR_Y (1 << 1) #define NOTIFY_ANCHOR_GRAVITY (1 << 2) diff --git a/src/tests/clutter/conform/actor-destroy.c b/src/tests/clutter/conform/actor-destroy.c index 10ad79df7..a0867fb27 100644 --- a/src/tests/clutter/conform/actor-destroy.c +++ b/src/tests/clutter/conform/actor-destroy.c @@ -1,6 +1,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + #define TEST_TYPE_DESTROY (test_destroy_get_type ()) #define TEST_DESTROY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_DESTROY, TestDestroy)) #define TEST_IS_DESTROY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_DESTROY)) diff --git a/src/tests/clutter/conform/actor-graph.c b/src/tests/clutter/conform/actor-graph.c index 8fbf4bcb7..b388fe127 100644 --- a/src/tests/clutter/conform/actor-graph.c +++ b/src/tests/clutter/conform/actor-graph.c @@ -1,5 +1,7 @@ #include +#include "tests/clutter-test-utils.h" + static void actor_add_child (void) { diff --git a/src/tests/clutter/conform/actor-invariants.c b/src/tests/clutter/conform/actor-invariants.c index 87df90bc1..42dad3a04 100644 --- a/src/tests/clutter/conform/actor-invariants.c +++ b/src/tests/clutter/conform/actor-invariants.c @@ -4,6 +4,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + static void actor_initial_state (void) { diff --git a/src/tests/clutter/conform/actor-iter.c b/src/tests/clutter/conform/actor-iter.c index 193f63b27..3e963c56a 100644 --- a/src/tests/clutter/conform/actor-iter.c +++ b/src/tests/clutter/conform/actor-iter.c @@ -1,6 +1,8 @@ #include #include +#include "tests/clutter-test-utils.h" + static void actor_iter_traverse_children (void) { diff --git a/src/tests/clutter/conform/actor-layout.c b/src/tests/clutter/conform/actor-layout.c index 2cc89400c..099a279e1 100644 --- a/src/tests/clutter/conform/actor-layout.c +++ b/src/tests/clutter/conform/actor-layout.c @@ -1,5 +1,7 @@ #include +#include "tests/clutter-test-utils.h" + static void actor_basic_layout (void) { diff --git a/src/tests/clutter/conform/actor-meta.c b/src/tests/clutter/conform/actor-meta.c index 52a313d22..0211f99ae 100644 --- a/src/tests/clutter/conform/actor-meta.c +++ b/src/tests/clutter/conform/actor-meta.c @@ -3,6 +3,8 @@ #include +#include "tests/clutter-test-utils.h" + static void actor_meta_clear (void) { diff --git a/src/tests/clutter/conform/actor-offscreen-redirect.c b/src/tests/clutter/conform/actor-offscreen-redirect.c index 9dbb7d2c5..368e041ad 100644 --- a/src/tests/clutter/conform/actor-offscreen-redirect.c +++ b/src/tests/clutter/conform/actor-offscreen-redirect.c @@ -1,6 +1,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + typedef struct _FooActor FooActor; typedef struct _FooActorClass FooActorClass; diff --git a/src/tests/clutter/conform/actor-paint-opacity.c b/src/tests/clutter/conform/actor-paint-opacity.c index 6df240872..8e0447de9 100644 --- a/src/tests/clutter/conform/actor-paint-opacity.c +++ b/src/tests/clutter/conform/actor-paint-opacity.c @@ -1,6 +1,8 @@ #include #include +#include "tests/clutter-test-utils.h" + static void opacity_label (void) { diff --git a/src/tests/clutter/conform/actor-pick.c b/src/tests/clutter/conform/actor-pick.c index 969b4920a..430f8442a 100644 --- a/src/tests/clutter/conform/actor-pick.c +++ b/src/tests/clutter/conform/actor-pick.c @@ -1,6 +1,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + #define STAGE_WIDTH 640 #define STAGE_HEIGHT 480 #define ACTORS_X 12 diff --git a/src/tests/clutter/conform/actor-shader-effect.c b/src/tests/clutter/conform/actor-shader-effect.c index ac99c5b40..5cbe51f06 100644 --- a/src/tests/clutter/conform/actor-shader-effect.c +++ b/src/tests/clutter/conform/actor-shader-effect.c @@ -2,6 +2,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + /**************************************************************** Old style shader effect This uses clutter_shader_effect_set_source diff --git a/src/tests/clutter/conform/actor-size.c b/src/tests/clutter/conform/actor-size.c index 7245f157d..0d909f028 100644 --- a/src/tests/clutter/conform/actor-size.c +++ b/src/tests/clutter/conform/actor-size.c @@ -3,6 +3,8 @@ #include +#include "tests/clutter-test-utils.h" + #define TEST_TYPE_ACTOR (test_actor_get_type ()) typedef struct _TestActor TestActor; diff --git a/src/tests/clutter/conform/behaviours.c b/src/tests/clutter/conform/behaviours.c index 6c531beff..523477106 100644 --- a/src/tests/clutter/conform/behaviours.c +++ b/src/tests/clutter/conform/behaviours.c @@ -1,6 +1,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + static void behaviour_opacity (void) { @@ -65,6 +67,12 @@ main (int argc, char *argv[]) { int i; + meta_wayland_override_display_name ("mutter-test-display"); + meta_xwayland_override_display_number (512); + meta_override_compositor_configuration (META_COMPOSITOR_TYPE_WAYLAND, + META_TYPE_BACKEND_X11_NESTED); + meta_init (); + clutter_test_init (&argc, &argv); for (i = 0; i < n_behaviour_tests; i++) diff --git a/src/tests/clutter/conform/binding-pool.c b/src/tests/clutter/conform/binding-pool.c index 4e4752b6b..7c9bbc1a1 100644 --- a/src/tests/clutter/conform/binding-pool.c +++ b/src/tests/clutter/conform/binding-pool.c @@ -2,6 +2,8 @@ #include +#include "tests/clutter-test-utils.h" + #define TYPE_KEY_GROUP (key_group_get_type ()) #define KEY_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_KEY_GROUP, KeyGroup)) #define IS_KEY_GROUP(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_KEY_GROUP)) diff --git a/src/tests/clutter/conform/color.c b/src/tests/clutter/conform/color.c index 03ecf3f08..f8a860b32 100644 --- a/src/tests/clutter/conform/color.c +++ b/src/tests/clutter/conform/color.c @@ -1,5 +1,7 @@ #include +#include "tests/clutter-test-utils.h" + static void color_hls_roundtrip (void) { diff --git a/src/tests/clutter/conform/group.c b/src/tests/clutter/conform/group.c index 3f7b1fb4b..a1eaf7eb7 100644 --- a/src/tests/clutter/conform/group.c +++ b/src/tests/clutter/conform/group.c @@ -1,6 +1,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + static void group_depth_sorting (void) { diff --git a/src/tests/clutter/conform/interval.c b/src/tests/clutter/conform/interval.c index 520437894..468f21312 100644 --- a/src/tests/clutter/conform/interval.c +++ b/src/tests/clutter/conform/interval.c @@ -1,5 +1,7 @@ #include +#include "tests/clutter-test-utils.h" + static void interval_initial_state (void) { diff --git a/src/tests/clutter/conform/meson.build b/src/tests/clutter/conform/meson.build index 5d0df7acd..6821e8963 100644 --- a/src/tests/clutter/conform/meson.build +++ b/src/tests/clutter/conform/meson.build @@ -59,6 +59,7 @@ foreach test : clutter_conform_tests test_executable = executable('@0@'.format(test), sources: [ '@0@.c'.format(test), + clutter_test_utils, ], include_directories: clutter_includes, c_args: clutter_tests_conform_c_args, @@ -66,7 +67,8 @@ foreach test : clutter_conform_tests dependencies: [ clutter_deps, libmutter_clutter_dep, - libmutter_cogl_path_dep + libmutter_cogl_path_dep, + libmutter_dep ], install: false, ) diff --git a/src/tests/clutter/conform/rectangle.c b/src/tests/clutter/conform/rectangle.c index 1c09f00b7..588c73a10 100644 --- a/src/tests/clutter/conform/rectangle.c +++ b/src/tests/clutter/conform/rectangle.c @@ -1,6 +1,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + static void rectangle_set_size (void) { diff --git a/src/tests/clutter/conform/script-parser.c b/src/tests/clutter/conform/script-parser.c index c2e2dbd08..d7fad094a 100644 --- a/src/tests/clutter/conform/script-parser.c +++ b/src/tests/clutter/conform/script-parser.c @@ -4,6 +4,8 @@ #define CLUTTER_DISABLE_DEPRECATION_WARNINGS #include +#include "tests/clutter-test-utils.h" + #define TEST_TYPE_GROUP (test_group_get_type ()) #define TEST_TYPE_GROUP_META (test_group_meta_get_type ()) diff --git a/src/tests/clutter/conform/text.c b/src/tests/clutter/conform/text.c index cef99023e..ebe4b7bb1 100644 --- a/src/tests/clutter/conform/text.c +++ b/src/tests/clutter/conform/text.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + typedef struct { gunichar unichar; const char bytes[6]; diff --git a/src/tests/clutter/conform/texture.c b/src/tests/clutter/conform/texture.c index 392fd5c47..3f1160308 100644 --- a/src/tests/clutter/conform/texture.c +++ b/src/tests/clutter/conform/texture.c @@ -2,6 +2,8 @@ #include #include +#include "tests/clutter-test-utils.h" + static CoglHandle make_texture (void) { diff --git a/src/tests/clutter/conform/units.c b/src/tests/clutter/conform/units.c index 06bfaf513..bcfb5890d 100644 --- a/src/tests/clutter/conform/units.c +++ b/src/tests/clutter/conform/units.c @@ -1,5 +1,7 @@ #include +#include "tests/clutter-test-utils.h" + static void units_cache (void) { diff --git a/src/tests/meson.build b/src/tests/meson.build index 51039d04f..dafe67ff8 100644 --- a/src/tests/meson.build +++ b/src/tests/meson.build @@ -1,6 +1,11 @@ -#if have_clutter_tests -# subdir('clutter') -#endif +clutter_test_utils = files ( + 'clutter-test-utils.c', + 'clutter-test-utils.h', +) + +if have_clutter_tests + subdir('clutter') +endif tests_includepath = mutter_includes tests_c_args = mutter_c_args