1
#include <clutter/clutter.h>
3
#include "test-conform-common.h"
6
test_animator_multi_properties (TestConformSimpleFixture *fixture,
9
ClutterScript *script = clutter_script_new ();
10
GObject *animator = NULL, *foo = NULL;
14
ClutterAnimatorKey *key;
15
GValue value = { 0, };
17
test_file = clutter_test_get_data_file ("test-animator-3.json");
18
clutter_script_load_from_file (script, test_file, &error);
19
if (g_test_verbose () && error)
20
g_print ("Error: %s", error->message);
22
#if GLIB_CHECK_VERSION (2, 20, 0)
23
g_assert_no_error (error);
25
g_assert (error == NULL);
28
foo = clutter_script_get_object (script, "foo");
29
g_assert (G_IS_OBJECT (foo));
31
animator = clutter_script_get_object (script, "animator");
32
g_assert (CLUTTER_IS_ANIMATOR (animator));
34
/* get all the keys for foo:x */
35
keys = clutter_animator_get_keys (CLUTTER_ANIMATOR (animator),
38
g_assert_cmpint (g_list_length (keys), ==, 3);
40
key = g_list_nth_data (keys, 1);
41
g_assert (key != NULL);
43
if (g_test_verbose ())
45
g_print ("(foo, x).keys[1] = \n"
50
clutter_get_script_id (clutter_animator_key_get_object (key)),
51
clutter_animator_key_get_progress (key),
52
clutter_animator_key_get_property_name (key),
53
g_type_name (clutter_animator_key_get_property_type (key)));
56
g_assert (clutter_animator_key_get_object (key) != NULL);
57
g_assert_cmpfloat (clutter_animator_key_get_progress (key), ==, 0.2);
58
g_assert_cmpstr (clutter_animator_key_get_property_name (key), ==, "x");
60
g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
62
g_value_init (&value, G_TYPE_FLOAT);
63
g_assert (clutter_animator_key_get_value (key, &value));
64
g_assert_cmpfloat (g_value_get_float (&value), ==, 150.0);
65
g_value_unset (&value);
69
/* get all the keys for foo:y */
70
keys = clutter_animator_get_keys (CLUTTER_ANIMATOR (animator),
73
g_assert_cmpint (g_list_length (keys), ==, 3);
75
key = g_list_nth_data (keys, 2);
76
g_assert (key != NULL);
78
if (g_test_verbose ())
80
g_print ("(foo, y).keys[2] = \n"
85
clutter_get_script_id (clutter_animator_key_get_object (key)),
86
clutter_animator_key_get_progress (key),
87
clutter_animator_key_get_property_name (key),
88
g_type_name (clutter_animator_key_get_property_type (key)));
91
g_assert (clutter_animator_key_get_object (key) != NULL);
92
g_assert_cmpfloat (clutter_animator_key_get_progress (key), ==, 0.8);
93
g_assert_cmpstr (clutter_animator_key_get_property_name (key), ==, "y");
95
g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
97
g_value_init (&value, G_TYPE_FLOAT);
98
g_assert (clutter_animator_key_get_value (key, &value));
99
g_assert_cmpfloat (g_value_get_float (&value), ==, 200.0);
100
g_value_unset (&value);
104
g_object_unref (script);
109
test_animator_properties (TestConformSimpleFixture *fixture,
112
ClutterScript *script = clutter_script_new ();
113
GObject *animator = NULL;
114
GError *error = NULL;
117
ClutterAnimatorKey *key;
118
GValue value = { 0, };
120
test_file = clutter_test_get_data_file ("test-animator-2.json");
121
clutter_script_load_from_file (script, test_file, &error);
122
if (g_test_verbose () && error)
123
g_print ("Error: %s", error->message);
125
#if GLIB_CHECK_VERSION (2, 20, 0)
126
g_assert_no_error (error);
128
g_assert (error == NULL);
131
animator = clutter_script_get_object (script, "animator");
132
g_assert (CLUTTER_IS_ANIMATOR (animator));
134
/* get all the keys */
135
keys = clutter_animator_get_keys (CLUTTER_ANIMATOR (animator),
137
g_assert_cmpint (g_list_length (keys), ==, 3);
139
key = g_list_nth_data (keys, 1);
140
g_assert (key != NULL);
142
if (g_test_verbose ())
144
g_print ("keys[1] = \n"
149
clutter_get_script_id (clutter_animator_key_get_object (key)),
150
clutter_animator_key_get_progress (key),
151
clutter_animator_key_get_property_name (key),
152
g_type_name (clutter_animator_key_get_property_type (key)));
155
g_assert (clutter_animator_key_get_object (key) != NULL);
156
g_assert_cmpfloat (clutter_animator_key_get_progress (key), ==, 0.2);
157
g_assert_cmpstr (clutter_animator_key_get_property_name (key), ==, "x");
159
g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
161
g_value_init (&value, G_TYPE_FLOAT);
162
g_assert (clutter_animator_key_get_value (key, &value));
163
g_assert_cmpfloat (g_value_get_float (&value), ==, 150.0);
164
g_value_unset (&value);
167
g_object_unref (script);
172
test_animator_base (TestConformSimpleFixture *fixture,
175
ClutterScript *script = clutter_script_new ();
176
GObject *animator = NULL;
177
GError *error = NULL;
181
test_file = clutter_test_get_data_file ("test-animator-1.json");
182
clutter_script_load_from_file (script, test_file, &error);
183
if (g_test_verbose () && error)
184
g_print ("Error: %s", error->message);
186
#if GLIB_CHECK_VERSION (2, 20, 0)
187
g_assert_no_error (error);
189
g_assert (error == NULL);
192
animator = clutter_script_get_object (script, "animator");
193
g_assert (CLUTTER_IS_ANIMATOR (animator));
195
duration = clutter_animator_get_duration (CLUTTER_ANIMATOR (animator));
196
g_assert_cmpint (duration, ==, 1000);
198
g_object_unref (script);