1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <clutter/clutter.h>
4
5 #include "test-conform-common.h"
6
7 static guint level = 0;
8
9 static void
on_score_started(ClutterScore * score)10 on_score_started (ClutterScore *score)
11 {
12 if (g_test_verbose ())
13 g_print ("Score started\n");
14 }
15
16 static void
on_score_completed(ClutterScore * score)17 on_score_completed (ClutterScore *score)
18 {
19 if (g_test_verbose ())
20 g_print ("Score completed\n");
21 }
22
23 static void
on_timeline_started(ClutterScore * score,ClutterTimeline * timeline)24 on_timeline_started (ClutterScore *score,
25 ClutterTimeline *timeline)
26 {
27 if (g_test_verbose ())
28 g_print ("Started timeline: '%s'\n",
29 (gchar *) g_object_get_data (G_OBJECT (timeline), "timeline-name"));
30
31 level += 1;
32 }
33
34 static void
on_timeline_completed(ClutterScore * score,ClutterTimeline * timeline)35 on_timeline_completed (ClutterScore *score,
36 ClutterTimeline *timeline)
37 {
38 if (g_test_verbose ())
39 g_print ("Completed timeline: '%s'\n",
40 (gchar *) g_object_get_data (G_OBJECT (timeline), "timeline-name"));
41
42 level -= 1;
43 }
44
45 void
score_base(TestConformSimpleFixture * fixture,gconstpointer data)46 score_base (TestConformSimpleFixture *fixture,
47 gconstpointer data)
48 {
49 ClutterScore *score;
50 ClutterTimeline *timeline_1;
51 ClutterTimeline *timeline_2;
52 ClutterTimeline *timeline_3;
53 ClutterTimeline *timeline_4;
54 ClutterTimeline *timeline_5;
55 GSList *timelines;
56
57 /* FIXME - this is necessary to make the master clock spin */
58 ClutterActor *stage = clutter_stage_new ();
59
60 timeline_1 = clutter_timeline_new (100);
61 g_object_set_data_full (G_OBJECT (timeline_1),
62 "timeline-name", g_strdup ("Timeline 1"),
63 free);
64
65 timeline_2 = clutter_timeline_new (100);
66 clutter_timeline_add_marker_at_time (timeline_2, "foo", 50);
67 g_object_set_data_full (G_OBJECT (timeline_2),
68 "timeline-name", g_strdup ("Timeline 2"),
69 free);
70
71 timeline_3 = clutter_timeline_new (100);
72 g_object_set_data_full (G_OBJECT (timeline_3),
73 "timeline-name", g_strdup ("Timeline 3"),
74 free);
75
76 timeline_4 = clutter_timeline_new (100);
77 g_object_set_data_full (G_OBJECT (timeline_4),
78 "timeline-name", g_strdup ("Timeline 4"),
79 free);
80
81 timeline_5 = clutter_timeline_new (100);
82 g_object_set_data_full (G_OBJECT (timeline_5),
83 "timeline-name", g_strdup ("Timeline 5"),
84 free);
85
86 score = clutter_score_new();
87 g_signal_connect (score, "started",
88 G_CALLBACK (on_score_started),
89 NULL);
90 g_signal_connect (score, "timeline-started",
91 G_CALLBACK (on_timeline_started),
92 NULL);
93 g_signal_connect (score, "timeline-completed",
94 G_CALLBACK (on_timeline_completed),
95 NULL);
96 g_signal_connect (score, "completed",
97 G_CALLBACK (on_score_completed),
98 NULL);
99
100 clutter_score_append (score, NULL, timeline_1);
101 clutter_score_append (score, timeline_1, timeline_2);
102 clutter_score_append (score, timeline_1, timeline_3);
103 clutter_score_append (score, timeline_3, timeline_4);
104
105 clutter_score_append_at_marker (score, timeline_2, "foo", timeline_5);
106
107 timelines = clutter_score_list_timelines (score);
108 g_assert (5 == g_slist_length (timelines));
109 g_slist_free (timelines);
110
111 clutter_score_start (score);
112
113 clutter_actor_destroy (stage);
114
115 g_object_unref (timeline_1);
116 g_object_unref (timeline_2);
117 g_object_unref (timeline_3);
118 g_object_unref (timeline_4);
119 g_object_unref (timeline_5);
120 g_object_unref (score);
121 }
122