2020-03-25 11:37:56 -04:00
|
|
|
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
|
2008-03-05 11:04:06 -05:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <glib.h>
|
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
2020-03-25 11:37:56 -04:00
|
|
|
#include "tests/clutter-test-utils.h"
|
2008-11-07 14:32:28 -05:00
|
|
|
|
2009-06-04 08:05:12 -04:00
|
|
|
#define TEST_TIMELINE_DURATION 500
|
2008-03-05 11:04:06 -05:00
|
|
|
#define TEST_WATCHDOG_KICK_IN_SECONDS 10
|
|
|
|
|
2009-05-01 10:08:42 -04:00
|
|
|
typedef struct _TestState
|
|
|
|
{
|
|
|
|
ClutterTimeline *timeline;
|
|
|
|
gint rewind_count;
|
|
|
|
} TestState;
|
2008-03-05 11:04:06 -05:00
|
|
|
|
|
|
|
static gboolean
|
2012-01-25 18:09:38 -05:00
|
|
|
watchdog_timeout (gpointer data)
|
2008-03-05 11:04:06 -05:00
|
|
|
{
|
2012-01-25 18:09:38 -05:00
|
|
|
TestState *state = data;
|
|
|
|
|
2009-06-11 06:38:49 -04:00
|
|
|
g_test_message ("Watchdog timer kicking in");
|
|
|
|
g_test_message ("rewind_count=%i", state->rewind_count);
|
2008-03-05 11:04:06 -05:00
|
|
|
if (state->rewind_count <= 3)
|
|
|
|
{
|
|
|
|
/* The test has hung */
|
2009-06-11 06:38:49 -04:00
|
|
|
g_test_message ("Failed (This test shouldn't have hung!)");
|
2008-03-05 11:04:06 -05:00
|
|
|
exit (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-11 06:38:49 -04:00
|
|
|
g_test_message ("Passed");
|
2008-11-07 14:32:28 -05:00
|
|
|
clutter_main_quit ();
|
2008-03-05 11:04:06 -05:00
|
|
|
}
|
|
|
|
|
2012-01-25 18:09:38 -05:00
|
|
|
return G_SOURCE_REMOVE;
|
2008-03-05 11:04:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
new_frame_cb (ClutterTimeline *timeline,
|
2011-01-24 06:49:04 -05:00
|
|
|
gint elapsed_time,
|
2008-03-05 11:04:06 -05:00
|
|
|
TestState *state)
|
|
|
|
{
|
2009-06-04 08:05:12 -04:00
|
|
|
if (elapsed_time == TEST_TIMELINE_DURATION)
|
2008-03-05 11:04:06 -05:00
|
|
|
{
|
2009-06-11 06:38:49 -04:00
|
|
|
g_test_message ("new-frame signal received (end of timeline)");
|
|
|
|
g_test_message ("Rewinding timeline");
|
2008-03-05 11:04:06 -05:00
|
|
|
clutter_timeline_rewind (timeline);
|
|
|
|
state->rewind_count++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-04 08:05:12 -04:00
|
|
|
if (elapsed_time == 0)
|
2008-03-05 11:04:06 -05:00
|
|
|
{
|
2009-06-11 06:38:49 -04:00
|
|
|
g_test_message ("new-frame signal received (start of timeline)");
|
2008-03-05 11:04:06 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-06-11 06:38:49 -04:00
|
|
|
g_test_message ("new-frame signal received (mid frame)");
|
2008-03-05 11:04:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
if (state->rewind_count >= 2)
|
|
|
|
{
|
2009-06-11 06:38:49 -04:00
|
|
|
g_test_message ("Sleeping for 1 second");
|
2008-03-05 11:04:06 -05:00
|
|
|
g_usleep (1000000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-25 11:37:56 -04:00
|
|
|
static void
|
2010-10-12 12:31:15 -04:00
|
|
|
timeline_rewind (void)
|
2008-03-05 11:04:06 -05:00
|
|
|
{
|
|
|
|
TestState state;
|
|
|
|
|
|
|
|
state.timeline =
|
2009-06-04 08:05:12 -04:00
|
|
|
clutter_timeline_new (TEST_TIMELINE_DURATION);
|
2008-03-05 11:04:06 -05:00
|
|
|
g_signal_connect (G_OBJECT(state.timeline),
|
|
|
|
"new-frame",
|
|
|
|
G_CALLBACK(new_frame_cb),
|
|
|
|
&state);
|
2008-11-07 14:32:28 -05:00
|
|
|
g_test_message ("Installing a watchdog timeout "
|
2009-06-11 06:38:49 -04:00
|
|
|
"to determine if this test hangs");
|
2012-01-25 18:09:38 -05:00
|
|
|
clutter_threads_add_timeout (TEST_WATCHDOG_KICK_IN_SECONDS * 1000,
|
|
|
|
watchdog_timeout,
|
|
|
|
&state);
|
2008-03-05 11:04:06 -05:00
|
|
|
state.rewind_count = 0;
|
2009-05-01 10:08:42 -04:00
|
|
|
|
2008-03-05 11:04:06 -05:00
|
|
|
clutter_timeline_start (state.timeline);
|
|
|
|
|
|
|
|
clutter_main();
|
2008-11-07 14:32:28 -05:00
|
|
|
|
|
|
|
g_object_unref (state.timeline);
|
2008-03-05 11:04:06 -05:00
|
|
|
}
|
2020-03-25 11:37:56 -04:00
|
|
|
|
|
|
|
CLUTTER_TEST_SUITE (
|
|
|
|
CLUTTER_TEST_UNIT ("/timeline/rewind", timeline_rewind)
|
|
|
|
)
|