~ubuntu-branches/ubuntu/vivid/clutter-1.0/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/conform/test-animator.c

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-07-18 17:21:49 UTC
  • mfrom: (1.2.1 upstream) (4.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20100718172149-j6s9u4chocaoykme
Tags: 1.2.12-1
* New upstream release.
* debian/libclutter-1.0-0.symbols,
  debian/rules:
  - Add a symbols file.
* debian/rules,
  debian/source/format:
  - Switch to source format 3.0 (quilt).
* debian/control.in:
  - Standards-Version is 3.9.0, no changes needed.
* Upload to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <clutter/clutter.h>
 
2
 
 
3
#include "test-conform-common.h"
 
4
 
 
5
void
 
6
test_animator_multi_properties (TestConformSimpleFixture *fixture,
 
7
                                gconstpointer dummy)
 
8
{
 
9
  ClutterScript *script = clutter_script_new ();
 
10
  GObject *animator = NULL, *foo = NULL;
 
11
  GError *error = NULL;
 
12
  gchar *test_file;
 
13
  GList *keys;
 
14
  ClutterAnimatorKey *key;
 
15
  GValue value = { 0, };
 
16
 
 
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);
 
21
 
 
22
#if GLIB_CHECK_VERSION (2, 20, 0)
 
23
  g_assert_no_error (error);
 
24
#else
 
25
  g_assert (error == NULL);
 
26
#endif
 
27
 
 
28
  foo = clutter_script_get_object (script, "foo");
 
29
  g_assert (G_IS_OBJECT (foo));
 
30
 
 
31
  animator = clutter_script_get_object (script, "animator");
 
32
  g_assert (CLUTTER_IS_ANIMATOR (animator));
 
33
 
 
34
  /* get all the keys for foo:x */
 
35
  keys = clutter_animator_get_keys (CLUTTER_ANIMATOR (animator),
 
36
                                    foo, "x",
 
37
                                    -1.0);
 
38
  g_assert_cmpint (g_list_length (keys), ==, 3);
 
39
 
 
40
  key = g_list_nth_data (keys, 1);
 
41
  g_assert (key != NULL);
 
42
 
 
43
  if (g_test_verbose ())
 
44
    {
 
45
      g_print ("(foo, x).keys[1] = \n"
 
46
               ".object = %s\n"
 
47
               ".progress = %.2f\n"
 
48
               ".name = '%s'\n"
 
49
               ".type = '%s'\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)));
 
54
    }
 
55
 
 
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");
 
59
 
 
60
  g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
 
61
 
 
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);
 
66
 
 
67
  g_list_free (keys);
 
68
 
 
69
  /* get all the keys for foo:y */
 
70
  keys = clutter_animator_get_keys (CLUTTER_ANIMATOR (animator),
 
71
                                    foo, "y",
 
72
                                    -1.0);
 
73
  g_assert_cmpint (g_list_length (keys), ==, 3);
 
74
 
 
75
  key = g_list_nth_data (keys, 2);
 
76
  g_assert (key != NULL);
 
77
 
 
78
  if (g_test_verbose ())
 
79
    {
 
80
      g_print ("(foo, y).keys[2] = \n"
 
81
               ".object = %s\n"
 
82
               ".progress = %.2f\n"
 
83
               ".name = '%s'\n"
 
84
               ".type = '%s'\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)));
 
89
    }
 
90
 
 
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");
 
94
 
 
95
  g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
 
96
 
 
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);
 
101
 
 
102
  g_list_free (keys);
 
103
 
 
104
  g_object_unref (script);
 
105
  g_free (test_file);
 
106
}
 
107
 
 
108
void
 
109
test_animator_properties (TestConformSimpleFixture *fixture,
 
110
                          gconstpointer dummy)
 
111
{
 
112
  ClutterScript *script = clutter_script_new ();
 
113
  GObject *animator = NULL;
 
114
  GError *error = NULL;
 
115
  gchar *test_file;
 
116
  GList *keys;
 
117
  ClutterAnimatorKey *key;
 
118
  GValue value = { 0, };
 
119
 
 
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);
 
124
 
 
125
#if GLIB_CHECK_VERSION (2, 20, 0)
 
126
  g_assert_no_error (error);
 
127
#else
 
128
  g_assert (error == NULL);
 
129
#endif
 
130
 
 
131
  animator = clutter_script_get_object (script, "animator");
 
132
  g_assert (CLUTTER_IS_ANIMATOR (animator));
 
133
 
 
134
  /* get all the keys */
 
135
  keys = clutter_animator_get_keys (CLUTTER_ANIMATOR (animator),
 
136
                                    NULL, NULL, -1.0);
 
137
  g_assert_cmpint (g_list_length (keys), ==, 3);
 
138
 
 
139
  key = g_list_nth_data (keys, 1);
 
140
  g_assert (key != NULL);
 
141
 
 
142
  if (g_test_verbose ())
 
143
    {
 
144
      g_print ("keys[1] = \n"
 
145
               ".object = %s\n"
 
146
               ".progress = %.2f\n"
 
147
               ".name = '%s'\n"
 
148
               ".type = '%s'\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)));
 
153
    }
 
154
 
 
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");
 
158
 
 
159
  g_assert (clutter_animator_key_get_property_type (key) == G_TYPE_FLOAT);
 
160
 
 
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);
 
165
 
 
166
  g_list_free (keys);
 
167
  g_object_unref (script);
 
168
  g_free (test_file);
 
169
}
 
170
 
 
171
void
 
172
test_animator_base (TestConformSimpleFixture *fixture,
 
173
                    gconstpointer dummy)
 
174
{
 
175
  ClutterScript *script = clutter_script_new ();
 
176
  GObject *animator = NULL;
 
177
  GError *error = NULL;
 
178
  guint duration = 0;
 
179
  gchar *test_file;
 
180
 
 
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);
 
185
 
 
186
#if GLIB_CHECK_VERSION (2, 20, 0)
 
187
  g_assert_no_error (error);
 
188
#else
 
189
  g_assert (error == NULL);
 
190
#endif
 
191
 
 
192
  animator = clutter_script_get_object (script, "animator");
 
193
  g_assert (CLUTTER_IS_ANIMATOR (animator));
 
194
 
 
195
  duration = clutter_animator_get_duration (CLUTTER_ANIMATOR (animator));
 
196
  g_assert_cmpint (duration, ==, 1000);
 
197
 
 
198
  g_object_unref (script);
 
199
  g_free (test_file);
 
200
}