1 /*****************************************************************************
2 * This file is part of gfxprim library. *
4 * Gfxprim is free software; you can redistribute it and/or *
5 * modify it under the terms of the GNU Lesser General Public *
6 * License as published by the Free Software Foundation; either *
7 * version 2.1 of the License, or (at your option) any later version. *
9 * Gfxprim is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
12 * Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public *
15 * License along with gfxprim; if not, write to the Free Software *
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, *
17 * Boston, MA 02110-1301 USA *
19 * Copyright (C) 2009-2014 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
27 #include <core/GP_Pixmap.h>
28 #include <core/GP_GetPutPixel.h>
29 #include <loaders/GP_Loaders.h>
33 static int test_load_JPG(const char *path
)
39 img
= GP_LoadJPG(path
, NULL
);
44 tst_msg("Not Implemented");
47 tst_msg("Got %s", strerror(errno
));
53 * TODO: check correct data.
61 static int test_save_JPG(GP_PixelType pixel_type
)
66 pixmap
= GP_PixmapAlloc(100, 100, pixel_type
);
69 tst_msg("Failed to allocate pixmap");
75 ret
= GP_SaveJPG(pixmap
, "/dev/null", NULL
);
78 tst_msg("Saved successfully");
79 GP_PixmapFree(pixmap
);
85 tst_msg("Not Implemented");
86 GP_PixmapFree(pixmap
);
89 tst_msg("Failed and errno is not ENOSYS (%i)", errno
);
90 GP_PixmapFree(pixmap
);
95 const struct tst_suite tst_suite
= {
98 /* JPEG loader tests */
99 {.name
= "JPEG Load 100x100 CMYK",
100 .tst_fn
= test_load_JPG
,
101 .res_path
= "data/jpeg/valid/100x100-cmyk-red.jpeg",
102 .data
= "100x100-cmyk-red.jpeg",
103 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
105 {.name
= "JPEG Load 100x100 RGB",
106 .tst_fn
= test_load_JPG
,
107 .res_path
= "data/jpeg/valid/100x100-red.jpeg",
108 .data
= "100x100-red.jpeg",
109 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
111 {.name
= "JPEG Load 100x100 G8",
112 .tst_fn
= test_load_JPG
,
113 .res_path
= "data/jpeg/valid/100x100-grayscale-white.jpeg",
114 .data
= "100x100-grayscale-white.jpeg",
115 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
117 {.name
= "JPEG Load 100x100 G8",
118 .tst_fn
= test_load_JPG
,
119 .res_path
= "data/jpeg/valid/100x100-grayscale-black.jpeg",
120 .data
= "100x100-grayscale-black.jpeg",
121 .flags
= TST_TMPDIR
| TST_CHECK_MALLOC
},
123 /* JPEG save tests */
124 {.name
= "JPEG Save 100x100 G8",
125 .tst_fn
= test_save_JPG
,
126 .data
= (void*)GP_PIXEL_G8
,
127 .flags
= TST_CHECK_MALLOC
},
129 {.name
= "JPEG Save 100x100 RGB888",
130 .tst_fn
= test_save_JPG
,
131 .data
= (void*)GP_PIXEL_RGB888
,
132 .flags
= TST_CHECK_MALLOC
},
134 {.name
= "JPEG Save 100x100 BGR888",
135 .tst_fn
= test_save_JPG
,
136 .data
= (void*)GP_PIXEL_BGR888
,
137 .flags
= TST_CHECK_MALLOC
},