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