Add a basic test for gdImageCreateFromWebp()

We're testing a lossless and a lossy Webp with alpha channel. The images
have been taken from <https://developers.google.com/speed/webp/gallery2>,
have been authored by Fizyplankton and are in the public domain.

The lossy test might fail for another libwebp version, so it appears to
be best to not cherry-pick into GD-2.2 yet.
master
Christoph M. Becker 2016-10-08 15:53:35 +02:00
parent d62f608c7c
commit f14192d70f
8 changed files with 49 additions and 1 deletions

View File

@ -1 +1,2 @@
/basic
/bug00111

View File

@ -1,5 +1,6 @@
IF(WEBP_FOUND)
LIST(APPEND TESTS_FILES
basic
bug00111
)
ENDIF(WEBP_FOUND)

View File

@ -1,7 +1,12 @@
if HAVE_LIBWEBP
libgd_test_programs += \
webp/basic \
webp/bug00111
endif
EXTRA_DIST += \
webp/CMakeLists.txt
webp/CMakeLists.txt \
webp/basic_lossless.webp \
webp/basic_lossless_exp.png \
webp/basic_lossy.webp \
webp/basic_lossy_exp.png

41
tests/webp/basic.c Normal file
View File

@ -0,0 +1,41 @@
/**
* Basic test of gdImageCreateFromWebp()
*
* We're testing that a lossless and a lossy WebP with alpha channel are
* decoded as expected.
*/
#include "gd.h"
#include "gdtest.h"
static void test_image(const char *name)
{
gdImagePtr im;
FILE *fp;
char buf[256];
char *path;
snprintf(buf, sizeof(buf), "%s.webp", name);
fp = gdTestFileOpen2("webp", buf);
im = gdImageCreateFromWebp(fp);
gdTestAssert(im != NULL);
fclose(fp);
snprintf(buf, sizeof(buf), "%s_exp.png", name);
path = gdTestFilePath2("webp", buf);
gdAssertImageEqualsToFile(path, im);
gdFree(path);
gdImageDestroy(im);
}
int main()
{
test_image("basic_lossless");
test_image("basic_lossy");
return gdNumFailures();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

BIN
tests/webp/basic_lossy.webp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB