From 0b4899ef23e4979326439613dfba814bd49aeb2e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Thu, 5 Nov 2009 17:30:33 +0000 Subject: [PATCH] tests: Clean up interactive test build The build for interactive tests creates symbolic links for the data under tests/data; it also uses symbolic links for creating "binaries" for each interactive test. This is less than ideal, though. Instead, the tests should build a path to the data files by using a pre-processor define like TESTS_DATADIR; both g_build_filename() and pre-processor string concatenation can be used to generate a valid file name with the full path to the files. The build system should also create wrapper scripts, just like we do inside the conformance test suite, to be able to launch single tests. --- .gitignore | 1 + tests/interactive/Makefile.am | 59 ++++++++++------- tests/interactive/test-actor-clone.c | 27 ++++---- tests/interactive/test-actors.c | 11 ++-- tests/interactive/test-behave.c | 14 ++-- tests/interactive/test-bin-layout.c | 6 +- tests/interactive/test-clip.c | 5 +- tests/interactive/test-cogl-multitexture.c | 15 ++++- tests/interactive/test-cogl-offscreen.c | 6 +- tests/interactive/test-cogl-tex-convert.c | 28 +++++--- tests/interactive/test-cogl-tex-getset.c | 12 ++-- tests/interactive/test-cogl-tex-polygon.c | 9 ++- tests/interactive/test-cogl-tex-tile.c | 6 +- tests/interactive/test-depth.c | 5 +- tests/interactive/test-devices.c | 5 +- tests/interactive/test-fbo.c | 11 +++- tests/interactive/test-layout.c | 5 +- tests/interactive/test-multistage.c | 5 +- tests/interactive/test-paint-wrapper.c | 5 +- tests/interactive/test-pixmap.c | 2 +- tests/interactive/test-rotate.c | 8 ++- tests/interactive/test-script.c | 9 ++- tests/interactive/test-shader.c | 76 ++++++++++++---------- tests/interactive/test-texture-async.c | 57 +++++++--------- tests/interactive/test-texture-quality.c | 15 +++-- tests/interactive/test-viewport.c | 8 ++- tests/interactive/wrapper.sh | 4 +- 27 files changed, 256 insertions(+), 158 deletions(-) diff --git a/.gitignore b/.gitignore index ff5f3f81c..17a20fc1c 100644 --- a/.gitignore +++ b/.gitignore @@ -135,6 +135,7 @@ TAGS /tests/interactive/test-bin-layout /tests/interactive/test-flow-layout /tests/interactive/test-box-layout +/tests/interactive/stamp-test-interactive /tests/conform/stamp-test-conformance /tests/conform/test-anchors /tests/conform/test-conformance diff --git a/tests/interactive/Makefile.am b/tests/interactive/Makefile.am index 4693ef002..43ffe7c1a 100644 --- a/tests/interactive/Makefile.am +++ b/tests/interactive/Makefile.am @@ -53,44 +53,53 @@ UNIT_TESTS += test-pixmap.c UNIT_TESTS += test-devices.c endif -#FIXME - this is is a bit of a yukky way of ensuring the tests find our data: -test-script.json: - $(QUIET_LN)ln -sf $(top_srcdir)/tests/data/test-script.json -redhand.png: - $(QUIET_LN)ln -sf $(top_srcdir)/tests/data/redhand.png -redhand_alpha.png: - $(QUIET_LN)ln -sf $(top_srcdir)/tests/data/redhand_alpha.png -light0.png: - $(QUIET_LN)ln -sf $(top_srcdir)/tests/data/light0.png - # For convenience, this provides a way to easily run individual unit tests: -.PHONY: wrappers -wrappers: test-interactive$(EXEEXT) - $(QUIET_GEN)for i in $(UNIT_TESTS); \ +wrappers: stamp-test-interactive + @true +stamp-test-interactive: test-interactive$(EXEEXT) + @for i in $(UNIT_TESTS); \ do \ - ln -sf $(top_srcdir)/tests/interactive/wrapper.sh $${i%*.c}; \ - done + test_bin=$${i%*.c} ; \ + echo " GEN $$test_bin" ; \ + ( echo "#!/bin/sh" ; \ + echo "$(top_srcdir)/tests/interactive/wrapper.sh $$test_bin" \ + ) > $$test_bin$(EXEEXT) ; \ + chmod +x $$test_bin$(EXEEXT) ; \ + done \ + && echo timestamp > $(@F) -# NB: BUILT_SOURCES here a misnomer. We aren't building source, just inserting -# a phony rule that will generate symlink scripts for running individual tests -BUILT_SOURCES = wrappers redhand.png redhand_alpha.png light0.png test-script.json +clean-wrappers: + @for i in $(UNIT_TESTS); \ + do \ + test_bin=$${i%*.c} ; \ + echo " RM $$test_bin"; \ + rm -f $$test_bin$(EXEEXT); \ + done \ + && rm -f stamp-test-interactive + +.PHONY: wrappers clean-wrappers INCLUDES = \ - -I$(top_srcdir) \ - -I$(top_srcdir)/clutter \ - -I$(top_srcdir)/clutter/cogl \ - -I$(top_builddir)/clutter \ - -I$(top_builddir)/clutter/cogl \ - -DG_DISABLE_SINGLE_INCLUDES + -I$(top_srcdir) \ + -I$(top_srcdir)/clutter \ + -I$(top_srcdir)/clutter/cogl \ + -I$(top_builddir)/clutter \ + -I$(top_builddir)/clutter/cogl common_ldadd = $(top_builddir)/clutter/libclutter-@CLUTTER_WINSYS@-@CLUTTER_API_VERSION@.la noinst_PROGRAMS = test-interactive test_interactive_SOURCES = test-main.c $(UNIT_TESTS) -test_interactive_CPPFLAGS = $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS) +test_interactive_CFLAGS = $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS) +test_interactive_CPPFLAGS = \ + -DTESTS_DATADIR=\""$(top_srcdir)/tests/data"\" \ + -DG_DISABLE_SINGLE_INCLUDES test_interactive_LDFLAGS = -export-dynamic test_interactive_LDADD = $(CLUTTER_LIBS) $(common_ldadd) EXTRA_DIST = wrapper.sh +BUILT_SOURCES = wrappers + +clean-local: clean-wrappers diff --git a/tests/interactive/test-actor-clone.c b/tests/interactive/test-actor-clone.c index 10548553c..489bd079f 100644 --- a/tests/interactive/test-actor-clone.c +++ b/tests/interactive/test-actor-clone.c @@ -130,14 +130,15 @@ my_sine_wave (ClutterAlpha *alpha, G_MODULE_EXPORT int test_actor_clone_main (int argc, char *argv[]) { - ClutterAlpha *alpha; - ClutterActor *stage; - ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; - SuperOH *oh; - gint i; - GError *error; - ClutterActor *real_hand, *tmp; - ClutterColor clr = { 0xff, 0xff, 0x00, 0xff }; + ClutterAlpha *alpha; + ClutterActor *stage; + ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; + SuperOH *oh; + gint i; + GError *error; + ClutterActor *real_hand, *tmp; + ClutterColor clr = { 0xff, 0xff, 0x00, 0xff }; + gchar *file; error = NULL; @@ -176,12 +177,12 @@ test_actor_clone_main (int argc, char *argv[]) oh->scaler_1 = clutter_behaviour_scale_new (alpha, 0.5, 0.5, 1.0, 1.0); oh->scaler_2 = clutter_behaviour_scale_new (alpha, 1.0, 1.0, 0.5, 0.5); - tmp = clutter_texture_new_from_file ("redhand.png", &error); + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + tmp = clutter_texture_new_from_file (file, &error); if (tmp == NULL) - { - g_error ("image load failed: %s", error->message); - return EXIT_FAILURE; - } + g_error ("image load failed: %s", error->message); + + g_free (file); clutter_actor_set_size (tmp, 300, 500); diff --git a/tests/interactive/test-actors.c b/tests/interactive/test-actors.c index aba8be43d..fb2f492f7 100644 --- a/tests/interactive/test-actors.c +++ b/tests/interactive/test-actors.c @@ -137,6 +137,7 @@ test_actors_main (int argc, char *argv[]) gint i; GError *error; ClutterActor *real_hand; + gchar *file; error = NULL; @@ -177,12 +178,12 @@ test_actors_main (int argc, char *argv[]) oh->scaler_1 = clutter_behaviour_scale_new (alpha, 0.5, 0.5, 1.0, 1.0); oh->scaler_2 = clutter_behaviour_scale_new (alpha, 1.0, 1.0, 0.5, 0.5); - real_hand = clutter_texture_new_from_file ("redhand.png", &error); + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + real_hand = clutter_texture_new_from_file (file, &error); if (real_hand == NULL) - { - g_error ("image load failed: %s", error->message); - return EXIT_FAILURE; - } + g_error ("image load failed: %s", error->message); + + g_free (file); /* create a new group to hold multiple actors in a group */ oh->group = clutter_group_new(); diff --git a/tests/interactive/test-behave.c b/tests/interactive/test-behave.c index 4a794f57b..e8097b5f5 100644 --- a/tests/interactive/test-behave.c +++ b/tests/interactive/test-behave.c @@ -76,6 +76,7 @@ test_behave_main (int argc, char *argv[]) ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; ClutterColor rect_bg_color = { 0x33, 0x22, 0x22, 0xff }; ClutterColor rect_border_color = { 0, 0, 0, 0 }; + gchar *file; int i; path_t path_type = PATH_POLY; @@ -138,13 +139,14 @@ test_behave_main (int argc, char *argv[]) group = clutter_group_new (); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group); clutter_actor_show (group); - - hand = clutter_texture_new_from_file ("redhand.png", NULL); + + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + hand = clutter_texture_new_from_file (file, NULL); if (hand == NULL) - { - g_error("pixbuf load failed"); - return 1; - } + g_error("Unable to load '%s'", file); + + g_free (file); + clutter_actor_set_position (hand, 0, 0); clutter_actor_show (hand); diff --git a/tests/interactive/test-bin-layout.c b/tests/interactive/test-bin-layout.c index 8fcc0515c..84fda7b54 100644 --- a/tests/interactive/test-bin-layout.c +++ b/tests/interactive/test-bin-layout.c @@ -131,9 +131,11 @@ test_bin_layout_main (int argc, char *argv[]) { ClutterActor *tex; GError *error; + gchar *file; error = NULL; - tex = clutter_texture_new_from_file ("redhand.png", &error); + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + tex = clutter_texture_new_from_file (file, &error); if (error) g_error ("Unable to create texture: %s", error->message); @@ -147,6 +149,8 @@ test_bin_layout_main (int argc, char *argv[]) clutter_actor_raise (tex, rect); clutter_actor_set_width (tex, 175); clutter_actor_set_name (tex, "texture"); + + g_free (file); } color = clutter_color_new (g_random_int_range (0, 255), diff --git a/tests/interactive/test-clip.c b/tests/interactive/test-clip.c index d756c100a..3414bd3c4 100644 --- a/tests/interactive/test-clip.c +++ b/tests/interactive/test-clip.c @@ -289,6 +289,7 @@ test_clip_main (int argc, char **argv) { CallbackData data; ClutterActor *stub_actor, *label; + gchar *file; clutter_init (&argc, &argv); @@ -300,10 +301,12 @@ test_clip_main (int argc, char **argv) stub_actor = clutter_rectangle_new (); clutter_container_add (CLUTTER_CONTAINER (data.stage), stub_actor, NULL); - data.hand = cogl_texture_new_from_file ("redhand.png", + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + data.hand = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); + g_free (file); label = clutter_text_new_with_text ("Sans 12px", instructions); clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE); diff --git a/tests/interactive/test-cogl-multitexture.c b/tests/interactive/test-cogl-multitexture.c index 621a045cf..d52567129 100644 --- a/tests/interactive/test-cogl-multitexture.c +++ b/tests/interactive/test-cogl-multitexture.c @@ -58,6 +58,7 @@ test_cogl_multitexture_main (int argc, char *argv[]) ClutterColor stage_color = { 0x61, 0x56, 0x56, 0xff }; TestMultiLayerMaterialState *state = g_new0 (TestMultiLayerMaterialState, 1); ClutterGeometry geom; + gchar **files; gfloat tex_coords[] = { /* tx1 ty1 tx2 ty2 */ @@ -82,8 +83,14 @@ test_cogl_multitexture_main (int argc, char *argv[]) g_signal_connect (state->group, "paint", G_CALLBACK(material_rectangle_paint), state); + files = g_new (gchar*, 4); + files[0] = g_build_filename (TESTS_DATADIR, "redhand_alpha.png", NULL); + files[1] = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + files[2] = g_build_filename (TESTS_DATADIR, "light0.png", NULL); + files[3] = NULL; + state->alpha_tex = - cogl_texture_new_from_file ("redhand_alpha.png", + cogl_texture_new_from_file (files[0], COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); @@ -91,7 +98,7 @@ test_cogl_multitexture_main (int argc, char *argv[]) g_critical ("Failed to load redhand_alpha.png: %s", error->message); state->redhand_tex = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (files[1], COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); @@ -99,13 +106,15 @@ test_cogl_multitexture_main (int argc, char *argv[]) g_critical ("Failed to load redhand.png: %s", error->message); state->light_tex0 = - cogl_texture_new_from_file ("light0.png", + cogl_texture_new_from_file (files[2], COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); if (!state->light_tex0) g_critical ("Failed to load light0.png: %s", error->message); + g_strfreev (files); + state->material = cogl_material_new (); cogl_material_set_layer (state->material, 0, state->alpha_tex); cogl_material_set_layer (state->material, 1, state->redhand_tex); diff --git a/tests/interactive/test-cogl-offscreen.c b/tests/interactive/test-cogl-offscreen.c index 2aa5e79f6..1bae10d32 100644 --- a/tests/interactive/test-cogl-offscreen.c +++ b/tests/interactive/test-cogl-offscreen.c @@ -140,13 +140,17 @@ static void test_coglbox_init (TestCoglbox *self) { TestCoglboxPrivate *priv; + gchar *file; + self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); printf ("Loading redhand.png\n"); - priv->texhand_id = cogl_texture_new_from_file ("redhand.png", + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + priv->texhand_id = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); + g_free (file); printf ("Creating texture with size\n"); priv->texture_id = cogl_texture_new_with_size (200, 200, diff --git a/tests/interactive/test-cogl-tex-convert.c b/tests/interactive/test-cogl-tex-convert.c index bd10d8773..271ee9f36 100644 --- a/tests/interactive/test-cogl-tex-convert.c +++ b/tests/interactive/test-cogl-tex-convert.c @@ -141,27 +141,37 @@ static void test_coglbox_init (TestCoglbox *self) { TestCoglboxPrivate *priv; + gchar *file; + self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - + + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + priv->cogl_tex_id[0] = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_ANY, NULL); + COGL_PIXEL_FORMAT_ANY, + NULL); priv->cogl_tex_id[1] = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_BGRA_8888, NULL); + COGL_PIXEL_FORMAT_BGRA_8888, + NULL); priv->cogl_tex_id[2] = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_ARGB_8888, NULL); + COGL_PIXEL_FORMAT_ARGB_8888, + NULL); priv->cogl_tex_id[3] = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_G_8, NULL); + COGL_PIXEL_FORMAT_G_8, + NULL); + + g_free (file); } static void diff --git a/tests/interactive/test-cogl-tex-getset.c b/tests/interactive/test-cogl-tex-getset.c index fb56b3b88..ffada94c1 100644 --- a/tests/interactive/test-cogl-tex-getset.c +++ b/tests/interactive/test-cogl-tex-getset.c @@ -126,22 +126,26 @@ test_coglbox_init (TestCoglbox *self) guchar *data; gint x,y,t; guchar *pixel; + gchar *file; self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); /* Load image from file */ - + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); priv->cogl_tex_id[0] = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, - COGL_PIXEL_FORMAT_ANY, NULL); + COGL_PIXEL_FORMAT_ANY, + NULL); if (priv->cogl_tex_id[0] == COGL_INVALID_HANDLE) { printf ("Failed loading redhand.png image!\n"); return; } - + + g_free (file); + printf("Texture loaded from file.\n"); /* Obtain pixel data */ diff --git a/tests/interactive/test-cogl-tex-polygon.c b/tests/interactive/test-cogl-tex-polygon.c index 1a86f8df6..8e359f2d6 100644 --- a/tests/interactive/test-cogl-tex-polygon.c +++ b/tests/interactive/test-cogl-tex-polygon.c @@ -248,13 +248,16 @@ test_coglbox_init (TestCoglbox *self) { TestCoglboxPrivate *priv; GError *error = NULL; + gchar *file; + self->priv = priv = TEST_COGLBOX_GET_PRIVATE (self); priv->use_linear_filtering = FALSE; priv->use_sliced = FALSE; + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); priv->sliced_tex = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, &error); @@ -271,7 +274,7 @@ test_coglbox_init (TestCoglbox *self) } priv->not_sliced_tex = - cogl_texture_new_from_file ("redhand.png", + cogl_texture_new_from_file (file, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_ANY, &error); @@ -285,6 +288,8 @@ test_coglbox_init (TestCoglbox *self) else g_warning ("Texture loading failed: "); } + + g_free (file); } static void diff --git a/tests/interactive/test-cogl-tex-tile.c b/tests/interactive/test-cogl-tex-tile.c index 9316443ca..6b16d33d5 100644 --- a/tests/interactive/test-cogl-tex-tile.c +++ b/tests/interactive/test-cogl-tex-tile.c @@ -138,12 +138,16 @@ static void test_coglbox_init (TestCoglbox *self) { TestCoglboxPrivate *priv; + gchar *file; + self->priv = priv = TEST_COGLBOX_GET_PRIVATE(self); - priv->cogl_tex_id = cogl_texture_new_from_file ("redhand.png", + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + priv->cogl_tex_id = cogl_texture_new_from_file (file, COGL_TEXTURE_NONE, COGL_PIXEL_FORMAT_ANY, NULL); + g_free (file); } static void diff --git a/tests/interactive/test-depth.c b/tests/interactive/test-depth.c index c06337c58..090e8f26b 100644 --- a/tests/interactive/test-depth.c +++ b/tests/interactive/test-depth.c @@ -139,7 +139,10 @@ test_depth_main (int argc, char *argv[]) clutter_actor_show (label); error = NULL; - hand = clutter_texture_new_from_file ("redhand.png", &error); + hand = clutter_texture_new_from_file (TESTS_DATADIR + G_DIR_SEPARATOR_S + "redhand.png", + &error); if (error) g_error ("Unable to load redhand.png: %s", error->message); clutter_actor_set_position (hand, 240, 100); diff --git a/tests/interactive/test-devices.c b/tests/interactive/test-devices.c index 0e81b973d..4fd2a2c44 100644 --- a/tests/interactive/test-devices.c +++ b/tests/interactive/test-devices.c @@ -80,7 +80,10 @@ test_devices_main (int argc, char **argv) g_print ("got a pointer device with id %d...\n", clutter_input_device_get_device_id (device)); - hand = clutter_texture_new_from_file ("redhand.png", NULL); + hand = clutter_texture_new_from_file (TESTS_DATADIR + G_DIR_SEPARATOR_S + "redhand.png", + NULL); g_hash_table_insert (app->devices, device, hand); clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand); diff --git a/tests/interactive/test-fbo.c b/tests/interactive/test-fbo.c index fdf8b83a9..48df005c7 100644 --- a/tests/interactive/test-fbo.c +++ b/tests/interactive/test-fbo.c @@ -13,15 +13,20 @@ ClutterActor * make_source (void) { ClutterActor *source, *actor; - GError *error = NULL; + GError *error = NULL; + gchar *file; ClutterColor yellow = {0xff, 0xff, 0x00, 0xff}; - source = clutter_group_new(); - actor = clutter_texture_new_from_file ("redhand.png", &error); + source = clutter_group_new (); + + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + actor = clutter_texture_new_from_file (file, &error); if (!actor) g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); + g_free (file); + clutter_group_add (source, actor); actor = clutter_text_new_with_text ("Sans Bold 50px", "Clutter"); diff --git a/tests/interactive/test-layout.c b/tests/interactive/test-layout.c index 2180c103e..b6ffe8a81 100644 --- a/tests/interactive/test-layout.c +++ b/tests/interactive/test-layout.c @@ -769,7 +769,10 @@ test_layout_main (int argc, char *argv[]) clutter_actor_set_position (box, 20, 20); clutter_actor_set_size (box, 350, -1); - icon = clutter_texture_new_from_file ("redhand.png", &error); + icon = clutter_texture_new_from_file (TESTS_DATADIR + G_DIR_SEPARATOR_S + "redhand.png", + &error); if (error) g_error ("Unable to load 'redhand.png': %s", error->message); diff --git a/tests/interactive/test-multistage.c b/tests/interactive/test-multistage.c index 1cc1fc8ab..48985fd6c 100644 --- a/tests/interactive/test-multistage.c +++ b/tests/interactive/test-multistage.c @@ -38,7 +38,10 @@ on_button_press (ClutterActor *actor, clutter_stage_set_color (CLUTTER_STAGE (new_stage), &color); clutter_actor_set_size (new_stage, 320, 240); - tex = clutter_texture_new_from_file ("redhand.png", NULL); + tex = clutter_texture_new_from_file (TESTS_DATADIR + G_DIR_SEPARATOR_S + "redhand.png", + NULL); if (!tex) g_error ("pixbuf load failed"); diff --git a/tests/interactive/test-paint-wrapper.c b/tests/interactive/test-paint-wrapper.c index 704ce7800..7b14cef42 100644 --- a/tests/interactive/test-paint-wrapper.c +++ b/tests/interactive/test-paint-wrapper.c @@ -224,7 +224,10 @@ test_paint_wrapper_main (int argc, char *argv[]) oh->scaler_1 = clutter_behaviour_scale_new (alpha, 0.5, 0.5, 1.0, 1.0); oh->scaler_2 = clutter_behaviour_scale_new (alpha, 1.0, 1.0, 0.5, 0.5); - real_hand = clutter_texture_new_from_file ("redhand.png", &error); + real_hand = clutter_texture_new_from_file (TESTS_DATADIR + G_DIR_SEPARATOR_S + "redhand.png", + &error); if (real_hand == NULL) { g_error ("image load failed: %s", error->message); diff --git a/tests/interactive/test-pixmap.c b/tests/interactive/test-pixmap.c index ec00955d1..7df2cf55f 100644 --- a/tests/interactive/test-pixmap.c +++ b/tests/interactive/test-pixmap.c @@ -16,7 +16,7 @@ #include #include -#define IMAGE "redhand.png" +#define IMAGE TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png" # ifdef USE_GDKPIXBUF # include diff --git a/tests/interactive/test-rotate.c b/tests/interactive/test-rotate.c index ee11ef353..e6174a5c0 100644 --- a/tests/interactive/test-rotate.c +++ b/tests/interactive/test-rotate.c @@ -16,6 +16,7 @@ test_rotate_main (int argc, char *argv[]) ClutterActor *stage; ClutterActor *hand, *label; ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; + gchar *file; clutter_init (&argc, &argv); @@ -25,9 +26,12 @@ test_rotate_main (int argc, char *argv[]) &stage_color); /* Make a hand */ - hand = clutter_texture_new_from_file ("redhand.png", NULL); + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + hand = clutter_texture_new_from_file (file, NULL); if (!hand) - g_error("pixbuf load failed"); + g_error("Unable to load '%s'", file); + + g_free (file); clutter_actor_set_position (hand, 240, 140); clutter_actor_show (hand); diff --git a/tests/interactive/test-script.c b/tests/interactive/test-script.c index 143fd33c4..27db01c85 100644 --- a/tests/interactive/test-script.c +++ b/tests/interactive/test-script.c @@ -136,6 +136,7 @@ test_script_main (int argc, char *argv[]) { GObject *stage, *blue_button, *red_button; GError *error = NULL; + gchar *file; gint res; clutter_init (&argc, &argv); @@ -152,17 +153,21 @@ test_script_main (int argc, char *argv[]) g_object_unref (script); return EXIT_FAILURE; } - - clutter_script_load_from_file (script, "test-script.json", &error); + + file = g_build_filename (TESTS_DATADIR, "test-script.json", NULL); + clutter_script_load_from_file (script, file, &error); if (error) { g_print ("*** Error:\n" "*** %s\n", error->message); g_error_free (error); g_object_unref (script); + g_free (file); return EXIT_FAILURE; } + g_free (file); + merge_id = clutter_script_load_from_data (script, test_unmerge, -1, &error); if (error) { diff --git a/tests/interactive/test-shader.c b/tests/interactive/test-shader.c index 8ceac6f52..4b3a6997c 100644 --- a/tests/interactive/test-shader.c +++ b/tests/interactive/test-shader.c @@ -304,11 +304,12 @@ timeout_cb (gpointer data) G_MODULE_EXPORT gint test_shader_main (gint argc, gchar *argv[]) { - ClutterActor *actor; - ClutterActor *stage; - ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; - ClutterShader *shader; - GError *error; + ClutterActor *actor; + ClutterActor *stage; + ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff }; + ClutterShader *shader; + GError *error; + gchar *file; clutter_init (&argc, &argv); @@ -338,45 +339,50 @@ test_shader_main (gint argc, gchar *argv[]) clutter_stage_set_title (CLUTTER_STAGE (stage), "Shader Test"); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + #ifndef TEST_GROUP - actor = g_object_new (CLUTTER_TYPE_TEXTURE, - "filename", "redhand.png", - "disable-slicing", TRUE, - NULL); - actor = clutter_texture_new_from_file ("redhand.png", &error); + actor = clutter_texture_new_from_file (file, &error); if (!actor) g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); - #else actor = clutter_group_new (); - { - ClutterActor *child1, *child2, *child3, *child4; - ClutterColor color = { 0xff, 0x22, 0x66, 0x99 }; - child1 = clutter_texture_new_from_file ("redhand.png", &error); - if (!child1) - g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); - child2 = clutter_texture_new_from_file ("redhand.png", &error); - if (!child2) - g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); - child3 = clutter_rectangle_new (); - child4 = clutter_text_new_with_text ("Sans 20px", "Shady stuff"); + { + ClutterActor *child1, *child2, *child3, *child4; + ClutterColor color = { 0xff, 0x22, 0x66, 0x99 }; - clutter_rectangle_set_color (child3, &color); - clutter_actor_set_size (child3, 50, 50); - clutter_actor_set_position (child1, 0, 0); - clutter_actor_set_position (child2, 50, 100); - clutter_actor_set_position (child3, 30, -30); - clutter_actor_set_position (child4, -50, 20); + child1 = clutter_texture_new_from_file (file, &error); + if (!child1) + g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); - clutter_group_add (CLUTTER_GROUP (actor), child1); - clutter_group_add (CLUTTER_GROUP (actor), child2); - clutter_group_add (CLUTTER_GROUP (actor), child3); - clutter_group_add (CLUTTER_GROUP (actor), child4); + child2 = clutter_texture_new_from_file (file, &error); + if (!child2) + g_error("pixbuf load failed: %s", error ? error->message : "Unknown"); - clutter_actor_show_all (actor); - } -#endif + child3 = clutter_rectangle_new (); + child4 = clutter_text_new_with_text ("Sans 20px", "Shady stuff"); + + clutter_rectangle_set_color (CLUTTER_RECTANGLE (child3), &color); + clutter_actor_set_size (child3, 50, 50); + + clutter_actor_set_position (child1, 0, 0); + clutter_actor_set_position (child2, 50, 100); + clutter_actor_set_position (child3, 30, -30); + clutter_actor_set_position (child4, -50, 20); + + clutter_container_add (CLUTTER_CONTAINER (actor), + child1, + child2, + child3, + child4, + NULL); + + clutter_actor_show_all (actor); + } +#endif /* !TEST_GROUP */ + + g_free (file); clutter_actor_set_shader (actor, shader); clutter_actor_set_position (actor, 100, 100); diff --git a/tests/interactive/test-texture-async.c b/tests/interactive/test-texture-async.c index 7c976d2dc..3a93a4d13 100644 --- a/tests/interactive/test-texture-async.c +++ b/tests/interactive/test-texture-async.c @@ -38,17 +38,17 @@ on_load_finished (ClutterTexture *texture, g_print ("%s successful\n", load_str); } -static void size_change_cb (ClutterTexture *texture, - gint width, - gint height, - gpointer user_data) +static void +size_change_cb (ClutterTexture *texture, + gint width, + gint height, + gpointer user_data) { clutter_actor_set_size (user_data, width, height); } - const gchar *path = "redhand.png"; - -static gboolean task (gpointer foo) +static +gboolean task (gpointer user_data) { ClutterTimeline *timeline; ClutterAlpha *alpha; @@ -56,18 +56,11 @@ static gboolean task (gpointer foo) ClutterActor *image[4]; ClutterActor *clone[4]; ClutterActor *stage; + gchar *path = user_data; gint i; stage = clutter_stage_get_default (); -#if 0 - for (i=0;i<4;i++) - image[i] = g_object_new (CLUTTER_TYPE_TEXTURE, - "filename", path, - "load-async", TRUE, - NULL); -#else - /*for (i=0;i<4;i++)*/ image[0] = g_object_new (CLUTTER_TYPE_TEXTURE, NULL); g_signal_connect (image[0], "load-finished", G_CALLBACK (on_load_finished), @@ -85,19 +78,14 @@ static gboolean task (gpointer foo) g_signal_connect (image[2], "load-finished", G_CALLBACK (on_load_finished), GINT_TO_POINTER (LOAD_ASYNC)); -#endif - for (i=0;i<3;i++) - { - clutter_texture_set_from_file (CLUTTER_TEXTURE (image[i]), path, NULL); - } + for (i = 0; i < 3; i++) + clutter_texture_set_from_file (CLUTTER_TEXTURE (image[i]), path, NULL); - for (i=0;i<3;i++) - { - clutter_container_add (CLUTTER_CONTAINER (stage), image[i], NULL); - } + for (i = 0; i < 3; i++) + clutter_container_add (CLUTTER_CONTAINER (stage), image[i], NULL); - for (i=0;i<3;i++) + for (i = 0; i < 3; i++) { clutter_actor_set_position (image[i], 50+i*100, 0+i*50); clone[i]=clutter_clone_new (image[i]); @@ -107,7 +95,7 @@ static gboolean task (gpointer foo) clutter_actor_set_position (clone[i], 50+i*100, 150+i*50+100); } - for (i=0; i<3; i++) + for (i = 0; i < 3; i++) { timeline = clutter_timeline_new (5000); alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); @@ -115,6 +103,7 @@ static gboolean task (gpointer foo) clutter_behaviour_apply (depth_behavior, image[i]); clutter_timeline_start (timeline); } + return FALSE; } @@ -122,9 +111,10 @@ static gboolean task (gpointer foo) G_MODULE_EXPORT gint test_texture_async_main (int argc, char *argv[]) { - ClutterActor *stage; - ClutterColor stage_color = { 0x12, 0x34, 0x56, 0xff }; - GError *error; + ClutterActor *stage; + ClutterColor stage_color = { 0x12, 0x34, 0x56, 0xff }; + GError *error; + gchar *path; clutter_init (&argc, &argv); @@ -139,13 +129,16 @@ test_texture_async_main (int argc, char *argv[]) error = NULL; - path = argv[1]?argv[1]:"redhand.png"; - + path = (argc > 0) + ? g_strdup (argv[1]) + : g_build_filename (TESTS_DATADIR, "redhand.png", NULL); - g_timeout_add (500, task, NULL); + g_timeout_add (500, task, path); clutter_main (); + g_free (path); + /*g_object_unref (depth_behavior); g_object_unref (timeline);*/ diff --git a/tests/interactive/test-texture-quality.c b/tests/interactive/test-texture-quality.c index 214923d25..39b190667 100644 --- a/tests/interactive/test-texture-quality.c +++ b/tests/interactive/test-texture-quality.c @@ -50,6 +50,7 @@ test_texture_quality_main (int argc, char *argv[]) ClutterColor stage_color = { 0x12, 0x34, 0x56, 0xff }; ClutterFog stage_fog = { 10.0, -50.0 }; GError *error; + gchar *file; clutter_init (&argc, &argv); @@ -62,14 +63,20 @@ test_texture_quality_main (int argc, char *argv[]) "button-press-event", G_CALLBACK (clutter_main_quit), NULL); + if (argc < 1) + g_print ("Hint: the redhand.png isn't a good test image for this test.\n" + "This test can take any image file as an argument\n"); + + file = (argc > 0) + ? g_strdup (argv[1]) + : g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + error = NULL; - image = clutter_texture_new_from_file (argv[1]?argv[1]:"redhand.png", &error); + image = clutter_texture_new_from_file (file, &error); if (error) g_error ("Unable to load image: %s", error->message); - if (!argv[1]) - g_print ("Hint: the redhand.png isn't a good test image for this test.\n" - "This test can take any clutter loadable image as an argument\n"); + g_free (file); /* center the image */ clutter_actor_set_position (image, diff --git a/tests/interactive/test-viewport.c b/tests/interactive/test-viewport.c index f406a7439..ec6bc1788 100644 --- a/tests/interactive/test-viewport.c +++ b/tests/interactive/test-viewport.c @@ -16,6 +16,7 @@ test_viewport_main (int argc, char *argv[]) ClutterActor *stage; ClutterActor *hand; ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff }; + gchar *file; clutter_init (&argc, &argv); @@ -25,9 +26,12 @@ test_viewport_main (int argc, char *argv[]) &stage_color); /* Make a hand */ - hand = clutter_texture_new_from_file ("redhand.png", NULL); + file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL); + hand = clutter_texture_new_from_file (file, NULL); if (!hand) - g_error("pixbuf load failed"); + g_error("Unable to load image '%s'", file); + + g_free (file); clutter_actor_set_position (hand, 300, 200); clutter_actor_set_clip (hand, 20, 21, 132, 170); diff --git a/tests/interactive/wrapper.sh b/tests/interactive/wrapper.sh index 4cfaa6bf5..6bae94c21 100755 --- a/tests/interactive/wrapper.sh +++ b/tests/interactive/wrapper.sh @@ -1,6 +1,8 @@ #!/bin/sh -UNIT_TEST=`basename $0` +UNIT_TEST=$1 + +shift echo "Running ./test-interactive $UNIT_TEST $@" echo ""