1/* -*- Mode: C; c-basic-offset: 2; -*- */
2/* GdkPixbuf library - test loaders
3 *
4 * Copyright (C) 2013 Red Hat, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Matthias Clasen
20 */
21
22#include "config.h"
23#include "gdk-pixbuf/gdk-pixbuf.h"
24#include "test-common.h"
25
26static void
27test_incremental (gconstpointer data)
28{
29 const gchar *filename = data;
30 GdkPixbufLoader *loader;
31 GdkPixbuf *pixbuf;
32 GError *error = NULL;
33 const gchar *profile;
34 gchar *contents;
35 gsize size;
36
37 if (!format_supported (filename))
38 {
39 g_test_skip (msg: "format not supported");
40 return;
41 }
42
43 g_file_get_contents (filename: g_test_get_filename (file_type: G_TEST_DIST, first_path: filename, NULL), contents: &contents, length: &size, error: &error);
44 g_assert_no_error (error);
45
46 loader = gdk_pixbuf_loader_new ();
47
48 gdk_pixbuf_loader_write (loader, buf: (const guchar*)contents, count: size, error: &error);
49 g_assert_no_error (error);
50
51 gdk_pixbuf_loader_close (loader, error: &error);
52 g_assert_no_error (error);
53
54 pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
55 profile = gdk_pixbuf_get_option (pixbuf, key: "icc-profile");
56 g_assert (profile != NULL);
57
58 g_object_unref (object: loader);
59 g_free (mem: contents);
60}
61
62static void
63test_nonincremental (gconstpointer data)
64{
65 const gchar *filename = data;
66 GError *error = NULL;
67 GdkPixbuf *pixbuf;
68 const gchar *profile;
69
70 if (!format_supported (filename))
71 {
72 g_test_skip (msg: "format not supported");
73 return;
74 }
75
76 pixbuf = gdk_pixbuf_new_from_file (filename: g_test_get_filename (file_type: G_TEST_DIST, first_path: filename, NULL), error: &error);
77 g_assert_no_error (error);
78
79 profile = gdk_pixbuf_get_option (pixbuf, key: "icc-profile");
80 g_assert (profile != NULL);
81
82 g_object_unref (object: pixbuf);
83}
84
85int
86main (int argc, char **argv)
87{
88 g_test_init (argc: &argc, argv: &argv, NULL);
89
90 g_test_add_data_func (testpath: "/pixbuf/icc/png", test_data: "icc-profile.png", test_func: test_nonincremental);
91 g_test_add_data_func (testpath: "/pixbuf/icc/jpeg", test_data: "icc-profile.jpeg", test_func: test_nonincremental);
92 g_test_add_data_func (testpath: "/pixbuf/icc/png/incremental", test_data: "icc-profile.png", test_func: test_incremental);
93 g_test_add_data_func (testpath: "/pixbuf/icc/jpeg/incremental", test_data: "icc-profile.jpeg", test_func: test_incremental);
94
95 return g_test_run ();
96}
97

source code of gtk/subprojects/gdk-pixbuf/tests/pixbuf-icc.c