mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
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.
This commit is contained in:
parent
c3368c0d15
commit
0b4899ef23
1
.gitignore
vendored
1
.gitignore
vendored
@ -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
|
||||
|
@ -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_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
|
||||
|
@ -138,6 +138,7 @@ test_actor_clone_main (int argc, char *argv[])
|
||||
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_free (file);
|
||||
|
||||
clutter_actor_set_size (tmp, 300, 500);
|
||||
|
||||
|
@ -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_free (file);
|
||||
|
||||
/* create a new group to hold multiple actors in a group */
|
||||
oh->group = clutter_group_new();
|
||||
|
@ -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;
|
||||
|
||||
@ -139,12 +140,13 @@ test_behave_main (int argc, char *argv[])
|
||||
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);
|
||||
|
||||
|
@ -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),
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
@ -126,15 +126,17 @@ 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)
|
||||
{
|
||||
@ -142,6 +144,8 @@ test_coglbox_init (TestCoglbox *self)
|
||||
return;
|
||||
}
|
||||
|
||||
g_free (file);
|
||||
|
||||
printf("Texture loaded from file.\n");
|
||||
|
||||
/* Obtain pixel data */
|
||||
|
@ -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: <unknown>");
|
||||
}
|
||||
|
||||
g_free (file);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -14,14 +14,19 @@ make_source (void)
|
||||
{
|
||||
ClutterActor *source, *actor;
|
||||
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");
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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");
|
||||
|
@ -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);
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include <X11/Xlib.h>
|
||||
#include <X11/extensions/Xcomposite.h>
|
||||
|
||||
#define IMAGE "redhand.png"
|
||||
#define IMAGE TESTS_DATADIR G_DIR_SEPARATOR_S "redhand.png"
|
||||
|
||||
# ifdef USE_GDKPIXBUF
|
||||
# include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
@ -153,16 +154,20 @@ test_script_main (int argc, char *argv[])
|
||||
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)
|
||||
{
|
||||
|
@ -309,6 +309,7 @@ test_shader_main (gint argc, gchar *argv[])
|
||||
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);
|
||||
child1 = clutter_texture_new_from_file (file, &error);
|
||||
if (!child1)
|
||||
g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
|
||||
child2 = clutter_texture_new_from_file ("redhand.png", &error);
|
||||
|
||||
child2 = clutter_texture_new_from_file (file, &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");
|
||||
|
||||
clutter_rectangle_set_color (child3, &color);
|
||||
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_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);
|
||||
clutter_container_add (CLUTTER_CONTAINER (actor),
|
||||
child1,
|
||||
child2,
|
||||
child3,
|
||||
child4,
|
||||
NULL);
|
||||
|
||||
clutter_actor_show_all (actor);
|
||||
}
|
||||
#endif
|
||||
#endif /* !TEST_GROUP */
|
||||
|
||||
g_free (file);
|
||||
|
||||
clutter_actor_set_shader (actor, shader);
|
||||
clutter_actor_set_position (actor, 100, 100);
|
||||
|
@ -38,7 +38,8 @@ on_load_finished (ClutterTexture *texture,
|
||||
g_print ("%s successful\n", load_str);
|
||||
}
|
||||
|
||||
static void size_change_cb (ClutterTexture *texture,
|
||||
static void
|
||||
size_change_cb (ClutterTexture *texture,
|
||||
gint width,
|
||||
gint height,
|
||||
gpointer user_data)
|
||||
@ -46,9 +47,8 @@ static void size_change_cb (ClutterTexture *texture,
|
||||
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++)
|
||||
{
|
||||
for (i = 0; i < 3; i++)
|
||||
clutter_texture_set_from_file (CLUTTER_TEXTURE (image[i]), path, NULL);
|
||||
}
|
||||
|
||||
for (i=0;i<3;i++)
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
@ -125,6 +114,7 @@ test_texture_async_main (int argc, char *argv[])
|
||||
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);*/
|
||||
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#!/bin/sh
|
||||
|
||||
UNIT_TEST=`basename $0`
|
||||
UNIT_TEST=$1
|
||||
|
||||
shift
|
||||
|
||||
echo "Running ./test-interactive $UNIT_TEST $@"
|
||||
echo ""
|
||||
|
Loading…
Reference in New Issue
Block a user