summaryrefslogtreecommitdiff
path: root/tests/conform/test-conform-main.c
blob: 04536ae977cd7c6db7dbf29f9c369a68dc62c959 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#include "config.h"

#include <clutter/clutter.h>

#include <glib.h>
#include <locale.h>
#include <stdlib.h>

#include "test-conform-common.h"

static void
test_conform_skip_test (TestConformSimpleFixture *fixture,
                        gconstpointer             data)
{
  /* void */
}

static void
test_conform_todo_test (TestConformSimpleFixture *fixture,
                        gconstpointer             data)
{
#ifdef G_OS_UNIX
  const TestConformTodo *todo = data;

  if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
    {
      todo->func (fixture, NULL);
      exit (0);
    }

  g_test_trap_assert_failed ();
#endif
}

void
verify_failure (TestConformSimpleFixture *fixture,
                gconstpointer             data)
{
  g_assert (FALSE);
}

static TestConformSharedState *shared_state = NULL;

/* This is a bit of sugar for adding new conformance tests:
 *
 * - It adds an extern function definition just to save maintaining a header
 *   that lists test entry points.
 * - It sets up callbacks for a fixture, which lets us share initialization
 *   *code* between tests. (see test-conform-common.c)
 * - It passes in a shared *data* pointer that is initialised once in main(),
 *   that gets passed to the fixture setup and test functions. (See the
 *   definition in test-conform-common.h)
 */
#define TEST_CONFORM_SIMPLE(NAMESPACE, FUNC)            G_STMT_START {  \
  extern void FUNC (TestConformSimpleFixture *, gconstpointer);         \
  g_test_add ("/conform" NAMESPACE "/" #FUNC,                           \
	      TestConformSimpleFixture,                                 \
	      shared_state, /* data argument for test */                \
	      test_conform_simple_fixture_setup,                        \
	      FUNC,                                                     \
	      test_conform_simple_fixture_teardown);    } G_STMT_END

/* this is a macro that conditionally executes a test if CONDITION
 * evaluates to TRUE; otherwise, it will put the test under the
 * "/skipped" namespace and execute a dummy function that will always
 * pass.
 */
#define TEST_CONFORM_SKIP(CONDITION, NAMESPACE, FUNC)   G_STMT_START {  \
  if (CONDITION) { TEST_CONFORM_SIMPLE (NAMESPACE, FUNC); }             \
  else {                                                                \
    g_test_add ("/skipped" NAMESPACE "/" #FUNC,                         \
                TestConformSimpleFixture,                               \
                shared_state, /* data argument for test */              \
                test_conform_simple_fixture_setup,                      \
                test_conform_skip_test,                                 \
                test_conform_simple_fixture_teardown);                  \
  }                                                     } G_STMT_END

#define TEST_CONFORM_TODO(NAMESPACE, FUNC)              G_STMT_START {  \
   extern void FUNC (TestConformSimpleFixture *, gconstpointer);        \
   TestConformTodo *_clos = g_new0 (TestConformTodo, 1);                \
   _clos->name = g_strdup ( #FUNC );                                    \
   _clos->func = FUNC;                                                  \
   g_test_add ("/todo" NAMESPACE "/" #FUNC,                             \
              TestConformSimpleFixture,                                 \
              _clos,                                                    \
              test_conform_simple_fixture_setup,                        \
              test_conform_todo_test,                                   \
              test_conform_simple_fixture_teardown);    } G_STMT_END

gchar *
clutter_test_get_data_file (const gchar *filename)
{
  return g_build_filename (TESTS_DATADIR, filename, NULL);
}

static void
clutter_test_init (gint    *argc,
                   gchar ***argv)
{
  /* Turning of sync-to-vblank removes a dependency on the specifics of the
   * test environment. It also means that the timeline-only tests are
   * throttled to a reasonable frame rate rather than running in tight
   * infinite loop.
   */
  g_setenv ("CLUTTER_VBLANK", "none", FALSE);

  g_test_init (argc, argv, NULL);

  g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=%s");

  /* Initialise the state you need to share with everything.
   */
  shared_state = g_new0 (TestConformSharedState, 1);
  shared_state->argc_addr = argc;
  shared_state->argv_addr = argv;
}

