Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/tests/bmpformat.c | 75 ------------------------------------ dlls/windowscodecs/tests/gifformat.c | 75 ++++++++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+), 75 deletions(-)
diff --git a/dlls/windowscodecs/tests/bmpformat.c b/dlls/windowscodecs/tests/bmpformat.c index 48985b9cba..8bac7a3853 100644 --- a/dlls/windowscodecs/tests/bmpformat.c +++ b/dlls/windowscodecs/tests/bmpformat.c @@ -1058,80 +1058,6 @@ static void test_createfromstream(void) IWICImagingFactory_Release(factory); }
-/* 1x1 pixel gif, missing trailer */ -static unsigned char gifimage_notrailer[] = { -0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x71,0xff,0xff,0xff, -0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44, -0x01,0x00 -}; - -static void test_gif_notrailer(void) -{ - IWICBitmapDecoder *decoder; - IWICImagingFactory *factory; - HRESULT hr; - IWICStream *gifstream; - IWICBitmapFrameDecode *framedecode; - double dpiX = 0.0, dpiY = 0.0; - UINT framecount; - - hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, - &IID_IWICImagingFactory, (void**)&factory); - ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr); - if (FAILED(hr)) return; - - hr = IWICImagingFactory_CreateStream(factory, &gifstream); - ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr); - if (SUCCEEDED(hr)) - { - hr = IWICStream_InitializeFromMemory(gifstream, gifimage_notrailer, - sizeof(gifimage_notrailer)); - ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr); - - if (SUCCEEDED(hr)) - { - hr = CoCreateInstance(&CLSID_WICGifDecoder, NULL, CLSCTX_INPROC_SERVER, - &IID_IWICBitmapDecoder, (void**)&decoder); - ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr); - } - - if (SUCCEEDED(hr)) - { - hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)gifstream, - WICDecodeMetadataCacheOnDemand); - ok(hr == S_OK, "Initialize failed, hr=%x\n", hr); - - if (SUCCEEDED(hr)) - { - hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode); - ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr); - if (SUCCEEDED(hr)) - { - hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY); - ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr); - ok(dpiX == 48.0, "expected dpiX=48.0, got %f\n", dpiX); - ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY); - - IWICBitmapFrameDecode_Release(framedecode); - } - } - - if (SUCCEEDED(hr)) - { - hr = IWICBitmapDecoder_GetFrameCount(decoder, &framecount); - ok(hr == S_OK, "GetFrameCount failed, hr=%x\n", hr); - ok(framecount == 1, "framecount=%u\n", framecount); - } - - IWICBitmapDecoder_Release(decoder); - } - - IWICStream_Release(gifstream); - } - - IWICImagingFactory_Release(factory); -} - static void test_create_decoder(void) { IWICBitmapDecoder *decoder; @@ -1170,7 +1096,6 @@ START_TEST(bmpformat) test_decode_rle4(); test_componentinfo(); test_createfromstream(); - test_gif_notrailer(); test_create_decoder();
CoUninitialize(); diff --git a/dlls/windowscodecs/tests/gifformat.c b/dlls/windowscodecs/tests/gifformat.c index 53b4e473bd..05affadca4 100644 --- a/dlls/windowscodecs/tests/gifformat.c +++ b/dlls/windowscodecs/tests/gifformat.c @@ -490,6 +490,80 @@ static void test_truncated_gif(void) IStream_Release(stream); }
+/* 1x1 pixel gif, missing trailer */ +static unsigned char gifimage_notrailer[] = { +0x47,0x49,0x46,0x38,0x37,0x61,0x01,0x00,0x01,0x00,0x80,0x00,0x71,0xff,0xff,0xff, +0xff,0xff,0xff,0x2c,0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x00,0x00,0x02,0x02,0x44, +0x01,0x00 +}; + +static void test_gif_notrailer(void) +{ + IWICBitmapDecoder *decoder; + IWICImagingFactory *factory; + HRESULT hr; + IWICStream *gifstream; + IWICBitmapFrameDecode *framedecode; + double dpiX = 0.0, dpiY = 0.0; + UINT framecount; + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICImagingFactory, (void**)&factory); + ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr); + if (FAILED(hr)) return; + + hr = IWICImagingFactory_CreateStream(factory, &gifstream); + ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + hr = IWICStream_InitializeFromMemory(gifstream, gifimage_notrailer, + sizeof(gifimage_notrailer)); + ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr); + + if (SUCCEEDED(hr)) + { + hr = CoCreateInstance(&CLSID_WICGifDecoder, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICBitmapDecoder, (void**)&decoder); + ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr); + } + + if (SUCCEEDED(hr)) + { + hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)gifstream, + WICDecodeMetadataCacheOnDemand); + ok(hr == S_OK, "Initialize failed, hr=%x\n", hr); + + if (SUCCEEDED(hr)) + { + hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode); + ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + hr = IWICBitmapFrameDecode_GetResolution(framedecode, &dpiX, &dpiY); + ok(SUCCEEDED(hr), "GetResolution failed, hr=%x\n", hr); + ok(dpiX == 48.0, "expected dpiX=48.0, got %f\n", dpiX); + ok(dpiY == 96.0, "expected dpiY=96.0, got %f\n", dpiY); + + IWICBitmapFrameDecode_Release(framedecode); + } + } + + if (SUCCEEDED(hr)) + { + hr = IWICBitmapDecoder_GetFrameCount(decoder, &framecount); + ok(hr == S_OK, "GetFrameCount failed, hr=%x\n", hr); + ok(framecount == 1, "framecount=%u\n", framecount); + } + + IWICBitmapDecoder_Release(decoder); + } + + IWICStream_Release(gifstream); + } + + IWICImagingFactory_Release(factory); +} + START_TEST(gifformat) { HRESULT hr; @@ -504,6 +578,7 @@ START_TEST(gifformat) test_global_gif_palette_2frames(); test_local_gif_palette(); test_gif_frame_sizes(); + test_gif_notrailer();
IWICImagingFactory_Release(factory); CoUninitialize();
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/windowscodecs/tests/converter.c | 65 ++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 7 deletions(-)
diff --git a/dlls/windowscodecs/tests/converter.c b/dlls/windowscodecs/tests/converter.c index 690e787be6..472bee54b2 100644 --- a/dlls/windowscodecs/tests/converter.c +++ b/dlls/windowscodecs/tests/converter.c @@ -632,9 +632,60 @@ static void test_encoder_properties(const CLSID* clsid_encoder, IPropertyBag2 *o } }
-static void check_bmp_format(IStream *stream, const WICPixelFormatGUID *format) +static void check_bmp_format(IStream *stream, const struct bitmap_data *data) { - /* FIXME */ + BITMAPFILEHEADER bfh; + BITMAPINFOHEADER bih; + HRESULT hr; + ULONG len; + + hr = IStream_Read(stream, &bfh, sizeof(bfh), &len); + ok(hr == S_OK, "Failed to read file header, hr %#x.\n", hr); + + hr = IStream_Read(stream, &bih, sizeof(bih), &len); + ok(hr == S_OK, "Failed to read file header, hr %#x.\n", hr); + + ok(bfh.bfType == 0x4d42, "Unexpected header type, %#x.\n", bfh.bfType); + ok(bfh.bfSize != 0, "Unexpected bitmap size %d.\n", bfh.bfSize); + ok(bfh.bfReserved1 == 0, "Unexpected bfReserved1 field.\n"); + ok(bfh.bfReserved2 == 0, "Unexpected bfReserved2 field.\n"); + + if (IsEqualGUID(data->format, &GUID_WICPixelFormat1bppIndexed) + || IsEqualGUID(data->format, &GUID_WICPixelFormat8bppIndexed)) + { + /* TODO: test with actual palette size */ + ok(bfh.bfOffBits > sizeof(bfh) + sizeof(bih), "Unexpected data offset %d, format %s.\n", + bfh.bfOffBits, wine_dbgstr_guid(data->format)); + } + else + ok(bfh.bfOffBits == sizeof(bfh) + sizeof(bih), "Unexpected data offset %d, format %s.\n", + bfh.bfOffBits, wine_dbgstr_guid(data->format)); + + ok(bih.biSize == sizeof(bih), "Unexpected header size %d.\n", bih.biSize); + ok(bih.biWidth == data->width, "Unexpected bitmap width %d.\n", bih.biWidth); +todo_wine + ok(bih.biHeight == data->height, "Unexpected bitmap height %d.\n", bih.biHeight); + ok(bih.biPlanes == 1, "Unexpected planes count %d.\n", bih.biPlanes); + + if (IsEqualGUID(data->format, &GUID_WICPixelFormat1bppIndexed)) + ok(bih.biBitCount == 1, "Unexpected bit count %u, format %s.\n", bih.biBitCount, + wine_dbgstr_guid(data->format)); + else if (IsEqualGUID(data->format, &GUID_WICPixelFormat8bppIndexed)) + ok(bih.biBitCount == 8, "Unexpected bit count %u, format %s.\n", bih.biBitCount, + wine_dbgstr_guid(data->format)); + else if (IsEqualGUID(data->format, &GUID_WICPixelFormat32bppBGR)) + ok(bih.biBitCount == 32, "Unexpected bit count %u, format %s.\n", bih.biBitCount, + wine_dbgstr_guid(data->format)); + + ok(bih.biCompression == BI_RGB, "Unexpected compression mode %u.\n", bih.biCompression); +todo_wine + ok(bih.biSizeImage == 0, "Unexpected image size %d.\n", bih.biSizeImage); + ok(bih.biXPelsPerMeter == 3780 || broken(bih.biXPelsPerMeter == 0) /* XP */, "Unexpected horz resolution %d.\n", + bih.biXPelsPerMeter); + ok(bih.biYPelsPerMeter == 3780 || broken(bih.biYPelsPerMeter == 0) /* XP */, "Unexpected vert resolution %d.\n", + bih.biYPelsPerMeter); + + /* FIXME: test actual data */ }
static void check_tiff_format(IStream *stream, const WICPixelFormatGUID *format) @@ -722,7 +773,7 @@ static void check_png_format(IStream *stream, const WICPixelFormatGUID *format) ok(0, "unknown PNG pixel format %s\n", wine_dbgstr_guid(format)); }
-static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WICPixelFormatGUID *format) +static void check_bitmap_format(IStream *stream, const CLSID *encoder, const struct bitmap_data *dst) { HRESULT hr; LARGE_INTEGER pos; @@ -732,11 +783,11 @@ static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WIC ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
if (IsEqualGUID(encoder, &CLSID_WICPngEncoder)) - check_png_format(stream, format); + check_png_format(stream, dst->format); else if (IsEqualGUID(encoder, &CLSID_WICBmpEncoder)) - check_bmp_format(stream, format); + check_bmp_format(stream, dst); else if (IsEqualGUID(encoder, &CLSID_WICTiffEncoder)) - check_tiff_format(stream, format); + check_tiff_format(stream, dst->format); else ok(0, "unknown encoder %s\n", wine_dbgstr_guid(encoder));
@@ -972,7 +1023,7 @@ static void test_multi_encoder(const struct bitmap_data **srcs, const CLSID* cls hr = IWICBitmapEncoder_Commit(encoder); ok(SUCCEEDED(hr), "Commit failed, hr=%x\n", hr);
- check_bitmap_format(stream, clsid_encoder, dsts[0]->format); + check_bitmap_format(stream, clsid_encoder, dsts[0]); }
if (SUCCEEDED(hr))
Signed-off-by: Vincent Povirk vincent@codeweavers.com
Nikolay Sivov nsivov@codeweavers.com wrote:
-static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WICPixelFormatGUID *format) +static void check_bitmap_format(IStream *stream, const CLSID *encoder, const struct bitmap_data *dst) { HRESULT hr; LARGE_INTEGER pos; @@ -732,11 +783,11 @@ static void check_bitmap_format(IStream *stream, const CLSID *encoder, const WIC ok(hr == S_OK, "IStream_Seek error %#x\n", hr);
if (IsEqualGUID(encoder, &CLSID_WICPngEncoder))
check_png_format(stream, format);
else if (IsEqualGUID(encoder, &CLSID_WICBmpEncoder))check_png_format(stream, dst->format);
check_bmp_format(stream, format);
else if (IsEqualGUID(encoder, &CLSID_WICTiffEncoder))check_bmp_format(stream, dst);
check_tiff_format(stream, format);
else ok(0, "unknown encoder %s\n", wine_dbgstr_guid(encoder));check_tiff_format(stream, dst->format);
It's commendable that you are trying to not copy and paste the patches from wine-staging, however you are intentionally breaking an original idea to make check_png_format/check_bmp_format/etc. helpers test only format related things (like a header) and leave everything else (pixel data and palette) to be hanlded by common code. That's unacceptable.