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