| 1 |
#include <glib.h> |
| 2 |
#include <clutter/clutter.h> |
| 3 |
#include "test-conform-common.h" |
| 4 |
|
| 5 |
void |
| 6 |
timeline_progress_step (TestConformSimpleFixture *fixture G_GNUC_UNUSED, |
| 7 |
gconstpointer dummy G_GNUC_UNUSED) |
| 8 |
{ |
| 9 |
ClutterTimeline *timeline; |
| 10 |
|
| 11 |
timeline = clutter_timeline_new (1000); |
| 12 |
|
| 13 |
if (g_test_verbose ()) |
| 14 |
g_print ("mode: step(3, end)\n"); |
| 15 |
|
| 16 |
clutter_timeline_rewind (timeline); |
| 17 |
clutter_timeline_set_step_progress (timeline, 3, CLUTTER_STEP_MODE_END); |
| 18 |
g_assert_cmpint (clutter_timeline_get_progress (timeline), ==, 0); |
| 19 |
|
| 20 |
clutter_timeline_advance (timeline, 1000 / 3 - 1); |
| 21 |
g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 0); |
| 22 |
|
| 23 |
clutter_timeline_advance (timeline, 1000 / 3 + 1); |
| 24 |
g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 333); |
| 25 |
|
| 26 |
clutter_timeline_advance (timeline, 1000 / 3 * 2 - 1); |
| 27 |
g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 333); |
| 28 |
|
| 29 |
clutter_timeline_advance (timeline, 1000 / 3 * 2 + 1); |
| 30 |
g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 666); |
| 31 |
|
| 32 |
clutter_timeline_rewind (timeline); |
| 33 |
clutter_timeline_set_progress_mode (timeline, CLUTTER_STEP_START); |
| 34 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 35 |
|
| 36 |
clutter_timeline_advance (timeline, 1); |
| 37 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 38 |
|
| 39 |
clutter_timeline_advance (timeline, 500); |
| 40 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 41 |
|
| 42 |
clutter_timeline_advance (timeline, 999); |
| 43 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 44 |
|
| 45 |
clutter_timeline_advance (timeline, 1000); |
| 46 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 47 |
|
| 48 |
if (g_test_verbose ()) |
| 49 |
g_print ("mode: step-start\n"); |
| 50 |
|
| 51 |
clutter_timeline_rewind (timeline); |
| 52 |
clutter_timeline_set_progress_mode (timeline, CLUTTER_STEP_START); |
| 53 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 54 |
|
| 55 |
clutter_timeline_advance (timeline, 1); |
| 56 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 57 |
|
| 58 |
clutter_timeline_advance (timeline, 500); |
| 59 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 60 |
|
| 61 |
clutter_timeline_advance (timeline, 999); |
| 62 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 63 |
|
| 64 |
clutter_timeline_advance (timeline, 1000); |
| 65 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 66 |
|
| 67 |
if (g_test_verbose ()) |
| 68 |
g_print ("mode: step-end\n"); |
| 69 |
|
| 70 |
clutter_timeline_rewind (timeline); |
| 71 |
clutter_timeline_set_progress_mode (timeline, CLUTTER_STEP_END); |
| 72 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 73 |
|
| 74 |
clutter_timeline_advance (timeline, 1); |
| 75 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 76 |
|
| 77 |
clutter_timeline_advance (timeline, 500); |
| 78 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 79 |
|
| 80 |
clutter_timeline_advance (timeline, 999); |
| 81 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 82 |
|
| 83 |
clutter_timeline_advance (timeline, 1000); |
| 84 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 85 |
|
| 86 |
g_object_unref (timeline); |
| 87 |
} |
| 88 |
|
| 89 |
void |
| 90 |
timeline_progress_mode (TestConformSimpleFixture *fixture G_GNUC_UNUSED, |
| 91 |
gconstpointer dummy G_GNUC_UNUSED) |
| 92 |
{ |
| 93 |
ClutterTimeline *timeline; |
| 94 |
|
| 95 |
timeline = clutter_timeline_new (1000); |
| 96 |
|
| 97 |
g_assert (clutter_timeline_get_progress_mode (timeline) == CLUTTER_LINEAR); |
| 98 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 99 |
|
| 100 |
clutter_timeline_advance (timeline, 500); |
| 101 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.5); |
| 102 |
|
| 103 |
clutter_timeline_advance (timeline, 1000); |
| 104 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0); |
| 105 |
|
| 106 |
clutter_timeline_rewind (timeline); |
| 107 |
g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0); |
| 108 |
|
| 109 |
g_object_unref (timeline); |
| 110 |
} |