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=
|
||||
|
||||
# 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
|
||||
|
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