2 * Copyright 2009 Vincent Povirk for CodeWeavers
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.
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.
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
23 #define WIN32_NO_STATUS
25 #define COM_NO_WINDOWS_H
32 //#include "wincodec.h"
33 #include <wincodecsdk.h>
34 #include <wine/test.h>
37 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
39 static HRESULT
get_component_info(const GUID
*clsid
, IWICComponentInfo
**result
)
41 IWICImagingFactory
*factory
;
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
;
49 hr
= IWICImagingFactory_CreateComponentInfo(factory
, clsid
, result
);
51 IWICImagingFactory_Release(factory
);
56 static BOOL
is_pixelformat(GUID
*format
)
58 IWICComponentInfo
*info
;
60 WICComponentType componenttype
;
62 hr
= get_component_info(format
, &info
);
66 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
68 IWICComponentInfo_Release(info
);
70 return SUCCEEDED(hr
) && componenttype
== WICPixelFormat
;
73 static void test_decoder_info(void)
75 IWICComponentInfo
*info
;
76 IWICBitmapDecoderInfo
*decoder_info
;
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};
83 GUID pixelformats
[20];
84 UINT num_formats
, count
;
87 hr
= get_component_info(&CLSID_WICBmpDecoder
, &info
);
89 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICBitmapDecoderInfo
, (void**)&decoder_info
);
90 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
92 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, NULL
);
93 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
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");
99 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, NULL
);
100 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
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
);
106 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, NULL
);
107 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
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
);
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
);
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
);
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
);
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
);
133 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, NULL
);
134 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
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
);
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");
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");
154 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, NULL
);
155 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
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
);
162 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 0, NULL
, NULL
);
163 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
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
);
169 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, len
, value
, NULL
);
170 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
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
);
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
);
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
);
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
);
191 IWICBitmapDecoderInfo_Release(decoder_info
);
193 IWICComponentInfo_Release(info
);
196 static void test_pixelformat_info(void)
198 IWICComponentInfo
*info
;
199 IWICPixelFormatInfo
*pixelformat_info
;
200 IWICPixelFormatInfo2
*pixelformat_info2
;
202 ULONG len
, known_len
;
205 WICComponentType componenttype
;
206 WICPixelFormatNumericRepresentation numericrepresentation
;
210 BOOL supportstransparency
;
212 hr
= get_component_info(&GUID_WICPixelFormat32bppBGRA
, &info
);
213 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
218 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, 0);
219 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
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
);
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");
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");
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");
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");
257 hr
= IWICComponentInfo_GetCLSID(info
, NULL
);
258 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
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
));
265 hr
= IWICComponentInfo_GetComponentType(info
, NULL
);
266 ok(hr
== E_INVALIDARG
, "GetComponentType failed, hr=%x\n", hr
);
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
);
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
);
277 hr
= IWICComponentInfo_GetSigningStatus(info
, NULL
);
278 ok(hr
== E_INVALIDARG
, "GetSigningStatus failed, hr=%x\n", hr
);
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
);
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 */
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
));
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 */
300 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo
, (void**)&pixelformat_info
);
301 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
305 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, NULL
);
306 ok(hr
== E_INVALIDARG
, "GetBitsPerPixel failed, hr=%x\n", hr
);
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
);
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
);
316 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, NULL
);
317 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
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
);
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");
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
);
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
);
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
);
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
));
354 IWICPixelFormatInfo_Release(pixelformat_info
);
357 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo2
, (void**)&pixelformat_info2
);
360 win_skip("IWICPixelFormatInfo2 not supported\n");
363 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, NULL
);
364 ok(hr
== E_INVALIDARG
, "GetNumericRepresentation failed, hr=%x\n", hr
);
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
);
371 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, NULL
);
372 ok(hr
== E_INVALIDARG
, "SupportsTransparency failed, hr=%x\n", hr
);
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
);
379 IWICPixelFormatInfo2_Release(pixelformat_info2
);
382 IWICComponentInfo_Release(info
);
385 static void test_reader_info(void)
387 IWICImagingFactory
*factory
;
388 IWICComponentInfo
*info
;
389 IWICMetadataReaderInfo
*reader_info
;
392 GUID container_formats
[10];
394 WICMetadataPattern
*patterns
;
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;
401 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICUnknownMetadataReader
, &info
);
402 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
404 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
405 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
407 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
408 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
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");
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");
418 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
419 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
422 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
424 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
426 ok(count
== 0, "unexpected count %d\n", count
);
428 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
429 0, NULL
, NULL
, NULL
);
430 ok(hr
== E_INVALIDARG
, "GetPatterns failed, hr=%x\n", hr
);
432 count
= size
= 0xdeadbeef;
433 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
434 0, NULL
, &count
, &size
);
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
);
441 IWICMetadataReaderInfo_Release(reader_info
);
443 IWICComponentInfo_Release(info
);
445 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICXMPStructMetadataReader
, &info
);
447 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
451 IWICImagingFactory_Release(factory
);
455 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
456 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
458 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
459 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
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");
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");
469 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
470 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
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
);
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
);
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
);
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
);
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
);
504 patterns
= HeapAlloc(GetProcessHeap(), 0, size
);
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
);
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
);
520 HeapFree(GetProcessHeap(), 0, patterns
);
523 IWICMetadataReaderInfo_Release(reader_info
);
525 IWICComponentInfo_Release(info
);
527 IWICImagingFactory_Release(factory
);
532 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
536 test_pixelformat_info();