1
0
Fork 0

conformance: Add more tests

Add back some deprecated and general purpose API tests. These are the
ones that were written already pretty much conforming to the GTest API
and style, and thus require minimal porting.
This commit is contained in:
Emmanuele Bassi 2013-12-12 15:05:16 +00:00
parent 7ec337f26f
commit 526d0ea884
14 changed files with 420 additions and 387 deletions

View file

@ -12,6 +12,7 @@ AM_CPPFLAGS = \
$(CLUTTER_DEBUG_CFLAGS) \ $(CLUTTER_DEBUG_CFLAGS) \
$(CLUTTER_PROFILE_CFLAGS) $(CLUTTER_PROFILE_CFLAGS)
# Basic actor API
actor_tests = \ actor_tests = \
actor-anchors \ actor-anchors \
actor-destroy \ actor-destroy \
@ -28,10 +29,29 @@ actor_tests = \
actor-size \ actor-size \
$(NULL) $(NULL)
general_tests = \ # Actor classes
classes_tests = \
text \
$(NULL) $(NULL)
# General API
general_tests = \
binding-pool \
color \
events-touch \
interval \
model \
script-parser \
units \
$(NULL)
# Test for deprecated functionality
deprecated_tests = \ deprecated_tests = \
animator \
behaviours \
group \
rectangle \
texture \
$(NULL) $(NULL)
test_programs = $(actor_tests) $(general_tests) $(deprecated_tests) test_programs = $(actor_tests) $(general_tests) $(deprecated_tests)
@ -54,3 +74,16 @@ script_tests = \
test-script-single.json \ test-script-single.json \
test-script-timeline-markers.json \ test-script-timeline-markers.json \
test-state-1.json test-state-1.json
# simple rules for generating a Git ignore file for the conformance test suite
$(srcdir)/.gitignore: Makefile
$(AM_V_GEN)( echo "/*.trs" ; \
echo "/*.log" ; \
echo "/.gitignore" ; \
for p in $(test_programs); do \
echo "/$$p" ; \
done ) > $(@F)
gitignore: $(srcdir)/.gitignore
all-am: gitignore

View file

