2013-12-12 15:05:16 +00:00
|
|
|
#define CLUTTER_DISABLE_DEPRECATION_WARNINGS
|
2010-02-02 12:56:04 +00:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
|
|
|
static void
|
2013-12-12 15:05:16 +00:00
|
|
|
behaviour_opacity (void)
|
2010-02-02 12:56:04 +00:00
|
|
|
{
|
|
|
|
ClutterBehaviour *behaviour;
|
2013-12-12 15:05:16 +00:00
|
|
|
ClutterTimeline *timeline;
|
|
|
|
ClutterAlpha *alpha;
|
2010-02-02 12:56:04 +00:00
|
|
|
guint8 start, end;
|
2010-02-09 13:00:39 +00:00
|
|
|
guint starti;
|
2010-02-02 12:56:04 +00:00
|
|
|
|
2013-12-12 15:05:16 +00:00
|
|
|
timeline = clutter_timeline_new (500);
|
|
|
|
alpha = clutter_alpha_new_full (timeline, CLUTTER_LINEAR);
|
|
|
|
behaviour = clutter_behaviour_opacity_new (alpha, 0, 255);
|
2010-02-02 12:56:04 +00:00
|
|
|
g_assert (CLUTTER_IS_BEHAVIOUR_OPACITY (behaviour));
|
2013-12-12 15:05:16 +00:00
|
|
|
g_object_add_weak_pointer (G_OBJECT (behaviour), (gpointer *) &behaviour);
|
|
|
|
g_object_add_weak_pointer (G_OBJECT (timeline), (gpointer *) &timeline);
|
2010-02-02 12:56:04 +00:00
|
|
|
|
|
|
|
clutter_behaviour_opacity_get_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour),
|
|
|
|
&start,
|
|
|
|
&end);
|
|
|
|
|
|
|
|
if (g_test_verbose ())
|
|
|
|
g_print ("BehaviourOpacity:bounds = %d, %d (expected: 0, 255)\n",
|
|
|
|
start,
|
|
|
|
end);
|
|
|
|
|
|
|
|
g_assert_cmpint (start, ==, 0);
|
|
|
|
g_assert_cmpint (end, ==, 255);
|
|
|
|
|
|
|
|
clutter_behaviour_opacity_set_bounds (CLUTTER_BEHAVIOUR_OPACITY (behaviour),
|
|
|
|
255,
|
|
|
|
0);
|
2010-02-09 13:00:39 +00:00
|
|
|
/* XXX: The gobject property is actually a unsigned int not unsigned char
|
|
|
|
* property so we have to be careful not to corrupt the stack by passing
|
|
|
|
* a guint8 pointer here... */
|
|
|
|
starti = 0;
|
|
|
|
g_object_get (G_OBJECT (behaviour), "opacity-start", &starti, NULL);
|
2010-02-02 12:56:04 +00:00
|
|
|
|
|
|
|
if (g_test_verbose ())
|
|
|
|
g_print ("BehaviourOpacity:start = %d (expected: 255)\n", start);
|
|
|
|
|
2010-02-09 13:00:39 +00:00
|
|
|
g_assert_cmpint (starti, ==, 255);
|
2010-02-02 12:56:04 +00:00
|
|
|
|
|
|
|
g_object_unref (behaviour);
|
2013-12-12 15:05:16 +00:00
|
|
|
g_object_unref (timeline);
|
|
|
|
|
|
|
|
g_assert_null (behaviour);
|
|
|
|
g_assert_null (timeline);
|
2010-02-02 12:56:04 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 15:05:16 +00:00
|
|
|
static struct
|
2010-02-02 12:56:04 +00:00
|
|
|
{
|
2013-12-12 15:05:16 +00:00
|
|
|
const gchar *path;
|
|
|
|
GTestFunc func;
|
2010-02-02 12:56:04 +00:00
|
|
|
} behaviour_tests[] = {
|
2013-12-12 15:05:16 +00:00
|
|
|
{ "opacity", behaviour_opacity },
|
2010-02-02 12:56:04 +00:00
|
|
|
};
|
|
|
|
|
2013-12-12 15:05:16 +00:00
|
|
|
static const int n_behaviour_tests = G_N_ELEMENTS (behaviour_tests);
|
2010-02-02 12:56:04 +00:00
|
|
|
|
2013-12-12 15:05:16 +00:00
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
2010-02-02 12:56:04 +00:00
|
|
|
{
|
2013-12-12 15:05:16 +00:00
|
|
|
int i;
|
2010-02-02 12:56:04 +00:00
|
|
|
|
2013-12-12 15:05:16 +00:00
|
|
|
clutter_test_init (&argc, &argv);
|
2010-02-02 12:56:04 +00:00
|
|
|
|
|
|
|
for (i = 0; i < n_behaviour_tests; i++)
|
|
|
|
{
|
2013-12-12 15:05:16 +00:00
|
|
|
char *path = g_strconcat ("/behaviours/", behaviour_tests[i].path, NULL);
|
|
|
|
|
|
|
|
clutter_test_add (path, behaviour_tests[i].func);
|
2010-02-02 12:56:04 +00:00
|
|
|
|
2013-12-12 15:05:16 +00:00
|
|
|
g_free (path);
|
2010-02-02 12:56:04 +00:00
|
|
|
}
|
|
|
|
|
2013-12-12 15:05:16 +00:00
|
|
|
return clutter_test_run ();
|
2010-02-02 12:56:04 +00:00
|
|
|
}
|