mirror of
https://github.com/brl/mutter.git
synced 2024-12-24 20:12:06 +00:00
603f936745
framework * configure.ac: * tests/*: The tests have been reorganised into different categories: conformance, interactive and micro benchmarks. - conformance tests can be run as part of automated tests - interactive tests are basically all the existing tests - micro benchmarks focus on a single performance metric I converted the timeline tests to conformance tests and also added some tests from Neil Roberts and Ebassi. Note: currently only the conformance tests use the glib test APIs, though the micro benchmarks should too. The other change is to make the unit tests link into monolithic binaries which makes the build time for unit tests considerably faster. To deal with the extra complexity this adds to debugging individual tests I have added some sugar to the makefiles so all the tests can be run directly via a symlink and when an individual test is run this way, then a note is printed to the terminal explaining exactly how that test may be debugged using GDB. There is a convenience make rule: 'make test-report', that will run all the conformance tests and hopefully even open the results in your web browser. It skips some of the slower timeline tests, but you can run those using 'make full-report'
99 lines
2.2 KiB
C
99 lines
2.2 KiB
C
#include <stdlib.h>
|
|
#include <glib.h>
|
|
#include <clutter/clutter.h>
|
|
|
|
#include "test-conform-common.h"
|
|
|
|
#define TEST_TIMELINE_FPS 10
|
|
#define TEST_TIMELINE_FRAME_COUNT 5
|
|
#define TEST_WATCHDOG_KICK_IN_SECONDS 10
|
|
|
|
typedef struct _TestState {
|
|
ClutterTimeline *timeline;
|
|
gint rewind_count;
|
|
}TestState;
|
|
|
|
|
|
static gboolean
|
|
watchdog_timeout (TestState *state)
|
|
{
|
|
g_test_message ("Watchdog timer kicking in\n");
|
|
g_test_message ("rewind_count=%i\n", state->rewind_count);
|
|
if (state->rewind_count <= 3)
|
|
{
|
|
/* The test has hung */
|
|
g_test_message ("Failed (This test shouldn't have hung!)\n");
|
|
exit (EXIT_FAILURE);
|
|
}
|
|
else
|
|
{
|
|
g_test_message ("Passed\n");
|
|
clutter_main_quit ();
|
|
}
|
|
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
static void
|
|
new_frame_cb (ClutterTimeline *timeline,
|
|
gint frame_num,
|
|
TestState *state)
|
|
{
|
|
gint current_frame = clutter_timeline_get_current_frame (timeline);
|
|
|
|
if (current_frame == TEST_TIMELINE_FRAME_COUNT)
|
|
{
|
|
g_test_message ("new-frame signal recieved (end of timeline)\n");
|
|
g_test_message ("Rewinding timeline\n");
|
|
clutter_timeline_rewind (timeline);
|
|
state->rewind_count++;
|
|
}
|
|
else
|
|
{
|
|
if (current_frame == 0)
|
|
{
|
|
g_test_message ("new-frame signal recieved (start of timeline)\n");
|
|
}
|
|
else
|
|
{
|
|
g_test_message ("new-frame signal recieved (mid frame)\n");
|
|
}
|
|
|
|
if (state->rewind_count >= 2)
|
|
{
|
|
g_test_message ("Sleeping for 1 second\n");
|
|
g_usleep (1000000);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
void
|
|
test_timeline_rewind (TestConformSimpleFixture *fixture,
|
|
gconstpointer data)
|
|
{
|
|
TestState state;
|
|
|
|
state.timeline =
|
|
clutter_timeline_new (TEST_TIMELINE_FRAME_COUNT,
|
|
TEST_TIMELINE_FPS);
|
|
g_signal_connect (G_OBJECT(state.timeline),
|
|
"new-frame",
|
|
G_CALLBACK(new_frame_cb),
|
|
&state);
|
|
g_test_message ("Installing a watchdog timeout "
|
|
"to determine if this test hangs\n");
|
|
g_timeout_add (TEST_WATCHDOG_KICK_IN_SECONDS*1000,
|
|
(GSourceFunc)watchdog_timeout,
|
|
&state);
|
|
state.rewind_count = 0;
|
|
|
|
clutter_timeline_start (state.timeline);
|
|
|
|
clutter_main();
|
|
|
|
g_object_unref (state.timeline);
|
|
}
|
|
|