| 1 |
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS |
| 2 |
#include <clutter/clutter.h> |
| 3 |
|
| 4 |
static void |
| 5 |
behaviour_opacity (void) |
| 6 |
{ |
| 7 |
ClutterBehaviour *behaviour; |
| 8 |
ClutterTimeline *timeline; |
| 9 |
ClutterAlpha *alpha; |
| 10 |
guint8 start, end; |
| 11 |
guint starti; |
| 12 |
|
| 13 |
timeline = clutter_timeline_new (500); |
| 14 |
alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR); |
| 15 |
behaviour = clutter_behaviour_opacity_new (alpha, 0, 255); |
| 16 |
g_assert (CLUTTER_IS_BEHAVIOUR_OPACITY (behaviour)); |
| 17 |
g_object_add_weak_pointer (G_OBJECT (behaviour), (gpointer *) &behaviour); |
| 18 |
g_object_add_weak_pointer (G_OBJECT (timeline), (gpointer *) &timeline); |
| 19 |
|
| 20 |
clutter_behaviour_opacity_get_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour), |
| 21 |
&start, |
| 22 |
&end); |
| 23 |
|
| 24 |
if (g_test_verbose ()) |
| 25 |
g_print ("BehaviourOpacity:bounds = %d, %d (expected: 0, 255)\n", |
| 26 |
start, |
| 27 |
end); |
| 28 |
|
| 29 |
g_assert_cmpint (start, ==, 0); |
| 30 |
g_assert_cmpint (end, ==, 255); |
| 31 |
|
| 32 |
clutter_behaviour_opacity_set_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour), |
| 33 |
255, |
| 34 |
0); |
| 35 |
/* XXX: The gobject property is actually a unsigned int not unsigned char |
| 36 |
* property so we have to be careful not to corrupt the stack by passing |
| 37 |
* a guint8 pointer here... */ |
| 38 |
starti = 0; |
| 39 |
g_object_get (G_OBJECT (behaviour), "opacity-start", &starti, NULL); |
| 40 |
|
| 41 |
if (g_test_verbose ()) |
| 42 |
g_print ("BehaviourOpacity:start = %d (expected: 255)\n", start); |
| 43 |
|
| 44 |
g_assert_cmpint (starti, ==, 255); |
| 45 |
|
| 46 |
g_object_unref (behaviour); |
| 47 |
g_object_unref (timeline); |
| 48 |
|
| 49 |
g_assert_null (behaviour); |
| 50 |
g_assert_null (timeline); |
| 51 |
} |
| 52 |
|
| 53 |
static struct |
| 54 |
{ |
| 55 |
const gchar *path; |
| 56 |
GTestFunc func; |
| 57 |
} behaviour_tests[] = { |
| 58 |
{ "opacity", behaviour_opacity }, |
| 59 |
}; |
| 60 |
|
| 61 |
static const int n_behaviour_tests = G_N_ELEMENTS (behaviour_tests); |
| 62 |
|
| 63 |
int |
| 64 |
main (int argc, char *argv[]) |
| 65 |
{ |
| 66 |
int i; |
| 67 |
|
| 68 |
clutter_test_init (&argc, &argv); |
| 69 |
|
| 70 |
for (i = 0; i < n_behaviour_tests; i++) |
| 71 |
{ |
| 72 |
char *path = g_strconcat ("/behaviours/", behaviour_tests[i].path, NULL); |
| 73 |
|
| 74 |
clutter_test_add (path, behaviour_tests[i].func); |
| 75 |
|
| 76 |
g_free (path); |
| 77 |
} |
| 78 |
|
| 79 |
return clutter_test_run (); |
| 80 |
} |