fd119ab226ed68cefb8aa0b8fed6549d2d6f0aa6
[profile/ivi/clutter.git] / tests / conform / test-conform-main.c
1 #include "config.h"
2
3 #include <clutter/clutter.h>
4
5 #include <glib.h>
6 #include <locale.h>
7 #include <stdlib.h>
8
9 #include "test-conform-common.h"
10
11 static void
12 test_conform_skip_test (TestConformSimpleFixture *fixture,
13                         gconstpointer             data)
14 {
15   /* void */
16 }
17
18 static void
19 test_conform_todo_test (TestConformSimpleFixture *fixture,
20                         gconstpointer             data)
21 {
22 #ifdef G_OS_UNIX
23   const TestConformTodo *todo = data;
24
25   if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
26     {
27       todo->func (fixture, NULL);
28       exit (0);
29     }
30
31   g_test_trap_assert_failed ();
32 #endif
33 }
34
35 void
36 verify_failure (TestConformSimpleFixture *fixture,
37                 gconstpointer             data)
38 {
39   g_assert (FALSE);
40 }
41
42 static TestConformSharedState *shared_state = NULL;
43
44 /* This is a bit of sugar for adding new conformance tests:
45  *
46  * - It adds an extern function definition just to save maintaining a header
47  *   that lists test entry points.
48  * - It sets up callbacks for a fixture, which lets us share initialization
49  *   *code* between tests. (see test-conform-common.c)
50  * - It passes in a shared *data* pointer that is initialised once in main(),
51  *   that gets passed to the fixture setup and test functions. (See the
52  *   definition in test-conform-common.h)
53  */
54 #define TEST_CONFORM_SIMPLE(NAMESPACE, FUNC)            G_STMT_START {  \
55   extern void FUNC (TestConformSimpleFixture *, gconstpointer);         \
56   g_test_add ("/conform" NAMESPACE "/" #FUNC,                           \
57               TestConformSimpleFixture,                                 \
58               shared_state, /* data argument for test */                \
59               test_conform_simple_fixture_setup,                        \
60               FUNC,                                                     \
61               test_conform_simple_fixture_teardown);    } G_STMT_END
62
63 /* this is a macro that conditionally executes a test if CONDITION
64  * evaluates to TRUE; otherwise, it will put the test under the
65  * "/skipped" namespace and execute a dummy function that will always
66  * pass.
67  */
68 #define TEST_CONFORM_SKIP(CONDITION, NAMESPACE, FUNC)   G_STMT_START {  \
69   if (CONDITION) { TEST_CONFORM_SIMPLE (NAMESPACE, FUNC); }             \
70   else {                                                                \
71     g_test_add ("/skipped" NAMESPACE "/" #FUNC,                         \
72                 TestConformSimpleFixture,                               \
73                 shared_state, /* data argument for test */              \
74                 test_conform_simple_fixture_setup,                      \
75                 test_conform_skip_test,                                 \
76                 test_conform_simple_fixture_teardown);                  \
77   }                                                     } G_STMT_END
78
79 #define TEST_CONFORM_TODO(NAMESPACE, FUNC)              G_STMT_START {  \
80    extern void FUNC (TestConformSimpleFixture *, gconstpointer);        \
81    TestConformTodo *_clos = g_new0 (TestConformTodo, 1);                \
82    _clos->name = g_strdup ( #FUNC );                                    \
83    _clos->func = FUNC;                                                  \
84    g_test_add ("/todo" NAMESPACE "/" #FUNC,                             \
85               TestConformSimpleFixture,                                 \
86               _clos,                                                    \
87               test_conform_simple_fixture_setup,                        \
88               test_conform_todo_test,                                   \
89               test_conform_simple_fixture_teardown);    } G_STMT_END
90
91 gchar *
92 clutter_test_get_data_file (const gchar *filename)
93 {
94   return g_build_filename (TESTS_DATADIR, filename, NULL);
95 }
96
97 static void
98 clutter_test_init (gint    *argc,
99                    gchar ***argv)
100 {
101   /* Turning of sync-to-vblank removes a dependency on the specifics of the
102    * test environment. It also means that the timeline-only tests are
103    * throttled to a reasonable frame rate rather than running in tight
104    * infinite loop.
105    */
106   g_setenv ("CLUTTER_VBLANK", "none", FALSE);
107
108   g_test_init (argc, argv, NULL);
109
110   g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=%s");
111
112   /* Initialise the state you need to share with everything.
113    */
114   shared_state = g_new0 (TestConformSharedState, 1);
115   shared_state->argc_addr = argc;
116   shared_state->argv_addr = argv;
117 }
118
119 int
120 main (int argc, char **argv)
121 {
122   clutter_test_init (&argc, &argv);
123
124   /* This file is run through a sed script during the make step so the
125      lines containing the tests need to be formatted on a single line
126      each. To comment out a test use the SKIP or TODO macros. Using
127      #if 0 would break the script. */
128
129   /* sanity check for the test suite itself */
130   TEST_CONFORM_TODO ("/suite", verify_failure);
131
132   TEST_CONFORM_SIMPLE ("/actor", actor_add_child);
133   TEST_CONFORM_SIMPLE ("/actor", actor_insert_child);
134   TEST_CONFORM_SIMPLE ("/actor", actor_raise_child);
135   TEST_CONFORM_SIMPLE ("/actor", actor_lower_child);
136   TEST_CONFORM_SIMPLE ("/actor", actor_replace_child);
137   TEST_CONFORM_SIMPLE ("/actor", actor_remove_child);
138   TEST_CONFORM_SIMPLE ("/actor", actor_remove_all);
139   TEST_CONFORM_SIMPLE ("/actor", actor_container_signals);
140   TEST_CONFORM_SIMPLE ("/actor", actor_destruction);
141   TEST_CONFORM_SIMPLE ("/actor", actor_anchors);
142   TEST_CONFORM_SIMPLE ("/actor", actor_pick);
143   TEST_CONFORM_SIMPLE ("/actor", actor_fixed_size);
144   TEST_CONFORM_SIMPLE ("/actor", actor_preferred_size);
145   TEST_CONFORM_SIMPLE ("/actor", actor_basic_layout);
146   TEST_CONFORM_SIMPLE ("/actor", actor_margin_layout);
147   TEST_CONFORM_SIMPLE ("/actor", actor_offscreen_redirect);
148   TEST_CONFORM_SIMPLE ("/actor", actor_shader_effect);
149
150   TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_children);
151   TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_remove);
152
153   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_initial_state);
154   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_shown_not_parented);
155   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_visibility_not_recursive);
156   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realized);
157   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realize_not_recursive);
158   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_map_recursive);
159   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_mapped);
160   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_show_on_set_parent);
161   TEST_CONFORM_SIMPLE ("/actor/invariants", clone_no_map);
162   TEST_CONFORM_SIMPLE ("/actor/invariants", actor_contains);
163   TEST_CONFORM_SIMPLE ("/actor/invariants", default_stage);
164
165   TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_label);
166   TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_rectangle);
167   TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_paint);
168
169   TEST_CONFORM_SIMPLE ("/text", text_utf8_validation);
170   TEST_CONFORM_SIMPLE ("/text", text_set_empty);
171   TEST_CONFORM_SIMPLE ("/text", text_set_text);
172   TEST_CONFORM_SIMPLE ("/text", text_append_some);
173   TEST_CONFORM_SIMPLE ("/text", text_prepend_some);
174   TEST_CONFORM_SIMPLE ("/text", text_insert);
175   TEST_CONFORM_SIMPLE ("/text", text_delete_chars);
176   TEST_CONFORM_SIMPLE ("/text", text_delete_text);
177   TEST_CONFORM_SIMPLE ("/text", text_cursor);
178   TEST_CONFORM_SIMPLE ("/text", text_event);
179   TEST_CONFORM_SIMPLE ("/text", text_get_chars);
180   TEST_CONFORM_SIMPLE ("/text", text_cache);
181   TEST_CONFORM_SIMPLE ("/text", text_password_char);
182   TEST_CONFORM_SIMPLE ("/text", text_idempotent_use_markup);
183
184   TEST_CONFORM_SIMPLE ("/rectangle", rectangle_set_size);
185   TEST_CONFORM_SIMPLE ("/rectangle", rectangle_set_color);
186
187   TEST_CONFORM_SIMPLE ("/texture", texture_pick_with_alpha);
188   TEST_CONFORM_SIMPLE ("/texture", texture_fbo);
189   TEST_CONFORM_SIMPLE ("/texture/cairo", texture_cairo);
190
191   TEST_CONFORM_SIMPLE ("/path", path_base);
192
193   TEST_CONFORM_SIMPLE ("/binding-pool", binding_pool);
194
195   TEST_CONFORM_SIMPLE ("/model", list_model_populate);
196   TEST_CONFORM_SIMPLE ("/model", list_model_iterate);
197   TEST_CONFORM_SIMPLE ("/model", list_model_filter);
198   TEST_CONFORM_SIMPLE ("/model", list_model_from_script);
199   TEST_CONFORM_SIMPLE ("/model", list_model_row_changed);
200
201   TEST_CONFORM_SIMPLE ("/color", color_from_string_valid);
202   TEST_CONFORM_SIMPLE ("/color", color_from_string_invalid);
203   TEST_CONFORM_SIMPLE ("/color", color_to_string);
204   TEST_CONFORM_SIMPLE ("/color", color_hls_roundtrip);
205   TEST_CONFORM_SIMPLE ("/color", color_operators);
206
207   TEST_CONFORM_SIMPLE ("/units", units_constructors);
208   TEST_CONFORM_SIMPLE ("/units", units_string);
209   TEST_CONFORM_SIMPLE ("/units", units_cache);
210
211   TEST_CONFORM_SIMPLE ("/group", group_depth_sorting);
212
213   TEST_CONFORM_SIMPLE ("/script", script_single);
214   TEST_CONFORM_SIMPLE ("/script", script_child);
215   TEST_CONFORM_SIMPLE ("/script", script_implicit_alpha);
216   TEST_CONFORM_SIMPLE ("/script", script_object_property);
217   TEST_CONFORM_SIMPLE ("/script", script_animation);
218   TEST_CONFORM_SIMPLE ("/script", script_named_object);
219   TEST_CONFORM_SIMPLE ("/script", script_layout_property);
220   TEST_CONFORM_SIMPLE ("/script", animator_base);
221   TEST_CONFORM_SIMPLE ("/script", animator_properties);
222   TEST_CONFORM_SIMPLE ("/script", animator_multi_properties);
223   TEST_CONFORM_SIMPLE ("/script", state_base);
224   TEST_CONFORM_SIMPLE ("/script", script_margin);
225
226   TEST_CONFORM_SIMPLE ("/timeline", timeline_base);
227   TEST_CONFORM_SIMPLE ("/timeline", timeline_markers_from_script);
228   TEST_CONFORM_SKIP (g_test_slow (), "/timeline", timeline_interpolation);
229   TEST_CONFORM_SKIP (g_test_slow (), "/timeline", timeline_rewind);
230
231   TEST_CONFORM_SIMPLE ("/score", score_base);
232
233   TEST_CONFORM_SIMPLE ("/behaviours", behaviours_base);
234
235   /* FIXME - see bug https://bugzilla.gnome.org/show_bug.cgi?id=655588 */
236   TEST_CONFORM_TODO ("/cally", cally_text);
237
238   TEST_CONFORM_SIMPLE ("/cogl", test_cogl_object);
239   TEST_CONFORM_SIMPLE ("/cogl", test_cogl_fixed);
240   TEST_CONFORM_SIMPLE ("/cogl", test_cogl_materials);
241   TEST_CONFORM_SIMPLE ("/cogl", test_cogl_premult);
242   TEST_CONFORM_SIMPLE ("/cogl", test_cogl_readpixels);
243
244   TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_npot_texture);
245   TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_multitexture);
246   TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_mipmaps);
247   TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_rectangle);
248   TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_pixmap_x11);
249   TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_get_set_data);
250   TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_atlas_migration);
251
252   TEST_CONFORM_SIMPLE ("/cogl/vertex-buffer", test_cogl_vertex_buffer_contiguous);
253   TEST_CONFORM_SIMPLE ("/cogl/vertex-buffer", test_cogl_vertex_buffer_interleved);
254   TEST_CONFORM_SIMPLE ("/cogl/vertex-buffer", test_cogl_vertex_buffer_mutability);
255
256   /* left to the end because they aren't currently very orthogonal and tend to
257    * break subsequent tests! */
258   TEST_CONFORM_SIMPLE ("/cogl", test_cogl_viewport);
259
260   return g_test_run ();
261 }