Commit c87e06bb authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

windowscodecs/tests: Make create_decoder() return an error code in PNG tests.

parent 73ef39fe
...@@ -276,37 +276,38 @@ static const char png_color_profile[] = { ...@@ -276,37 +276,38 @@ static const char png_color_profile[] = {
static IWICImagingFactory *factory; static IWICImagingFactory *factory;
static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size) static HRESULT create_decoder(const void *image_data, UINT image_size, IWICBitmapDecoder **decoder)
{ {
HRESULT hr; HRESULT hr;
IWICBitmapDecoder *decoder = NULL;
IStream *stream; IStream *stream;
GUID format; GUID format;
LONG refcount; LONG refcount;
ULARGE_INTEGER pos; ULARGE_INTEGER pos;
LARGE_INTEGER zero; LARGE_INTEGER zero;
*decoder = NULL;
stream = SHCreateMemStream (image_data, image_size); stream = SHCreateMemStream (image_data, image_size);
ok(stream != NULL, "SHCreateMemStream error\n"); ok(stream != NULL, "SHCreateMemStream error\n");
hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, &decoder); hr = IWICImagingFactory_CreateDecoderFromStream(factory, stream, NULL, 0, decoder);
ok(hr == S_OK, "CreateDecoderFromStream error %#x\n", hr); if (hr == S_OK)
if (FAILED(hr)) return NULL; {
hr = IWICBitmapDecoder_GetContainerFormat(*decoder, &format);
hr = IWICBitmapDecoder_GetContainerFormat(decoder, &format); ok(hr == S_OK, "GetContainerFormat error %#x\n", hr);
ok(hr == S_OK, "GetContainerFormat error %#x\n", hr); ok(IsEqualGUID(&format, &GUID_ContainerFormatPng),
ok(IsEqualGUID(&format, &GUID_ContainerFormatPng), "wrong container format %s\n", wine_dbgstr_guid(&format));
"wrong container format %s\n", wine_dbgstr_guid(&format));
zero.QuadPart = 0;
zero.QuadPart = 0; IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos);
IStream_Seek (stream, zero, STREAM_SEEK_CUR, &pos); ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n",
ok(pos.QuadPart < image_size, "seek beyond the end of stream: %x%08x >= %x\n", (UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size);
(UINT)(pos.QuadPart >> 32), (UINT)pos.QuadPart, image_size);
refcount = IStream_Release(stream);
refcount = IStream_Release(stream); ok(refcount > 0, "expected stream refcount > 0\n");
ok(refcount > 0, "expected stream refcount > 0\n"); }
return decoder; return hr;
} }
static WCHAR *save_profile( BYTE *buffer, UINT size ) static WCHAR *save_profile( BYTE *buffer, UINT size )
...@@ -342,9 +343,9 @@ static void test_color_contexts(void) ...@@ -342,9 +343,9 @@ static void test_color_contexts(void)
BYTE *buffer; BYTE *buffer;
BOOL ret; BOOL ret;
decoder = create_decoder(png_no_color_profile, sizeof(png_no_color_profile)); hr = create_decoder(png_no_color_profile, sizeof(png_no_color_profile), &decoder);
ok(decoder != 0, "Failed to load PNG image data\n"); ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
if (!decoder) return; if (hr != S_OK) return;
/* global color context */ /* global color context */
hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL); hr = IWICBitmapDecoder_GetColorContexts(decoder, 0, NULL, NULL);
...@@ -370,9 +371,9 @@ static void test_color_contexts(void) ...@@ -370,9 +371,9 @@ static void test_color_contexts(void)
IWICBitmapFrameDecode_Release(frame); IWICBitmapFrameDecode_Release(frame);
IWICBitmapDecoder_Release(decoder); IWICBitmapDecoder_Release(decoder);
decoder = create_decoder(png_color_profile, sizeof(png_color_profile)); hr = create_decoder(png_color_profile, sizeof(png_color_profile), &decoder);
ok(decoder != 0, "Failed to load PNG image data\n"); ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
if (!decoder) return; if (hr != S_OK) return;
/* global color context */ /* global color context */
count = 0xdeadbeef; count = 0xdeadbeef;
...@@ -548,9 +549,9 @@ static void test_png_palette(void) ...@@ -548,9 +549,9 @@ static void test_png_palette(void)
UINT count, ret; UINT count, ret;
WICColor color[256]; WICColor color[256];
decoder = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS)); hr = create_decoder(png_PLTE_tRNS, sizeof(png_PLTE_tRNS), &decoder);
ok(decoder != 0, "Failed to load PNG image data\n"); ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
if (!decoder) return; if (hr != S_OK) return;
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
ok(hr == S_OK, "GetFrame error %#x\n", hr); ok(hr == S_OK, "GetFrame error %#x\n", hr);
...@@ -618,9 +619,9 @@ static void test_color_formats(void) ...@@ -618,9 +619,9 @@ static void test_color_formats(void)
buf[24] = td[i].bit_depth; buf[24] = td[i].bit_depth;
buf[25] = td[i].color_type; buf[25] = td[i].color_type;
decoder = create_decoder(buf, sizeof(buf)); hr = create_decoder(buf, sizeof(buf), &decoder);
ok(decoder != NULL, "Failed to load PNG image data\n"); ok(hr == S_OK, "Failed to load PNG image data %#x\n", hr);
if (!decoder) continue; if (hr != S_OK) return;
hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame); hr = IWICBitmapDecoder_GetFrame(decoder, 0, &frame);
ok(hr == S_OK, "GetFrame error %#x\n", hr); ok(hr == S_OK, "GetFrame error %#x\n", hr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment