dwrite: Stub for CreateMonitorRenderingParams().
[wine] / dlls / windowscodecs / tests / info.c
1 /*
2  * Copyright 2009 Vincent Povirk for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include <stdio.h>
20 #include <stdarg.h>
21 #include <math.h>
22
23 #define COBJMACROS
24
25 #include "windef.h"
26 #include "objbase.h"
27 #include "wincodec.h"
28 #include "wincodecsdk.h"
29 #include "wine/test.h"
30
31 #include "initguid.h"
32 DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
33
34 static const char *debugstr_guid(GUID *guid)
35 {
36     static char buf[50];
37
38     if(!guid)
39         return "(null)";
40
41     sprintf(buf, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
42             guid->Data1, guid->Data2, guid->Data3, guid->Data4[0],
43             guid->Data4[1], guid->Data4[2], guid->Data4[3], guid->Data4[4],
44             guid->Data4[5], guid->Data4[6], guid->Data4[7]);
45
46     return buf;
47 }
48
49 static HRESULT get_component_info(const GUID *clsid, IWICComponentInfo **result)
50 {
51     IWICImagingFactory *factory;
52     HRESULT hr;
53
54     hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
55         &IID_IWICImagingFactory, (void**)&factory);
56     ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
57     if (FAILED(hr)) return hr;
58
59     hr = IWICImagingFactory_CreateComponentInfo(factory, clsid, result);
60
61     IWICImagingFactory_Release(factory);
62
63     return hr;
64 }
65
66 static int is_pixelformat(GUID *format)
67 {
68     IWICComponentInfo *info;
69     HRESULT hr;
70     WICComponentType componenttype;
71
72     hr = get_component_info(format, &info);
73     if (FAILED(hr))
74         return FALSE;
75
76     hr = IWICComponentInfo_GetComponentType(info, &componenttype);
77
78     IWICComponentInfo_Release(info);
79
80     return SUCCEEDED(hr) && componenttype == WICPixelFormat;
81 }
82
83 static void test_decoder_info(void)
84 {
85     IWICComponentInfo *info;
86     IWICBitmapDecoderInfo *decoder_info;
87     HRESULT hr;
88     ULONG len;
89     WCHAR value[256];
90     const WCHAR expected_mimetype[] = {'i','m','a','g','e','/','b','m','p',0};
91     CLSID clsid;
92     GUID pixelformats[20];
93     UINT num_formats, count;
94     int i;
95
96     hr = get_component_info(&CLSID_WICBmpDecoder, &info);
97
98     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICBitmapDecoderInfo, (void**)&decoder_info);
99     ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
100
101     hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, NULL);
102     ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
103
104     hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, &clsid);
105     ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
106     ok(IsEqualGUID(&CLSID_WICBmpDecoder, &clsid), "GetCLSID returned wrong result\n");
107
108     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, NULL);
109     ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
110
111     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, NULL, &len);
112     ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
113     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
114
115     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, NULL);
116     ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
117
118     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, &len);
119     ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
120     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
121
122     value[0] = 0;
123     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, &len);
124     ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
125     ok(lstrcmpW(value, expected_mimetype) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
126     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
127
128     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, value, &len);
129     ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetMimeType failed, hr=%x\n", hr);
130     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
131
132     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 256, value, &len);
133     ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
134     ok(lstrcmpW(value, expected_mimetype) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
135     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
136
137     num_formats = 0xdeadbeef;
138     hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, NULL, &num_formats);
139     ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
140     ok(num_formats < 20 && num_formats > 1, "got %d formats\n", num_formats);
141
142     hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, NULL, NULL);
143     ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
144
145     count = 0xdeadbeef;
146     hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, pixelformats, &count);
147     ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
148     ok(count == 0, "got %d formats\n", count);
149
150     count = 0xdeadbeef;
151     hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 1, pixelformats, &count);
152     ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
153     ok(count == 1, "got %d formats\n", count);
154     ok(is_pixelformat(&pixelformats[0]), "got invalid pixel format\n");
155
156     count = 0xdeadbeef;
157     hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, num_formats, pixelformats, &count);
158     ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
159     ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
160     for (i=0; i<num_formats; i++)
161         ok(is_pixelformat(&pixelformats[i]), "got invalid pixel format\n");
162
163     hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, num_formats, pixelformats, NULL);
164     ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
165
166     count = 0xdeadbeef;
167     hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 20, pixelformats, &count);
168     ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
169     ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
170
171     IWICBitmapDecoderInfo_Release(decoder_info);
172
173     IWICComponentInfo_Release(info);
174 }
175
176 static void test_pixelformat_info(void)
177 {
178     IWICComponentInfo *info;
179     IWICPixelFormatInfo *pixelformat_info;
180     IWICPixelFormatInfo2 *pixelformat_info2;
181     HRESULT hr;
182     ULONG len, known_len;
183     WCHAR value[256];
184     GUID guid;
185     WICComponentType componenttype;
186     WICPixelFormatNumericRepresentation numericrepresentation;
187     DWORD signing;
188     UINT uiresult;
189     BYTE abbuffer[256];
190     BOOL supportstransparency;
191
192     hr = get_component_info(&GUID_WICPixelFormat32bppBGRA, &info);
193     ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
194
195     if (FAILED(hr))
196         return;
197
198     hr = IWICComponentInfo_GetAuthor(info, 0, NULL, 0);
199     ok(hr == E_INVALIDARG, "GetAuthor failed, hr=%x\n", hr);
200
201     len = 0xdeadbeef;
202     hr = IWICComponentInfo_GetAuthor(info, 0, NULL, &len);
203     ok(hr == S_OK, "GetAuthor failed, hr=%x\n", hr);
204     ok(len < 255 && len > 0, "invalid length 0x%x\n", len);
205     known_len = len;
206
207     memset(value, 0xaa, 256 * sizeof(WCHAR));
208     hr = IWICComponentInfo_GetAuthor(info, len-1, value, NULL);
209     ok(hr == E_INVALIDARG, "GetAuthor failed, hr=%x\n", hr);
210     ok(value[0] = 0xaaaa, "string modified\n");
211
212     len = 0xdeadbeef;
213     memset(value, 0xaa, 256 * sizeof(WCHAR));
214     hr = IWICComponentInfo_GetAuthor(info, known_len-1, value, &len);
215     ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetAuthor failed, hr=%x\n", hr);
216     ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
217     ok(value[known_len-1] == 0xaaaa, "string modified past given length\n");
218     ok(value[0] == 0xaaaa, "string modified\n");
219
220     len = 0xdeadbeef;
221     memset(value, 0xaa, 256 * sizeof(WCHAR));
222     hr = IWICComponentInfo_GetAuthor(info, known_len, value, &len);
223     ok(hr == S_OK, "GetAuthor failed, hr=%x\n", hr);
224     ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
225     ok(value[known_len-1] == 0, "string not terminated at expected length\n");
226     ok(value[known_len-2] != 0xaaaa, "string not modified at given length\n");
227
228     len = 0xdeadbeef;
229     memset(value, 0xaa, 256 * sizeof(WCHAR));
230     hr = IWICComponentInfo_GetAuthor(info, known_len+1, value, &len);
231     ok(hr == S_OK, "GetAuthor failed, hr=%x\n", hr);
232     ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
233     ok(value[known_len] == 0xaaaa, "string modified past end\n");
234     ok(value[known_len-1] == 0, "string not terminated at expected length\n");
235     ok(value[known_len-2] != 0xaaaa, "string not modified at given length\n");
236
237     hr = IWICComponentInfo_GetCLSID(info, NULL);
238     ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
239
240     memset(&guid, 0xaa, sizeof(guid));
241     hr = IWICComponentInfo_GetCLSID(info, &guid);
242     ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
243     ok(IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA), "unexpected CLSID %s\n", debugstr_guid(&guid));
244
245     hr = IWICComponentInfo_GetComponentType(info, NULL);
246     ok(hr == E_INVALIDARG, "GetComponentType failed, hr=%x\n", hr);
247
248     hr = IWICComponentInfo_GetComponentType(info, &componenttype);
249     ok(hr == S_OK, "GetComponentType failed, hr=%x\n", hr);
250     ok(componenttype == WICPixelFormat, "unexpected component type 0x%x\n", componenttype);
251
252     len = 0xdeadbeef;
253     hr = IWICComponentInfo_GetFriendlyName(info, 0, NULL, &len);
254     ok(hr == S_OK, "GetFriendlyName failed, hr=%x\n", hr);
255     ok(len < 255 && len > 0, "invalid length 0x%x\n", len);
256
257     hr = IWICComponentInfo_GetSigningStatus(info, NULL);
258     ok(hr == E_INVALIDARG, "GetSigningStatus failed, hr=%x\n", hr);
259
260     hr = IWICComponentInfo_GetSigningStatus(info, &signing);
261     ok(hr == S_OK, "GetSigningStatus failed, hr=%x\n", hr);
262     ok(signing == WICComponentSigned, "unexpected signing status 0x%x\n", signing);
263
264     len = 0xdeadbeef;
265     hr = IWICComponentInfo_GetSpecVersion(info, 0, NULL, &len);
266     ok(hr == S_OK, "GetSpecVersion failed, hr=%x\n", hr);
267     ok(len == 0, "invalid length 0x%x\n", len); /* spec version does not apply to pixel formats */
268
269     memset(&guid, 0xaa, sizeof(guid));
270     hr = IWICComponentInfo_GetVendorGUID(info, &guid);
271     ok(hr == S_OK, "GetVendorGUID failed, hr=%x\n", hr);
272     ok(IsEqualGUID(&guid, &GUID_VendorMicrosoft) ||
273        broken(IsEqualGUID(&guid, &GUID_NULL)) /* XP */, "unexpected GUID %s\n", debugstr_guid(&guid));
274
275     len = 0xdeadbeef;
276     hr = IWICComponentInfo_GetVersion(info, 0, NULL, &len);
277     ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
278     ok(len == 0, "invalid length 0x%x\n", len); /* version does not apply to pixel formats */
279
280     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void**)&pixelformat_info);
281     ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
282
283     if (SUCCEEDED(hr))
284     {
285         hr = IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info, NULL);
286         ok(hr == E_INVALIDARG, "GetBitsPerPixel failed, hr=%x\n", hr);
287
288         hr = IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info, &uiresult);
289         ok(hr == S_OK, "GetBitsPerPixel failed, hr=%x\n", hr);
290         ok(uiresult == 32, "unexpected bpp %i\n", uiresult);
291
292         hr = IWICPixelFormatInfo_GetChannelCount(pixelformat_info, &uiresult);
293         ok(hr == S_OK, "GetChannelCount failed, hr=%x\n", hr);
294         ok(uiresult == 4, "unexpected channel count %i\n", uiresult);
295
296         hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 0, NULL, NULL);
297         ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%x\n", hr);
298
299         uiresult = 0xdeadbeef;
300         hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 0, NULL, &uiresult);
301         ok(hr == S_OK, "GetChannelMask failed, hr=%x\n", hr);
302         ok(uiresult == 4, "unexpected length %i\n", uiresult);
303
304         memset(abbuffer, 0xaa, sizeof(abbuffer));
305         hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, known_len, abbuffer, NULL);
306         ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%x\n", hr);
307         ok(abbuffer[0] == 0xaa, "buffer modified\n");
308
309         uiresult = 0xdeadbeef;
310         memset(abbuffer, 0xaa, sizeof(abbuffer));
311         hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 3, abbuffer, &uiresult);
312         ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%x\n", hr);
313         ok(abbuffer[0] == 0xaa, "buffer modified\n");
314         ok(uiresult == 4, "unexpected length %i\n", uiresult);
315
316         memset(abbuffer, 0xaa, sizeof(abbuffer));
317         hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 4, abbuffer, &uiresult);
318         ok(hr == S_OK, "GetChannelMask failed, hr=%x\n", hr);
319         ok(*((ULONG*)abbuffer) == 0xff, "unexpected mask 0x%x\n", *((ULONG*)abbuffer));
320         ok(uiresult == 4, "unexpected length %i\n", uiresult);
321
322         memset(abbuffer, 0xaa, sizeof(abbuffer));
323         hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 5, abbuffer, &uiresult);
324         ok(hr == S_OK, "GetChannelMask failed, hr=%x\n", hr);
325         ok(*((ULONG*)abbuffer) == 0xff, "unexpected mask 0x%x\n", *((ULONG*)abbuffer));
326         ok(abbuffer[4] == 0xaa, "buffer modified past actual length\n");
327         ok(uiresult == 4, "unexpected length %i\n", uiresult);
328
329         memset(&guid, 0xaa, sizeof(guid));
330         hr = IWICPixelFormatInfo_GetFormatGUID(pixelformat_info, &guid);
331         ok(hr == S_OK, "GetFormatGUID failed, hr=%x\n", hr);
332         ok(IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA), "unexpected GUID %s\n", debugstr_guid(&guid));
333
334         IWICPixelFormatInfo_Release(pixelformat_info);
335     }
336
337     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void**)&pixelformat_info2);
338
339     if (FAILED(hr))
340         win_skip("IWICPixelFormatInfo2 not supported\n");
341     else
342     {
343         hr = IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2, NULL);
344         ok(hr == E_INVALIDARG, "GetNumericRepresentation failed, hr=%x\n", hr);
345
346         numericrepresentation = 0xdeadbeef;
347         hr = IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2, &numericrepresentation);
348         ok(hr == S_OK, "GetNumericRepresentation failed, hr=%x\n", hr);
349         ok(numericrepresentation == WICPixelFormatNumericRepresentationUnsignedInteger, "unexpected numeric representation %i\n", numericrepresentation);
350
351         hr = IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2, NULL);
352         ok(hr == E_INVALIDARG, "SupportsTransparency failed, hr=%x\n", hr);
353
354         supportstransparency = 0xdeadbeef;
355         hr = IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2, &supportstransparency);
356         ok(hr == S_OK, "SupportsTransparency failed, hr=%x\n", hr);
357         ok(supportstransparency == 1, "unexpected value %i\n", supportstransparency);
358
359         IWICPixelFormatInfo2_Release(pixelformat_info2);
360     }
361
362     IWICComponentInfo_Release(info);
363 }
364
365 static void test_reader_info(void)
366 {
367     IWICImagingFactory *factory;
368     IWICComponentInfo *info;
369     IWICMetadataReaderInfo *reader_info;
370     HRESULT hr;
371     CLSID clsid;
372     GUID container_formats[10];
373     UINT count, size;
374     WICMetadataPattern *patterns;
375
376     hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
377         &IID_IWICImagingFactory, (void**)&factory);
378     ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
379     if (FAILED(hr)) return;
380
381     hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICUnknownMetadataReader, &info);
382     ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
383
384     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
385     ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
386
387     hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
388     ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
389
390     hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
391     ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
392     ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader, &clsid), "GetCLSID returned wrong result\n");
393
394     hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
395     ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
396     ok(IsEqualGUID(&GUID_MetadataFormatUnknown, &clsid), "GetMetadataFormat returned wrong result\n");
397
398     hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
399     ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
400
401     count = 0xdeadbeef;
402     hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
403 todo_wine
404     ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
405 todo_wine
406     ok(count == 0, "unexpected count %d\n", count);
407
408     hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
409         0, NULL, NULL, NULL);
410     ok(hr == E_INVALIDARG, "GetPatterns failed, hr=%x\n", hr);
411
412     count = size = 0xdeadbeef;
413     hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
414         0, NULL, &count, &size);
415 todo_wine
416     ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
417         "GetPatterns failed, hr=%x\n", hr);
418     ok(count == 0xdeadbeef, "unexpected count %d\n", count);
419     ok(size == 0xdeadbeef, "unexpected size %d\n", size);
420
421     IWICMetadataReaderInfo_Release(reader_info);
422
423     IWICComponentInfo_Release(info);
424
425     hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICXMPStructMetadataReader, &info);
426 todo_wine
427     ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
428
429     if (FAILED(hr))
430     {
431         IWICImagingFactory_Release(factory);
432         return;
433     }
434
435     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
436     ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
437
438     hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
439     ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
440
441     hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
442     ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
443     ok(IsEqualGUID(&CLSID_WICXMPStructMetadataReader, &clsid), "GetCLSID returned wrong result\n");
444
445     hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
446     ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
447     ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct, &clsid), "GetMetadataFormat returned wrong result\n");
448
449     hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
450     ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
451
452     count = 0xdeadbeef;
453     hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
454     ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
455     ok(count >= 2, "unexpected count %d\n", count);
456
457     count = 0xdeadbeef;
458     hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 1, container_formats, &count);
459     ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
460     ok(count == 1, "unexpected count %d\n", count);
461
462     count = 0xdeadbeef;
463     hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 10, container_formats, &count);
464     ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
465     ok(count == min(count, 10), "unexpected count %d\n", count);
466
467     count = size = 0xdeadbeef;
468     hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
469         0, NULL, &count, &size);
470     ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
471         "GetPatterns failed, hr=%x\n", hr);
472     ok(count == 0xdeadbeef, "unexpected count %d\n", count);
473     ok(size == 0xdeadbeef, "unexpected size %d\n", size);
474
475     count = size = 0xdeadbeef;
476     hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
477         0, NULL, &count, &size);
478     ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
479     ok(count == 1, "unexpected count %d\n", count);
480     ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
481
482     if (hr == S_OK)
483     {
484         patterns = HeapAlloc(GetProcessHeap(), 0, size);
485
486         count = size = 0xdeadbeef;
487         hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
488             size-1, patterns, &count, &size);
489         ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
490         ok(count == 1, "unexpected count %d\n", count);
491         ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
492
493         count = size = 0xdeadbeef;
494         hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
495             size, patterns, &count, &size);
496         ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
497         ok(count == 1, "unexpected count %d\n", count);
498         ok(size == sizeof(WICMetadataPattern) + patterns->Length * 2, "unexpected size %d\n", size);
499
500         HeapFree(GetProcessHeap(), 0, patterns);
501     }
502
503     IWICMetadataReaderInfo_Release(reader_info);
504
505     IWICComponentInfo_Release(info);
506
507     IWICImagingFactory_Release(factory);
508 }
509
510 START_TEST(info)
511 {
512     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
513
514     test_decoder_info();
515     test_reader_info();
516     test_pixelformat_info();
517
518     CoUninitialize();
519 }