|
Packit |
a4058c |
/* -*- Mode: C; c-basic-offset: 2; -*- */
|
|
Packit |
a4058c |
/* GdkPixbuf library - test loaders
|
|
Packit |
a4058c |
*
|
|
Packit |
a4058c |
* Copyright (C) 2013 Red Hat, Inc.
|
|
Packit |
a4058c |
*
|
|
Packit |
a4058c |
* This program is free software; you can redistribute it and/or modify
|
|
Packit |
a4058c |
* it under the terms of the GNU General Public License as published by
|
|
Packit |
a4058c |
* the Free Software Foundation; either version 2 of the License, or
|
|
Packit |
a4058c |
* (at your option) any later version.
|
|
Packit |
a4058c |
*
|
|
Packit |
a4058c |
* This program is distributed in the hope that it will be useful,
|
|
Packit |
a4058c |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
a4058c |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
Packit |
a4058c |
* GNU General Public License for more details.
|
|
Packit |
a4058c |
*
|
|
Packit |
a4058c |
* You should have received a copy of the GNU General Public License
|
|
Packit |
a4058c |
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit |
a4058c |
*
|
|
Packit |
a4058c |
* Author: Matthias Clasen
|
|
Packit |
a4058c |
*/
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
#include "config.h"
|
|
Packit |
a4058c |
#include "gdk-pixbuf/gdk-pixbuf.h"
|
|
Packit |
a4058c |
#include "test-common.h"
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
static void
|
|
Packit |
a4058c |
test_incremental (gconstpointer data)
|
|
Packit |
a4058c |
{
|
|
Packit |
a4058c |
const gchar *filename = data;
|
|
Packit |
a4058c |
GdkPixbufLoader *loader;
|
|
Packit |
a4058c |
GdkPixbuf *pixbuf;
|
|
Packit |
a4058c |
GError *error = NULL;
|
|
Packit |
a4058c |
const gchar *profile;
|
|
Packit |
a4058c |
gchar *contents;
|
|
Packit |
a4058c |
gsize size;
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
if (!format_supported (filename))
|
|
Packit |
a4058c |
{
|
|
Packit |
a4058c |
g_test_skip ("format not supported");
|
|
Packit |
a4058c |
return;
|
|
Packit |
a4058c |
}
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
g_file_get_contents (g_test_get_filename (G_TEST_DIST, filename, NULL), &contents, &size, &error);
|
|
Packit |
a4058c |
g_assert_no_error (error);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
loader = gdk_pixbuf_loader_new ();
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
gdk_pixbuf_loader_write (loader, (const guchar*)contents, size, &error);
|
|
Packit |
a4058c |
g_assert_no_error (error);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
gdk_pixbuf_loader_close (loader, &error);
|
|
Packit |
a4058c |
g_assert_no_error (error);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
|
|
Packit |
a4058c |
profile = gdk_pixbuf_get_option (pixbuf, "icc-profile");
|
|
Packit |
a4058c |
g_assert (profile != NULL);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
g_object_unref (loader);
|
|
Packit |
a4058c |
g_free (contents);
|
|
Packit |
a4058c |
}
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
static void
|
|
Packit |
a4058c |
test_nonincremental (gconstpointer data)
|
|
Packit |
a4058c |
{
|
|
Packit |
a4058c |
const gchar *filename = data;
|
|
Packit |
a4058c |
GError *error = NULL;
|
|
Packit |
a4058c |
GdkPixbuf *pixbuf;
|
|
Packit |
a4058c |
const gchar *profile;
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
if (!format_supported (filename))
|
|
Packit |
a4058c |
{
|
|
Packit |
a4058c |
g_test_skip ("format not supported");
|
|
Packit |
a4058c |
return;
|
|
Packit |
a4058c |
}
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
pixbuf = gdk_pixbuf_new_from_file (g_test_get_filename (G_TEST_DIST, filename, NULL), &error);
|
|
Packit |
a4058c |
g_assert_no_error (error);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
profile = gdk_pixbuf_get_option (pixbuf, "icc-profile");
|
|
Packit |
a4058c |
g_assert (profile != NULL);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
g_object_unref (pixbuf);
|
|
Packit |
a4058c |
}
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
int
|
|
Packit |
a4058c |
main (int argc, char **argv)
|
|
Packit |
a4058c |
{
|
|
Packit |
a4058c |
g_test_init (&argc, &argv, NULL);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
g_test_add_data_func ("/pixbuf/icc/png", "icc-profile.png", test_nonincremental);
|
|
Packit |
a4058c |
g_test_add_data_func ("/pixbuf/icc/jpeg", "icc-profile.jpeg", test_nonincremental);
|
|
Packit |
a4058c |
g_test_add_data_func ("/pixbuf/icc/png/incremental", "icc-profile.png", test_incremental);
|
|
Packit |
a4058c |
g_test_add_data_func ("/pixbuf/icc/jpeg/incremental", "icc-profile.jpeg", test_incremental);
|
|
Packit |
a4058c |
|
|
Packit |
a4058c |
return g_test_run ();
|
|
Packit |
a4058c |
}
|