forked from AuroraMiddleware/gtk
Add some GdkRGBA tests
This commit is contained in:
parent
503698f587
commit
366a37d8c1
@ -2,26 +2,27 @@ include $(top_srcdir)/Makefile.decl
|
|||||||
|
|
||||||
NULL=
|
NULL=
|
||||||
|
|
||||||
# check_PROGRAMS=check-gdk-cairo
|
noinst_PROGRAMS = $(TEST_PROGS)
|
||||||
check_PROGRAMS=
|
|
||||||
TESTS=$(check_PROGRAMS)
|
|
||||||
TESTS_ENVIRONMENT=GDK_PIXBUF_MODULE_FILE=$(top_builddir)/gdk-pixbuf/loaders.cache
|
|
||||||
|
|
||||||
AM_CPPFLAGS=\
|
AM_CPPFLAGS = \
|
||||||
$(GDK_DEP_CFLAGS) \
|
$(GDK_DEP_CFLAGS) \
|
||||||
-I$(top_srcdir) \
|
-I$(top_srcdir) \
|
||||||
-I$(top_builddir)/gdk \
|
-I$(top_builddir)/gdk \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
check_gdk_cairo_SOURCES=\
|
progs_ldadd = \
|
||||||
check-gdk-cairo.c \
|
|
||||||
$(NULL)
|
|
||||||
check_gdk_cairo_LDADD=\
|
|
||||||
$(GDK_DEP_LIBS) \
|
$(GDK_DEP_LIBS) \
|
||||||
$(top_builddir)/gdk-pixbuf/libgdk_pixbuf-$(GTK_API_VERSION).la \
|
|
||||||
$(top_builddir)/gdk/libgdk-$(gdktarget)-$(GTK_API_VERSION).la \
|
$(top_builddir)/gdk/libgdk-$(gdktarget)-$(GTK_API_VERSION).la \
|
||||||
$(NULL)
|
$(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 = \
|
CLEANFILES = \
|
||||||
cairosurface.png \
|
cairosurface.png \
|
||||||
gdksurface.png
|
gdksurface.png
|
||||||
|
62
gdk/tests/gdk-color.c
Normal file
62
gdk/tests/gdk-color.c
Normal file
@ -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 ();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user