[monet/style-stylable] [tests] add a test for MnStylable



commit 7ee92c23590a6f2351d58fab5c738d1277e411dc
Author: Thomas Wood <thomas wood intel com>
Date:   Fri Sep 18 15:25:13 2009 +0100

    [tests] add a test for MnStylable
    
    Use the MnItem's simple implementation of MnStylable to test MnStylable
    and MnStyle.

 tests/Makefile.am     |    3 +-
 tests/test-item.css   |    7 ++++++
 tests/test-stylable.c |   53 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 4032492..5ebd5fa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -2,8 +2,9 @@ AM_CFLAGS = $(MONET_CFLAGS)
 INCLUDES = -I$(top_srcdir)
 LDADD = $(MONET_LIBS) $(top_builddir)/monet/libmonet.la
 
-noinst_PROGRAMS = test-drawing
+noinst_PROGRAMS = test-drawing test-stylable
 
 test_drawing_SOURCES = test-drawing.c
+test_stylable_SOURCES = test-stylable.c
 
 -include $(top_srcdir)/git.mk
diff --git a/tests/test-item.css b/tests/test-item.css
new file mode 100644
index 0000000..51d71b8
--- /dev/null
+++ b/tests/test-item.css
@@ -0,0 +1,7 @@
+TestItem#item-one {
+  background-color: #f00;
+}
+
+TestItem#item-two {
+  background-color: #00f;
+}
diff --git a/tests/test-stylable.c b/tests/test-stylable.c
new file mode 100644
index 0000000..dbcfde6
--- /dev/null
+++ b/tests/test-stylable.c
@@ -0,0 +1,53 @@
+#include <monet/monet.h>
+#include <stdio.h>
+
+int
+main (int argc, char **argv)
+{
+  MnStyle *style;
+  MnItem *item1, *item2;
+  MnColor *color;
+  gchar *string;
+  GError *err = NULL;
+
+  monet_init (&argc, &argv);
+
+  style = mn_style_new ();
+  mn_style_load_from_file (style, "test-item.css", &err);
+
+  if (err)
+    {
+      printf ("Error: %s\n", err->message);
+      return 1;
+    }
+
+  item1 = mn_item_new ();
+  g_object_set (item1,
+                "style", style,
+                "style-type", "TestItem",
+                "style-id", "item-one",
+                NULL);
+
+  item2 = mn_item_new ();
+  g_object_set (item2,
+                "style", style,
+                "style-type", "TestItem",
+                "style-id", "item-two",
+                NULL);
+
+  mn_stylable_get (MN_STYLABLE (item1), "background-color", &color, NULL);
+  string = mn_color_to_string (color);
+  printf ("item1 background = %s\n", string);
+  g_free (string);
+
+  mn_stylable_get (MN_STYLABLE (item2), "background-color", &color, NULL);
+  string = mn_color_to_string (color);
+  printf ("item2 background = %s\n", string);
+  g_free (string);
+
+  g_object_unref (item1);
+  g_object_unref (item2);
+  g_object_unref (style);
+
+  return 0;
+}



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