build: Move gdk/tests/ to testsuite/gdk/
This is a reorganization of the testsuite to be in the testsuite/ directory, so it can be installed from there.
This commit is contained in:
6
testsuite/Makefile.am
Normal file
6
testsuite/Makefile.am
Normal file
@@ -0,0 +1,6 @@
|
||||
include $(top_srcdir)/Makefile.decl
|
||||
|
||||
SUBDIRS = gdk
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
|
||||
68
testsuite/gdk/Makefile.am
Normal file
68
testsuite/gdk/Makefile.am
Normal file
@@ -0,0 +1,68 @@
|
||||
include $(top_srcdir)/Makefile.decl
|
||||
|
||||
NULL=
|
||||
|
||||
noinst_PROGRAMS = $(TEST_PROGS)
|
||||
|
||||
AM_CPPFLAGS = \
|
||||
$(GDK_DEP_CFLAGS) \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_builddir)/gdk \
|
||||
$(NULL)
|
||||
|
||||
progs_ldadd = \
|
||||
$(GDK_DEP_LIBS) \
|
||||
$(top_builddir)/gdk/libgdk-3.la \
|
||||
$(NULL)
|
||||
|
||||
#TEST_PROGS += check-gdk-cairo
|
||||
#check_gdk_cairo_SOURCES = check-gdk-cairo.c
|
||||
#check_gdk_cairo_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += rgba
|
||||
rgba_SOURCES = rgba.c
|
||||
rgba_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += encoding
|
||||
encoding_SOURCES = encoding.c
|
||||
encoding_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += display
|
||||
display_SOURCES = display.c
|
||||
display_LDADD = $(progs_ldadd)
|
||||
|
||||
TEST_PROGS += keysyms
|
||||
keysyms_SOURCES = keysyms.c
|
||||
keysyms_LDADD = $(progs_ldadd)
|
||||
|
||||
CLEANFILES = \
|
||||
cairosurface.png \
|
||||
gdksurface.png
|
||||
|
||||
if BUILDOPT_INSTALL_TESTS
|
||||
insttestdir=$(pkglibexecdir)/installed-tests
|
||||
insttest_PROGRAMS = $(TEST_PROGS)
|
||||
|
||||
substitutions = \
|
||||
-e s,@pkglibexecdir\@,$(pkglibexecdir),g \
|
||||
$(NULL)
|
||||
|
||||
test_in_files = \
|
||||
rgba.test.in \
|
||||
encoding.test.in \
|
||||
display.test.in \
|
||||
keysyms.test.in \
|
||||
$(NULL)
|
||||
|
||||
test_files = $(test_in_files:.test.in=.test)
|
||||
|
||||
$(test_files): %.test: %.test.in
|
||||
$(AM_V_GEN) sed $(substitutions) $< > $@.tmp && mv $@.tmp $@
|
||||
|
||||
EXTRA_DIST += $(test_in_files)
|
||||
|
||||
testmetadir = $(datadir)/installed-tests/$(PACKAGE)
|
||||
testmeta_DATA = $(test_files)
|
||||
endif
|
||||
|
||||
-include $(top_srcdir)/git.mk
|
||||
149
testsuite/gdk/check-gdk-cairo.c
Normal file
149
testsuite/gdk/check-gdk-cairo.c
Normal file
@@ -0,0 +1,149 @@
|
||||
/* This file is part of GTK+
|
||||
*
|
||||
* AUTHORS
|
||||
* Sven Herzberg
|
||||
*
|
||||
* Copyright (C) 2008 Sven Herzberg
|
||||
*
|
||||
* This work is provided "as is"; redistribution and modification
|
||||
* in whole or in part, in any medium, physical or electronic is
|
||||
* permitted without restriction.
|
||||
*
|
||||
* This work is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* In no event shall the authors or contributors be liable for any
|
||||
* direct, indirect, incidental, special, exemplary, or consequential
|
||||
* damages (including, but not limited to, procurement of substitute
|
||||
* goods or services; loss of use, data, or profits; or business
|
||||
* interruption) however caused and on any theory of liability, whether
|
||||
* in contract, strict liability, or tort (including negligence or
|
||||
* otherwise) arising in any way out of the use of this software, even
|
||||
* if advised of the possibility of such damage.
|
||||
*/
|
||||
|
||||
#include <glib/gstdio.h>
|
||||
#include <gdk/gdk.h>
|
||||
#ifdef CAIRO_HAS_QUARTZ_SURFACE
|
||||
#include <cairo-quartz.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
test (cairo_t* cr)
|
||||
{
|
||||
cairo_save (cr);
|
||||
cairo_set_source_rgb (cr, 1.0, 1.0, 1.0);
|
||||
cairo_paint (cr);
|
||||
cairo_restore (cr);
|
||||
|
||||
cairo_move_to (cr, 10.0, 20.0);
|
||||
cairo_line_to (cr, 10.0, 30.0);
|
||||
cairo_stroke (cr);
|
||||
|
||||
cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 0.5);
|
||||
cairo_arc (cr, 0.0, 0.0, 10.0, 0.0, G_PI/2);
|
||||
cairo_stroke (cr);
|
||||
}
|
||||
|
||||
static void
|
||||
test_surface_orientation (void)
|
||||
{
|
||||
cairo_surface_t *surface;
|
||||
GdkPixbuf* pixbuf;
|
||||
GdkPixbuf* pbuf_platform;
|
||||
GdkPixbuf* pbuf_imagesrf;
|
||||
GError * error = NULL;
|
||||
cairo_surface_t* surface;
|
||||
cairo_t* cr;
|
||||
guchar* data_platform;
|
||||
guchar* data_imagesrf;
|
||||
guint i;
|
||||
|
||||
/* create "platform.png" via native cairo surface */
|
||||
surface = gdk_window_create_similar_surface (gdk_get_default_root_window (),
|
||||
CAIRO_CONTENT_COLOR,
|
||||
100,
|
||||
80);
|
||||
cr = cairo_create (surface);
|
||||
test (cr);
|
||||
cairo_destroy (cr);
|
||||
|
||||
pixbuf = gdk_pixbuf_get_from_surface (NULL,
|
||||
surface,
|
||||
0, 0,
|
||||
0, 0,
|
||||
100, 80);
|
||||
if (!gdk_pixbuf_save (pixbuf, "gdksurface.png", "png", NULL, NULL)) {
|
||||
g_error ("Eeek! Couldn't save the file \"gdksurface.png\"");
|
||||
}
|
||||
g_object_unref (pixbuf);
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
/* create "cairosurface.png" via pure cairo */
|
||||
#ifndef CAIRO_HAS_QUARTZ_SURFACE
|
||||
surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, 100, 80);
|
||||
#else
|
||||
surface = cairo_quartz_surface_create (CAIRO_FORMAT_RGB24, 100, 80);
|
||||
#endif
|
||||
cr = cairo_create (surface);
|
||||
test (cr);
|
||||
cairo_destroy (cr);
|
||||
if (CAIRO_STATUS_SUCCESS != cairo_surface_write_to_png (surface, "cairosurface.png")) {
|
||||
g_error ("Eeek! Couldn't save the file \"cairosurface.png\"");
|
||||
}
|
||||
cairo_surface_destroy (surface);
|
||||
|
||||
/* compare the images */
|
||||
pbuf_platform = gdk_pixbuf_new_from_file ("gdksurface.png", &error);
|
||||
if (!pbuf_platform || error) {
|
||||
g_error ("Eeek! Error loading \"gdksurface.png\"");
|
||||
}
|
||||
pbuf_imagesrf = gdk_pixbuf_new_from_file ("cairosurface.png", &error);
|
||||
if (!pbuf_imagesrf || error) {
|
||||
g_object_unref (pbuf_platform);
|
||||
g_error ("Eeek! Error loading \"cairosurface.png\"");
|
||||
}
|
||||
|
||||
g_assert (gdk_pixbuf_get_width (pbuf_platform) ==
|
||||
gdk_pixbuf_get_width (pbuf_imagesrf));
|
||||
g_assert (gdk_pixbuf_get_height (pbuf_platform) ==
|
||||
gdk_pixbuf_get_height (pbuf_imagesrf));
|
||||
g_assert (gdk_pixbuf_get_rowstride (pbuf_platform) ==
|
||||
gdk_pixbuf_get_rowstride (pbuf_imagesrf));
|
||||
g_assert (gdk_pixbuf_get_n_channels (pbuf_platform) ==
|
||||
gdk_pixbuf_get_n_channels (pbuf_imagesrf));
|
||||
|
||||
data_platform = gdk_pixbuf_get_pixels (pbuf_platform);
|
||||
data_imagesrf = gdk_pixbuf_get_pixels (pbuf_imagesrf);
|
||||
|
||||
for (i = 0; i < gdk_pixbuf_get_height (pbuf_platform) * gdk_pixbuf_get_rowstride (pbuf_platform); i++) {
|
||||
if (data_platform[i] != data_imagesrf[i]) {
|
||||
g_warning ("Eeek! Images are differing at byte %d", i);
|
||||
g_object_unref (pbuf_platform);
|
||||
g_object_unref (pbuf_imagesrf);
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
}
|
||||
|
||||
g_object_unref (pbuf_platform);
|
||||
g_object_unref (pbuf_imagesrf);
|
||||
|
||||
g_unlink ("gdksurface.png");
|
||||
g_unlink ("cairosurface.png");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc,
|
||||
char**argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
gdk_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/gdk/surface/orientation",
|
||||
test_surface_orientation);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
|
||||
74
testsuite/gdk/display.c
Normal file
74
testsuite/gdk/display.c
Normal file
@@ -0,0 +1,74 @@
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
static void
|
||||
test_unset_display (void)
|
||||
{
|
||||
if (g_test_trap_fork (0, 0))//G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
||||
{
|
||||
GdkDisplayManager *manager;
|
||||
|
||||
g_unsetenv ("DISPLAY");
|
||||
|
||||
g_assert (!gdk_init_check (NULL, NULL));
|
||||
manager = gdk_display_manager_get ();
|
||||
g_assert (manager != NULL);
|
||||
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
g_test_trap_assert_passed ();
|
||||
|
||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
||||
{
|
||||
g_unsetenv ("DISPLAY");
|
||||
|
||||
gdk_init (NULL, NULL);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
g_test_trap_assert_failed ();
|
||||
g_test_trap_assert_stderr ("*cannot open display*");
|
||||
}
|
||||
|
||||
static void
|
||||
test_bad_display (void)
|
||||
{
|
||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
||||
{
|
||||
GdkDisplayManager *manager;
|
||||
|
||||
g_setenv ("DISPLAY", "poo", TRUE);
|
||||
|
||||
g_assert (!gdk_init_check (NULL, NULL));
|
||||
manager = gdk_display_manager_get ();
|
||||
g_assert (manager != NULL);
|
||||
g_assert (gdk_display_manager_get_default_display (manager) == NULL);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
g_test_trap_assert_passed ();
|
||||
|
||||
if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
|
||||
{
|
||||
g_setenv ("DISPLAY", "poo", TRUE);
|
||||
|
||||
gdk_init (NULL, NULL);
|
||||
|
||||
exit (0);
|
||||
}
|
||||
g_test_trap_assert_failed ();
|
||||
g_test_trap_assert_stderr ("*cannot open display*");
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_add_func ("/display/unset-display", test_unset_display);
|
||||
g_test_add_func ("/display/bad-display", test_bad_display);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
3
testsuite/gdk/display.test.in
Normal file
3
testsuite/gdk/display.test.in
Normal file
@@ -0,0 +1,3 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "@pkglibexecdir@/installed-tests/display"
|
||||
Type=session
|
||||
46
testsuite/gdk/encoding.c
Normal file
46
testsuite/gdk/encoding.c
Normal file
@@ -0,0 +1,46 @@
|
||||
#include <gdk/gdk.h>
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
#include <gdk/x11/gdkx.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
test_to_text_list (void)
|
||||
{
|
||||
GdkDisplay *display;
|
||||
|
||||
display = gdk_display_get_default ();
|
||||
|
||||
#ifdef GDK_WINDOWING_X11
|
||||
if (GDK_IS_X11_DISPLAY (display))
|
||||
{
|
||||
GdkAtom encoding;
|
||||
gint format;
|
||||
const guchar *text;
|
||||
gint length;
|
||||
gchar **list;
|
||||
gint n;
|
||||
|
||||
encoding = gdk_atom_intern ("UTF8_STRING", FALSE);
|
||||
format = 8;
|
||||
text = (const guchar*)"abcdef \304\201 \304\205\0ABCDEF \304\200 \304\204";
|
||||
length = 25;
|
||||
n = gdk_x11_display_text_property_to_text_list (display, encoding, format, text, length, &list);
|
||||
g_assert_cmpint (n, ==, 2);
|
||||
g_assert (g_str_has_prefix (list[0], "abcdef "));
|
||||
g_assert (g_str_has_prefix (list[1], "ABCDEF "));
|
||||
|
||||
gdk_x11_free_text_list (list);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
gdk_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/encoding/to-text-list", test_to_text_list);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
3
testsuite/gdk/encoding.test.in
Normal file
3
testsuite/gdk/encoding.test.in
Normal file
@@ -0,0 +1,3 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "@pkglibexecdir@/installed-tests/encoding"
|
||||
Type=session
|
||||
69
testsuite/gdk/keysyms.c
Normal file
69
testsuite/gdk/keysyms.c
Normal file
@@ -0,0 +1,69 @@
|
||||
#include <locale.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
static void
|
||||
test_keysyms_basic (void)
|
||||
{
|
||||
struct {
|
||||
guint keyval;
|
||||
const gchar *name;
|
||||
const gchar *other_name;
|
||||
} tests[] = {
|
||||
{ GDK_KEY_space, "space", NULL },
|
||||
{ GDK_KEY_a, "a", NULL },
|
||||
{ GDK_KEY_Thorn, "Thorn", "THORN" },
|
||||
{ GDK_KEY_Hangul_J_RieulTieut, "Hangul_J_RieulTieut", NULL },
|
||||
{ GDK_KEY_Page_Up, "Page_Up", NULL },
|
||||
{ GDK_KEY_KP_Multiply, "KP_Multiply", NULL },
|
||||
{ GDK_KEY_MonBrightnessUp, "MonBrightnessUp", NULL },
|
||||
{ 0, NULL }
|
||||
};
|
||||
gint i;
|
||||
|
||||
for (i = 0; tests[i].keyval != 0; i++)
|
||||
{
|
||||
g_assert_cmpstr (gdk_keyval_name (tests[i].keyval), ==, tests[i].name);
|
||||
g_assert_cmpuint (gdk_keyval_from_name (tests[i].name), ==, tests[i].keyval);
|
||||
if (tests[i].other_name)
|
||||
g_assert_cmpuint (gdk_keyval_from_name (tests[i].other_name), ==, tests[i].keyval);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
test_keysyms_void (void)
|
||||
{
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("NoSuchKeysym"), ==, GDK_KEY_VoidSymbol);
|
||||
g_assert_cmpstr (gdk_keyval_name (GDK_KEY_VoidSymbol), ==, "0xffffff");
|
||||
}
|
||||
|
||||
static void
|
||||
test_keysyms_xf86 (void)
|
||||
{
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("XF86MonBrightnessUp"), ==, GDK_KEY_MonBrightnessUp);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("XF86MonBrightnessDown"), ==, GDK_KEY_MonBrightnessDown);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("XF86KbdBrightnessUp"), ==, GDK_KEY_KbdBrightnessUp);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("XF86KbdBrightnessDown"), ==, GDK_KEY_KbdBrightnessDown);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("XF86Battery"), ==, GDK_KEY_Battery);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("XF86Display"), ==, GDK_KEY_Display);
|
||||
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("MonBrightnessUp"), ==, GDK_KEY_MonBrightnessUp);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("MonBrightnessDown"), ==, GDK_KEY_MonBrightnessDown);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("KbdBrightnessUp"), ==, GDK_KEY_KbdBrightnessUp);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("KbdBrightnessDown"), ==, GDK_KEY_KbdBrightnessDown);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("Battery"), ==, GDK_KEY_Battery);
|
||||
g_assert_cmpuint (gdk_keyval_from_name ("Display"), ==, GDK_KEY_Display);
|
||||
}
|
||||
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
gdk_init (&argc, &argv);
|
||||
|
||||
g_test_add_func ("/keysyms/basic", test_keysyms_basic);
|
||||
g_test_add_func ("/keysyms/void", test_keysyms_void);
|
||||
g_test_add_func ("/keysyms/xf86", test_keysyms_xf86);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
3
testsuite/gdk/keysyms.test.in
Normal file
3
testsuite/gdk/keysyms.test.in
Normal file
@@ -0,0 +1,3 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "@pkglibexecdir@/installed-tests/keysyms"
|
||||
Type=session
|
||||
164
testsuite/gdk/rgba.c
Normal file
164
testsuite/gdk/rgba.c
Normal file
@@ -0,0 +1,164 @@
|
||||
#include <locale.h>
|
||||
#include <gdk/gdk.h>
|
||||
|
||||
static void
|
||||
test_color_parse (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
GdkRGBA expected;
|
||||
gboolean res;
|
||||
|
||||
res = gdk_rgba_parse (&color, "foo");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "");
|
||||
g_assert (!res);
|
||||
|
||||
expected.red = 100/255.;
|
||||
expected.green = 90/255.;
|
||||
expected.blue = 80/255.;
|
||||
expected.alpha = 0.1;
|
||||
res = gdk_rgba_parse (&color, "rgba(100,90,80,0.1)");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
expected.red = 0.4;
|
||||
expected.green = 0.3;
|
||||
expected.blue = 0.2;
|
||||
expected.alpha = 0.1;
|
||||
res = gdk_rgba_parse (&color, "rgba(40%,30%,20%,0.1)");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgba( 40 % , 30 % , 20 % , 0.1 )");
|
||||
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 (&color, "red");
|
||||
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 (&color, "#0080ff");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
|
||||
expected.red = 0.0;
|
||||
expected.green = 0.0;
|
||||
expected.blue = 0.0;
|
||||
expected.alpha = 1.0;
|
||||
res = gdk_rgba_parse (&color, "rgb(0,0,0)");
|
||||
g_assert (res);
|
||||
g_assert (gdk_rgba_equal (&color, &expected));
|
||||
}
|
||||
|
||||
static void
|
||||
test_color_to_string (void)
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
GdkRGBA out;
|
||||
gchar *res;
|
||||
gchar *res_de;
|
||||
gchar *res_en;
|
||||
gchar *orig;
|
||||
|
||||
/* Using /255. values for the r, g, b components should
|
||||
* make sure they round-trip exactly without rounding
|
||||
* from the double => integer => double conversions */
|
||||
rgba.red = 1.0;
|
||||
rgba.green = 128/255.;
|
||||
rgba.blue = 64/255.;
|
||||
rgba.alpha = 0.5;
|
||||
|
||||
orig = g_strdup (setlocale (LC_ALL, NULL));
|
||||
res = gdk_rgba_to_string (&rgba);
|
||||
gdk_rgba_parse (&out, res);
|
||||
g_assert (gdk_rgba_equal (&rgba, &out));
|
||||
|
||||
setlocale (LC_ALL, "de_DE.utf-8");
|
||||
res_de = gdk_rgba_to_string (&rgba);
|
||||
g_assert_cmpstr (res, ==, res_de);
|
||||
|
||||
setlocale (LC_ALL, "en_US.utf-8");
|
||||
res_en = gdk_rgba_to_string (&rgba);
|
||||
g_assert_cmpstr (res, ==, res_en);
|
||||
|
||||
g_free (res);
|
||||
g_free (res_de);
|
||||
g_free (res_en);
|
||||
|
||||
setlocale (LC_ALL, orig);
|
||||
g_free (orig);
|
||||
}
|
||||
|
||||
static void
|
||||
test_color_copy (void)
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
GdkRGBA *out;
|
||||
|
||||
rgba.red = 0.0;
|
||||
rgba.green = 0.1;
|
||||
rgba.blue = 0.6;
|
||||
rgba.alpha = 0.9;
|
||||
|
||||
out = gdk_rgba_copy (&rgba);
|
||||
g_assert (gdk_rgba_equal (&rgba, out));
|
||||
|
||||
gdk_rgba_free (out);
|
||||
}
|
||||
|
||||
static void
|
||||
test_color_parse_nonsense (void)
|
||||
{
|
||||
GdkRGBA color;
|
||||
gboolean res;
|
||||
|
||||
g_test_bug ("667485");
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(,,)");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(%,%,%)");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(nan,nan,nan)");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(inf,inf,inf)");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(1p12,0,0)");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(5d1%,1,1)");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(0,0,0)moo");
|
||||
g_assert (!res);
|
||||
|
||||
res = gdk_rgba_parse (&color, "rgb(0,0,0) moo");
|
||||
g_assert (!res);
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char *argv[])
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
|
||||
g_test_bug_base ("http://bugzilla.gnome.org");
|
||||
|
||||
g_test_add_func ("/rgba/parse", test_color_parse);
|
||||
g_test_add_func ("/rgba/parse/nonsense", test_color_parse_nonsense);
|
||||
g_test_add_func ("/rgba/to-string", test_color_to_string);
|
||||
g_test_add_func ("/rgba/copy", test_color_copy);
|
||||
|
||||
return g_test_run ();
|
||||
}
|
||||
3
testsuite/gdk/rgba.test.in
Normal file
3
testsuite/gdk/rgba.test.in
Normal file
@@ -0,0 +1,3 @@
|
||||
[Test]
|
||||
Exec=/bin/sh -c "@pkglibexecdir@/installed-tests/rgba"
|
||||
Type=session
|
||||
Reference in New Issue
Block a user