[WINDOWSCODECS_WINETEST] Sync with Wine Staging 1.7.55. CORE-10536
[reactos.git] / rostests / winetests / windowscodecs / pngformat.c
index 43e8599..6a9427b 100644 (file)
@@ -281,18 +281,6 @@ static const char png_color_profile[] = {
 
 static IWICImagingFactory *factory;
 
-static const char *debugstr_guid(const GUID *guid)
-{
-    static char buf[50];
-
-    if (!guid) return "(null)";
-    sprintf(buf, "{%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}",
-            guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
-            guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
-            guid->Data4[5], guid->Data4[6], guid->Data4[7]);
-    return buf;
-}
-
 static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size)
 {
     HGLOBAL hmem;
@@ -301,6 +289,7 @@ static IWICBitmapDecoder *create_decoder(const void *image_data, UINT image_size
     IWICBitmapDecoder *decoder = NULL;
     IStream *stream;
     GUID format;
+    LONG refcount;
 
     hmem = GlobalAlloc(0, image_size);
     data = GlobalLock(hmem);
@@ -312,13 +301,15 @@ 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);
     ok(IsEqualGUID(&format, &GUID_ContainerFormatPng),
-       "wrong container format %s\n", debugstr_guid(&format));
+       "wrong container format %s\n", wine_dbgstr_guid(&format));
 
-    IStream_Release(stream);
+    refcount = IStream_Release(stream);
+    ok(refcount > 0, "expected stream refcount > 0\n");
 
     return decoder;
 }
@@ -358,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);
@@ -385,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;
@@ -562,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);
@@ -569,7 +563,7 @@ static void test_png_palette(void)
     hr = IWICBitmapFrameDecode_GetPixelFormat(frame, &format);
     ok(hr == S_OK, "GetPixelFormat error %#x\n", hr);
     ok(IsEqualGUID(&format, &GUID_WICPixelFormat1bppIndexed),
-       "got wrong format %s\n", debugstr_guid(&format));
+       "got wrong format %s\n", wine_dbgstr_guid(&format));
 
     hr = IWICImagingFactory_CreatePalette(factory, &palette);
     ok(hr == S_OK, "CreatePalette error %#x\n", hr);