[clutter/clutter-1.18] conformance: Add actor tests
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter/clutter-1.18] conformance: Add actor tests
- Date: Thu, 12 Dec 2013 19:09:50 +0000 (UTC)
commit 7ec337f26f242db18039c67c5e0b046f818434cc
Author: Emmanuele Bassi <ebassi gnome org>
Date: Thu Dec 12 14:51:00 2013 +0000
conformance: Add actor tests
Port the ClutterActor tests to the test API, and ensure they run under
the new TAP harness.
tests/conform/Makefile.am | 13 ++
tests/conform/actor-anchors.c | 53 +++++-
tests/conform/actor-destroy.c | 17 ++-
tests/conform/actor-graph.c | 119 +++++++++---
tests/conform/actor-invariants.c | 206 +++++----------------
tests/conform/actor-iter.c | 22 ++-
tests/conform/actor-layout.c | 239 +++---------------------
tests/conform/actor-meta.c | 15 +-
tests/conform/actor-offscreen-limit-max-size.c | 128 +++++++------
tests/conform/actor-offscreen-redirect.c | 25 +--
tests/conform/actor-paint-opacity.c | 43 ++---
tests/conform/actor-pick.c | 40 ++--
tests/conform/actor-shader-effect.c | 41 +++--
tests/conform/actor-size.c | 13 +-
14 files changed, 412 insertions(+), 562 deletions(-)
---
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
index d0497d1..996dfd8 100644
--- a/tests/conform/Makefile.am
+++ b/tests/conform/Makefile.am
@@ -13,6 +13,19 @@ AM_CPPFLAGS = \
$(CLUTTER_PROFILE_CFLAGS)
actor_tests = \
+ actor-anchors \
+ actor-destroy \
+ actor-graph \
+ actor-invariants \
+ actor-iter \
+ actor-layout \
+ actor-meta \
+ actor-offscreen-limit-max-size \
+ actor-offscreen-redirect \
+ actor-paint-opacity \
+ actor-pick \
+ actor-shader-effect \
+ actor-size \
$(NULL)
general_tests = \
diff --git a/tests/conform/actor-anchors.c b/tests/conform/actor-anchors.c
index 42e23ce..ee3b6a5 100644
--- a/tests/conform/actor-anchors.c
+++ b/tests/conform/actor-anchors.c
@@ -1,8 +1,8 @@
-#include <clutter/clutter.h>
#include <stdlib.h>
#include <string.h>
-#include "test-conform-common.h"
+#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
+#include <clutter/clutter.h>
#define NOTIFY_ANCHOR_X (1 << 0)
#define NOTIFY_ANCHOR_Y (1 << 1)
@@ -671,16 +671,16 @@ idle_cb (gpointer data)
return G_SOURCE_REMOVE;
}
-void
+static void
actor_anchors (void)
{
TestState state;
ClutterActor *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
- state.rect = clutter_rectangle_new ();
- clutter_container_add (CLUTTER_CONTAINER (stage), state.rect, NULL);
+ state.rect = clutter_actor_new ();
+ clutter_actor_add_child (stage, state.rect);
clutter_actor_set_position (state.rect, 100, 200);
clutter_actor_set_size (state.rect, RECT_WIDTH, RECT_HEIGHT);
@@ -696,9 +696,46 @@ actor_anchors (void)
clutter_actor_show (stage);
clutter_main ();
+}
+
+static void
+actor_pivot (void)
+{
+ ClutterActor *stage, *actor_implicit, *actor_explicit;
+ ClutterMatrix transform, result_implicit, result_explicit;
+ ClutterActorBox allocation = CLUTTER_ACTOR_BOX_INIT (0, 0, 90, 30);
+ gfloat angle = 30;
+
+ stage = clutter_test_get_stage ();
+
+ actor_implicit = clutter_actor_new ();
+ actor_explicit = clutter_actor_new ();
+
+ clutter_actor_add_child (stage, actor_implicit);
+ clutter_actor_add_child (stage, actor_explicit);
+
+ /* Fake allocation or pivot-point will not have any effect */
+ clutter_actor_allocate (actor_implicit, &allocation, CLUTTER_ALLOCATION_NONE);
+ clutter_actor_allocate (actor_explicit, &allocation, CLUTTER_ALLOCATION_NONE);
+
+ clutter_actor_set_pivot_point (actor_implicit, 0.5, 0.5);
+ clutter_actor_set_pivot_point (actor_explicit, 0.5, 0.5);
+
+ /* Implict transformation */
+ clutter_actor_set_rotation_angle (actor_implicit, CLUTTER_Z_AXIS, angle);
+
+ /* Explict transformation */
+ clutter_matrix_init_identity(&transform);
+ cogl_matrix_rotate (&transform, angle, 0, 0, 1.0);
+ clutter_actor_set_transform (actor_explicit, &transform);
- g_idle_remove_by_data (&state);
+ clutter_actor_get_transform (actor_implicit, &result_implicit);
+ clutter_actor_get_transform (actor_explicit, &result_explicit);
- clutter_actor_destroy (stage);
+ g_assert (cogl_matrix_equal (&result_implicit, &result_explicit));
}
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/transforms/anchor-point", actor_anchors)
+ CLUTTER_TEST_UNIT ("/actor/transforms/pivot-point", actor_pivot)
+)
diff --git a/tests/conform/actor-destroy.c b/tests/conform/actor-destroy.c
index eed2aa6..03092a0 100644
--- a/tests/conform/actor-destroy.c
+++ b/tests/conform/actor-destroy.c
@@ -1,5 +1,5 @@
+#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h>
-#include "test-conform-common.h"
#define TEST_TYPE_DESTROY (test_destroy_get_type ())
#define TEST_DESTROY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TEST_TYPE_DESTROY, TestDestroy))
@@ -26,6 +26,8 @@ struct _TestDestroyClass
static void clutter_container_init (ClutterContainerIface *iface);
+GType test_destroy_get_type (void);
+
G_DEFINE_TYPE_WITH_CODE (TestDestroy, test_destroy, CLUTTER_TYPE_ACTOR,
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTAINER,
clutter_container_init));
@@ -160,13 +162,18 @@ on_destroy (ClutterActor *actor,
*destroy_called = TRUE;
}
-void
+static void
actor_destruction (void)
{
ClutterActor *test = g_object_new (TEST_TYPE_DESTROY, NULL);
ClutterActor *child = clutter_rectangle_new ();
gboolean destroy_called = FALSE;
+ g_object_ref_sink (test);
+
+ g_object_add_weak_pointer (G_OBJECT (test), (gpointer *) &test);
+ g_object_add_weak_pointer (G_OBJECT (child), (gpointer *) &child);
+
if (g_test_verbose ())
g_print ("Adding external child...\n");
@@ -179,4 +186,10 @@ actor_destruction (void)
clutter_actor_destroy (test);
g_assert (destroy_called);
+ g_assert_null (child);
+ g_assert_null (test);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/destruction", actor_destruction)
+)
diff --git a/tests/conform/actor-graph.c b/tests/conform/actor-graph.c
index 81b31f4..22a28a6 100644
--- a/tests/conform/actor-graph.c
+++ b/tests/conform/actor-graph.c
@@ -1,9 +1,7 @@
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-void
-actor_add_child (TestConformSimpleFixture *fixture,
- gconstpointer dummy)
+static void
+actor_add_child (void)
{
ClutterActor *actor = clutter_actor_new ();
ClutterActor *iter;
@@ -49,9 +47,8 @@ actor_add_child (TestConformSimpleFixture *fixture,
g_assert (actor == NULL);
}
-void
-actor_insert_child (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_insert_child (void)
{
ClutterActor *actor = clutter_actor_new ();
ClutterActor *iter;
@@ -137,9 +134,8 @@ actor_insert_child (TestConformSimpleFixture *fixture,
g_assert (actor == NULL);
}
-void
-actor_remove_child (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_remove_child (void)
{
ClutterActor *actor = clutter_actor_new ();
ClutterActor *iter;
@@ -182,9 +178,8 @@ actor_remove_child (TestConformSimpleFixture *fixture,
g_assert (actor == NULL);
}
-void
-actor_raise_child (TestConformSimpleFixture *fixture,
- gconstpointer dummy)
+static void
+actor_raise_child (void)
{
ClutterActor *actor = clutter_actor_new ();
ClutterActor *iter;
@@ -249,9 +244,8 @@ actor_raise_child (TestConformSimpleFixture *fixture,
g_assert (iter == NULL);
}
-void
-actor_lower_child (TestConformSimpleFixture *fixture,
- gconstpointer dummy)
+static void
+actor_lower_child (void)
{
ClutterActor *actor = clutter_actor_new ();
ClutterActor *iter;
@@ -314,9 +308,8 @@ actor_lower_child (TestConformSimpleFixture *fixture,
g_assert (actor == NULL);
}
-void
-actor_replace_child (TestConformSimpleFixture *fixture,
- gconstpointer dummy)
+static void
+actor_replace_child (void)
{
ClutterActor *actor = clutter_actor_new ();
ClutterActor *iter;
@@ -375,9 +368,8 @@ actor_replace_child (TestConformSimpleFixture *fixture,
g_assert (actor == NULL);
}
-void
-actor_remove_all (TestConformSimpleFixture *fixture,
- gconstpointer dummy)
+static void
+actor_remove_all (void)
{
ClutterActor *actor = clutter_actor_new ();
@@ -436,9 +428,8 @@ actor_removed (ClutterContainer *container,
*counter += 1;
}
-void
-actor_container_signals (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
- gconstpointer data G_GNUC_UNUSED)
+static void
+actor_container_signals (void)
{
ClutterActor *actor = clutter_actor_new ();
int add_count, remove_count;
@@ -478,3 +469,81 @@ actor_container_signals (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
clutter_actor_destroy (actor);
g_assert (actor == NULL);
}
+
+static void
+actor_contains (void)
+{
+ /* This build up the following tree:
+ *
+ * a
+ * ╱ │ ╲
+ * ╱ │ ╲
+ * b c d
+ * ╱ ╲ ╱ ╲ ╱ ╲
+ * e f g h i j
+ */
+ struct {
+ ClutterActor *actor_a, *actor_b, *actor_c, *actor_d, *actor_e;
+ ClutterActor *actor_f, *actor_g, *actor_h, *actor_i, *actor_j;
+ } d;
+ int x, y;
+ ClutterActor **actor_array = &d.actor_a;
+
+ /* Matrix of expected results */
+ static const gboolean expected_results[] =
+ { /* a, b, c, d, e, f, g, h, i, j */
+ /* a */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ /* b */ 0, 1, 0, 0, 1, 1, 0, 0, 0, 0,
+ /* c */ 0, 0, 1, 0, 0, 0, 1, 1, 0, 0,
+ /* d */ 0, 0, 0, 1, 0, 0, 0, 0, 1, 1,
+ /* e */ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
+ /* f */ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
+ /* g */ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
+ /* h */ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
+ /* i */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
+ /* j */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
+ };
+
+ d.actor_a = clutter_actor_new ();
+ d.actor_b = clutter_actor_new ();
+ d.actor_c = clutter_actor_new ();
+ d.actor_d = clutter_actor_new ();
+ d.actor_e = clutter_actor_new ();
+ d.actor_f = clutter_actor_new ();
+ d.actor_g = clutter_actor_new ();
+ d.actor_h = clutter_actor_new ();
+ d.actor_i = clutter_actor_new ();
+ d.actor_j = clutter_actor_new ();
+
+ clutter_actor_add_child (d.actor_a, d.actor_b);
+ clutter_actor_add_child (d.actor_a, d.actor_c);
+ clutter_actor_add_child (d.actor_a, d.actor_d);
+
+ clutter_actor_add_child (d.actor_b, d.actor_e);
+ clutter_actor_add_child (d.actor_b, d.actor_f);
+
+ clutter_actor_add_child (d.actor_c, d.actor_g);
+ clutter_actor_add_child (d.actor_c, d.actor_h);
+
+ clutter_actor_add_child (d.actor_d, d.actor_i);
+ clutter_actor_add_child (d.actor_d, d.actor_j);
+
+ for (y = 0; y < 10; y++)
+ for (x = 0; x < 10; x++)
+ g_assert_cmpint (clutter_actor_contains (actor_array[x],
+ actor_array[y]),
+ ==,
+ expected_results[x * 10 + y]);
+}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/graph/add-child", actor_add_child)
+ CLUTTER_TEST_UNIT ("/actor/graph/insert-child", actor_insert_child)
+ CLUTTER_TEST_UNIT ("/actor/graph/remove-child", actor_remove_child)
+ CLUTTER_TEST_UNIT ("/actor/graph/raise-child", actor_raise_child)
+ CLUTTER_TEST_UNIT ("/actor/graph/lower-child", actor_lower_child)
+ CLUTTER_TEST_UNIT ("/actor/graph/replace-child", actor_replace_child)
+ CLUTTER_TEST_UNIT ("/actor/graph/remove-all", actor_remove_all)
+ CLUTTER_TEST_UNIT ("/actor/graph/container-signals", actor_container_signals)
+ CLUTTER_TEST_UNIT ("/actor/graph/contains", actor_contains)
+)
diff --git a/tests/conform/actor-invariants.c b/tests/conform/actor-invariants.c
index eb62239..cdab5d5 100644
--- a/tests/conform/actor-invariants.c
+++ b/tests/conform/actor-invariants.c
@@ -3,11 +3,8 @@
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
-void
-actor_initial_state (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_initial_state (void)
{
ClutterActor *actor;
@@ -29,13 +26,12 @@ actor_initial_state (TestConformSimpleFixture *fixture,
g_assert (actor == NULL);
}
-void
-actor_shown_not_parented (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_shown_not_parented (void)
{
ClutterActor *actor;
- actor = clutter_rectangle_new ();
+ actor = clutter_actor_new ();
g_object_ref_sink (actor);
g_object_add_weak_pointer (G_OBJECT (actor), (gpointer *) &actor);
@@ -55,14 +51,13 @@ actor_shown_not_parented (TestConformSimpleFixture *fixture,
g_assert (actor == NULL);
}
-void
-actor_realized (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_realized (void)
{
ClutterActor *actor;
ClutterActor *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
actor = clutter_actor_new ();
@@ -76,18 +71,15 @@ actor_realized (TestConformSimpleFixture *fixture,
g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor)));
g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor)));
-
- clutter_actor_destroy (stage);
}
-void
-actor_mapped (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_mapped (void)
{
ClutterActor *actor;
ClutterActor *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
clutter_actor_show (stage);
actor = clutter_actor_new ();
@@ -120,18 +112,16 @@ actor_mapped (TestConformSimpleFixture *fixture,
g_assert (CLUTTER_ACTOR_IS_REALIZED (actor));
g_assert (!CLUTTER_ACTOR_IS_MAPPED (actor));
g_assert (!CLUTTER_ACTOR_IS_VISIBLE (actor));
-
- clutter_actor_destroy (stage);
}
-void
-actor_visibility_not_recursive (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_visibility_not_recursive (void)
{
ClutterActor *actor, *group;
ClutterActor *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
+
group = clutter_actor_new ();
actor = clutter_actor_new ();
@@ -162,18 +152,15 @@ actor_visibility_not_recursive (TestConformSimpleFixture *fixture,
clutter_actor_show (stage);
g_assert (!CLUTTER_ACTOR_IS_VISIBLE (actor));
-
- clutter_actor_destroy (stage);
}
-void
-actor_realize_not_recursive (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_realize_not_recursive (void)
{
ClutterActor *actor, *group;
ClutterActor *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
clutter_actor_show (stage);
group = clutter_actor_new ();
@@ -200,18 +187,15 @@ actor_realize_not_recursive (TestConformSimpleFixture *fixture,
g_assert (!CLUTTER_ACTOR_IS_REALIZED (actor));
g_assert (!(CLUTTER_ACTOR_IS_MAPPED (actor)));
g_assert (!(CLUTTER_ACTOR_IS_VISIBLE (actor)));
-
- clutter_actor_destroy (stage);
}
-void
-actor_map_recursive (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_map_recursive (void)
{
ClutterActor *actor, *group;
ClutterActor *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
clutter_actor_show (stage);
group = clutter_actor_new ();
@@ -248,19 +232,16 @@ actor_map_recursive (TestConformSimpleFixture *fixture,
g_assert (CLUTTER_ACTOR_IS_MAPPED (actor));
g_assert (CLUTTER_ACTOR_IS_VISIBLE (group));
g_assert (CLUTTER_ACTOR_IS_VISIBLE (actor));
-
- clutter_actor_destroy (stage);
}
-void
-actor_show_on_set_parent (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_show_on_set_parent (void)
{
ClutterActor *actor, *group;
gboolean show_on_set_parent;
ClutterActor *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
group = clutter_actor_new ();
@@ -321,20 +302,17 @@ actor_show_on_set_parent (TestConformSimpleFixture *fixture,
g_assert (!show_on_set_parent);
clutter_actor_destroy (actor);
-
- clutter_actor_destroy (stage);
}
-void
-clone_no_map (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+clone_no_map (void)
{
ClutterActor *stage;
ClutterActor *group;
ClutterActor *actor;
ClutterActor *clone;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
clutter_actor_show (stage);
group = clutter_actor_new ();
@@ -358,83 +336,15 @@ clone_no_map (TestConformSimpleFixture *fixture,
clutter_actor_destroy (CLUTTER_ACTOR (clone));
clutter_actor_destroy (CLUTTER_ACTOR (group));
- clutter_actor_destroy (stage);
-}
-
-void
-actor_contains (TestConformSimpleFixture *fixture,
- gconstpointer data)
-{
- /* This build up the following tree:
- *
- * a
- * ╱ │ ╲
- * ╱ │ ╲
- * b c d
- * ╱ ╲ ╱ ╲ ╱ ╲
- * e f g h i j
- */
- struct {
- ClutterActor *actor_a, *actor_b, *actor_c, *actor_d, *actor_e;
- ClutterActor *actor_f, *actor_g, *actor_h, *actor_i, *actor_j;
- } d;
- int x, y;
- ClutterActor **actor_array = &d.actor_a;
-
- /* Matrix of expected results */
- static const gboolean expected_results[] =
- { /* a, b, c, d, e, f, g, h, i, j */
- /* a */ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- /* b */ 0, 1, 0, 0, 1, 1, 0, 0, 0, 0,
- /* c */ 0, 0, 1, 0, 0, 0, 1, 1, 0, 0,
- /* d */ 0, 0, 0, 1, 0, 0, 0, 0, 1, 1,
- /* e */ 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
- /* f */ 0, 0, 0, 0, 0, 1, 0, 0, 0, 0,
- /* g */ 0, 0, 0, 0, 0, 0, 1, 0, 0, 0,
- /* h */ 0, 0, 0, 0, 0, 0, 0, 1, 0, 0,
- /* i */ 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
- /* j */ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
- };
-
- d.actor_a = clutter_actor_new ();
- d.actor_b = clutter_actor_new ();
- d.actor_c = clutter_actor_new ();
- d.actor_d = clutter_actor_new ();
- d.actor_e = clutter_actor_new ();
- d.actor_f = clutter_actor_new ();
- d.actor_g = clutter_actor_new ();
- d.actor_h = clutter_actor_new ();
- d.actor_i = clutter_actor_new ();
- d.actor_j = clutter_actor_new ();
-
- clutter_actor_add_child (d.actor_a, d.actor_b);
- clutter_actor_add_child (d.actor_a, d.actor_c);
- clutter_actor_add_child (d.actor_a, d.actor_d);
-
- clutter_actor_add_child (d.actor_b, d.actor_e);
- clutter_actor_add_child (d.actor_b, d.actor_f);
-
- clutter_actor_add_child (d.actor_c, d.actor_g);
- clutter_actor_add_child (d.actor_c, d.actor_h);
-
- clutter_actor_add_child (d.actor_d, d.actor_i);
- clutter_actor_add_child (d.actor_d, d.actor_j);
-
- for (y = 0; y < 10; y++)
- for (x = 0; x < 10; x++)
- g_assert_cmpint (clutter_actor_contains (actor_array[x],
- actor_array[y]),
- ==,
- expected_results[x * 10 + y]);
}
-void
-default_stage (TestConformSimpleFixture *fixture,
- gconstpointer data)
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+static void
+default_stage (void)
{
ClutterActor *stage, *def_stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
def_stage = clutter_stage_get_default ();
if (clutter_feature_available (CLUTTER_FEATURE_STAGE_MULTIPLE))
@@ -444,43 +354,17 @@ default_stage (TestConformSimpleFixture *fixture,
g_assert (CLUTTER_ACTOR_IS_REALIZED (def_stage));
}
-
-void
-actor_pivot_transformation (TestConformSimpleFixture *fixture,
- gconstpointer data)
-{
- ClutterActor *stage, *actor_implicit, *actor_explicit;
- ClutterMatrix transform, result_implicit, result_explicit;
- ClutterActorBox allocation = CLUTTER_ACTOR_BOX_INIT (0, 0, 90, 30);
- gfloat angle = 30;
-
- stage = clutter_stage_new ();
-
- actor_implicit = clutter_actor_new ();
- actor_explicit = clutter_actor_new ();
-
- clutter_actor_add_child (stage, actor_implicit);
- clutter_actor_add_child (stage, actor_explicit);
-
- /* Fake allocation or pivot-point will not have any effect */
- clutter_actor_allocate (actor_implicit, &allocation, CLUTTER_ALLOCATION_NONE);
- clutter_actor_allocate (actor_explicit, &allocation, CLUTTER_ALLOCATION_NONE);
-
- clutter_actor_set_pivot_point (actor_implicit, 0.5, 0.5);
- clutter_actor_set_pivot_point (actor_explicit, 0.5, 0.5);
-
- /* Implict transformation */
- clutter_actor_set_rotation_angle (actor_implicit, CLUTTER_Z_AXIS, angle);
-
- /* Explict transformation */
- clutter_matrix_init_identity(&transform);
- cogl_matrix_rotate (&transform, angle, 0, 0, 1.0);
- clutter_actor_set_transform (actor_explicit, &transform);
-
- clutter_actor_get_transform (actor_implicit, &result_implicit);
- clutter_actor_get_transform (actor_explicit, &result_explicit);
-
- clutter_actor_destroy (stage);
-
- g_assert (cogl_matrix_equal (&result_implicit, &result_explicit));
-}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/invariants/initial-state", actor_initial_state)
+ CLUTTER_TEST_UNIT ("/actor/invariants/show-not-parented", actor_shown_not_parented)
+ CLUTTER_TEST_UNIT ("/actor/invariants/realized", actor_realized)
+ CLUTTER_TEST_UNIT ("/actor/invariants/mapped", actor_mapped)
+ CLUTTER_TEST_UNIT ("/actor/invariants/visibility-not-recursive", actor_visibility_not_recursive)
+ CLUTTER_TEST_UNIT ("/actor/invariants/realize-not-recursive", actor_realize_not_recursive)
+ CLUTTER_TEST_UNIT ("/actor/invariants/map-recursive", actor_map_recursive)
+ CLUTTER_TEST_UNIT ("/actor/invariants/show-on-set-parent", actor_show_on_set_parent)
+ CLUTTER_TEST_UNIT ("/actor/invariants/clone-no-map", clone_no_map)
+ CLUTTER_TEST_UNIT ("/actor/invariants/default-stage", default_stage)
+)
diff --git a/tests/conform/actor-iter.c b/tests/conform/actor-iter.c
index 4c55079..193f63b 100644
--- a/tests/conform/actor-iter.c
+++ b/tests/conform/actor-iter.c
@@ -1,10 +1,8 @@
#include <glib.h>
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-void
-actor_iter_traverse_children (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
- gconstpointer dummy G_GNUC_UNUSED)
+static void
+actor_iter_traverse_children (void)
{
ClutterActorIter iter;
ClutterActor *actor;
@@ -78,9 +76,8 @@ actor_iter_traverse_children (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
g_object_unref (actor);
}
-void
-actor_iter_traverse_remove (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
- gconstpointer dummy G_GNUC_UNUSED)
+static void
+actor_iter_traverse_remove (void)
{
ClutterActorIter iter;
ClutterActor *actor;
@@ -135,9 +132,8 @@ actor_iter_traverse_remove (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
g_assert_cmpint (0, ==, clutter_actor_get_n_children (actor));
}
-void
-actor_iter_assignment (TestConformSimpleFixture *fixure G_GNUC_UNUSED,
- gconstpointer dummy G_GNUC_UNUSED)
+static void
+actor_iter_assignment (void)
{
ClutterActorIter iter_a, iter_b;
ClutterActor *actor;
@@ -214,3 +210,9 @@ actor_iter_assignment (TestConformSimpleFixture *fixure G_GNUC_UNUSED,
g_object_unref (actor);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/iter/traverse-children", actor_iter_traverse_children)
+ CLUTTER_TEST_UNIT ("/actor/iter/traverse-remove", actor_iter_traverse_remove)
+ CLUTTER_TEST_UNIT ("/actor/iter/assignment", actor_iter_assignment)
+)
diff --git a/tests/conform/actor-layout.c b/tests/conform/actor-layout.c
index cb7f315..2cc8940 100644
--- a/tests/conform/actor-layout.c
+++ b/tests/conform/actor-layout.c
@@ -1,199 +1,15 @@
-#include <math.h>
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
-typedef struct _TestState TestState;
-
-struct _TestState
-{
- GPtrArray *actors;
- GPtrArray *colors;
-
- ClutterActor *stage;
-
- gulong id;
-
- gint in_validation;
-
- guint was_painted : 1;
-};
-
-static TestState *
-test_state_new (void)
-{
- return g_slice_new0 (TestState);
-}
-
-static void
-test_state_free (TestState *state)
-{
- if (state->id != 0)
- g_source_remove (state->id);
-
- if (state->actors != NULL)
- g_ptr_array_unref (state->actors);
-
- if (state->colors != NULL)
- g_ptr_array_unref (state->colors);
-
- if (state->stage != NULL)
- clutter_actor_destroy (state->stage);
-
- g_slice_free (TestState, state);
-}
-
-static void
-test_state_set_stage (TestState *state,
- ClutterActor *stage)
-{
- g_assert (!state->was_painted);
-
- state->stage = stage;
-}
static void
-test_state_add_actor (TestState *state,
- ClutterActor *actor,
- const ClutterColor *color)
-{
- g_assert (!state->was_painted);
-
- if (state->actors == NULL)
- {
- state->actors = g_ptr_array_new ();
- g_ptr_array_set_free_func (state->actors,
- (GDestroyNotify) g_object_unref);
- }
-
- g_ptr_array_add (state->actors, g_object_ref (actor));
-
- if (state->colors == NULL)
- {
- state->colors = g_ptr_array_new ();
- g_ptr_array_set_free_func (state->colors,
- (GDestroyNotify) clutter_color_free);
- }
-
- g_ptr_array_add (state->colors, clutter_color_copy (color));
-}
-
-static void
-test_state_push_validation (TestState *state)
-{
- state->in_validation += 1;
-}
-
-static void
-test_state_pop_validation (TestState *state)
-{
- state->in_validation -= 1;
-}
-
-static gboolean
-test_state_in_validation (TestState *state)
+actor_basic_layout (void)
{
- return state->in_validation > 0;
-}
-
-static gboolean
-check_color_at (ClutterActor *stage,
- ClutterActor *actor,
- ClutterColor *expected_color,
- float x,
- float y)
-{
- guchar *buffer;
-
- if (g_test_verbose ())
- g_print ("Checking actor '%s'\n", clutter_actor_get_name (actor));
-
- if (g_test_verbose ())
- g_print ("Sampling at { %d, %d }\t", (int) x, (int) y);
-
- buffer = clutter_stage_read_pixels (CLUTTER_STAGE (stage), x, y, 1, 1);
- g_assert (buffer != NULL);
-
- if (g_test_verbose ())
- g_print ("Color: { %d, %d, %d } - Expected color { %d, %d, %d }\n",
- buffer[0],
- buffer[1],
- buffer[2],
- expected_color->red,
- expected_color->green,
- expected_color->blue);
-
- g_assert_cmpint (buffer[0], ==, expected_color->red);
- g_assert_cmpint (buffer[1], ==, expected_color->green);
- g_assert_cmpint (buffer[2], ==, expected_color->blue);
-
- g_free (buffer);
-
- return TRUE;
-}
-
-static gboolean
-validate_state (gpointer data)
-{
- TestState *state = data;
- int i;
-
- /* avoid recursion */
- if (test_state_in_validation (state))
- return G_SOURCE_REMOVE;
-
- g_assert (state->actors != NULL);
- g_assert (state->colors != NULL);
-
- g_assert_cmpint (state->actors->len, ==, state->colors->len);
-
- test_state_push_validation (state);
-
- if (g_test_verbose ())
- g_print ("Sampling %d actors\n", state->actors->len);
-
- for (i = 0; i < state->actors->len; i++)
- {
- ClutterActor *actor = g_ptr_array_index (state->actors, i);
- ClutterColor *color = g_ptr_array_index (state->colors, i);
- ClutterActorBox box;
-
- clutter_actor_get_allocation_box (actor, &box);
-
- check_color_at (state->stage, actor, color, box.x1 + 2, box.y1 + 2);
- check_color_at (state->stage, actor, color, box.x2 - 2, box.y2 - 2);
- }
-
- test_state_pop_validation (state);
-
- state->was_painted = TRUE;
-
- return G_SOURCE_REMOVE;
-}
-
-static gboolean
-test_state_run (TestState *state)
-{
- clutter_threads_add_repaint_func_full (CLUTTER_REPAINT_FLAGS_POST_PAINT,
- validate_state,
- state,
- NULL);
-
- while (!state->was_painted)
- g_main_context_iteration (NULL, FALSE);
-
- return TRUE;
-}
-
-void
-actor_basic_layout (TestConformSimpleFixture *fixture,
- gconstpointer data)
-{
- ClutterActor *stage = clutter_stage_new ();
+ ClutterActor *stage = clutter_test_get_stage ();
ClutterActor *vase;
ClutterActor *flower[3];
- TestState *state;
+ ClutterPoint p;
vase = clutter_actor_new ();
+ clutter_actor_set_name (vase, "Vase");
clutter_actor_set_layout_manager (vase, clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
clutter_actor_add_child (stage, vase);
@@ -215,30 +31,27 @@ actor_basic_layout (TestConformSimpleFixture *fixture,
clutter_actor_set_name (flower[2], "Green Flower");
clutter_actor_add_child (vase, flower[2]);
- clutter_actor_show_all (stage);
-
- state = test_state_new ();
- test_state_set_stage (state, stage);
- test_state_add_actor (state, flower[0], CLUTTER_COLOR_Red);
- test_state_add_actor (state, flower[1], CLUTTER_COLOR_Yellow);
- test_state_add_actor (state, flower[2], CLUTTER_COLOR_Green);
+ clutter_point_init (&p, 50, 50);
+ clutter_test_assert_actor_at_point (stage, &p, flower[0]);
- g_assert (test_state_run (state));
+ clutter_point_init (&p, 150, 50);
+ clutter_test_assert_actor_at_point (stage, &p, flower[1]);
- test_state_free (state);
+ clutter_point_init (&p, 250, 50);
+ clutter_test_assert_actor_at_point (stage, &p, flower[2]);
}
-void
-actor_margin_layout (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_margin_layout (void)
{
- ClutterActor *stage = clutter_stage_new ();
+ ClutterActor *stage = clutter_test_get_stage ();
ClutterActor *vase;
ClutterActor *flower[3];
- TestState *state;
+ ClutterPoint p;
vase = clutter_actor_new ();
- clutter_actor_set_layout_manager (vase, clutter_flow_layout_new (CLUTTER_FLOW_HORIZONTAL));
+ clutter_actor_set_name (vase, "Vase");
+ clutter_actor_set_layout_manager (vase, clutter_box_layout_new ());
clutter_actor_add_child (stage, vase);
flower[0] = clutter_actor_new ();
@@ -263,15 +76,17 @@ actor_margin_layout (TestConformSimpleFixture *fixture,
clutter_actor_set_margin_bottom (flower[2], 6);
clutter_actor_add_child (vase, flower[2]);
- clutter_actor_show_all (stage);
+ clutter_point_init (&p, 0, 7);
+ clutter_test_assert_actor_at_point (stage, &p, flower[0]);
- state = test_state_new ();
- test_state_set_stage (state, stage);
- test_state_add_actor (state, flower[0], CLUTTER_COLOR_Red);
- test_state_add_actor (state, flower[1], CLUTTER_COLOR_Yellow);
- test_state_add_actor (state, flower[2], CLUTTER_COLOR_Green);
+ clutter_point_init (&p, 106, 50);
+ clutter_test_assert_actor_at_point (stage, &p, flower[1]);
- g_assert (test_state_run (state));
-
- test_state_free (state);
+ clutter_point_init (&p, 212, 7);
+ clutter_test_assert_actor_at_point (stage, &p, flower[2]);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/layout/basic", actor_basic_layout)
+ CLUTTER_TEST_UNIT ("/actor/layout/margin", actor_margin_layout)
+)
diff --git a/tests/conform/actor-meta.c b/tests/conform/actor-meta.c
index 5cae53a..52a313d 100644
--- a/tests/conform/actor-meta.c
+++ b/tests/conform/actor-meta.c
@@ -3,15 +3,12 @@
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
-void
-actor_meta_clear (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
- gconstpointer data G_GNUC_UNUSED)
+static void
+actor_meta_clear (void)
{
ClutterActor *actor, *stage;
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
actor = clutter_actor_new ();
g_object_ref_sink (actor);
@@ -36,6 +33,8 @@ actor_meta_clear (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
clutter_actor_destroy (actor);
g_assert (actor == NULL);
-
- clutter_actor_destroy (stage);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/meta/clear", actor_meta_clear)
+)
diff --git a/tests/conform/actor-offscreen-limit-max-size.c b/tests/conform/actor-offscreen-limit-max-size.c
index 9729866..1d17789 100644
--- a/tests/conform/actor-offscreen-limit-max-size.c
+++ b/tests/conform/actor-offscreen-limit-max-size.c
@@ -1,7 +1,6 @@
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
#define STAGE_WIDTH (300)
#define STAGE_HEIGHT (300)
@@ -21,18 +20,27 @@ check_results (ClutterStage *stage, gpointer user_data)
{
Data *data = user_data;
gfloat width, height;
+ ClutterRect rect;
+
+ clutter_offscreen_effect_get_target_rect (CLUTTER_OFFSCREEN_EFFECT (data->blur_effect1),
+ &rect);
- clutter_offscreen_effect_get_target_size (CLUTTER_OFFSCREEN_EFFECT (data->blur_effect1),
- &width, &height);
+ width = clutter_rect_get_width (&rect);
+ height = clutter_rect_get_height (&rect);
if (g_test_verbose ())
- g_print ("Checking effect1 size: %.2f x %.2f\n", width, height);
+ g_print ("Checking effect1 size: %.2f x %.2f\n",
+ clutter_rect_get_width (&rect),
+ clutter_rect_get_height (&rect));
g_assert_cmpint (width, <, STAGE_WIDTH);
g_assert_cmpint (height, <, STAGE_HEIGHT);
- clutter_offscreen_effect_get_target_size (CLUTTER_OFFSCREEN_EFFECT (data->blur_effect2),
- &width, &height);
+ clutter_offscreen_effect_get_target_rect (CLUTTER_OFFSCREEN_EFFECT (data->blur_effect2),
+ &rect);
+
+ width = clutter_rect_get_width (&rect);
+ height = clutter_rect_get_height (&rect);
if (g_test_verbose ())
g_print ("Checking effect2 size: %.2f x %.2f\n", width, height);
@@ -58,60 +66,56 @@ create_actor (gfloat x, gfloat y,
NULL);
}
-void
-actor_offscreen_limit_max_size (TestConformSimpleFixture *fixture,
- gconstpointer test_data)
+static void
+actor_offscreen_limit_max_size (void)
{
- if (cogl_features_available (COGL_FEATURE_OFFSCREEN))
- {
- Data data;
-
- data.stage = clutter_stage_new ();
- clutter_stage_set_paint_callback (CLUTTER_STAGE (data.stage),
- check_results,
- &data,
- NULL);
- clutter_actor_set_size (data.stage, STAGE_WIDTH, STAGE_HEIGHT);
-
- data.actor_group1 = clutter_actor_new ();
- clutter_actor_add_child (data.stage, data.actor_group1);
- data.blur_effect1 = clutter_blur_effect_new ();
- clutter_actor_add_effect (data.actor_group1, data.blur_effect1);
- clutter_actor_add_child (data.actor_group1,
- create_actor (10, 10,
- 100, 100,
- CLUTTER_COLOR_Blue));
- clutter_actor_add_child (data.actor_group1,
- create_actor (100, 100,
- 100, 100,
- CLUTTER_COLOR_Gray));
-
- data.actor_group2 = clutter_actor_new ();
- clutter_actor_add_child (data.stage, data.actor_group2);
- data.blur_effect2 = clutter_blur_effect_new ();
- clutter_actor_add_effect (data.actor_group2, data.blur_effect2);
- clutter_actor_add_child (data.actor_group2,
- create_actor (-10, -10,
- 100, 100,
- CLUTTER_COLOR_Yellow));
- clutter_actor_add_child (data.actor_group2,
- create_actor (250, 10,
- 100, 100,
- CLUTTER_COLOR_ScarletRed));
- clutter_actor_add_child (data.actor_group2,
- create_actor (10, 250,
- 100, 100,
- CLUTTER_COLOR_Yellow));
-
- clutter_actor_show (data.stage);
-
- clutter_main ();
-
- clutter_actor_destroy (data.stage);
-
- if (g_test_verbose ())
- g_print ("OK\n");
- }
- else if (g_test_verbose ())
- g_print ("Skipping\n");
+ Data data;
+
+ if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
+ return;
+
+ data.stage = clutter_test_get_stage ();
+ clutter_stage_set_paint_callback (CLUTTER_STAGE (data.stage),
+ check_results,
+ &data,
+ NULL);
+ clutter_actor_set_size (data.stage, STAGE_WIDTH, STAGE_HEIGHT);
+
+ data.actor_group1 = clutter_actor_new ();
+ clutter_actor_add_child (data.stage, data.actor_group1);
+ data.blur_effect1 = clutter_blur_effect_new ();
+ clutter_actor_add_effect (data.actor_group1, data.blur_effect1);
+ clutter_actor_add_child (data.actor_group1,
+ create_actor (10, 10,
+ 100, 100,
+ CLUTTER_COLOR_Blue));
+ clutter_actor_add_child (data.actor_group1,
+ create_actor (100, 100,
+ 100, 100,
+ CLUTTER_COLOR_Gray));
+
+ data.actor_group2 = clutter_actor_new ();
+ clutter_actor_add_child (data.stage, data.actor_group2);
+ data.blur_effect2 = clutter_blur_effect_new ();
+ clutter_actor_add_effect (data.actor_group2, data.blur_effect2);
+ clutter_actor_add_child (data.actor_group2,
+ create_actor (-10, -10,
+ 100, 100,
+ CLUTTER_COLOR_Yellow));
+ clutter_actor_add_child (data.actor_group2,
+ create_actor (250, 10,
+ 100, 100,
+ CLUTTER_COLOR_ScarletRed));
+ clutter_actor_add_child (data.actor_group2,
+ create_actor (10, 250,
+ 100, 100,
+ CLUTTER_COLOR_Yellow));
+
+ clutter_actor_show (data.stage);
+
+ clutter_main ();
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/offscreen/limit-max-size", actor_offscreen_limit_max_size)
+)
diff --git a/tests/conform/actor-offscreen-redirect.c b/tests/conform/actor-offscreen-redirect.c
index dab8519..f47af36 100644
--- a/tests/conform/actor-offscreen-redirect.c
+++ b/tests/conform/actor-offscreen-redirect.c
@@ -1,7 +1,6 @@
+#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
typedef struct _FooActor FooActor;
typedef struct _FooActorClass FooActorClass;
@@ -98,6 +97,8 @@ struct _FooGroup
ClutterActor parent;
};
+GType foo_group_get_type (void);
+
G_DEFINE_TYPE (FooGroup, foo_group, CLUTTER_TYPE_ACTOR)
static gboolean
@@ -294,21 +295,15 @@ run_verify (gpointer user_data)
return G_SOURCE_REMOVE;
}
-void
-actor_offscreen_redirect (TestConformSimpleFixture *fixture,
- gconstpointer test_data)
+static void
+actor_offscreen_redirect (void)
{
Data data;
if (!cogl_features_available (COGL_FEATURE_OFFSCREEN))
- {
- if (g_test_verbose ())
- g_print ("Offscreen buffers are not available, skipping test.\n");
+ return;
- return;
- }
-
- data.stage = clutter_stage_new ();
+ data.stage = clutter_test_get_stage ();
data.parent_container = clutter_actor_new ();
data.container = g_object_new (foo_group_get_type (), NULL);
data.foo_actor = g_object_new (foo_actor_get_type (), NULL);
@@ -335,6 +330,8 @@ actor_offscreen_redirect (TestConformSimpleFixture *fixture,
while (!data.was_painted)
g_main_context_iteration (NULL, FALSE);
-
- clutter_actor_destroy (data.stage);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/offscreen/redirect", actor_offscreen_redirect)
+)
diff --git a/tests/conform/actor-paint-opacity.c b/tests/conform/actor-paint-opacity.c
index 0ea219a..6df2408 100644
--- a/tests/conform/actor-paint-opacity.c
+++ b/tests/conform/actor-paint-opacity.c
@@ -1,18 +1,15 @@
#include <clutter/clutter.h>
#include <stdlib.h>
-#include "test-conform-common.h"
-
-void
-opacity_label (TestConformSimpleFixture *fixture,
- gpointer dummy)
+static void
+opacity_label (void)
{
ClutterActor *stage;
ClutterActor *label;
ClutterColor label_color = { 255, 0, 0, 128 };
ClutterColor color_check = { 0, };
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
label = clutter_text_new_with_text ("Sans 18px", "Label, 50% opacity");
clutter_text_set_color (CLUTTER_TEXT (label), &label_color);
@@ -22,7 +19,7 @@ opacity_label (TestConformSimpleFixture *fixture,
clutter_text_get_color (CLUTTER_TEXT (label), &color_check);
g_assert (color_check.alpha == label_color.alpha);
- clutter_container_add (CLUTTER_CONTAINER (stage), label, NULL);
+ clutter_actor_add_child (stage, label);
clutter_actor_set_position (label, 10, 10);
if (g_test_verbose ())
@@ -38,20 +35,18 @@ opacity_label (TestConformSimpleFixture *fixture,
g_print ("label 50%%.get_paint_opacity()/2\n");
clutter_actor_set_opacity (label, 128);
g_assert (clutter_actor_get_paint_opacity (label) == 128);
-
- clutter_actor_destroy (stage);
}
-void
-opacity_rectangle (TestConformSimpleFixture *fixture,
- gpointer dummy)
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+static void
+opacity_rectangle (void)
{
ClutterActor *stage;
ClutterActor *rect;
ClutterColor rect_color = { 0, 0, 255, 255 };
ClutterColor color_check = { 0, };
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
rect = clutter_rectangle_new_with_color (&rect_color);
clutter_actor_set_size (rect, 128, 128);
@@ -62,7 +57,7 @@ opacity_rectangle (TestConformSimpleFixture *fixture,
clutter_rectangle_get_color (CLUTTER_RECTANGLE (rect), &color_check);
g_assert (color_check.alpha == rect_color.alpha);
- clutter_container_add (CLUTTER_CONTAINER (stage), rect, NULL);
+ clutter_actor_add_child (stage, rect);
if (g_test_verbose ())
g_print ("rect 100%%.get_color()/2\n");
@@ -72,13 +67,12 @@ opacity_rectangle (TestConformSimpleFixture *fixture,
if (g_test_verbose ())
g_print ("rect 100%%.get_paint_opacity()\n");
g_assert (clutter_actor_get_paint_opacity (rect) == 255);
-
- clutter_actor_destroy (stage);
}
+G_GNUC_END_IGNORE_DEPRECATIONS
-void
-opacity_paint (TestConformSimpleFixture *fixture,
- gpointer dummy)
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
+static void
+opacity_paint (void)
{
ClutterActor *stage, *group1, *group2;
ClutterActor *label, *rect;
@@ -86,7 +80,7 @@ opacity_paint (TestConformSimpleFixture *fixture,
ClutterColor rect_color = { 0, 0, 255, 255 };
ClutterColor color_check = { 0, };
- stage = clutter_stage_new ();
+ stage = clutter_test_get_stage ();
group1 = clutter_group_new ();
clutter_actor_set_opacity (group1, 128);
@@ -137,6 +131,11 @@ opacity_paint (TestConformSimpleFixture *fixture,
if (g_test_verbose ())
g_print ("rect 100%%.get_paint_opacity()\n");
g_assert (clutter_actor_get_paint_opacity (rect) == 128);
-
- clutter_actor_destroy (stage);
}
+G_GNUC_END_IGNORE_DEPRECATIONS
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/opacity/text", opacity_label)
+ CLUTTER_TEST_UNIT ("/actor/opacity/rectangle", opacity_rectangle)
+ CLUTTER_TEST_UNIT ("/actor/opacity/paint", opacity_paint)
+)
diff --git a/tests/conform/actor-pick.c b/tests/conform/actor-pick.c
index e2399ba..4db39c4 100644
--- a/tests/conform/actor-pick.c
+++ b/tests/conform/actor-pick.c
@@ -1,7 +1,6 @@
+#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
#define STAGE_WIDTH 640
#define STAGE_HEIGHT 480
#define ACTORS_X 12
@@ -34,6 +33,8 @@ typedef struct _ShiftEffectClass ShiftEffectClass;
#define TYPE_SHIFT_EFFECT (shift_effect_get_type ())
+GType shift_effect_get_type (void);
+
G_DEFINE_TYPE (ShiftEffect,
shift_effect,
CLUTTER_TYPE_SHADER_EFFECT);
@@ -120,8 +121,7 @@ on_timeout (gpointer data)
isn't visible so it shouldn't affect the picking */
over_actor = clutter_rectangle_new_with_color (&red);
clutter_actor_set_size (over_actor, STAGE_WIDTH, STAGE_HEIGHT);
- clutter_container_add (CLUTTER_CONTAINER (state->stage),
- over_actor, NULL);
+ clutter_actor_add_child (state->stage, over_actor);
clutter_actor_hide (over_actor);
if (g_test_verbose ())
@@ -165,8 +165,9 @@ on_timeout (gpointer data)
"blur");
clutter_actor_add_effect_with_name (CLUTTER_ACTOR (state->stage),
- "shift",
- g_object_new (TYPE_SHIFT_EFFECT, NULL));
+ "shift",
+ g_object_new (TYPE_SHIFT_EFFECT,
+ NULL));
if (g_test_verbose ())
g_print ("With shift effect:\n");
@@ -190,12 +191,12 @@ on_timeout (gpointer data)
if (test_num == 4)
pick_x -= SHIFT_STEP;
- actor
- = clutter_stage_get_actor_at_pos (CLUTTER_STAGE (state->stage),
- CLUTTER_PICK_ALL,
- pick_x,
- y * state->actor_height
- + state->actor_height / 2);
+ actor =
+ clutter_stage_get_actor_at_pos (CLUTTER_STAGE (state->stage),
+ CLUTTER_PICK_ALL,
+ pick_x,
+ y * state->actor_height
+ + state->actor_height / 2);
if (g_test_verbose ())
g_print ("% 3i,% 3i / %p -> ",
@@ -239,7 +240,7 @@ on_timeout (gpointer data)
return G_SOURCE_REMOVE;
}
-void
+static void
actor_pick (void)
{
int y, x;
@@ -247,7 +248,7 @@ actor_pick (void)
state.pass = TRUE;
- state.stage = clutter_stage_new ();
+ state.stage = clutter_test_get_stage ();
state.actor_width = STAGE_WIDTH / ACTORS_X;
state.actor_height = STAGE_HEIGHT / ACTORS_Y;
@@ -267,7 +268,7 @@ actor_pick (void)
state.actor_width,
state.actor_height);
- clutter_container_add (CLUTTER_CONTAINER (state.stage), rect, NULL);
+ clutter_actor_add_child (state.stage, rect);
state.actors[y * ACTORS_X + x] = rect;
}
@@ -278,10 +279,9 @@ actor_pick (void)
clutter_main ();
- if (g_test_verbose ())
- g_print ("end result: %s\n", state.pass ? "pass" : "FAIL");
-
g_assert (state.pass);
-
- clutter_actor_destroy (state.stage);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/pick", actor_pick)
+)
diff --git a/tests/conform/actor-shader-effect.c b/tests/conform/actor-shader-effect.c
index db3400b..632caf6 100644
--- a/tests/conform/actor-shader-effect.c
+++ b/tests/conform/actor-shader-effect.c
@@ -1,7 +1,7 @@
+#define CLUTTER_ENABLE_EXPERIMENTAL_API
+#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
/****************************************************************
Old style shader effect
This uses clutter_shader_effect_set_source
@@ -27,6 +27,8 @@ typedef struct _FooOldShaderEffect
ClutterShaderEffect parent;
} FooOldShaderEffect;
+GType foo_old_shader_effect_get_type (void);
+
G_DEFINE_TYPE (FooOldShaderEffect,
foo_old_shader_effect,
CLUTTER_TYPE_SHADER_EFFECT);
@@ -85,6 +87,8 @@ typedef struct _FooNewShaderEffect
ClutterShaderEffect parent;
} FooNewShaderEffect;
+GType foo_new_shader_effect_get_type (void);
+
G_DEFINE_TYPE (FooNewShaderEffect,
foo_new_shader_effect,
CLUTTER_TYPE_SHADER_EFFECT);
@@ -160,6 +164,8 @@ typedef struct _FooAnotherNewShaderEffect
ClutterShaderEffect parent;
} FooAnotherNewShaderEffect;
+GType foo_another_new_shader_effect_get_type (void);
+
G_DEFINE_TYPE (FooAnotherNewShaderEffect,
foo_another_new_shader_effect,
CLUTTER_TYPE_SHADER_EFFECT);
@@ -218,8 +224,11 @@ get_pixel (int x, int y)
}
static void
-paint_cb (ClutterActor *stage)
+paint_cb (ClutterStage *stage,
+ gpointer data)
{
+ gboolean *was_painted = data;
+
/* old shader effect */
g_assert_cmpint (get_pixel (50, 50), ==, 0xff0000);
/* new shader effect */
@@ -229,15 +238,15 @@ paint_cb (ClutterActor *stage)
/* new shader effect */
g_assert_cmpint (get_pixel (350, 50), ==, 0x00ffff);
- clutter_main_quit ();
+ *was_painted = TRUE;
}
-void
-actor_shader_effect (TestConformSimpleFixture *fixture,
- gconstpointer data)
+static void
+actor_shader_effect (void)
{
ClutterActor *stage;
ClutterActor *rect;
+ gboolean was_painted;
if (!clutter_feature_available (CLUTTER_FEATURE_SHADERS_GLSL))
return;
@@ -261,12 +270,16 @@ actor_shader_effect (TestConformSimpleFixture *fixture,
clutter_actor_show (stage);
- g_signal_connect_after (stage, "paint", G_CALLBACK (paint_cb), NULL);
-
- clutter_main ();
+ was_painted = FALSE;
+ clutter_stage_set_paint_callback (CLUTTER_STAGE (stage),
+ paint_cb,
+ &was_painted,
+ NULL);
- clutter_actor_destroy (stage);
-
- if (g_test_verbose ())
- g_print ("OK\n");
+ while (!was_painted)
+ g_main_context_iteration (NULL, FALSE);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/shader-effect", actor_shader_effect)
+)
diff --git a/tests/conform/actor-size.c b/tests/conform/actor-size.c
index 6d837c6..7245f15 100644
--- a/tests/conform/actor-size.c
+++ b/tests/conform/actor-size.c
@@ -3,8 +3,6 @@
#include <clutter/clutter.h>
-#include "test-conform-common.h"
-
#define TEST_TYPE_ACTOR (test_actor_get_type ())
typedef struct _TestActor TestActor;
@@ -18,6 +16,8 @@ struct _TestActor
guint preferred_height_called : 1;
};
+GType test_actor_get_type (void);
+
G_DEFINE_TYPE (TestActor, test_actor, CLUTTER_TYPE_ACTOR);
static void
@@ -78,7 +78,7 @@ test_actor_init (TestActor *self)
{
}
-void
+static void
actor_preferred_size (void)
{
ClutterActor *test;
@@ -138,7 +138,7 @@ actor_preferred_size (void)
clutter_actor_destroy (test);
}
-void
+static void
actor_fixed_size (void)
{
ClutterActor *rect;
@@ -209,3 +209,8 @@ actor_fixed_size (void)
clutter_actor_destroy (rect);
g_object_unref (rect);
}
+
+CLUTTER_TEST_SUITE (
+ CLUTTER_TEST_UNIT ("/actor/size/preferred", actor_preferred_size)
+ CLUTTER_TEST_UNIT ("/actor/size/fixed", actor_fixed_size)
+)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]