windowscodecs: Add test for IWICMetadataReaderInfo.

This commit is contained in:
Vincent Povirk 2012-05-31 12:38:34 -05:00 committed by Alexandre Julliard
parent eae43717db
commit 46991dc9fb
2 changed files with 146 additions and 0 deletions

View File

@ -24,6 +24,7 @@
#include "windef.h"
#include "objbase.h"
#include "wincodec.h"
#include "wincodecsdk.h"
#include "wine/test.h"
static void test_decoder_info(void)
@ -91,11 +92,153 @@ static void test_decoder_info(void)
IWICImagingFactory_Release(factory);
}
static void test_reader_info(void)
{
IWICImagingFactory *factory;
IWICComponentInfo *info;
IWICMetadataReaderInfo *reader_info;
HRESULT hr;
CLSID clsid;
GUID container_formats[10];
UINT count, size;
WICMetadataPattern *patterns;
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_CreateComponentInfo(factory, &CLSID_WICUnknownMetadataReader, &info);
todo_wine ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
if (FAILED(hr))
{
IWICImagingFactory_Release(factory);
return;
}
hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader, &clsid), "GetCLSID returned wrong result\n");
hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
ok(IsEqualGUID(&GUID_MetadataFormatUnknown, &clsid), "GetMetadataFormat returned wrong result\n");
hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
count = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
ok(count == 0, "unexpected count %d\n", count);
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
0, NULL, NULL, NULL);
ok(hr == E_INVALIDARG, "GetPatterns failed, hr=%x\n", hr);
count = size = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
0, NULL, &count, &size);
ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
"GetPatterns failed, hr=%x\n", hr);
ok(count == 0xdeadbeef, "unexpected count %d\n", count);
ok(size == 0xdeadbeef, "unexpected size %d\n", size);
IWICMetadataReaderInfo_Release(reader_info);
IWICComponentInfo_Release(info);
hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICXMBStructMetadataReader, &info);
ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
ok(IsEqualGUID(&CLSID_WICXMBStructMetadataReader, &clsid), "GetCLSID returned wrong result\n");
hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct, &clsid), "GetMetadataFormat returned wrong result\n");
hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
count = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
ok(count >= 2, "unexpected count %d\n", count);
count = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 1, container_formats, &count);
ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
ok(count == 1, "unexpected count %d\n", count);
count = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 10, container_formats, &count);
ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
ok(count == min(count, 10), "unexpected count %d\n", count);
count = size = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
0, NULL, &count, &size);
ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
"GetPatterns failed, hr=%x\n", hr);
ok(count == 0xdeadbeef, "unexpected count %d\n", count);
ok(size == 0xdeadbeef, "unexpected size %d\n", size);
count = size = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
0, NULL, &count, &size);
ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
ok(count == 1, "unexpected count %d\n", count);
ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
if (hr == S_OK)
{
patterns = HeapAlloc(GetProcessHeap(), 0, size);
count = size = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
size-1, patterns, &count, &size);
ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
ok(count == 1, "unexpected count %d\n", count);
ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
count = size = 0xdeadbeef;
hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
size, patterns, &count, &size);
ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
ok(count == 1, "unexpected count %d\n", count);
ok(size == sizeof(WICMetadataPattern) + patterns->Length * 2, "unexpected size %d\n", size);
HeapFree(GetProcessHeap(), 0, patterns);
}
IWICMetadataReaderInfo_Release(reader_info);
IWICComponentInfo_Release(info);
IWICImagingFactory_Release(factory);
}
START_TEST(info)
{
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
test_decoder_info();
test_reader_info();
CoUninitialize();
}

View File

@ -40,6 +40,8 @@ cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunktEXt, 0x568d8936,0xc0a9,0x4923,0x
cpp_quote("DEFINE_GUID(GUID_MetadataFormatChunktIME, 0x6b00ae2d,0xe24b,0x460a,0x98,0xb6,0x87,0x8b,0xd0,0x30,0x72,0xfd);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatIfd, 0x537396c6,0x2d8a,0x4bb6,0x9b,0xf8,0x2f,0x0a,0x8e,0x2a,0x3a,0xdf);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatExif, 0x1c3c4f9d,0xb84a,0x467d,0x94,0x93,0x36,0xcf,0xbd,0x59,0xea,0x57);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMP, 0xbb5acc38,0xf216,0x4cec,0xa6,0xc5,0x5f,0x6e,0x73,0x97,0x63,0xa9);")
cpp_quote("DEFINE_GUID(GUID_MetadataFormatXMPStruct, 0x22383cf1,0xed17,0x4e2e,0xaf,0x17,0xd8,0x5b,0x8f,0x6b,0x30,0xd0);")
cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataReader, 0x699745c2,0x5066,0x4b82,0xa8,0xe3,0xd4,0x04,0x78,0xdb,0xec,0x8c);")
cpp_quote("DEFINE_GUID(CLSID_WICUnknownMetadataWriter, 0xa09cca86,0x27ba,0x4f39,0x90,0x53,0x12,0x1f,0xa4,0xdc,0x08,0xfc);")
@ -47,6 +49,7 @@ cpp_quote("DEFINE_GUID(CLSID_WICPngTextMetadataReader, 0x4b59afcc,0xb8c3,0x408a,
cpp_quote("DEFINE_GUID(CLSID_WICPngTextMetadataWriter, 0xb5ebafb9,0x253e,0x4a72,0xa7,0x44,0x07,0x62,0xd2,0x68,0x56,0x83);")
cpp_quote("DEFINE_GUID(CLSID_WICIfdMetadataReader, 0x8f914656,0x9d0a,0x4eb2,0x90,0x19,0x0b,0xf9,0x6d,0x8a,0x9e,0xe6);")
cpp_quote("DEFINE_GUID(CLSID_WICExifMetadataReader, 0xd9403860,0x297f,0x4a49,0xbf,0x9b,0x77,0x89,0x81,0x50,0xa4,0x42);")
cpp_quote("DEFINE_GUID(CLSID_WICXMBStructMetadataReader, 0x01b90d9a,0x8209,0x47f7,0x9c,0x52,0xe1,0x24,0x4b,0xf5,0x0c,0xed);")
typedef struct WICMetadataPattern {
ULARGE_INTEGER Position;