Merge branch 'animator-parser'
* animator-parser: docs: Describe the Animation definition syntax animator: Provide a ClutterScript parser animator: Allow retrieving type property type from a key script: Use a node when resolving an animation mode
This commit is contained in:
@ -45,6 +45,7 @@ test_conformance_SOURCES = \
|
||||
test-script-parser.c \
|
||||
test-actor-destroy.c \
|
||||
test-behaviours.c \
|
||||
test-animator.c \
|
||||
$(NULL)
|
||||
|
||||
# For convenience, this provides a way to easily run individual unit tests:
|
||||
|
88
tests/conform/test-animator.c
Normal file
88
tests/conform/test-animator.c
Normal file
@ -0,0 +1,88 @@
|
||||
#include <clutter/clutter.h>
|
||||
|
||||
#include "test-conform-common.h"
|
||||
|
||||
void
|
||||
test_animator_properties (TestConformSimpleFixture *fixture,
|
||||
gconstpointer dummy)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
GObject *animator = NULL;
|
||||
GError *error = NULL;
|
||||
gchar *test_file;
|
||||
GList *keys;
|
||||
|
||||
test_file = clutter_test_get_data_file ("test-animator-2.json");
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (g_test_verbose () && error)
|
||||
g_print ("Error: %s", error->message);
|
||||
g_assert (error == NULL);
|
||||
|
||||
animator = clutter_script_get_object (script, "animator");
|
||||
g_assert (CLUTTER_IS_ANIMATOR (animator));
|
||||
|
||||
/* get all the keys */
|
||||
keys = clutter_animator_get_keys (CLUTTER_ANIMATOR (animator),
|
||||
NULL, NULL, -1.0);
|
||||
g_assert_cmpint (g_list_length (keys), ==, 3);
|
||||
|
||||
{
|
||||
const ClutterAnimatorKey *key = g_list_nth_data (keys, 1);
|
||||
GValue value = { 0, };
|
||||
|
||||
g_assert (key != NULL);
|
||||
|
||||
if (g_test_verbose ())
|
||||
{
|
||||
g_print ("keys[1] = \n"
|
||||
".object = %s\n"
|
||||
".progress = %.2f\n"
|
||||
".name = '%s'\n"
|
||||
".type = '%s'\n",
|
||||
clutter_get_script_id (clutter_animator_key_get_object (key)),
|
||||
clutter_animator_key_get_progress (key),
|
||||
clutter_animator_key_get_property_name (key),
|
||||
g_type_name (clutter_animator_key_get_property_type (key)));
|
||||
}
|
||||
|
||||
g_assert (clutter_animator_key_get_object (key) != NULL);
|
||||
g_assert_cmpfloat (clutter_animator_key_get_progress (key), ==, 0.2);
|
||||
g_assert_cmpstr (clutter_animator_key_get_property_name (key), ==, "x");
|
||||
|
||||
g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
|
||||
|
||||
g_value_init (&value, G_TYPE_FLOAT);
|
||||
g_assert (clutter_animator_key_get_value (key, &value));
|
||||
g_assert_cmpfloat (g_value_get_float (&value), ==, 150.0);
|
||||
}
|
||||
|
||||
g_list_free (keys);
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
||||
|
||||
void
|
||||
test_animator_base (TestConformSimpleFixture *fixture,
|
||||
gconstpointer dummy)
|
||||
{
|
||||
ClutterScript *script = clutter_script_new ();
|
||||
GObject *animator = NULL;
|
||||
GError *error = NULL;
|
||||
guint duration = 0;
|
||||
gchar *test_file;
|
||||
|
||||
test_file = clutter_test_get_data_file ("test-animator-1.json");
|
||||
clutter_script_load_from_file (script, test_file, &error);
|
||||
if (g_test_verbose () && error)
|
||||
g_print ("Error: %s", error->message);
|
||||
g_assert (error == NULL);
|
||||
|
||||
animator = clutter_script_get_object (script, "animator");
|
||||
g_assert (CLUTTER_IS_ANIMATOR (animator));
|
||||
|
||||
duration = clutter_animator_get_duration (CLUTTER_ANIMATOR (animator));
|
||||
g_assert_cmpint (duration, ==, 1000);
|
||||
|
||||
g_object_unref (script);
|
||||
g_free (test_file);
|
||||
}
|
@ -177,6 +177,8 @@ main (int argc, char **argv)
|
||||
TEST_CONFORM_SIMPLE ("/script", test_script_object_property);
|
||||
TEST_CONFORM_SIMPLE ("/script", test_script_animation);
|
||||
TEST_CONFORM_SIMPLE ("/script", test_script_named_object);
|
||||
TEST_CONFORM_SIMPLE ("/script", test_animator_base);
|
||||
TEST_CONFORM_SIMPLE ("/script", test_animator_properties);
|
||||
|
||||
TEST_CONFORM_SIMPLE ("/behaviours", test_behaviours);
|
||||
|
||||
|
@ -8,6 +8,8 @@ json_files = \
|
||||
test-script-named-object.json \
|
||||
test-script-object-property.json \
|
||||
test-script-single.json \
|
||||
test-animator-1.json \
|
||||
test-animator-2.json \
|
||||
$(NULL)
|
||||
|
||||
png_files = \
|
||||
|
5
tests/data/test-animator-1.json
Normal file
5
tests/data/test-animator-1.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"type" : "ClutterAnimator",
|
||||
"id" : "animator",
|
||||
"duration" : 1000
|
||||
}
|
29
tests/data/test-animator-2.json
Normal file
29
tests/data/test-animator-2.json
Normal file
@ -0,0 +1,29 @@
|
||||
[
|
||||
{
|
||||
"type" : "ClutterRectangle",
|
||||
"id" : "foo",
|
||||
"x" : 0,
|
||||
"y" : 0,
|
||||
"width" : 100,
|
||||
"height" : 100
|
||||
},
|
||||
{
|
||||
"type" : "ClutterAnimator",
|
||||
"id" : "animator",
|
||||
"duration" : 1000,
|
||||
|
||||
"properties" : [
|
||||
{
|
||||
"object" : "foo",
|
||||
"name" : "x",
|
||||
"ease-in" : true,
|
||||
"interpolation" : "linear",
|
||||
"keys" : [
|
||||
[ 0.0, "easeInCubic", 100.0 ],
|
||||
[ 0.2, "easeOutCubic", 150.0 ],
|
||||
[ 0.8, "linear", 200.0 ]
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
Reference in New Issue
Block a user