Commit 9fa240c1 authored by Matthias Clasen's avatar Matthias Clasen

Make testsuite robust against disabled formats

Skip tests if their file format is not supported by the
available loaders.

https://bugzilla.gnome.org/show_bug.cgi?id=722651
parent 6079c11a
......@@ -42,17 +42,57 @@ dist_installed_test_data = \
icc-profile.png \
$(wildcard $(srcdir)/test-images/*)
pixbuf_icc_SOURCES = \
pixbuf-icc.c \
test-common.c \
test-common.h \
$(NULL)
pixbuf_scale_SOURCES = \
pixbuf-scale.c \
test-common.c \
test-common.h \
$(NULL)
pixbuf_stream_SOURCES = \
pixbuf-stream.c \
test-common.c \
test-common.h \
$(NULL)
pixbuf_threads_SOURCES = \
pixbuf-threads.c \
test-common.c \
test-common.h \
$(NULL)
pixbuf_icon_serialize_SOURCES = \
pixbuf-icon-serialize.c \
test-common.c \
test-common.h \
$(NULL)
pixbuf_save_SOURCES = \
pixbuf-save.c \
test-common.c \
test-common.h \
$(NULL)
pixbuf_resource_SOURCES = \
pixbuf-resource.c \
test-common.c \
test-common.h \
resources.h \
resources.c
resources.c \
$(NULL)
BUILT_SOURCES += resources.h resources.c
DISTCLEANFILES += \
resources.h resources.c \
pixbuf-save-options \
pixbuf-randomly-modified-image \
pixbuf-save-roundtrip
pixbuf-save-roundtrip \
$(NULL)
EXTRA_DIST += resources.gresource.xml
TESTS_ENVIRONMENT += GDK_PIXBUF_MODULE_FILE=$(top_builddir)/gdk-pixbuf/loaders.cache
......
......@@ -22,6 +22,7 @@
#include "config.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
static void
test_incremental (gconstpointer data)
......@@ -34,7 +35,12 @@ test_incremental (gconstpointer data)
gchar *contents;
gsize size;
if (!format_supported (filename))
{
g_test_skip ("format not supported");
return;
}
g_file_get_contents (g_test_get_filename (G_TEST_DIST, filename, NULL), &contents, &size, &error);
g_assert_no_error (error);
......@@ -62,6 +68,12 @@ test_nonincremental (gconstpointer data)
GdkPixbuf *pixbuf;
const gchar *profile;
if (!format_supported (filename))
{
g_test_skip ("format not supported");
return;
}
pixbuf = gdk_pixbuf_new_from_file (g_test_get_filename (G_TEST_DIST, filename, NULL), &error);
g_assert_no_error (error);
......
#include "config.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
#include <string.h>
#include <glib.h>
......@@ -13,6 +14,12 @@ test_serialize (void)
GIcon *icon;
GInputStream *stream;
if (!format_supported ("png"))
{
g_test_skip ("format not supported");
return;
}
pixbuf = gdk_pixbuf_new_from_file (g_test_get_filename (G_TEST_DIST, "test-image.png", NULL), &error);
g_assert_no_error (error);
g_assert (pixbuf != NULL);
......
......@@ -22,6 +22,7 @@
#include "config.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
#include <string.h>
#define compare_option(p1, p2, key) \
......@@ -77,6 +78,12 @@ test_resource (void)
GError *error = NULL;
GdkPixbuf *pixbuf, *ref;
if (!format_supported ("png"))
{
g_test_skip ("format not supported");
return;
}
path = g_test_get_filename (G_TEST_DIST, "icc-profile.png", NULL);
ref = gdk_pixbuf_new_from_file (path, &error);
g_assert_no_error (error);
......@@ -111,6 +118,12 @@ test_resource_at_scale (void)
GError *error = NULL;
GdkPixbuf *pixbuf, *ref;
if (!format_supported ("png"))
{
g_test_skip ("format not supported");
return;
}
path = g_test_get_filename (G_TEST_DIST, "icc-profile.png", NULL);
ref = gdk_pixbuf_new_from_file_at_scale (path, 40, 10, FALSE, &error);
g_assert_no_error (error);
......
......@@ -21,6 +21,7 @@
*/
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
#include <string.h>
#define compare_option(p1, p2, key) \
......@@ -76,6 +77,12 @@ test_save_roundtrip (void)
GdkPixbuf *ref;
GdkPixbuf *pixbuf;
if (!format_supported ("png"))
{
g_test_skip ("format not supported");
return;
}
ref = gdk_pixbuf_new_from_file (g_test_get_filename (G_TEST_DIST, "test-image.png", NULL), &error);
g_assert_no_error (error);
......@@ -98,6 +105,12 @@ test_save_options (void)
GdkPixbuf *pixbuf;
GError *error = NULL;
if (!format_supported ("png"))
{
g_test_skip ("format not supported");
return;
}
ref = gdk_pixbuf_new (GDK_COLORSPACE_RGB, FALSE, 8, 10, 10);
gdk_pixbuf_fill (ref, 0xff00ff00);
......
......@@ -22,6 +22,7 @@
#include "config.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
static void
test_scale (gconstpointer data)
......@@ -33,6 +34,12 @@ test_scale (gconstpointer data)
GdkPixbuf *pixbuf;
gint width, height;
if (!format_supported (filename))
{
g_test_skip ("format not supported");
return;
}
path = g_test_get_filename (G_TEST_DIST, filename, NULL);
ref = gdk_pixbuf_new_from_file (path, &error);
g_assert_no_error (error);
......
......@@ -22,6 +22,7 @@
#include "config.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
#include <string.h>
#define compare_option(p1, p2, key) \
......@@ -71,6 +72,12 @@ test_stream (gconstpointer data)
GFile *file;
GInputStream *stream;
if (!format_supported (filename))
{
g_test_skip ("format not supported");
return;
}
path = g_test_get_filename (G_TEST_DIST, filename, NULL);
ref = gdk_pixbuf_new_from_file (path, &error);
g_assert_no_error (error);
......@@ -116,6 +123,12 @@ test_stream_async (gconstpointer data)
gsize size;
GInputStream *stream;
if (!format_supported (filename))
{
g_test_skip ("format not supported");
return;
}
path = g_test_get_filename (G_TEST_DIST, filename, NULL);
ref = gdk_pixbuf_new_from_file (path, &error);
g_assert_no_error (error);
......@@ -138,6 +151,12 @@ test_stream_at_scale (gconstpointer data)
GFile *file;
GInputStream *stream;
if (!format_supported (filename))
{
g_test_skip ("format not supported");
return;
}
path = g_test_get_filename (G_TEST_DIST, filename, NULL);
ref = gdk_pixbuf_new_from_file_at_scale (path, 20, 30, TRUE, &error);
g_assert_no_error (error);
......@@ -167,6 +186,12 @@ test_stream_at_scale_async (gconstpointer data)
gsize size;
GInputStream *stream;
if (!format_supported (filename))
{
g_test_skip ("format not supported");
return;
}
path = g_test_get_filename (G_TEST_DIST, filename, NULL);
ref = gdk_pixbuf_new_from_file_at_scale (path, 40, 10, FALSE, &error);
g_assert_no_error (error);
......
......@@ -18,7 +18,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include "test-common.h"
static void
load_image (gpointer data,
......@@ -71,15 +73,24 @@ test_threads (void)
for (i = 0; i < iterations; i++)
{
g_thread_pool_push (pool, "valid_jpeg_test", NULL);
g_thread_pool_push (pool, "valid_png_test", NULL);
g_thread_pool_push (pool, "valid_gif_test", NULL);
g_thread_pool_push (pool, "valid_bmp_test", NULL);
g_thread_pool_push (pool, "valid_jpeg_progressive_test", NULL);
g_thread_pool_push (pool, "valid_xpm_test", NULL);
g_thread_pool_push (pool, "valid_ras_test", NULL);
g_thread_pool_push (pool, "valid_tga_test", NULL);
g_thread_pool_push (pool, "valid_tiff1_test", NULL);
if (format_supported ("jpeg"))
g_thread_pool_push (pool, "valid_jpeg_test", NULL);
if (format_supported ("png"))
g_thread_pool_push (pool, "valid_png_test", NULL);
if (format_supported ("gif"))
g_thread_pool_push (pool, "valid_gif_test", NULL);
if (format_supported ("bmp"))
g_thread_pool_push (pool, "valid_bmp_test", NULL);
if (format_supported ("jpeg"))
g_thread_pool_push (pool, "valid_jpeg_progressive_test", NULL);
if (format_supported ("xpm"))
g_thread_pool_push (pool, "valid_xpm_test", NULL);
if (format_supported ("ras"))
g_thread_pool_push (pool, "valid_ras_test", NULL);
if (format_supported ("tga"))
g_thread_pool_push (pool, "valid_tga_test", NULL);
if (format_supported ("tiff"))
g_thread_pool_push (pool, "valid_tiff1_test", NULL);
}
g_thread_pool_free (pool, FALSE, TRUE);
......
/* -*- Mode: C; c-basic-offset: 2; -*- */
/* GdkPixbuf library - test loaders
*
* Copyright (C) 2014 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Author: Matthias Clasen
*/
#include "config.h"
#include "test-common.h"
#include "gdk-pixbuf/gdk-pixbuf.h"
#include <string.h>
gboolean
format_supported (const gchar *filename)
{
const gchar *name = NULL;
GSList *formats, *l;
gboolean retval;
const gchar *names[] = { "png", "jpeg", "bmp", "gif", "ras",
"tga", "xpm", "xbm" };
gint i;
for (i = 0; i < G_N_ELEMENTS (names); i++)
{
if (strstr (filename, names[i]))
{
name = names[i];
break;
}
}
if (name == NULL)
return FALSE;
retval = FALSE;
formats = gdk_pixbuf_get_formats ();
for (l = formats; l; l = l->next)
{
GdkPixbufFormat *format = l->data;
if (g_str_equal (gdk_pixbuf_format_get_name (format), name))
{
retval = TRUE;
break;
}
}
g_slist_free (formats);
return retval;
}
/* -*- Mode: C; c-basic-offset: 2; -*- */
/* GdkPixbuf library - test loaders
*
* Copyright (C) 2014 Red Hat, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
*
* Author: Matthias Clasen
*/
#ifndef __TEST_COMMON_H__
#include <glib.h>
G_BEGIN_DECLS
gboolean format_supported (const gchar *filename);
G_END_DECLS
#endif /* __TEST_COMMON_H__ */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment