From 009f66741f4142e62ab9b2e367bda13f77105e87 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 28 Jul 2009 17:21:42 -0500 Subject: [PATCH] windowscodecs: add test for IWICImagingFactory::CreateDecoderFromStream --- dlls/windowscodecs/tests/bmpformat.c | 49 ++++++++++++++++++++++++++++++++++ 1 files changed, 49 insertions(+), 0 deletions(-) diff --git a/dlls/windowscodecs/tests/bmpformat.c b/dlls/windowscodecs/tests/bmpformat.c index 6f6b83a..a880b22 100644 --- a/dlls/windowscodecs/tests/bmpformat.c +++ b/dlls/windowscodecs/tests/bmpformat.c @@ -986,6 +986,54 @@ static void test_componentinfo(void) } } +void test_createfromstream(void) +{ + IWICBitmapDecoder *decoder; + IWICImagingFactory *factory; + HRESULT hr; + HGLOBAL hbmpdata; + char *bmpdata; + IStream *bmpstream; + GUID guidresult; + + hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER, + &IID_IWICImagingFactory, (void**)&factory); + ok(SUCCEEDED(hr), "CoCreateInstance failed, hr=%x\n", hr); + if (!SUCCEEDED(hr)) return; + + hbmpdata = GlobalAlloc(GMEM_MOVEABLE, sizeof(testbmp_1bpp)); + ok(hbmpdata != 0, "GlobalAlloc failed\n"); + if (hbmpdata) + { + bmpdata = GlobalLock(hbmpdata); + memcpy(bmpdata, testbmp_1bpp, sizeof(testbmp_1bpp)); + GlobalUnlock(hbmpdata); + + hr = CreateStreamOnHGlobal(hbmpdata, FALSE, &bmpstream); + ok(SUCCEEDED(hr), "CreateStreamOnHGlobal failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + hr = IWICImagingFactory_CreateDecoderFromStream(factory, bmpstream, + NULL, WICDecodeMetadataCacheOnDemand, &decoder); + ok(SUCCEEDED(hr), "CreateDecoderFromStream failed, hr=%x\n", hr); + if (SUCCEEDED(hr)) + { + hr = IWICBitmapDecoder_GetContainerFormat(decoder, &guidresult); + ok(SUCCEEDED(hr), "GetContainerFormat failed, hr=%x\n", hr); + ok(IsEqualGUID(&guidresult, &GUID_ContainerFormatBmp), "unexpected container format\n"); + + IWICBitmapDecoder_Release(decoder); + } + + IStream_Release(bmpstream); + } + + GlobalFree(hbmpdata); + } + + IWICImagingFactory_Release(factory); +} + START_TEST(bmpformat) { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); @@ -996,6 +1044,7 @@ START_TEST(bmpformat) test_decode_rle8(); test_decode_rle4(); test_componentinfo(); + test_createfromstream(); CoUninitialize(); } -- 1.5.4.3