File: timeline-progress.c

package info (click to toggle)
clutter-1.0 1.26.4%2Bgit2779b932%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,672 kB
  • sloc: ansic: 130,756; xml: 1,641; makefile: 1,607; sh: 980; perl: 192; ruby: 167
file content (110 lines) | stat: -rw-r--r-- 3,926 bytes parent folder | download | duplicates (4)
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
#include <glib.h>
#include <clutter/clutter.h>
#include "test-conform-common.h"

void
timeline_progress_step (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
                        gconstpointer dummy G_GNUC_UNUSED)
{
  ClutterTimeline *timeline;

  timeline = clutter_timeline_new (1000);

  if (g_test_verbose ())
    g_print ("mode: step(3, end)\n");

  clutter_timeline_rewind (timeline);
  clutter_timeline_set_step_progress (timeline, 3, CLUTTER_STEP_MODE_END);
  g_assert_cmpint (clutter_timeline_get_progress (timeline), ==, 0);

  clutter_timeline_advance (timeline, 1000 / 3 - 1);
  g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 0);

  clutter_timeline_advance (timeline, 1000 / 3 + 1);
  g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 333);

  clutter_timeline_advance (timeline, 1000 / 3 * 2 - 1);
  g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 333);

  clutter_timeline_advance (timeline, 1000 / 3 * 2 + 1);
  g_assert_cmpint (clutter_timeline_get_progress (timeline) * 1000, ==, 666);

  clutter_timeline_rewind (timeline);
  clutter_timeline_set_progress_mode (timeline, CLUTTER_STEP_START);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  clutter_timeline_advance (timeline, 1);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  clutter_timeline_advance (timeline, 500);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  clutter_timeline_advance (timeline, 999);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  clutter_timeline_advance (timeline, 1000);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  if (g_test_verbose ())
    g_print ("mode: step-start\n");

  clutter_timeline_rewind (timeline);
  clutter_timeline_set_progress_mode (timeline, CLUTTER_STEP_START);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  clutter_timeline_advance (timeline, 1);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  clutter_timeline_advance (timeline, 500);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  clutter_timeline_advance (timeline, 999);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  clutter_timeline_advance (timeline, 1000);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  if (g_test_verbose ())
    g_print ("mode: step-end\n");

  clutter_timeline_rewind (timeline);
  clutter_timeline_set_progress_mode (timeline, CLUTTER_STEP_END);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  clutter_timeline_advance (timeline, 1);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  clutter_timeline_advance (timeline, 500);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  clutter_timeline_advance (timeline, 999);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  clutter_timeline_advance (timeline, 1000);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  g_object_unref (timeline);
}

void
timeline_progress_mode (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
                        gconstpointer dummy G_GNUC_UNUSED)
{
  ClutterTimeline *timeline;

  timeline = clutter_timeline_new (1000);

  g_assert (clutter_timeline_get_progress_mode (timeline) == CLUTTER_LINEAR);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  clutter_timeline_advance (timeline, 500);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.5);

  clutter_timeline_advance (timeline, 1000);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 1.0);

  clutter_timeline_rewind (timeline);
  g_assert_cmpfloat (clutter_timeline_get_progress (timeline), ==, 0.0);

  g_object_unref (timeline);
}