~elementary-os/elementaryos/os-patch-notify-osd-precise

« back to all changes in this revision

Viewing changes to egg/test-timeline-dup-frames.c

  • Committer: Sergey "Shnatsel" Davidoff
  • Date: 2012-06-18 21:08:31 UTC
  • Revision ID: shnatsel@gmail.com-20120618210831-g6k5y7vecjdylgic
Initial import, version 0.9.34-0ubuntu2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdlib.h>
 
2
#include <glib.h>
 
3
#include <egg/egg-hack.h>
 
4
 
 
5
/* We use a nice slow timeline for this test since we
 
6
 * dont want the timeouts to interpolate the timeline
 
7
 * forward multiple frames */
 
8
#define TEST_TIMELINE_FPS 10
 
9
#define TEST_TIMELINE_FRAME_COUNT 20
 
10
 
 
11
typedef struct _TestState {
 
12
  EggTimeline *timeline;
 
13
  gint prev_frame;
 
14
  gint completion_count;
 
15
  gint passed;
 
16
}TestState;
 
17
 
 
18
 
 
19
static void
 
20
new_frame_cb (EggTimeline *timeline,
 
21
              gint frame_num,
 
22
              TestState *state)
 
23
{
 
24
  gint current_frame = egg_timeline_get_current_frame (state->timeline);
 
25
  
 
26
  if (state->prev_frame != egg_timeline_get_current_frame (state->timeline))
 
27
    {
 
28
      g_print("timeline previous frame=%-4i actual frame=%-4i (OK)\n",
 
29
              state->prev_frame,
 
30
              current_frame);
 
31
    }
 
32
  else
 
33
    {
 
34
      g_print("timeline previous frame=%-4i actual frame=%-4i (FAILED)\n",
 
35
              state->prev_frame,
 
36
              current_frame);
 
37
 
 
38
      state->passed = FALSE;
 
39
    }
 
40
 
 
41
  state->prev_frame = current_frame;
 
42
}
 
43
 
 
44
 
 
45
static void
 
46
completed_cb (EggTimeline *timeline,
 
47
              TestState *state)
 
48
{
 
49
  state->completion_count++;
 
50
 
 
51
  if (state->completion_count == 2)
 
52
    {
 
53
        if (state->passed)
 
54
          {
 
55
              g_print("Passed\n");
 
56
              exit(EXIT_SUCCESS);
 
57
          }
 
58
        else
 
59
          {
 
60
              g_print("Failed\n");
 
61
              exit(EXIT_FAILURE);
 
62
          }
 
63
    }
 
64
}
 
65
 
 
66
 
 
67
int
 
68
main(int argc, char **argv)
 
69
{
 
70
  TestState state;
 
71
 
 
72
  egg_init(&argc, &argv);
 
73
  
 
74
  state.timeline = 
 
75
    egg_timeline_new (TEST_TIMELINE_FRAME_COUNT,
 
76
                          TEST_TIMELINE_FPS);
 
77
  egg_timeline_set_loop (state.timeline, TRUE);
 
78
  g_signal_connect (G_OBJECT(state.timeline),
 
79
                    "new-frame",
 
80
                    G_CALLBACK(new_frame_cb),
 
81
                    &state);
 
82
  g_signal_connect (G_OBJECT(state.timeline),
 
83
                    "completed",
 
84
                    G_CALLBACK(completed_cb),
 
85
                    &state);
 
86
 
 
87
  state.prev_frame = -1;
 
88
  state.completion_count = 0;
 
89
  state.passed = TRUE;
 
90
 
 
91
  egg_timeline_start (state.timeline);
 
92
  
 
93
  egg_main();
 
94
  
 
95
  return EXIT_FAILURE;
 
96
}
 
97