int
main (int argc, char **argv)
{
  clutter_test_init (&argc, &argv);

  /* This file is run through a sed script during the make step so the
     lines containing the tests need to be formatted on a single line
     each. To comment out a test use the SKIP or TODO macros. Using
     #if 0 would break the script. */

  /* sanity check for the test suite itself */
  TEST_CONFORM_TODO ("/suite", verify_failure);

  TEST_CONFORM_SIMPLE ("/actor", actor_add_child);
  TEST_CONFORM_SIMPLE ("/actor", actor_insert_child);
  TEST_CONFORM_SIMPLE ("/actor", actor_raise_child);
  TEST_CONFORM_SIMPLE ("/actor", actor_lower_child);
  TEST_CONFORM_SIMPLE ("/actor", actor_replace_child);
  TEST_CONFORM_SIMPLE ("/actor", actor_remove_child);
  TEST_CONFORM_SIMPLE ("/actor", actor_remove_all);
  TEST_CONFORM_SIMPLE ("/actor", actor_container_signals);
  TEST_CONFORM_SIMPLE ("/actor", actor_destruction);
  TEST_CONFORM_SIMPLE ("/actor", actor_anchors);
  TEST_CONFORM_SIMPLE ("/actor", actor_pick);
  TEST_CONFORM_SIMPLE ("/actor", actor_fixed_size);
  TEST_CONFORM_SIMPLE ("/actor", actor_preferred_size);
  TEST_CONFORM_SIMPLE ("/actor", actor_basic_layout);
  TEST_CONFORM_SIMPLE ("/actor", actor_margin_layout);
  TEST_CONFORM_SIMPLE ("/actor", actor_offscreen_redirect);
  TEST_CONFORM_SIMPLE ("/actor", actor_shader_effect);

  TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_children);
  TEST_CONFORM_SIMPLE ("/actor/iter", actor_iter_traverse_remove);

  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_initial_state);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_shown_not_parented);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_visibility_not_recursive);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realized);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_realize_not_recursive);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_map_recursive);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_mapped);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_show_on_set_parent);
  TEST_CONFORM_SIMPLE ("/actor/invariants", clone_no_map);
  TEST_CONFORM_SIMPLE ("/actor/invariants", actor_contains);
  TEST_CONFORM_SIMPLE ("/actor/invariants", default_stage);

  TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_label);
  TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_rectangle);
  TEST_CONFORM_SIMPLE ("/actor/opacity", opacity_paint);

  TEST_CONFORM_SIMPLE ("/text", text_utf8_validation);
  TEST_CONFORM_SIMPLE ("/text", text_set_empty);
  TEST_CONFORM_SIMPLE ("/text", text_set_text);
  TEST_CONFORM_SIMPLE ("/text", text_append_some);
  TEST_CONFORM_SIMPLE ("/text", text_prepend_some);
  TEST_CONFORM_SIMPLE ("/text", text_insert);
  TEST_CONFORM_SIMPLE ("/text", text_delete_chars);
  TEST_CONFORM_SIMPLE ("/text", text_delete_text);
  TEST_CONFORM_SIMPLE ("/text", text_cursor);
  TEST_CONFORM_SIMPLE ("/text", text_event);
  TEST_CONFORM_SIMPLE ("/text", text_get_chars);
  TEST_CONFORM_SIMPLE ("/text", text_cache);
  TEST_CONFORM_SIMPLE ("/text", text_password_char);
  TEST_CONFORM_SIMPLE ("/text", text_idempotent_use_markup);

  TEST_CONFORM_SIMPLE ("/rectangle", rectangle_set_size);
  TEST_CONFORM_SIMPLE ("/rectangle", rectangle_set_color);

  TEST_CONFORM_SIMPLE ("/texture", texture_pick_with_alpha);
  TEST_CONFORM_SIMPLE ("/texture", texture_fbo);
  TEST_CONFORM_SIMPLE ("/texture/cairo", texture_cairo);

  TEST_CONFORM_SIMPLE ("/path", path_base);

  TEST_CONFORM_SIMPLE ("/binding-pool", binding_pool);

  TEST_CONFORM_SIMPLE ("/model", list_model_populate);
  TEST_CONFORM_SIMPLE ("/model", list_model_iterate);
  TEST_CONFORM_SIMPLE ("/model", list_model_filter);
  TEST_CONFORM_SIMPLE ("/model", list_model_from_script);
  TEST_CONFORM_SIMPLE ("/model", list_model_row_changed);

  TEST_CONFORM_SIMPLE ("/color", color_from_string_valid);
  TEST_CONFORM_SIMPLE ("/color", color_from_string_invalid);
  TEST_CONFORM_SIMPLE ("/color", color_to_string);
  TEST_CONFORM_SIMPLE ("/color", color_hls_roundtrip);
  TEST_CONFORM_SIMPLE ("/color", color_operators);

  TEST_CONFORM_SIMPLE ("/units", units_constructors);
  TEST_CONFORM_SIMPLE ("/units", units_string);
  TEST_CONFORM_SIMPLE ("/units", units_cache);

  TEST_CONFORM_SIMPLE ("/group", group_depth_sorting);

  TEST_CONFORM_SIMPLE ("/script", script_single);
  TEST_CONFORM_SIMPLE ("/script", script_child);
  TEST_CONFORM_SIMPLE ("/script", script_implicit_alpha);
  TEST_CONFORM_SIMPLE ("/script", script_object_property);
  TEST_CONFORM_SIMPLE ("/script", script_animation);
  TEST_CONFORM_SIMPLE ("/script", script_named_object);
  TEST_CONFORM_SIMPLE ("/script", script_layout_property);
  TEST_CONFORM_SIMPLE ("/script", animator_base);
  TEST_CONFORM_SIMPLE ("/script", animator_properties);
  TEST_CONFORM_SIMPLE ("/script", animator_multi_properties);
  TEST_CONFORM_SIMPLE ("/script", state_base);

  TEST_CONFORM_SIMPLE ("/timeline", timeline_base);
  TEST_CONFORM_SIMPLE ("/timeline", timeline_markers_from_script);
  TEST_CONFORM_SKIP (g_test_slow (), "/timeline", timeline_interpolation);
  TEST_CONFORM_SKIP (g_test_slow (), "/timeline", timeline_rewind);

  TEST_CONFORM_SIMPLE ("/score", score_base);

  TEST_CONFORM_SIMPLE ("/behaviours", behaviours_base);

  /* FIXME - see bug https://bugzilla.gnome.org/show_bug.cgi?id=655588 */
  TEST_CONFORM_TODO ("/cally", cally_text);

  TEST_CONFORM_SIMPLE ("/cogl", test_cogl_object);
  TEST_CONFORM_SIMPLE ("/cogl", test_cogl_fixed);
  TEST_CONFORM_SIMPLE ("/cogl", test_cogl_materials);
  TEST_CONFORM_SIMPLE ("/cogl", test_cogl_premult);
  TEST_CONFORM_SIMPLE ("/cogl", test_cogl_readpixels);

  TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_npot_texture);
  TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_multitexture);
  TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_mipmaps);
  TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_rectangle);
  TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_pixmap_x11);
  TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_texture_get_set_data);
  TEST_CONFORM_SIMPLE ("/cogl/texture", test_cogl_atlas_migration);

  TEST_CONFORM_SIMPLE ("/cogl/vertex-buffer", test_cogl_vertex_buffer_contiguous);
  TEST_CONFORM_SIMPLE ("/cogl/vertex-buffer", test_cogl_vertex_buffer_interleved);
  TEST_CONFORM_SIMPLE ("/cogl/vertex-buffer", test_cogl_vertex_buffer_mutability);

  /* left to the end because they aren't currently very orthogonal and tend to
   * break subsequent tests! */
  TEST_CONFORM_SIMPLE ("/cogl", test_cogl_viewport);

  return g_test_run ();
}