@ -1,10 +1,8 @@
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h" static void
animator_multi_properties (void)
void
animator_multi_properties (TestConformSimpleFixture *fixture,
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
GObject *animator = NULL, *foo = NULL; GObject *animator = NULL, *foo = NULL;
@ -14,16 +12,15 @@ animator_multi_properties (TestConformSimpleFixture *fixture,
ClutterAnimatorKey *key; ClutterAnimatorKey *key;
GValue value = { 0, }; GValue value = { 0, };
test_file = clutter_test_get_data_file ("test-animator-3.json"); test_file = g_test_build_filename (G_TEST_DIST,
"scripts",
"test-animator-3.json",
NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
foo = clutter_script_get_object (script, "foo"); foo = clutter_script_get_object (script, "foo");
g_assert (G_IS_OBJECT (foo)); g_assert (G_IS_OBJECT (foo));
@ -105,9 +102,8 @@ animator_multi_properties (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
animator_properties (TestConformSimpleFixture *fixture, animator_properties (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
GObject *animator = NULL; GObject *animator = NULL;
@ -117,16 +113,15 @@ animator_properties (TestConformSimpleFixture *fixture,
ClutterAnimatorKey *key; ClutterAnimatorKey *key;
GValue value = { 0, }; GValue value = { 0, };
test_file = clutter_test_get_data_file ("test-animator-2.json"); test_file = g_test_build_filename (G_TEST_DIST,
"scripts",
"test-animator-2.json",
NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
animator = clutter_script_get_object (script, "animator"); animator = clutter_script_get_object (script, "animator");
g_assert (CLUTTER_IS_ANIMATOR (animator)); g_assert (CLUTTER_IS_ANIMATOR (animator));
@ -168,9 +163,8 @@ animator_properties (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
animator_base (TestConformSimpleFixture *fixture, animator_base (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
GObject *animator = NULL; GObject *animator = NULL;
@ -178,16 +172,15 @@ animator_base (TestConformSimpleFixture *fixture,
guint duration = 0; guint duration = 0;
gchar *test_file; gchar *test_file;
test_file = clutter_test_get_data_file ("test-animator-1.json"); test_file = g_test_build_filename (G_TEST_DIST,
"scripts",
"test-animator-1.json",
NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
animator = clutter_script_get_object (script, "animator"); animator = clutter_script_get_object (script, "animator");
g_assert (CLUTTER_IS_ANIMATOR (animator)); g_assert (CLUTTER_IS_ANIMATOR (animator));
@ -198,3 +191,9 @@ animator_base (TestConformSimpleFixture *fixture,
g_object_unref (script); g_object_unref (script);
g_free (test_file); g_free (test_file);
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/script/animator/base", animator_base)
CLUTTER_TEST_UNIT ("/script/animator/properties", animator_properties)
CLUTTER_TEST_UNIT ("/script/animator/multi-properties", animator_multi_properties)
)

View file

@ -1,28 +1,21 @@
#include <glib.h> #define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h"
typedef struct _BehaviourFixture BehaviourFixture;
typedef void (* BehaviourTestFunc) (BehaviourFixture *fixture);
struct _BehaviourFixture
{
ClutterTimeline *timeline;
ClutterAlpha *alpha;
ClutterActor *rect;
};
static void static void
opacity_behaviour (BehaviourFixture *fixture) behaviour_opacity (void)
{ {
ClutterBehaviour *behaviour; ClutterBehaviour *behaviour;
ClutterTimeline *timeline;
ClutterAlpha *alpha;
guint8 start, end; guint8 start, end;
guint starti; guint starti;
behaviour = clutter_behaviour_opacity_new (fixture->alpha, 0, 255); timeline = clutter_timeline_new (500);
alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
behaviour = clutter_behaviour_opacity_new (alpha, 0, 255);
g_assert (CLUTTER_IS_BEHAVIOUR_OPACITY (behaviour)); g_assert (CLUTTER_IS_BEHAVIOUR_OPACITY (behaviour));
g_object_add_weak_pointer (G_OBJECT (behaviour), (gpointer *) &behaviour);
g_object_add_weak_pointer (G_OBJECT (timeline), (gpointer *) &timeline);
clutter_behaviour_opacity_get_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour), clutter_behaviour_opacity_get_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour),
&start, &start,
@ -51,40 +44,37 @@ opacity_behaviour (BehaviourFixture *fixture)
g_assert_cmpint (starti, ==, 255); g_assert_cmpint (starti, ==, 255);
g_object_unref (behaviour); g_object_unref (behaviour);
g_object_unref (timeline);
g_assert_null (behaviour);
g_assert_null (timeline);
} }
static const struct static struct
{ {
const gchar *desc; const gchar *path;
BehaviourTestFunc func; GTestFunc func;
} behaviour_tests[] = { } behaviour_tests[] = {
{ "BehaviourOpacity", opacity_behaviour } { "opacity", behaviour_opacity },
}; };
static const gint n_behaviour_tests = G_N_ELEMENTS (behaviour_tests); static const int n_behaviour_tests = G_N_ELEMENTS (behaviour_tests);
void int
behaviours_base (TestConformSimpleFixture *fixture, main (int argc, char *argv[])
gconstpointer dummy)
{ {
BehaviourFixture b_fixture; int i;
gint i;
b_fixture.timeline = clutter_timeline_new (1000); clutter_test_init (&argc, &argv);
b_fixture.alpha = clutter_alpha_new_full (b_fixture.timeline, CLUTTER_LINEAR);
b_fixture.rect = clutter_rectangle_new ();
g_object_ref_sink (b_fixture.alpha);
g_object_unref (b_fixture.timeline);
for (i = 0; i < n_behaviour_tests; i++) for (i = 0; i < n_behaviour_tests; i++)
{ {
if (g_test_verbose ()) char *path = g_strconcat ("/behaviours/", behaviour_tests[i].path, NULL);
g_print ("Testing: %s\n", behaviour_tests[i].desc);
behaviour_tests[i].func (&b_fixture); clutter_test_add (path, behaviour_tests[i].func);
g_free (path);
} }
g_object_unref (b_fixture.alpha); return clutter_test_run ();
clutter_actor_destroy (b_fixture.rect);
} }

View file

@ -1,11 +1,6 @@
#include <string.h> #include <string.h>
#include <glib.h>
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include <clutter/clutter-keysyms.h>
#include "test-conform-common.h"
#define TYPE_KEY_GROUP (key_group_get_type ()) #define TYPE_KEY_GROUP (key_group_get_type ())
#define KEY_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_KEY_GROUP, KeyGroup)) #define KEY_GROUP(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_KEY_GROUP, KeyGroup))
@ -18,20 +13,22 @@ typedef struct _KeyGroupClass KeyGroupClass;
struct _KeyGroup struct _KeyGroup
{ {
ClutterGroup parent_instance; ClutterActor parent_instance;
gint selected_index; gint selected_index;
}; };
struct _KeyGroupClass struct _KeyGroupClass
{ {
ClutterGroupClass parent_class; ClutterActorClass parent_class;
void (* activate) (KeyGroup *group, void (* activate) (KeyGroup *group,
ClutterActor *child); ClutterActor *child);
}; };
G_DEFINE_TYPE (KeyGroup, key_group, CLUTTER_TYPE_GROUP); GType key_group_get_type (void);
G_DEFINE_TYPE (KeyGroup, key_group, CLUTTER_TYPE_ACTOR)
enum enum
{ {
@ -53,7 +50,7 @@ key_group_action_move_left (KeyGroup *self,
g_assert_cmpstr (action_name, ==, "move-left"); g_assert_cmpstr (action_name, ==, "move-left");
g_assert_cmpint (key_val, ==, CLUTTER_KEY_Left); g_assert_cmpint (key_val, ==, CLUTTER_KEY_Left);
n_children = clutter_group_get_n_children (CLUTTER_GROUP (self)); n_children = clutter_actor_get_n_children (CLUTTER_ACTOR (self));
self->selected_index -= 1; self->selected_index -= 1;
@ -74,7 +71,7 @@ key_group_action_move_right (KeyGroup *self,
g_assert_cmpstr (action_name, ==, "move-right"); g_assert_cmpstr (action_name, ==, "move-right");
g_assert_cmpint (key_val, ==, CLUTTER_KEY_Right); g_assert_cmpint (key_val, ==, CLUTTER_KEY_Right);
n_children = clutter_group_get_n_children (CLUTTER_GROUP (self)); n_children = clutter_actor_get_n_children (CLUTTER_ACTOR (self));
self->selected_index += 1; self->selected_index += 1;
@ -100,10 +97,8 @@ key_group_action_activate (KeyGroup *self,
if (self->selected_index == -1) if (self->selected_index == -1)
return FALSE; return FALSE;
child = clutter_group_get_nth_child (CLUTTER_GROUP (self), child = clutter_actor_get_child_at_index (CLUTTER_ACTOR (self), self->selected_index);
self->selected_index); if (child != NULL)
if (child)
{ {
g_signal_emit (self, group_signals[ACTIVATE], 0, child); g_signal_emit (self, group_signals[ACTIVATE], 0, child);
return TRUE; return TRUE;
@ -138,15 +133,13 @@ static void
key_group_paint (ClutterActor *actor) key_group_paint (ClutterActor *actor)
{ {
KeyGroup *self = KEY_GROUP (actor); KeyGroup *self = KEY_GROUP (actor);
GList *children, *l; ClutterActorIter iter;
gint i; ClutterActor *child;
gint i = 0;
children = clutter_container_get_children (CLUTTER_CONTAINER (self)); clutter_actor_iter_init (&iter, actor);
while (clutter_actor_iter_next (&iter, &child))
for (l = children, i = 0; l != NULL; l = l->next, i++)
{ {
ClutterActor *child = l->data;
/* paint the selection rectangle */ /* paint the selection rectangle */
if (i == self->selected_index) if (i == self->selected_index)
{ {
@ -165,14 +158,6 @@ key_group_paint (ClutterActor *actor)
clutter_actor_paint (child); clutter_actor_paint (child);
} }
g_list_free (children);
}
static void
key_group_finalize (GObject *gobject)
{
G_OBJECT_CLASS (key_group_parent_class)->finalize (gobject);
} }
static void static void
@ -182,8 +167,6 @@ key_group_class_init (KeyGroupClass *klass)
ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass); ClutterActorClass *actor_class = CLUTTER_ACTOR_CLASS (klass);
ClutterBindingPool *binding_pool; ClutterBindingPool *binding_pool;
gobject_class->finalize = key_group_finalize;
actor_class->paint = key_group_paint; actor_class->paint = key_group_paint;
actor_class->key_press_event = key_group_key_press; actor_class->key_press_event = key_group_key_press;
@ -261,29 +244,30 @@ on_activate (KeyGroup *key_group,
g_assert_cmpint (key_group->selected_index, ==, _index); g_assert_cmpint (key_group->selected_index, ==, _index);
} }
void static void
binding_pool (TestConformSimpleFixture *fixture, binding_pool (void)
gconstpointer data)
{ {
KeyGroup *key_group = g_object_new (TYPE_KEY_GROUP, NULL); KeyGroup *key_group = g_object_new (TYPE_KEY_GROUP, NULL);
g_object_ref_sink (key_group);
clutter_container_add (CLUTTER_CONTAINER (key_group), clutter_actor_add_child (CLUTTER_ACTOR (key_group),
g_object_new (CLUTTER_TYPE_RECTANGLE, g_object_new (CLUTTER_TYPE_ACTOR,
"width", 50.0, "width", 50.0,
"height", 50.0, "height", 50.0,
"x", 0.0, "y", 0.0, "x", 0.0, "y", 0.0,
NULL), NULL));
g_object_new (CLUTTER_TYPE_RECTANGLE, clutter_actor_add_child (CLUTTER_ACTOR (key_group),
g_object_new (CLUTTER_TYPE_ACTOR,
"width", 50.0, "width", 50.0,
"height", 50.0, "height", 50.0,
"x", 75.0, "y", 0.0, "x", 75.0, "y", 0.0,
NULL), NULL));
g_object_new (CLUTTER_TYPE_RECTANGLE, clutter_actor_add_child (CLUTTER_ACTOR (key_group),
g_object_new (CLUTTER_TYPE_ACTOR,
"width", 50.0, "width", 50.0,
"height", 50.0, "height", 50.0,
"x", 150.0, "y", 0.0, "x", 150.0, "y", 0.0,
NULL), NULL));
NULL);
g_assert_cmpint (key_group->selected_index, ==, -1); g_assert_cmpint (key_group->selected_index, ==, -1);
@ -307,3 +291,7 @@ binding_pool (TestConformSimpleFixture *fixture,
clutter_actor_destroy (CLUTTER_ACTOR (key_group)); clutter_actor_destroy (CLUTTER_ACTOR (key_group));
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/binding-pool", binding_pool)
)

View file

@ -1,20 +1,16 @@
#include <stdio.h>
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h" static void
color_hls_roundtrip (void)
void
color_hls_roundtrip (TestConformSimpleFixture *fixture,
gconstpointer data)
{ {
ClutterColor color; ClutterColor color;
gfloat hue, luminance, saturation; gfloat hue, luminance, saturation;
/* test luminance only */ /* test luminance only */
clutter_color_from_string (&color, "#7f7f7f"); clutter_color_from_string (&color, "#7f7f7f");
g_assert_cmpint (color.red, ==, 0x7f); g_assert_cmpuint (color.red, ==, 0x7f);
g_assert_cmpint (color.green, ==, 0x7f); g_assert_cmpuint (color.green, ==, 0x7f);
g_assert_cmpint (color.blue, ==, 0x7f); g_assert_cmpuint (color.blue, ==, 0x7f);
clutter_color_to_hls (&color, &hue, &luminance, &saturation); clutter_color_to_hls (&color, &hue, &luminance, &saturation);
g_assert_cmpfloat (hue, ==, 0.0); g_assert_cmpfloat (hue, ==, 0.0);
@ -34,17 +30,17 @@ color_hls_roundtrip (TestConformSimpleFixture *fixture,
color.red = color.green = color.blue = 0; color.red = color.green = color.blue = 0;
clutter_color_from_hls (&color, hue, luminance, saturation); clutter_color_from_hls (&color, hue, luminance, saturation);
g_assert_cmpint (color.red, ==, 0x7f); g_assert_cmpuint (color.red, ==, 0x7f);
g_assert_cmpint (color.green, ==, 0x7f); g_assert_cmpuint (color.green, ==, 0x7f);
g_assert_cmpint (color.blue, ==, 0x7f); g_assert_cmpuint (color.blue, ==, 0x7f);
/* full conversion */ /* full conversion */
clutter_color_from_string (&color, "#7f8f7f"); clutter_color_from_string (&color, "#7f8f7f");
color.alpha = 255; color.alpha = 255;
g_assert_cmpint (color.red, ==, 0x7f); g_assert_cmpuint (color.red, ==, 0x7f);
g_assert_cmpint (color.green, ==, 0x8f); g_assert_cmpuint (color.green, ==, 0x8f);
g_assert_cmpint (color.blue, ==, 0x7f); g_assert_cmpuint (color.blue, ==, 0x7f);
clutter_color_to_hls (&color, &hue, &luminance, &saturation); clutter_color_to_hls (&color, &hue, &luminance, &saturation);
g_assert (hue >= 0.0 && hue < 360.0); g_assert (hue >= 0.0 && hue < 360.0);
@ -64,17 +60,16 @@ color_hls_roundtrip (TestConformSimpleFixture *fixture,
color.red = color.green = color.blue = 0; color.red = color.green = color.blue = 0;
clutter_color_from_hls (&color, hue, luminance, saturation); clutter_color_from_hls (&color, hue, luminance, saturation);
g_assert_cmpint (color.red, ==, 0x7f); g_assert_cmpuint (color.red, ==, 0x7f);
g_assert_cmpint (color.green, ==, 0x8f); g_assert_cmpuint (color.green, ==, 0x8f);
g_assert_cmpint (color.blue, ==, 0x7f); g_assert_cmpuint (color.blue, ==, 0x7f);
/* the alpha channel should be untouched */ /* the alpha channel should be untouched */
g_assert_cmpint (color.alpha, ==, 255); g_assert_cmpuint (color.alpha, ==, 255);
} }
void static void
color_from_string_invalid (TestConformSimpleFixture *fixture, color_from_string_invalid (void)
gconstpointer data)
{ {
ClutterColor color; ClutterColor color;
@ -88,9 +83,8 @@ color_from_string_invalid (TestConformSimpleFixture *fixture,
g_assert (!clutter_color_from_string (&color, "hsla(100%, 0%, 50%, 20%)")); g_assert (!clutter_color_from_string (&color, "hsla(100%, 0%, 50%, 20%)"));
} }
void static void
color_from_string_valid (TestConformSimpleFixture *fixture, color_from_string_valid (void)
gconstpointer data)
{ {
ClutterColor color; ClutterColor color;
@ -103,10 +97,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert (color.red == 0xff); g_assert_cmpuint (color.red, ==, 0xff);
g_assert (color.green == 0); g_assert_cmpuint (color.green, ==, 0);
g_assert (color.blue == 0); g_assert_cmpuint (color.blue, ==, 0);
g_assert (color.alpha == 0xff); g_assert_cmpuint (color.alpha, ==, 0xff);
g_assert (clutter_color_from_string (&color, "#0f0f")); g_assert (clutter_color_from_string (&color, "#0f0f"));
if (g_test_verbose ()) if (g_test_verbose ())
@ -117,10 +111,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert (color.red == 0); g_assert_cmpuint (color.red, ==, 0);
g_assert (color.green == 0xff); g_assert_cmpuint (color.green, ==, 0xff);
g_assert (color.blue == 0); g_assert_cmpuint (color.blue, ==, 0);
g_assert (color.alpha == 0xff); g_assert_cmpuint (color.alpha, ==, 0xff);
g_assert (clutter_color_from_string (&color, "#0000ff")); g_assert (clutter_color_from_string (&color, "#0000ff"));
if (g_test_verbose ()) if (g_test_verbose ())
@ -131,10 +125,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert (color.red == 0); g_assert_cmpuint (color.red, ==, 0);
g_assert (color.green == 0); g_assert_cmpuint (color.green, ==, 0);
g_assert (color.blue == 0xff); g_assert_cmpuint (color.blue, ==, 0xff);
g_assert (color.alpha == 0xff); g_assert_cmpuint (color.alpha, ==, 0xff);
g_assert (clutter_color_from_string (&color, "#abc")); g_assert (clutter_color_from_string (&color, "#abc"));
if (g_test_verbose ()) if (g_test_verbose ())
@ -145,10 +139,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert (color.red == 0xaa); g_assert_cmpuint (color.red, ==, 0xaa);
g_assert (color.green == 0xbb); g_assert_cmpuint (color.green, ==, 0xbb);
g_assert (color.blue == 0xcc); g_assert_cmpuint (color.blue, ==, 0xcc);
g_assert (color.alpha == 0xff); g_assert_cmpuint (color.alpha, ==, 0xff);
g_assert (clutter_color_from_string (&color, "#123abc")); g_assert (clutter_color_from_string (&color, "#123abc"));
if (g_test_verbose ()) if (g_test_verbose ())
@ -173,10 +167,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert_cmpint (color.red, ==, 255); g_assert_cmpuint (color.red, ==, 255);
g_assert_cmpint (color.green, ==, 128); g_assert_cmpuint (color.green, ==, 128);
g_assert_cmpint (color.blue, ==, 64); g_assert_cmpuint (color.blue, ==, 64);
g_assert_cmpint (color.alpha, ==, 255); g_assert_cmpuint (color.alpha, ==, 255);
g_assert (clutter_color_from_string (&color, "rgba ( 30%, 0, 25%, 0.5 ) ")); g_assert (clutter_color_from_string (&color, "rgba ( 30%, 0, 25%, 0.5 ) "));
if (g_test_verbose ()) if (g_test_verbose ())
@ -189,10 +183,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
CLAMP (255.0 / 100.0 * 30.0, 0, 255), CLAMP (255.0 / 100.0 * 30.0, 0, 255),
CLAMP (255.0 / 100.0 * 25.0, 0, 255)); CLAMP (255.0 / 100.0 * 25.0, 0, 255));
} }
g_assert_cmpint (color.red, ==, (255.0 / 100.0 * 30.0)); g_assert_cmpuint (color.red, ==, (255.0 / 100.0 * 30.0));
g_assert_cmpint (color.green, ==, 0); g_assert_cmpuint (color.green, ==, 0);
g_assert_cmpint (color.blue, ==, (255.0 / 100.0 * 25.0)); g_assert_cmpuint (color.blue, ==, (255.0 / 100.0 * 25.0));
g_assert_cmpint (color.alpha, ==, 127); g_assert_cmpuint (color.alpha, ==, 127);
g_assert (clutter_color_from_string (&color, "rgb( 50%, -50%, 150% )")); g_assert (clutter_color_from_string (&color, "rgb( 50%, -50%, 150% )"));
if (g_test_verbose ()) if (g_test_verbose ())
@ -203,10 +197,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert_cmpint (color.red, ==, 127); g_assert_cmpuint (color.red, ==, 127);
g_assert_cmpint (color.green, ==, 0); g_assert_cmpuint (color.green, ==, 0);
g_assert_cmpint (color.blue, ==, 255); g_assert_cmpuint (color.blue, ==, 255);
g_assert_cmpint (color.alpha, ==, 255); g_assert_cmpuint (color.alpha, ==, 255);
g_assert (clutter_color_from_string (&color, "hsl( 0, 100%, 50% )")); g_assert (clutter_color_from_string (&color, "hsl( 0, 100%, 50% )"));
if (g_test_verbose ()) if (g_test_verbose ())
@ -217,10 +211,10 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert_cmpint (color.red, ==, 255); g_assert_cmpuint (color.red, ==, 255);
g_assert_cmpint (color.green, ==, 0); g_assert_cmpuint (color.green, ==, 0);
g_assert_cmpint (color.blue, ==, 0); g_assert_cmpuint (color.blue, ==, 0);
g_assert_cmpint (color.alpha, ==, 255); g_assert_cmpuint (color.alpha, ==, 255);
g_assert (clutter_color_from_string (&color, "hsla( 0, 100%, 50%, 0.5 )")); g_assert (clutter_color_from_string (&color, "hsla( 0, 100%, 50%, 0.5 )"));
if (g_test_verbose ()) if (g_test_verbose ())
@ -231,15 +225,14 @@ color_from_string_valid (TestConformSimpleFixture *fixture,
color.blue, color.blue,
color.alpha); color.alpha);
} }
g_assert_cmpint (color.red, ==, 255); g_assert_cmpuint (color.red, ==, 255);
g_assert_cmpint (color.green, ==, 0); g_assert_cmpuint (color.green, ==, 0);
g_assert_cmpint (color.blue, ==, 0); g_assert_cmpuint (color.blue, ==, 0);
g_assert_cmpint (color.alpha, ==, 127); g_assert_cmpuint (color.alpha, ==, 127);
} }
void static void
color_to_string (TestConformSimpleFixture *fixture, color_to_string (void)
gconstpointer data)
{ {
ClutterColor color; ClutterColor color;
gchar *str; gchar *str;
@ -255,24 +248,23 @@ color_to_string (TestConformSimpleFixture *fixture,
g_free (str); g_free (str);
} }
void static void
color_operators (TestConformSimpleFixture *fixture, color_operators (void)
gconstpointer data)
{ {
ClutterColor op1, op2; ClutterColor op1, op2;
ClutterColor res; ClutterColor res;
clutter_color_from_pixel (&op1, 0xff0000ff); clutter_color_from_pixel (&op1, 0xff0000ff);
g_assert_cmpint (op1.red, ==, 0xff); g_assert_cmpuint (op1.red, ==, 0xff);
g_assert_cmpint (op1.green, ==, 0); g_assert_cmpuint (op1.green, ==, 0);
g_assert_cmpint (op1.blue, ==, 0); g_assert_cmpuint (op1.blue, ==, 0);
g_assert_cmpint (op1.alpha, ==, 0xff); g_assert_cmpuint (op1.alpha, ==, 0xff);
clutter_color_from_pixel (&op2, 0x00ff00ff); clutter_color_from_pixel (&op2, 0x00ff00ff);
g_assert_cmpint (op2.red, ==, 0); g_assert_cmpuint (op2.red, ==, 0);
g_assert_cmpint (op2.green, ==, 0xff); g_assert_cmpuint (op2.green, ==, 0xff);
g_assert_cmpint (op2.blue, ==, 0); g_assert_cmpuint (op2.blue, ==, 0);
g_assert_cmpint (op2.alpha, ==, 0xff); g_assert_cmpuint (op2.alpha, ==, 0xff);
if (g_test_verbose ()) if (g_test_verbose ())
g_print ("Adding %x, %x; expected result: %x\n", g_print ("Adding %x, %x; expected result: %x\n",
@ -281,7 +273,7 @@ color_operators (TestConformSimpleFixture *fixture,
0xffff00ff); 0xffff00ff);
clutter_color_add (&op1, &op2, &res); clutter_color_add (&op1, &op2, &res);
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0xffff00ff); g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0xffff00ff);
if (g_test_verbose ()) if (g_test_verbose ())
g_print ("Checking alpha channel on color add\n"); g_print ("Checking alpha channel on color add\n");
@ -289,7 +281,7 @@ color_operators (TestConformSimpleFixture *fixture,
op1.alpha = 0xdd; op1.alpha = 0xdd;
op2.alpha = 0xcc; op2.alpha = 0xcc;
clutter_color_add (&op1, &op2, &res); clutter_color_add (&op1, &op2, &res);
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0xffff00dd); g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0xffff00dd);
clutter_color_from_pixel (&op1, 0xffffffff); clutter_color_from_pixel (&op1, 0xffffffff);
clutter_color_from_pixel (&op2, 0xff00ffff); clutter_color_from_pixel (&op2, 0xff00ffff);
@ -301,7 +293,7 @@ color_operators (TestConformSimpleFixture *fixture,
0x00ff00ff); 0x00ff00ff);
clutter_color_subtract (&op1, &op2, &res); clutter_color_subtract (&op1, &op2, &res);
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0x00ff00ff); g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0x00ff00ff);
if (g_test_verbose ()) if (g_test_verbose ())
g_print ("Checking alpha channel on color subtract\n"); g_print ("Checking alpha channel on color subtract\n");
@ -309,5 +301,13 @@ color_operators (TestConformSimpleFixture *fixture,
op1.alpha = 0xdd; op1.alpha = 0xdd;
op2.alpha = 0xcc; op2.alpha = 0xcc;
clutter_color_subtract (&op1, &op2, &res); clutter_color_subtract (&op1, &op2, &res);
g_assert_cmpint (clutter_color_to_pixel (&res), ==, 0x00ff00cc); g_assert_cmpuint (clutter_color_to_pixel (&res), ==, 0x00ff00cc);
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/color/hls-roundtrip", color_hls_roundtrip)
CLUTTER_TEST_UNIT ("/color/from-string/invalid", color_from_string_invalid)
CLUTTER_TEST_UNIT ("/color/from-string/valid", color_from_string_valid)
CLUTTER_TEST_UNIT ("/color/to-string", color_to_string)
CLUTTER_TEST_UNIT ("/color/operators", color_operators)
)

View file

@ -19,7 +19,6 @@
* *
*/ */
#include "config.h"
#include <clutter/clutter.h> #include <clutter/clutter.h>
#if defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2 #if defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2
@ -36,8 +35,6 @@
#include <clutter/x11/clutter-x11.h> #include <clutter/x11/clutter-x11.h>
#include "test-conform-common.h"
#define ABS_MAX_X 32768 #define ABS_MAX_X 32768
#define ABS_MAX_Y 32768 #define ABS_MAX_Y 32768
@ -360,7 +357,7 @@ error:
#endif /* defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2 */ #endif /* defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2 */
void static void
events_touch (void) events_touch (void)
{ {
#if defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2 #if defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2
@ -374,7 +371,7 @@ events_touch (void)
state.pass = TRUE; state.pass = TRUE;
state.gesture_points = 0; state.gesture_points = 0;
stage = clutter_stage_new (); stage = clutter_test_get_stage ();
g_signal_connect (stage, "event", G_CALLBACK (event_cb), &state); g_signal_connect (stage, "event", G_CALLBACK (event_cb), &state);
clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE); clutter_stage_set_fullscreen (CLUTTER_STAGE (stage), TRUE);
clutter_actor_show (stage); clutter_actor_show (stage);
@ -387,7 +384,9 @@ events_touch (void)
g_print ("end result: %s\n", state.pass ? "pass" : "FAIL"); g_print ("end result: %s\n", state.pass ? "pass" : "FAIL");
g_assert (state.pass); g_assert (state.pass);
clutter_actor_destroy (stage);
#endif /* defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2 */ #endif /* defined CLUTTER_WINDOWING_X11 && OS_LINUX && HAVE_XINPUT_2_2 */
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/events/touch", events_touch)
)

View file

@ -1,9 +1,8 @@
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h"
void static void
group_depth_sorting (TestConformSimpleFixture *fixture, group_depth_sorting (void)
gconstpointer data)
{ {
ClutterActor *group; ClutterActor *group;
ClutterActor *child, *test; ClutterActor *child, *test;
@ -55,3 +54,7 @@ group_depth_sorting (TestConformSimpleFixture *fixture,
clutter_actor_destroy (group); clutter_actor_destroy (group);
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/group/depth-sorting", group_depth_sorting)
)

View file

@ -1,10 +1,7 @@
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h" static void
interval_initial_state (void)
void
interval_initial_state (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
gconstpointer dummy G_GNUC_UNUSED)
{ {
ClutterInterval *interval; ClutterInterval *interval;
int initial, final; int initial, final;
@ -38,9 +35,8 @@ interval_initial_state (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
g_object_unref (interval); g_object_unref (interval);
} }
void static void
interval_transform (TestConformSimpleFixture *fixture G_GNUC_UNUSED, interval_transform (void)
gconstpointer dummy G_GNUC_UNUSED)
{ {
ClutterInterval *interval; ClutterInterval *interval;
GValue value = G_VALUE_INIT; GValue value = G_VALUE_INIT;
@ -68,3 +64,54 @@ interval_transform (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
g_object_unref (interval); g_object_unref (interval);
} }
static void
interval_from_script (void)
{
ClutterScript *script = clutter_script_new ();
ClutterInterval *interval;
gchar *test_file;
GError *error = NULL;
GValue *initial, *final;
test_file = g_test_build_filename (G_TEST_DIST,
"scripts",
"test-script-interval.json",
NULL);
clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error)
g_printerr ("\tError: %s", error->message);
g_assert_no_error (error);
interval = CLUTTER_INTERVAL (clutter_script_get_object (script, "int-1"));
initial = clutter_interval_peek_initial_value (interval);
if (g_test_verbose ())
g_test_message ("\tinitial ['%s'] = '%.2f'",
g_type_name (G_VALUE_TYPE (initial)),
g_value_get_float (initial));
g_assert (G_VALUE_HOLDS (initial, G_TYPE_FLOAT));
g_assert_cmpfloat (g_value_get_float (initial), ==, 23.3f);
final = clutter_interval_peek_final_value (interval);
if (g_test_verbose ())
g_test_message ("\tfinal ['%s'] = '%.2f'",
g_type_name (G_VALUE_TYPE (final)),
g_value_get_float (final));
g_assert (G_VALUE_HOLDS (final, G_TYPE_FLOAT));
g_assert_cmpfloat (g_value_get_float (final), ==, 42.2f);
interval = CLUTTER_INTERVAL (clutter_script_get_object (script, "int-2"));
initial = clutter_interval_peek_initial_value (interval);
g_assert (G_VALUE_HOLDS (initial, CLUTTER_TYPE_COLOR));
final = clutter_interval_peek_final_value (interval);
g_assert (G_VALUE_HOLDS (final, CLUTTER_TYPE_COLOR));
g_object_unref (script);
g_free (test_file);
}
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/interval/initial-state", interval_initial_state)
CLUTTER_TEST_UNIT ("/interval/transform", interval_transform)
CLUTTER_TEST_UNIT ("/interval/from-script", interval_from_script)
)

View file

@ -2,8 +2,6 @@
#include <string.h> #include <string.h>
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h"
typedef struct _ModelData typedef struct _ModelData
{ {
ClutterModel *model; ClutterModel *model;
@ -171,9 +169,8 @@ filter_odd_rows (ClutterModel *model,
return FALSE; return FALSE;
} }
void static void
list_model_filter (TestConformSimpleFixture *fixture, list_model_filter (void)
gconstpointer data)
{ {
ModelData test_data = { NULL, 0 }; ModelData test_data = { NULL, 0 };
ClutterModelIter *iter; ClutterModelIter *iter;
@ -259,9 +256,8 @@ list_model_filter (TestConformSimpleFixture *fixture,
g_object_unref (test_data.model); g_object_unref (test_data.model);
} }
void static void
list_model_iterate (TestConformSimpleFixture *fixture, list_model_iterate (void)
gconstpointer data)
{ {
ModelData test_data = { NULL, 0 }; ModelData test_data = { NULL, 0 };
ClutterModelIter *iter; ClutterModelIter *iter;
@ -334,9 +330,8 @@ list_model_iterate (TestConformSimpleFixture *fixture,
g_object_unref (test_data.model); g_object_unref (test_data.model);
} }
void static void
list_model_populate (TestConformSimpleFixture *fixture, list_model_populate (void)
gconstpointer data)
{ {
ModelData test_data = { NULL, 0 }; ModelData test_data = { NULL, 0 };
gint i; gint i;
@ -365,9 +360,8 @@ list_model_populate (TestConformSimpleFixture *fixture,
g_object_unref (test_data.model); g_object_unref (test_data.model);
} }
void static void
list_model_from_script (TestConformSimpleFixture *fixture, list_model_from_script (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
GObject *model; GObject *model;
@ -378,7 +372,7 @@ list_model_from_script (TestConformSimpleFixture *fixture,
ClutterModelIter *iter; ClutterModelIter *iter;
GValue value = { 0, }; GValue value = { 0, };
test_file = clutter_test_get_data_file ("test-script-model.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-model.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
@ -406,7 +400,7 @@ list_model_from_script (TestConformSimpleFixture *fixture,
g_print ("column[2]: %s, type: %s\n", name, g_type_name (type)); g_print ("column[2]: %s, type: %s\n", name, g_type_name (type));
g_assert (strcmp (name, "actor-column") == 0); g_assert (strcmp (name, "actor-column") == 0);
g_assert (type == CLUTTER_TYPE_RECTANGLE); g_assert (g_type_is_a (type, CLUTTER_TYPE_ACTOR));
g_assert (clutter_model_get_n_rows (CLUTTER_MODEL (model)) == 3); g_assert (clutter_model_get_n_rows (CLUTTER_MODEL (model)) == 3);
@ -429,13 +423,13 @@ list_model_from_script (TestConformSimpleFixture *fixture,
iter = clutter_model_iter_next (iter); iter = clutter_model_iter_next (iter);
clutter_model_iter_get_value (iter, 2, &value); clutter_model_iter_get_value (iter, 2, &value);
g_assert (G_VALUE_HOLDS_OBJECT (&value)); g_assert (G_VALUE_HOLDS_OBJECT (&value));
g_assert (CLUTTER_IS_RECTANGLE (g_value_get_object (&value))); g_assert (CLUTTER_IS_ACTOR (g_value_get_object (&value)));
g_value_unset (&value); g_value_unset (&value);
iter = clutter_model_iter_next (iter); iter = clutter_model_iter_next (iter);
clutter_model_iter_get_value (iter, 2, &value); clutter_model_iter_get_value (iter, 2, &value);
g_assert (G_VALUE_HOLDS_OBJECT (&value)); g_assert (G_VALUE_HOLDS_OBJECT (&value));
g_assert (CLUTTER_IS_RECTANGLE (g_value_get_object (&value))); g_assert (CLUTTER_IS_ACTOR (g_value_get_object (&value)));
g_assert (strcmp (clutter_actor_get_name (g_value_get_object (&value)), g_assert (strcmp (clutter_actor_get_name (g_value_get_object (&value)),
"actor-row-3") == 0); "actor-row-3") == 0);
g_value_unset (&value); g_value_unset (&value);
@ -460,9 +454,8 @@ on_row_changed (ClutterModel *model,
data->n_emissions += 1; data->n_emissions += 1;
} }
void static void
list_model_row_changed (TestConformSimpleFixture *fixture, list_model_row_changed (void)
gconstpointer data)
{ {
ChangedData test_data = { NULL, NULL, 0, 0 }; ChangedData test_data = { NULL, NULL, 0, 0 };
GValue value = { 0, }; GValue value = { 0, };
@ -524,3 +517,11 @@ list_model_row_changed (TestConformSimpleFixture *fixture,
g_object_unref (test_data.iter); g_object_unref (test_data.iter);
g_object_unref (test_data.model); g_object_unref (test_data.model);
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/list-model/populate", list_model_populate)
CLUTTER_TEST_UNIT ("/list-model/iterate", list_model_iterate)
CLUTTER_TEST_UNIT ("/list-model/filter", list_model_filter)
CLUTTER_TEST_UNIT ("/list-model/row-changed", list_model_row_changed)
CLUTTER_TEST_UNIT ("/list-model/from-script", list_model_from_script)
)

View file

@ -1,16 +1,8 @@
#include <stdio.h> #define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h" static void
rectangle_set_size (void)
void
rectangle_set_size (TestConformSimpleFixture *fixture,
gconstpointer data)
{ {
ClutterActor *rect = clutter_rectangle_new (); ClutterActor *rect = clutter_rectangle_new ();
@ -32,9 +24,8 @@ rectangle_set_size (TestConformSimpleFixture *fixture,
clutter_actor_destroy (rect); clutter_actor_destroy (rect);
} }
void static void
rectangle_set_color (TestConformSimpleFixture *fixture, rectangle_set_color (void)
gconstpointer data)
{ {
ClutterActor *rect = clutter_rectangle_new (); ClutterActor *rect = clutter_rectangle_new ();
ClutterColor white = { 255, 255, 255, 255 }; ClutterColor white = { 255, 255, 255, 255 };
@ -54,3 +45,7 @@ rectangle_set_color (TestConformSimpleFixture *fixture,
clutter_actor_destroy (rect); clutter_actor_destroy (rect);
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/rectangle/set-size", rectangle_set_size)
CLUTTER_TEST_UNIT ("/rectangle/set-color", rectangle_set_color)
)

View file

@ -1,8 +1,8 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <clutter/clutter.h>
#include "test-conform-common.h" #define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h>
#define TEST_TYPE_GROUP (test_group_get_type ()) #define TEST_TYPE_GROUP (test_group_get_type ())
#define TEST_TYPE_GROUP_META (test_group_meta_get_type ()) #define TEST_TYPE_GROUP_META (test_group_meta_get_type ())
@ -13,7 +13,8 @@
#define TEST_GROUP_META(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_GROUP_META, TestGroupMeta)) #define TEST_GROUP_META(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_GROUP_META, TestGroupMeta))
#define TEST_IS_GROUP_META(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_GROUP_META)) #define TEST_IS_GROUP_META(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TEST_TYPE_GROUP_META))
typedef struct _ClutterGroup TestGroup; typedef struct _ClutterActor TestGroup;
typedef struct _ClutterActorClass TestGroupClass;
typedef struct _TestGroupMeta { typedef struct _TestGroupMeta {
ClutterChildMeta parent_instance; ClutterChildMeta parent_instance;
@ -21,10 +22,11 @@ typedef struct _TestGroupMeta {
guint is_focus : 1; guint is_focus : 1;
} TestGroupMeta; } TestGroupMeta;
typedef struct _ClutterGroupClass TestGroupClass;
typedef struct _ClutterChildMetaClass TestGroupMetaClass; typedef struct _ClutterChildMetaClass TestGroupMetaClass;
G_DEFINE_TYPE (TestGroupMeta, test_group_meta, CLUTTER_TYPE_CHILD_META); GType test_group_meta_get_type (void);
G_DEFINE_TYPE (TestGroupMeta, test_group_meta, CLUTTER_TYPE_CHILD_META)
enum enum
{ {
@ -100,9 +102,11 @@ clutter_container_iface_init (ClutterContainerIface *iface)
iface->child_meta_type = TEST_TYPE_GROUP_META; iface->child_meta_type = TEST_TYPE_GROUP_META;
} }
G_DEFINE_TYPE_WITH_CODE (TestGroup, test_group, CLUTTER_TYPE_GROUP, GType test_group_get_type (void);
G_DEFINE_TYPE_WITH_CODE (TestGroup, test_group, CLUTTER_TYPE_ACTOR,
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER, G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
clutter_container_iface_init)); clutter_container_iface_init))
static void static void
test_group_class_init (TestGroupClass *klass) test_group_class_init (TestGroupClass *klass)
@ -114,9 +118,8 @@ test_group_init (TestGroup *self)
{ {
} }
void static void
script_child (TestConformSimpleFixture *fixture, script_child (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
GObject *container, *actor; GObject *container, *actor;
@ -124,16 +127,12 @@ script_child (TestConformSimpleFixture *fixture,
gboolean focus_ret; gboolean focus_ret;
gchar *test_file; gchar *test_file;
test_file = clutter_test_get_data_file ("test-script-child.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-child.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
container = actor = NULL; container = actor = NULL;
clutter_script_get_objects (script, clutter_script_get_objects (script,
@ -164,9 +163,8 @@ script_child (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
script_single (TestConformSimpleFixture *fixture, script_single (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
ClutterColor color = { 0, }; ClutterColor color = { 0, };
@ -175,16 +173,12 @@ script_single (TestConformSimpleFixture *fixture,
ClutterActor *rect; ClutterActor *rect;
gchar *test_file; gchar *test_file;
test_file = clutter_test_get_data_file ("test-script-single.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-single.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
actor = clutter_script_get_object (script, "test"); actor = clutter_script_get_object (script, "test");
g_assert (CLUTTER_IS_RECTANGLE (actor)); g_assert (CLUTTER_IS_RECTANGLE (actor));
@ -202,9 +196,8 @@ script_single (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
script_implicit_alpha (TestConformSimpleFixture *fixture, script_implicit_alpha (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
ClutterTimeline *timeline; ClutterTimeline *timeline;
@ -213,7 +206,7 @@ script_implicit_alpha (TestConformSimpleFixture *fixture,
ClutterAlpha *alpha; ClutterAlpha *alpha;
gchar *test_file; gchar *test_file;
test_file = clutter_test_get_data_file ("test-script-implicit-alpha.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-implicit-alpha.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
@ -241,9 +234,8 @@ script_implicit_alpha (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
script_object_property (TestConformSimpleFixture *fixture, script_object_property (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
@ -251,16 +243,12 @@ script_object_property (TestConformSimpleFixture *fixture,
GError *error = NULL; GError *error = NULL;
gchar *test_file; gchar *test_file;
test_file = clutter_test_get_data_file ("test-script-object-property.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-object-property.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
actor = clutter_script_get_object (script, "test"); actor = clutter_script_get_object (script, "test");
g_assert (CLUTTER_IS_BOX (actor)); g_assert (CLUTTER_IS_BOX (actor));
@ -272,9 +260,8 @@ script_object_property (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
script_named_object (TestConformSimpleFixture *fixture, script_named_object (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
ClutterLayoutManager *manager; ClutterLayoutManager *manager;
@ -282,16 +269,12 @@ script_named_object (TestConformSimpleFixture *fixture,
GError *error = NULL; GError *error = NULL;
gchar *test_file; gchar *test_file;
test_file = clutter_test_get_data_file ("test-script-named-object.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-named-object.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
actor = clutter_script_get_object (script, "test"); actor = clutter_script_get_object (script, "test");
g_assert (CLUTTER_IS_BOX (actor)); g_assert (CLUTTER_IS_BOX (actor));
@ -304,25 +287,20 @@ script_named_object (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
script_animation (TestConformSimpleFixture *fixture, script_animation (void)
gconstpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
GObject *animation = NULL; GObject *animation = NULL;
GError *error = NULL; GError *error = NULL;
gchar *test_file; gchar *test_file;
test_file = clutter_test_get_data_file ("test-script-animation.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-animation.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
animation = clutter_script_get_object (script, "test"); animation = clutter_script_get_object (script, "test");
g_assert (CLUTTER_IS_ANIMATION (animation)); g_assert (CLUTTER_IS_ANIMATION (animation));
@ -331,9 +309,8 @@ script_animation (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void static void
script_layout_property (TestConformSimpleFixture *fixture, script_layout_property (void)
gconstpointer dummy G_GNUC_UNUSED)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
GObject *manager, *container, *actor1, *actor2; GObject *manager, *container, *actor1, *actor2;
@ -342,16 +319,12 @@ script_layout_property (TestConformSimpleFixture *fixture,
gboolean x_fill, expand; gboolean x_fill, expand;
ClutterBoxAlignment y_align; ClutterBoxAlignment y_align;
test_file = clutter_test_get_data_file ("test-script-layout-property.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-layout-property.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
#if GLIB_CHECK_VERSION (2, 20, 0)
g_assert_no_error (error); g_assert_no_error (error);
#else
g_assert (error == NULL);
#endif
manager = container = actor1 = actor2 = NULL; manager = container = actor1 = actor2 = NULL;
clutter_script_get_objects (script, clutter_script_get_objects (script,
@ -399,16 +372,15 @@ script_layout_property (TestConformSimpleFixture *fixture,
g_object_unref (script); g_object_unref (script);
} }
void static void
script_margin (TestConformSimpleFixture *fixture, script_margin (void)
gpointer dummy)
{ {
ClutterScript *script = clutter_script_new (); ClutterScript *script = clutter_script_new ();
ClutterActor *actor; ClutterActor *actor;
gchar *test_file; gchar *test_file;
GError *error = NULL; GError *error = NULL;
test_file = clutter_test_get_data_file ("test-script-margin.json"); test_file = g_test_build_filename (G_TEST_DIST, "scripts", "test-script-margin.json", NULL);
clutter_script_load_from_file (script, test_file, &error); clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error) if (g_test_verbose () && error)
g_print ("Error: %s", error->message); g_print ("Error: %s", error->message);
@ -443,37 +415,13 @@ script_margin (TestConformSimpleFixture *fixture,
g_free (test_file); g_free (test_file);
} }
void CLUTTER_TEST_SUITE (
script_interval (TestConformSimpleFixture *fixture, CLUTTER_TEST_UNIT ("/script/single-object", script_single)
gpointer dummy) CLUTTER_TEST_UNIT ("/script/container-child", script_child)
{ CLUTTER_TEST_UNIT ("/script/named-object", script_named_object)
ClutterScript *script = clutter_script_new (); CLUTTER_TEST_UNIT ("/script/animation", script_animation)
ClutterInterval *interval; CLUTTER_TEST_UNIT ("/script/implicit-alpha", script_implicit_alpha)
gchar *test_file; CLUTTER_TEST_UNIT ("/script/object-property", script_object_property)
GError *error = NULL; CLUTTER_TEST_UNIT ("/script/layout-property", script_layout_property)
GValue *initial, *final; CLUTTER_TEST_UNIT ("/script/actor-margin", script_margin)
)
test_file = clutter_test_get_data_file ("test-script-interval.json");
clutter_script_load_from_file (script, test_file, &error);
if (g_test_verbose () && error)
g_print ("Error: %s", error->message);
g_assert_no_error (error);
interval = CLUTTER_INTERVAL (clutter_script_get_object (script, "int-1"));
initial = clutter_interval_peek_initial_value (interval);
g_assert (G_VALUE_HOLDS (initial, G_TYPE_FLOAT));
g_assert_cmpfloat (g_value_get_float (initial), ==, 23.3f);
final = clutter_interval_peek_final_value (interval);
g_assert (G_VALUE_HOLDS (final, G_TYPE_FLOAT));
g_assert_cmpfloat (g_value_get_float (final), ==, 42.2f);
interval = CLUTTER_INTERVAL (clutter_script_get_object (script, "int-2"));
initial = clutter_interval_peek_initial_value (interval);
g_assert (G_VALUE_HOLDS (initial, CLUTTER_TYPE_COLOR));
final = clutter_interval_peek_final_value (interval);
g_assert (G_VALUE_HOLDS (final, CLUTTER_TYPE_COLOR));
g_object_unref (script);
g_free (test_file);
}

View file

@ -2,8 +2,6 @@
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include <string.h> #include <string.h>
#include "test-conform-common.h"
typedef struct { typedef struct {
gunichar unichar; gunichar unichar;
const char bytes[6]; const char bytes[6];
@ -16,7 +14,7 @@ test_text_data[] = {
{ 0x2665, "\xe2\x99\xa5", 3 } /* BLACK HEART SUIT */ { 0x2665, "\xe2\x99\xa5", 3 } /* BLACK HEART SUIT */
}; };
void static void
text_utf8_validation (void) text_utf8_validation (void)
{ {
int i; int i;
@ -32,11 +30,11 @@ text_utf8_validation (void)
nbytes = g_unichar_to_utf8 (t->unichar, bytes); nbytes = g_unichar_to_utf8 (t->unichar, bytes);
bytes[nbytes] = '\0'; bytes[nbytes] = '\0';
g_assert (nbytes == t->nbytes); g_assert_cmpint (nbytes, ==, t->nbytes);
g_assert (memcmp (t->bytes, bytes, nbytes) == 0); g_assert (memcmp (t->bytes, bytes, nbytes) == 0);
unichar = g_utf8_get_char_validated (bytes, nbytes); unichar = g_utf8_get_char_validated (bytes, nbytes);
g_assert (unichar == t->unichar); g_assert_cmpint (unichar, ==, t->unichar);
} }
} }
@ -69,10 +67,11 @@ insert_unichar (ClutterText *text, gunichar unichar, int position)
clutter_text_insert_unichar (text, unichar); clutter_text_insert_unichar (text, unichar);
} }
void static void
text_set_empty (void) text_set_empty (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
g_object_ref_sink (text);
g_assert_cmpstr (clutter_text_get_text (text), ==, ""); g_assert_cmpstr (clutter_text_get_text (text), ==, "");
g_assert_cmpint (*clutter_text_get_text (text), ==, '\0'); g_assert_cmpint (*clutter_text_get_text (text), ==, '\0');
@ -86,10 +85,11 @@ text_set_empty (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_set_text (void) text_set_text (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
g_object_ref_sink (text);
clutter_text_set_text (text, "abcdef"); clutter_text_set_text (text, "abcdef");
g_assert_cmpint (get_nchars (text), ==, 6); g_assert_cmpint (get_nchars (text), ==, 6);
@ -107,12 +107,14 @@ text_set_text (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_append_some (void) text_append_some (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i; int i;
g_object_ref_sink (text);
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++) for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{ {
const TestData *t = &test_text_data[i]; const TestData *t = &test_text_data[i];
@ -133,12 +135,14 @@ text_append_some (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_prepend_some (void) text_prepend_some (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i; int i;
g_object_ref_sink (text);
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++) for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{ {
const TestData *t = &test_text_data[i]; const TestData *t = &test_text_data[i];
@ -165,12 +169,14 @@ text_prepend_some (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_insert (void) text_insert (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i; int i;
g_object_ref_sink (text);
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++) for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{ {
const TestData *t = &test_text_data[i]; const TestData *t = &test_text_data[i];
@ -190,12 +196,14 @@ text_insert (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_delete_chars (void) text_delete_chars (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i; int i;
g_object_ref_sink (text);
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++) for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{ {
const TestData *t = &test_text_data[i]; const TestData *t = &test_text_data[i];
@ -222,12 +230,14 @@ text_delete_chars (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_get_chars (void) text_get_chars (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
gchar *chars; gchar *chars;
g_object_ref_sink (text);
clutter_text_set_text (text, "00abcdef11"); clutter_text_set_text (text, "00abcdef11");
g_assert_cmpint (get_nchars (text), ==, 10); g_assert_cmpint (get_nchars (text), ==, 10);
g_assert_cmpint (get_nbytes (text), ==, 10); g_assert_cmpint (get_nbytes (text), ==, 10);
@ -252,12 +262,14 @@ text_get_chars (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_delete_text (void) text_delete_text (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i; int i;
g_object_ref_sink (text);
for (i = 0; i < G_N_ELEMENTS (test_text_data); i++) for (i = 0; i < G_N_ELEMENTS (test_text_data); i++)
{ {
const TestData *t = &test_text_data[i]; const TestData *t = &test_text_data[i];
@ -282,11 +294,13 @@ text_delete_text (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_password_char (void) text_password_char (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
g_object_ref_sink (text);
g_assert_cmpint (clutter_text_get_password_char (text), ==, 0); g_assert_cmpint (clutter_text_get_password_char (text), ==, 0);
clutter_text_set_text (text, "hello"); clutter_text_set_text (text, "hello");
@ -339,12 +353,14 @@ send_unichar (ClutterText *text, gunichar unichar)
clutter_event_free (event); clutter_event_free (event);
} }
void static void
text_cursor (void) text_cursor (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i; int i;
g_object_ref_sink (text);
/* only editable entries listen to events */ /* only editable entries listen to events */
clutter_text_set_editable (text, TRUE); clutter_text_set_editable (text, TRUE);
@ -385,12 +401,14 @@ text_cursor (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
void static void
text_event (void) text_event (void)
{ {
ClutterText *text = CLUTTER_TEXT (clutter_text_new ()); ClutterText *text = CLUTTER_TEXT (clutter_text_new ());
int i; int i;
g_object_ref_sink (text);
/* only editable entries listen to events */ /* only editable entries listen to events */
clutter_text_set_editable (text, TRUE); clutter_text_set_editable (text, TRUE);
@ -449,7 +467,7 @@ validate_markup_attributes (ClutterText *text,
pango_attr_iterator_destroy (iter); pango_attr_iterator_destroy (iter);
} }
void static void
text_idempotent_use_markup (void) text_idempotent_use_markup (void)
{ {
ClutterText *text; ClutterText *text;
@ -465,6 +483,7 @@ text_idempotent_use_markup (void)
text = g_object_new (CLUTTER_TYPE_TEXT, text = g_object_new (CLUTTER_TYPE_TEXT,
"text", contents, "use-markup", TRUE, "text", contents, "use-markup", TRUE,
NULL); NULL);
g_object_ref_sink (text);
if (g_test_verbose ()) if (g_test_verbose ())
g_print ("Contents: '%s' (expected: '%s')\n", g_print ("Contents: '%s' (expected: '%s')\n",
@ -502,3 +521,19 @@ text_idempotent_use_markup (void)
clutter_actor_destroy (CLUTTER_ACTOR (text)); clutter_actor_destroy (CLUTTER_ACTOR (text));
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/text/utf8-validation", text_utf8_validation)
CLUTTER_TEST_UNIT ("/text/set-empty", text_set_empty)
CLUTTER_TEST_UNIT ("/text/set-text", text_set_text)
CLUTTER_TEST_UNIT ("/text/append-some", text_append_some)
CLUTTER_TEST_UNIT ("/text/prepend-some", text_prepend_some)
CLUTTER_TEST_UNIT ("/text/insert", text_insert)
CLUTTER_TEST_UNIT ("/text/delete-chars", text_delete_chars)
CLUTTER_TEST_UNIT ("/text/get-chars", text_get_chars)
CLUTTER_TEST_UNIT ("/text/delete-text", text_delete_text)
CLUTTER_TEST_UNIT ("/text/password-char", text_password_char)
CLUTTER_TEST_UNIT ("/text/cursor", text_cursor)
CLUTTER_TEST_UNIT ("/text/event", text_event)
CLUTTER_TEST_UNIT ("/text/idempotent-use-markup", text_idempotent_use_markup)
)

View file

@ -1,9 +1,7 @@
#include <glib.h> #define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include <string.h> #include <string.h>
#include "test-conform-common.h"
static CoglHandle static CoglHandle
make_texture (void) make_texture (void)
{ {
@ -28,17 +26,16 @@ make_texture (void)
(guchar *)data); (guchar *)data);
} }
void static void
texture_pick_with_alpha (TestConformSimpleFixture *fixture, texture_pick_with_alpha (void)
gconstpointer data)
{ {
ClutterTexture *tex = CLUTTER_TEXTURE (clutter_texture_new ()); ClutterTexture *tex = CLUTTER_TEXTURE (clutter_texture_new ());
ClutterStage *stage = CLUTTER_STAGE (clutter_stage_new ()); ClutterStage *stage = CLUTTER_STAGE (clutter_test_get_stage ());
ClutterActor *actor; ClutterActor *actor;
clutter_texture_set_cogl_texture (tex, make_texture ()); clutter_texture_set_cogl_texture (tex, make_texture ());
clutter_container_add_actor (CLUTTER_CONTAINER (stage), CLUTTER_ACTOR (tex)); clutter_actor_add_child (CLUTTER_ACTOR (stage), CLUTTER_ACTOR (tex));
clutter_actor_show (CLUTTER_ACTOR (stage)); clutter_actor_show (CLUTTER_ACTOR (stage));
@ -80,10 +77,8 @@ texture_pick_with_alpha (TestConformSimpleFixture *fixture,
if (g_test_verbose ()) if (g_test_verbose ())
g_print ("actor @ (10, 10) = %p\n", actor); g_print ("actor @ (10, 10) = %p\n", actor);
g_assert (actor == CLUTTER_ACTOR (tex)); g_assert (actor == CLUTTER_ACTOR (tex));
clutter_actor_destroy (CLUTTER_ACTOR (stage));
if (g_test_verbose ())
g_print ("OK\n");
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/texture/pick-with-alpha", texture_pick_with_alpha)
)

View file

@ -1,11 +1,7 @@
#include <stdio.h>
#include <clutter/clutter.h> #include <clutter/clutter.h>
#include "test-conform-common.h" static void
units_cache (void)
void
units_cache (TestConformSimpleFixture *fixture,
gconstpointer data)
{ {
ClutterUnits units; ClutterUnits units;
ClutterSettings *settings; ClutterSettings *settings;
@ -28,9 +24,8 @@ units_cache (TestConformSimpleFixture *fixture,
g_object_set (settings, "font-dpi", old_dpi, NULL); g_object_set (settings, "font-dpi", old_dpi, NULL);
} }
void static void
units_constructors (TestConformSimpleFixture *fixture, units_constructors (void)
gconstpointer data)
{ {
ClutterUnits units, units_cm; ClutterUnits units, units_cm;
@ -56,9 +51,8 @@ units_constructors (TestConformSimpleFixture *fixture,
clutter_units_to_pixels (&units_cm)); clutter_units_to_pixels (&units_cm));
} }
void static void
units_string (TestConformSimpleFixture *fixture, units_string (void)
gconstpointer data)
{ {
ClutterUnits units; ClutterUnits units;
gchar *string; gchar *string;
@ -129,3 +123,9 @@ units_string (TestConformSimpleFixture *fixture,
g_free (string); g_free (string);
} }
CLUTTER_TEST_SUITE (
CLUTTER_TEST_UNIT ("/units/string", units_string)
CLUTTER_TEST_UNIT ("/units/cache", units_cache)
CLUTTER_TEST_UNIT ("/units/constructors", units_constructors)
)