~ubuntu-branches/ubuntu/vivid/clutter-1.0/vivid-proposed

« back to all changes in this revision

Viewing changes to tests/conform/test-behaviours.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2012-05-01 23:50:39 UTC
  • mfrom: (4.1.22 experimental)
  • Revision ID: package-import@ubuntu.com-20120501235039-7wehcmtr33nqhv67
Tags: 1.10.4-2
Upload to unstable

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <glib.h>
2
 
 
3
 
#undef CLUTTER_DISABLE_DEPRECATED
4
 
#include <clutter/clutter.h>
5
 
 
6
 
#include "test-conform-common.h"
7
 
 
8
 
typedef struct _BehaviourFixture BehaviourFixture;
9
 
 
10
 
typedef void (* BehaviourTestFunc) (BehaviourFixture *fixture);
11
 
 
12
 
struct _BehaviourFixture
13
 
{
14
 
  ClutterTimeline *timeline;
15
 
  ClutterAlpha *alpha;
16
 
  ClutterActor *rect;
17
 
};
18
 
 
19
 
static void
20
 
opacity_behaviour (BehaviourFixture *fixture)
21
 
{
22
 
  ClutterBehaviour *behaviour;
23
 
  guint8 start, end;
24
 
  guint starti;
25
 
 
26
 
  behaviour = clutter_behaviour_opacity_new (fixture->alpha, 0, 255);
27
 
  g_assert (CLUTTER_IS_BEHAVIOUR_OPACITY (behaviour));
28
 
 
29
 
  clutter_behaviour_opacity_get_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour),
30
 
                                        &start,
31
 
                                        &end);
32
 
 
33
 
  if (g_test_verbose ())
34
 
    g_print ("BehaviourOpacity:bounds = %d, %d (expected: 0, 255)\n",
35
 
             start,
36
 
             end);
37
 
 
38
 
  g_assert_cmpint (start, ==, 0);
39
 
  g_assert_cmpint (end, ==, 255);
40
 
 
41
 
  clutter_behaviour_opacity_set_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour),
42
 
                                        255,
43
 
                                        0);
44
 
  /* XXX: The gobject property is actually a unsigned int not unsigned char
45
 
   * property so we have to be careful not to corrupt the stack by passing
46
 
   * a guint8 pointer here... */
47
 
  starti = 0;
48
 
  g_object_get (G_OBJECT (behaviour), "opacity-start", &starti, NULL);
49
 
 
50
 
  if (g_test_verbose ())
51
 
    g_print ("BehaviourOpacity:start = %d (expected: 255)\n", start);
52
 
 
53
 
  g_assert_cmpint (starti, ==, 255);
54
 
 
55
 
  g_object_unref (behaviour);
56
 
}
57
 
 
58
 
static const struct
59
 
{
60
 
  const gchar *desc;
61
 
  BehaviourTestFunc func;
62
 
} behaviour_tests[] = {
63
 
  { "BehaviourOpacity", opacity_behaviour }
64
 
};
65
 
 
66
 
static const gint n_behaviour_tests = G_N_ELEMENTS (behaviour_tests);
67
 
 
68
 
void
69
 
test_behaviours (TestConformSimpleFixture *fixture,
70
 
                 gconstpointer dummy)
71
 
{
72
 
  BehaviourFixture b_fixture;
73
 
  gint i;
74
 
 
75
 
  b_fixture.timeline = clutter_timeline_new (1000);
76
 
  b_fixture.alpha = clutter_alpha_new_full (b_fixture.timeline, CLUTTER_LINEAR);
77
 
  b_fixture.rect = clutter_rectangle_new ();
78
 
 
79
 
  g_object_ref_sink (b_fixture.alpha);
80
 
  g_object_unref (b_fixture.timeline);
81
 
 
82
 
  for (i = 0; i < n_behaviour_tests; i++)
83
 
    {
84
 
      if (g_test_verbose ())
85
 
        g_print ("Testing: %s\n", behaviour_tests[i].desc);
86
 
 
87
 
      behaviour_tests[i].func (&b_fixture);
88
 
    }
89
 
 
90
 
  g_object_unref (b_fixture.alpha);
91
 
  clutter_actor_destroy (b_fixture.rect);
92
 
}