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-2013 Cyril Hrubis <metan@ucw.cz> *
21 *****************************************************************************/
27 #include <core/GP_Pixmap.h>
28 #include <loaders/GP_Loaders.h>
37 static int test_load(struct test
*test
)
39 GP_Container
*zip
= GP_OpenZip(test
->path
);
41 int ret
= TST_SUCCESS
;
44 tst_msg("Failed to open zip");
48 img
= GP_ContainerLoad(zip
, NULL
);
51 tst_msg("Failed to load image");
55 if (img
->w
!= test
->w
|| img
->h
!= test
->h
) {
56 tst_msg("Image has wrong size, expected %ux%u have %ux%u",
57 test
->w
, test
->h
, img
->w
, img
->h
);
62 GP_ContainerClose(zip
);
67 struct test jpeg_deflated
= {
70 .path
= "jpeg_deflated.zip"
73 struct test jpeg_stored
= {
76 .path
= "jpeg_stored.zip"
79 struct test mixed_content
= {
82 .path
= "mixed_content.zip"
86 * Test ZIP with no images, we expect to get NULL with errno set to zero
88 static int no_images(const char *path
)
90 GP_Container
*zip
= GP_OpenZip(path
);
92 int ret
= TST_SUCCESS
;
95 tst_msg("Failed to open zip");
99 img
= GP_ContainerLoad(zip
, NULL
);
102 tst_msg("Loaded image from zip without images");
107 tst_msg("Get errno %d (%s)", errno
, strerror(errno
));
111 GP_ContainerClose(zip
);
116 const struct tst_suite tst_suite
= {
119 {.name
= "Load JPEG deflated in ZIP",
121 .res_path
= "data/zip/valid/jpeg_deflated.zip",
122 .data
= &jpeg_deflated
,
123 .flags
= TST_TMPDIR
| TST_MALLOC_CANARIES
},
125 {.name
= "Load JPEG stored in ZIP",
127 .res_path
= "data/zip/valid/jpeg_stored.zip",
128 .data
= &jpeg_stored
,
129 .flags
= TST_TMPDIR
| TST_MALLOC_CANARIES
},
131 {.name
= "Load JPEG is second file in ZIP",
133 .res_path
= "data/zip/valid/mixed_content.zip",
134 .data
= &mixed_content
,
135 .flags
= TST_TMPDIR
| TST_MALLOC_CANARIES
},
137 {.name
= "Load ZIP with no images",
139 .res_path
= "data/zip/valid/no_images.zip",
140 .data
= "no_images.zip",
141 .flags
= TST_TMPDIR
| TST_MALLOC_CANARIES
},