[clutter] conform: Initial suite for ClutterInterval



commit aacd28cc2115f663df2c18ee3f4cdac2e5dbf055
Author: Emmanuele Bassi <ebassi linux intel com>
Date:   Mon Jun 18 17:51:48 2012 +0100

    conform: Initial suite for ClutterInterval
    
    ClutterInterval is undertested, so we should start adding a unit test
    for it.

 tests/conform/Makefile.am         |    1 +
 tests/conform/interval.c          |   39 +++++++++++++++++++++++++++++++++++++
 tests/conform/test-conform-main.c |    2 +
 3 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/tests/conform/Makefile.am b/tests/conform/Makefile.am
index d897070..51482a4 100644
--- a/tests/conform/Makefile.am
+++ b/tests/conform/Makefile.am
@@ -61,6 +61,7 @@ units_sources += \
 	binding-pool.c			\
 	cairo-texture.c    		\
 	group.c				\
+	interval.c			\
 	path.c 				\
 	rectangle.c 			\
 	texture-fbo.c			\
diff --git a/tests/conform/interval.c b/tests/conform/interval.c
new file mode 100644
index 0000000..9bc63be
--- /dev/null
+++ b/tests/conform/interval.c
@@ -0,0 +1,39 @@
+#include <clutter/clutter.h>
+
+#include "test-conform-common.h"
+
+void
+interval_initial_state (TestConformSimpleFixture *fixture G_GNUC_UNUSED,
+                        gconstpointer dummy G_GNUC_UNUSED)
+{
+  ClutterInterval *interval;
+  int initial, final;
+  const GValue *value;
+
+  interval = clutter_interval_new (G_TYPE_INT, 0, 100);
+  g_assert (CLUTTER_IS_INTERVAL (interval));
+  g_assert (clutter_interval_get_value_type (interval) == G_TYPE_INT);
+
+  clutter_interval_get_interval (interval, &initial, &final);
+  g_assert_cmpint (initial, ==, 0);
+  g_assert_cmpint (final, ==, 100);
+
+  value = clutter_interval_compute (interval, 0);
+  g_assert (G_VALUE_HOLDS_INT (value));
+  g_assert_cmpint (g_value_get_int (value), ==, 0);
+
+  value = clutter_interval_compute (interval, 1);
+  g_assert (G_VALUE_HOLDS_INT (value));
+  g_assert_cmpint (g_value_get_int (value), ==, 100);
+
+  value = clutter_interval_compute (interval, 0.5);
+  g_assert (G_VALUE_HOLDS_INT (value));
+  g_assert_cmpint (g_value_get_int (value), ==, 50);
+
+  clutter_interval_set_final (interval, 200);
+  value = clutter_interval_peek_final_value (interval);
+  g_assert (G_VALUE_HOLDS_INT (value));
+  g_assert_cmpint (g_value_get_int (value), ==, 200);
+
+  g_object_unref (interval);
+}
diff --git a/tests/conform/test-conform-main.c b/tests/conform/test-conform-main.c
index 41922c0..0e5b457 100644
--- a/tests/conform/test-conform-main.c
+++ b/tests/conform/test-conform-main.c
@@ -188,6 +188,8 @@ main (int argc, char **argv)
   TEST_CONFORM_SIMPLE ("/texture", texture_fbo);
   TEST_CONFORM_SIMPLE ("/texture/cairo", texture_cairo);
 
+  TEST_CONFORM_SIMPLE ("/interval", interval_initial_state);
+
   TEST_CONFORM_SIMPLE ("/path", path_base);
 
   TEST_CONFORM_SIMPLE ("/binding-pool", binding_pool);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]