From 025250b862071b119b88065d8ad97da45a9163c7 Mon Sep 17 00:00:00 2001 From: Amine Khaldi Date: Mon, 23 Nov 2015 09:52:05 +0000 Subject: [PATCH] [WINDOWSCODECS_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536 svn path=/trunk/; revision=70066 --- rostests/winetests/windowscodecs/gifformat.c | 97 ++++++++++++++++++- rostests/winetests/windowscodecs/pngformat.c | 4 + rostests/winetests/windowscodecs/tiffformat.c | 4 + 3 files changed, 101 insertions(+), 4 deletions(-) diff --git a/rostests/winetests/windowscodecs/gifformat.c b/rostests/winetests/windowscodecs/gifformat.c index 61111ba00a9..4b75d06470b 100644 --- a/rostests/winetests/windowscodecs/gifformat.c +++ b/rostests/winetests/windowscodecs/gifformat.c @@ -86,15 +86,12 @@ static const char gif_frame_sizes[] = { static IWICImagingFactory *factory; -static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size) +static IStream *create_stream(const void *image_data, UINT image_size) { HGLOBAL hmem; BYTE *data; HRESULT hr; - IWICBitmapDecoder *decoder = NULL; IStream *stream; - GUID format; - LONG refcount; hmem = GlobalAlloc(0, image_size); data = GlobalLock(hmem); @@ -104,6 +101,20 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size hr = CreateStreamOnHGlobal(hmem, TRUE, &stream); ok(hr == S_OK, "CreateStreamOnHGlobal error %#x\n", hr); + return stream; +} + +static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size) +{ + HRESULT hr; + IWICBitmapDecoder *decoder; + IStream *stream; + GUID format; + LONG refcount; + + stream = create_stream(image_data, image_size); + if (!stream) return NULL; + hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); @@ -408,6 +419,83 @@ static void test_gif_frame_sizes(void) IWICBitmapDecoder_Release(decoder); } +static const char gif_with_trailer_1[] = { +/* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x80,0x00,0x00, +/* palette */0xff,0xff,0xff,0xff,0xff,0xff, +/* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00, +/* image data */0x02,0x02,0x44,0x01,0x00,0x3b +}; +static const char gif_with_trailer_2[] = { +/* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x00,0x00,0x00, +/* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00, +/* image data */0x02,0x02,0x44,0x3b +}; +static const char gif_without_trailer_1[] = { +/* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x80,0x00,0x00, +/* palette */0xff,0xff,0xff,0xff,0xff,0xff, +/* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00, +/* image data */0x02,0x02,0x44,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef +}; + +static const char gif_without_trailer_2[] = { +/* LSD */'G','I','F','8','7','a',0x01,0x00,0x01,0x00,0x00,0x00,0x00, +/* IMD */0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00, +/* image data */0x02,0x02,0x44,0xde,0xad,0xbe,0xef,0xde,0xad,0xbe,0xef +}; + +static void test_truncated_gif(void) +{ + HRESULT hr; + IStream *stream; + IWICBitmapDecoder *decoder; + GUID format; + + stream = create_stream(gif_with_trailer_1, sizeof(gif_with_trailer_1)); + if (!stream) return; + + hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); + ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); + hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + IWICBitmapDecoder_Release(decoder); + IStream_Release(stream); + + stream = create_stream(gif_with_trailer_2, sizeof(gif_with_trailer_2)); + if (!stream) return; + hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); + ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); + hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + IWICBitmapDecoder_Release(decoder); + IStream_Release(stream); + + stream = create_stream(gif_without_trailer_1, sizeof(gif_without_trailer_1)); + if (!stream) return; + hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); + ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); + hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + IWICBitmapDecoder_Release(decoder); + IStream_Release(stream); + + stream = create_stream(gif_without_trailer_2, sizeof(gif_without_trailer_2)); + if (!stream) return; + hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); + ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); + hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); + ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); + ok(IsEqualGUID(&format, &GUID_ContainerFormatGif), + "wrong container format %s\n", wine_dbgstr_guid(&format)); + IWICBitmapDecoder_Release(decoder); + IStream_Release(stream); +} + START_TEST(gifformat) { HRESULT hr; @@ -434,6 +522,7 @@ START_TEST(gifformat) test_global_gif_palette_2frames(); test_local_gif_palette(); test_gif_frame_sizes(); + test_truncated_gif(); IWICImagingFactory_Release(factory); } diff --git a/rostests/winetests/windowscodecs/pngformat.c b/rostests/winetests/windowscodecs/pngformat.c index 97c87d4c6e0..6a9427bc2d4 100644 --- a/rostests/winetests/windowscodecs/pngformat.c +++ b/rostests/winetests/windowscodecs/pngformat.c @@ -301,6 +301,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); + if (FAILED(hr)) return NULL; hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); @@ -348,6 +349,7 @@ static void test_color_contexts(void) decoder = create_decoder(png_no_color_profile, sizeof(png_no_color_profile)); ok(decoder != 0, "Failed to load PNG image data\n"); + if (!decoder) return; /* global color context */ hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL); @@ -375,6 +377,7 @@ static void test_color_contexts(void) decoder = create_decoder(png_color_profile, sizeof(png_color_profile)); ok(decoder != 0, "Failed to load PNG image data\n"); + if (!decoder) return; /* global color context */ count = 0xdeadbeef; @@ -552,6 +555,7 @@ static void test_png_palette(void) decoder = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS)); ok(decoder != 0, "Failed to load PNG image data\n"); + if (!decoder) return; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); diff --git a/rostests/winetests/windowscodecs/tiffformat.c b/rostests/winetests/windowscodecs/tiffformat.c index 57c8435aedb..d99c005b23c 100644 --- a/rostests/winetests/windowscodecs/tiffformat.c +++ b/rostests/winetests/windowscodecs/tiffformat.c @@ -176,6 +176,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); + if (FAILED(hr)) return NULL; hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guid); ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); @@ -196,6 +197,7 @@ static void test_tiff_palette(void) decoder = create_decoder(&tiff_1bpp_data, sizeof(tiff_1bpp_data)); ok(decoder != 0, "Failed to load TIFF image data\n"); + if (!decoder) return; hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); ok(hr == S_OK, "GetFrame error %#x\n", hr); @@ -237,6 +239,7 @@ static void test_QueryCapability(void) hr = IWICImagingFactory_CreateDecoder(factory, &GUID_ContainerFormatTiff, NULL, &decoder); ok(hr == S_OK, "CreateDecoder error %#x\n", hr); + if (FAILED(hr)) return; frame_count = 0xdeadbeef; hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count); @@ -328,6 +331,7 @@ static void test_tiff_8bpp_alpha(void) decoder = create_decoder(&tiff_8bpp_alpha, sizeof(tiff_8bpp_alpha)); ok(decoder != 0, "Failed to load TIFF image data\n"); + if (!decoder) return; hr = IWICBitmapDecoder_GetFrameCount(decoder, &frame_count); ok(hr == S_OK, "GetFrameCount error %#x\n", hr); -- 2.17.1