[gtk+] Add some GdkRGBA tests
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] Add some GdkRGBA tests
- Date: Mon, 25 Oct 2010 16:01:55 +0000 (UTC)
commit 366a37d8c1a9ee540c0090b6fef9c4cc3b8807c6
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Oct 25 12:01:11 2010 -0400
Add some GdkRGBA tests
gdk/tests/Makefile.am | 21 ++++++++--------
gdk/tests/gdk-color.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 73 insertions(+), 10 deletions(-)
---
diff --git a/gdk/tests/Makefile.am b/gdk/tests/Makefile.am
index 2567627..04e5b25 100644
--- a/gdk/tests/Makefile.am
+++ b/gdk/tests/Makefile.am
@@ -2,26 +2,27 @@ include $(top_srcdir)/Makefile.decl
NULL=
-# check_PROGRAMS=check-gdk-cairo
-check_PROGRAMS=
-TESTS=$(check_PROGRAMS)
-TESTS_ENVIRONMENT=GDK_PIXBUF_MODULE_FILE=$(top_builddir)/gdk-pixbuf/loaders.cache
+noinst_PROGRAMS = $(TEST_PROGS)
-AM_CPPFLAGS=\
+AM_CPPFLAGS = \
$(GDK_DEP_CFLAGS) \
-I$(top_srcdir) \
-I$(top_builddir)/gdk \
$(NULL)
-check_gdk_cairo_SOURCES=\
- check-gdk-cairo.c \
- $(NULL)
-check_gdk_cairo_LDADD=\
+progs_ldadd = \
$(GDK_DEP_LIBS) \
- $(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
$(top_builddir)/gdk/libgdk-$(gdktarget)-$(GTK_API_VERSION).la \
$(NULL)
+#TEST_PROGS += check-gdk-cairo
+check_gdk_cairo_SOURCES = check-gdk-cairo.c
+check_gdk_cairo_LDADD = $(progs_ldadd)
+
+TEST_PROGS += gdk-color
+gdk_color_SOURCES = gdk-color.c
+gdk_color_LDADD = $(progs_ldadd)
+
CLEANFILES = \
cairosurface.png \
gdksurface.png
diff --git a/gdk/tests/gdk-color.c b/gdk/tests/gdk-color.c
new file mode 100644
index 0000000..f2346de
--- /dev/null
+++ b/gdk/tests/gdk-color.c
@@ -0,0 +1,62 @@
+#include <gdk/gdk.h>
+
+static void
+test_color_parse (void)
+{
+ GdkRGBA color;
+ GdkRGBA expected;
+ gboolean res;
+
+ res = gdk_rgba_parse ("foo", &color);
+ g_assert (!res);
+
+ res = gdk_rgba_parse ("", &color);
+ g_assert (!res);
+
+ expected.red = 0.4;
+ expected.green = 0.3;
+ expected.blue = 0.2;
+ expected.alpha = 0.1;
+ res = gdk_rgba_parse ("rgba(0.4,0.3,0.2,0.1)", &color);
+ g_assert (res);
+ g_assert (gdk_rgba_equal (&color, &expected));
+
+ res = gdk_rgba_parse ("rgba ( 0.4 , 0.3 , 0.2 , 0.1 )", &color);
+ g_assert (res);
+ g_assert (gdk_rgba_equal (&color, &expected));
+
+ expected.red = 0.4;
+ expected.green = 0.3;
+ expected.blue = 0.2;
+ expected.alpha = 1.0;
+ res = gdk_rgba_parse ("rgb(0.4,0.3,0.2)", &color);
+ g_assert (res);
+ g_assert (gdk_rgba_equal (&color, &expected));
+
+ expected.red = 1.0;
+ expected.green = 0.0;
+ expected.blue = 0.0;
+ expected.alpha = 1.0;
+ res = gdk_rgba_parse ("red", &color);
+ g_assert (res);
+ g_assert (gdk_rgba_equal (&color, &expected));
+
+ expected.red = 0.0;
+ expected.green = 0x8080 / 65535.;
+ expected.blue = 1.0;
+ expected.alpha = 1.0;
+ res = gdk_rgba_parse ("#0080ff", &color);
+ g_assert (res);
+ g_assert (gdk_rgba_equal (&color, &expected));
+}
+
+int
+main (int argc, char *argv[])
+{
+ g_test_init (&argc, &argv, NULL);
+ gdk_init (&argc, &argv);
+
+ g_test_add_func ("/color/parse", test_color_parse);
+
+ return g_test_run ();
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]