mutter/clutter/tests/interactive/test-state-script.c

46 lines
1.2 KiB
C
Raw Normal View History

#include <stdlib.h>
#include <gmodule.h>
#include <clutter/clutter.h>
Fully rework the conformance test suite The current conformance test suite is suboptimal in many ways. All tests are built into the same binary, which makes adding new tests, builting tests, and running groups of tests much more awkward than it needs to be. The first issue, especially, raises the bar of contribution in a significant way, while the other two take their toll on the maintainer. All of these changes were introduced back when we had both Clutter and Cogl tests in tree, and because we were building the test suite for every single change; since then, Cogl moved out of tree with all its tests, and we build the conformance test suite only when running the `check` make target. This admittedly large-ish commit changes the way the conformance test suite works, taking advantage of the changes in the GTest API and test harness. First of all, all tests are now built separately, using their own test suite as defined by each separate file. All tests run under the TAP harness provided by GTest and Automake, to gather a proper report using the Test Anything Protocol without using the `gtester` harness and the `gtester-report` script. We also use the Makefile rules provided by GLib to vastly simplify the build environment for the conformance test suite. On top of the changes for the build and harness, we also provide new API for creating and running test suites for Clutter. The API is public, because the test suite has to use it, but it's minimal and mostly provides convenience wrappers around GTest that make writing test units for Clutter easier. This commit disables all tests in the conformance test suite, as well as moving the data files outside of the tests/data directory; the next few commits will re-establish the conformance test suite separately so we can check that everything works in a reliable way.
2013-12-12 09:36:16 -05:00
#define TEST_STATE_SCRIPT_FILE "test-script-signals.json"
int
test_state_script_main (int argc, char *argv[]);
G_MODULE_EXPORT int
test_state_script_main (int argc, char *argv[])
{
ClutterActor *stage, *button;
ClutterScript *script;
GError *error = NULL;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return EXIT_FAILURE;
script = clutter_script_new ();
clutter_script_load_from_file (script, TEST_STATE_SCRIPT_FILE, &error);
if (error != NULL)
g_error ("Unable to load '%s': %s\n",
TEST_STATE_SCRIPT_FILE,
error->message);
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "State Script");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_actor_show (stage);
button = CLUTTER_ACTOR (clutter_script_get_object (script, "button"));
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button);
clutter_actor_add_constraint (button, clutter_align_constraint_new (stage, CLUTTER_ALIGN_BOTH, 0.5));
clutter_script_connect_signals (script, NULL);
clutter_main ();
g_object_unref (script);
return EXIT_SUCCESS;
}