[2/2] windowscodecs/tests: Add test cases for *_CopyPixels calls with NULL rectangle (try 2).

Krzysztof Nowicki krissn at op.pl
Tue Oct 19 11:57:47 CDT 2010


Following the fix for handling NULL rectangle in *_CopyPixels functions I've
added some basic test cases to test this feature.

I also ported the fix to one of the test case function to avoid a NULL pointer
dereference.

Version 2:
No changes - just a resend of the whole series.

---
 dlls/windowscodecs/tests/bmpformat.c |    4 +++
 dlls/windowscodecs/tests/converter.c |   37 ++++++++++++++++++++++++++++++++-
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/dlls/windowscodecs/tests/bmpformat.c b/dlls/windowscodecs/tests/bmpformat.c
index 0fcdc06..378c375 100644
--- a/dlls/windowscodecs/tests/bmpformat.c
+++ b/dlls/windowscodecs/tests/bmpformat.c
@@ -197,6 +197,10 @@ static void test_decode_24bpp(void)
                 ok(SUCCEEDED(hr), "CopyPixels failed, hr=%x\n", hr);
                 ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
 
+                hr = IWICBitmapFrameDecode_CopyPixels(framedecode, NULL, 6, sizeof(imagedata), imagedata);
+                ok(SUCCEEDED(hr), "CopyPixels(rect=NULL) failed, hr=%x\n", hr);
+                ok(!memcmp(imagedata, expected_imagedata, sizeof(imagedata)), "unexpected image data\n");
+
                 IWICBitmapFrameDecode_Release(framedecode);
             }
 
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c
index 5c66636..408a6ca 100644
--- a/dlls/windowscodecs/tests/converter.c
+++ b/dlls/windowscodecs/tests/converter.c
@@ -110,9 +110,21 @@ static HRESULT WINAPI BitmapTestSrc_CopyPixels(IWICBitmapSource *iface,
     UINT bytesperrow;
     UINT srcstride;
     UINT row_offset;
+    WICRect rc;
 
-    if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->data->width || prc->Y+prc->Height > This->data->height)
-        return E_INVALIDARG;
+    if (!prc)
+    {
+        rc.X = 0;
+        rc.Y = 0;
+        rc.Width = This->data->width;
+        rc.Height = This->data->height;
+        prc = &rc;
+    }
+    else
+    {
+        if (prc->X < 0 || prc->Y < 0 || prc->X+prc->Width > This->data->width || prc->Y+prc->Height > This->data->height)
+            return E_INVALIDARG;
+    }
 
     bytesperrow = ((This->data->bpp * prc->Width)+7)/8;
     srcstride = ((This->data->bpp * This->data->width)+7)/8;
@@ -233,6 +245,27 @@ static void compare_bitmap_data(const struct bitmap_data *expect, IWICBitmapSour
     }
     else
         ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "unexpected pixel data (%s)\n", name);
+
+    /* Test with NULL rectangle - should copy the whole bitmap */
+    hr = IWICBitmapSource_CopyPixels(source, NULL, stride, buffersize, converted_bits);
+    ok(SUCCEEDED(hr), "CopyPixels(%s,rc=NULL) failed, hr=%x\n", name, hr);
+    if (IsEqualGUID(expect->format, &GUID_WICPixelFormat32bppBGR))
+    {
+        /* ignore the padding byte when comparing data */
+        UINT i;
+        BOOL equal=TRUE;
+        const DWORD *a=(const DWORD*)expect->bits, *b=(const DWORD*)converted_bits;
+        for (i=0; i<(buffersize/4); i++)
+            if ((a[i]&0xffffff) != (b[i]&0xffffff))
+            {
+                equal = FALSE;
+                break;
+            }
+        ok(equal, "unexpected pixel data with rc=NULL (%s)\n", name);
+    }
+    else
+        ok(memcmp(expect->bits, converted_bits, buffersize) == 0, "unexpected pixel data with rc=NULL (%s)\n", name);
+
     HeapFree(GetProcessHeap(), 0, converted_bits);
 }
 
-- 
1.7.1




More information about the wine-patches mailing list