Module: wine Branch: master Commit: 29a5d9b3f66a9c58ce2dbd22145f189e30acd4f3 URL: http://source.winehq.org/git/wine.git/?a=commit;h=29a5d9b3f66a9c58ce2dbd2214...
Author: Krzysztof Nowicki krissn@op.pl Date: Tue Oct 19 18:57:47 2010 +0200
windowscodecs/tests: Add test cases for *_CopyPixels calls with NULL rectangle.
---
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); }