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
28 #include "wincodecsdk.h"
29 #include "wine/test.h"
32 DEFINE_GUID(GUID_NULL
,0,0,0,0,0,0,0,0,0,0,0);
34 static HRESULT
get_component_info(const GUID
*clsid
, IWICComponentInfo
**result
)
36 IWICImagingFactory
*factory
;
39 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
40 &IID_IWICImagingFactory
, (void**)&factory
);
41 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
42 if (FAILED(hr
)) return hr
;
44 hr
= IWICImagingFactory_CreateComponentInfo(factory
, clsid
, result
);
46 IWICImagingFactory_Release(factory
);
51 static BOOL
is_pixelformat(GUID
*format
)
53 IWICComponentInfo
*info
;
55 WICComponentType componenttype
;
57 hr
= get_component_info(format
, &info
);
61 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
63 IWICComponentInfo_Release(info
);
65 return SUCCEEDED(hr
) && componenttype
== WICPixelFormat
;
68 static void test_decoder_info(void)
70 struct decoder_info_test
74 const char *extensions
;
76 } decoder_info_tests
[] =
90 "image/ico,image/x-icon",
95 &CLSID_WICJpegDecoder
,
96 "image/jpeg,image/jpe,image/jpg",
97 ".jpeg,.jpe,.jpg,.jfif,.exif",
101 &CLSID_WICPngDecoder
,
106 &CLSID_WICTiffDecoder
,
107 "image/tiff,image/tif",
112 IWICBitmapDecoderInfo
*decoder_info
, *decoder_info2
;
113 IWICComponentInfo
*info
;
118 GUID pixelformats
[32];
119 UINT num_formats
, count
;
122 for (i
= 0; i
< sizeof(decoder_info_tests
)/sizeof(decoder_info_tests
[0]); i
++)
124 struct decoder_info_test
*test
= &decoder_info_tests
[i
];
125 IWICBitmapDecoder
*decoder
, *decoder2
;
126 WCHAR extensionsW
[64];
129 hr
= CoCreateInstance(test
->clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWICBitmapDecoder
, (void **)&decoder
);
130 ok(SUCCEEDED(hr
), "Failed to create decoder, hr %#x.\n", hr
);
133 hr
= IWICBitmapDecoder_GetDecoderInfo(decoder
, &decoder_info
);
134 ok(hr
== S_OK
|| broken(IsEqualCLSID(&CLSID_WICBmpDecoder
, test
->clsid
) && FAILED(hr
)) /* Fails on Windows */,
135 "%u: failed to get decoder info, hr %#x.\n", i
, hr
);
139 decoder_info2
= NULL
;
140 hr
= IWICBitmapDecoder_GetDecoderInfo(decoder
, &decoder_info2
);
141 ok(hr
== S_OK
, "Failed to get decoder info, hr %#x.\n", hr
);
142 ok(decoder_info
== decoder_info2
, "Unexpected decoder info instance.\n");
144 hr
= IWICBitmapDecoderInfo_QueryInterface(decoder_info
, &IID_IWICBitmapDecoder
, (void **)&decoder2
);
145 ok(hr
== E_NOINTERFACE
, "Unexpected hr %#x.\n", hr
);
147 IWICBitmapDecoderInfo_Release(decoder_info
);
148 IWICBitmapDecoderInfo_Release(decoder_info2
);
150 IWICBitmapDecoder_Release(decoder
);
152 MultiByteToWideChar(CP_ACP
, 0, test
->mimetype
, -1, mimetypeW
, sizeof(mimetypeW
)/sizeof(mimetypeW
[0]));
153 MultiByteToWideChar(CP_ACP
, 0, test
->extensions
, -1, extensionsW
, sizeof(extensionsW
)/sizeof(extensionsW
[0]));
155 hr
= get_component_info(test
->clsid
, &info
);
156 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
158 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICBitmapDecoderInfo
, (void **)&decoder_info
);
159 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
161 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, NULL
);
162 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
164 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, &clsid
);
165 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
166 ok(IsEqualGUID(test
->clsid
, &clsid
), "GetCLSID returned wrong result\n");
168 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, NULL
);
169 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
172 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, NULL
, &len
);
173 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
174 todo_wine_if(test
->todo
)
175 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
177 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, NULL
);
178 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
181 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, &len
);
182 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
183 todo_wine_if(test
->todo
)
184 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
187 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, &len
);
188 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
189 todo_wine_if(test
->todo
) {
190 ok(lstrcmpW(value
, mimetypeW
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
191 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
193 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, value
, &len
);
194 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetMimeType failed, hr=%x\n", hr
);
195 todo_wine_if(test
->todo
)
196 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
198 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 256, value
, &len
);
199 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
200 todo_wine_if(test
->todo
) {
201 ok(lstrcmpW(value
, mimetypeW
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
202 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
204 num_formats
= 0xdeadbeef;
205 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, &num_formats
);
206 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
207 ok((num_formats
<= 21 && num_formats
>= 1) ||
208 broken(IsEqualCLSID(test
->clsid
, &CLSID_WICIcoDecoder
) && num_formats
== 0) /* WinXP */,
209 "%u: got %d formats\n", i
, num_formats
);
211 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, NULL
);
212 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
215 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, pixelformats
, &count
);
216 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
217 ok(count
== 0, "got %d formats\n", count
);
220 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 1, pixelformats
, &count
);
221 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
222 ok((count
== 1) || broken(IsEqualCLSID(test
->clsid
, &CLSID_WICIcoDecoder
) && count
== 0) /* WinXP */,
223 "%u: got %d formats\n", i
, num_formats
);
224 ok(is_pixelformat(&pixelformats
[0]), "got invalid pixel format\n");
227 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, &count
);
228 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
229 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
230 for (j
= 0; j
< num_formats
; j
++)
231 ok(is_pixelformat(&pixelformats
[j
]), "got invalid pixel format\n");
233 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, NULL
);
234 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
237 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, sizeof(pixelformats
)/sizeof(pixelformats
[0]),
238 pixelformats
, &count
);
239 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
240 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
242 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 0, NULL
, NULL
);
243 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
245 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 1, NULL
, &len
);
246 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
247 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
248 ok(len
== lstrlenW(extensionsW
) + 1, "%u: GetFileExtensions returned wrong len %i\n", i
, len
);
250 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, len
, value
, NULL
);
251 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
253 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 0, NULL
, &len
);
254 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
255 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
256 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
259 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, len
, value
, &len
);
260 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
261 todo_wine_if(test
->todo
)
262 ok(lstrcmpW(value
, extensionsW
) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value
));
263 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
264 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
266 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 1, value
, &len
);
267 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetFileExtensions failed, hr=%x\n", hr
);
268 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
269 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
271 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 256, value
, &len
);
272 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
273 todo_wine_if(test
->todo
)
274 ok(lstrcmpW(value
, extensionsW
) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value
));
275 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
276 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
278 IWICBitmapDecoderInfo_Release(decoder_info
);
279 IWICComponentInfo_Release(info
);
283 static void test_pixelformat_info(void)
285 IWICComponentInfo
*info
;
286 IWICPixelFormatInfo
*pixelformat_info
;
287 IWICPixelFormatInfo2
*pixelformat_info2
;
289 ULONG len
, known_len
;
292 WICComponentType componenttype
;
293 WICPixelFormatNumericRepresentation numericrepresentation
;
297 BOOL supportstransparency
;
299 hr
= get_component_info(&GUID_WICPixelFormat32bppBGRA
, &info
);
300 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
305 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, 0);
306 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
309 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, &len
);
310 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
311 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
314 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
315 hr
= IWICComponentInfo_GetAuthor(info
, len
-1, value
, NULL
);
316 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
317 ok(value
[0] == 0xaaaa, "string modified\n");
320 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
321 hr
= IWICComponentInfo_GetAuthor(info
, known_len
-1, value
, &len
);
322 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetAuthor failed, hr=%x\n", hr
);
323 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
324 ok(value
[known_len
-1] == 0xaaaa, "string modified past given length\n");
325 ok(value
[0] == 0xaaaa, "string modified\n");
328 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
329 hr
= IWICComponentInfo_GetAuthor(info
, known_len
, value
, &len
);
330 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
331 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
332 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
333 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
336 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
337 hr
= IWICComponentInfo_GetAuthor(info
, known_len
+1, value
, &len
);
338 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
339 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
340 ok(value
[known_len
] == 0xaaaa, "string modified past end\n");
341 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
342 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
344 hr
= IWICComponentInfo_GetCLSID(info
, NULL
);
345 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
347 memset(&guid
, 0xaa, sizeof(guid
));
348 hr
= IWICComponentInfo_GetCLSID(info
, &guid
);
349 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
350 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected CLSID %s\n", wine_dbgstr_guid(&guid
));
352 hr
= IWICComponentInfo_GetComponentType(info
, NULL
);
353 ok(hr
== E_INVALIDARG
, "GetComponentType failed, hr=%x\n", hr
);
355 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
356 ok(hr
== S_OK
, "GetComponentType failed, hr=%x\n", hr
);
357 ok(componenttype
== WICPixelFormat
, "unexpected component type 0x%x\n", componenttype
);
360 hr
= IWICComponentInfo_GetFriendlyName(info
, 0, NULL
, &len
);
361 ok(hr
== S_OK
, "GetFriendlyName failed, hr=%x\n", hr
);
362 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
364 hr
= IWICComponentInfo_GetSigningStatus(info
, NULL
);
365 ok(hr
== E_INVALIDARG
, "GetSigningStatus failed, hr=%x\n", hr
);
367 hr
= IWICComponentInfo_GetSigningStatus(info
, &signing
);
368 ok(hr
== S_OK
, "GetSigningStatus failed, hr=%x\n", hr
);
369 ok(signing
== WICComponentSigned
, "unexpected signing status 0x%x\n", signing
);
372 hr
= IWICComponentInfo_GetSpecVersion(info
, 0, NULL
, &len
);
373 ok(hr
== S_OK
, "GetSpecVersion failed, hr=%x\n", hr
);
374 ok(len
== 0, "invalid length 0x%x\n", len
); /* spec version does not apply to pixel formats */
376 memset(&guid
, 0xaa, sizeof(guid
));
377 hr
= IWICComponentInfo_GetVendorGUID(info
, &guid
);
378 ok(hr
== S_OK
, "GetVendorGUID failed, hr=%x\n", hr
);
379 ok(IsEqualGUID(&guid
, &GUID_VendorMicrosoft
) ||
380 broken(IsEqualGUID(&guid
, &GUID_NULL
)) /* XP */, "unexpected GUID %s\n", wine_dbgstr_guid(&guid
));
383 hr
= IWICComponentInfo_GetVersion(info
, 0, NULL
, &len
);
384 ok(hr
== S_OK
, "GetVersion failed, hr=%x\n", hr
);
385 ok(len
== 0, "invalid length 0x%x\n", len
); /* version does not apply to pixel formats */
387 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo
, (void**)&pixelformat_info
);
388 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
392 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, NULL
);
393 ok(hr
== E_INVALIDARG
, "GetBitsPerPixel failed, hr=%x\n", hr
);
395 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, &uiresult
);
396 ok(hr
== S_OK
, "GetBitsPerPixel failed, hr=%x\n", hr
);
397 ok(uiresult
== 32, "unexpected bpp %i\n", uiresult
);
399 hr
= IWICPixelFormatInfo_GetChannelCount(pixelformat_info
, &uiresult
);
400 ok(hr
== S_OK
, "GetChannelCount failed, hr=%x\n", hr
);
401 ok(uiresult
== 4, "unexpected channel count %i\n", uiresult
);
403 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, NULL
);
404 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
406 uiresult
= 0xdeadbeef;
407 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, &uiresult
);
408 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
409 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
411 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
412 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, known_len
, abbuffer
, NULL
);
413 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
414 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
416 uiresult
= 0xdeadbeef;
417 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
418 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 3, abbuffer
, &uiresult
);
419 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
420 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
421 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
423 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
424 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 4, abbuffer
, &uiresult
);
425 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
426 ok(*((ULONG
*)abbuffer
) == 0xff, "unexpected mask 0x%x\n", *((ULONG
*)abbuffer
));
427 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
429 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
430 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 5, abbuffer
, &uiresult
);
431 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
432 ok(*((ULONG
*)abbuffer
) == 0xff, "unexpected mask 0x%x\n", *((ULONG
*)abbuffer
));
433 ok(abbuffer
[4] == 0xaa, "buffer modified past actual length\n");
434 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
436 memset(&guid
, 0xaa, sizeof(guid
));
437 hr
= IWICPixelFormatInfo_GetFormatGUID(pixelformat_info
, &guid
);
438 ok(hr
== S_OK
, "GetFormatGUID failed, hr=%x\n", hr
);
439 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected GUID %s\n", wine_dbgstr_guid(&guid
));
441 IWICPixelFormatInfo_Release(pixelformat_info
);
444 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo2
, (void**)&pixelformat_info2
);
447 win_skip("IWICPixelFormatInfo2 not supported\n");
450 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, NULL
);
451 ok(hr
== E_INVALIDARG
, "GetNumericRepresentation failed, hr=%x\n", hr
);
453 numericrepresentation
= 0xdeadbeef;
454 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, &numericrepresentation
);
455 ok(hr
== S_OK
, "GetNumericRepresentation failed, hr=%x\n", hr
);
456 ok(numericrepresentation
== WICPixelFormatNumericRepresentationUnsignedInteger
, "unexpected numeric representation %i\n", numericrepresentation
);
458 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, NULL
);
459 ok(hr
== E_INVALIDARG
, "SupportsTransparency failed, hr=%x\n", hr
);
461 supportstransparency
= 0xdeadbeef;
462 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, &supportstransparency
);
463 ok(hr
== S_OK
, "SupportsTransparency failed, hr=%x\n", hr
);
464 ok(supportstransparency
== 1, "unexpected value %i\n", supportstransparency
);
466 IWICPixelFormatInfo2_Release(pixelformat_info2
);
469 IWICComponentInfo_Release(info
);
472 static DWORD WINAPI
cache_across_threads_test(void *arg
)
474 IWICComponentInfo
*info
;
479 hr
= get_component_info(&CLSID_WICUnknownMetadataReader
, &info
);
480 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
481 ok(info
== arg
, "unexpected info pointer %p\n", info
);
482 IWICComponentInfo_Release(info
);
488 static void test_reader_info(void)
490 IWICImagingFactory
*factory
;
491 IWICComponentInfo
*info
, *info2
;
492 IWICMetadataReaderInfo
*reader_info
;
495 GUID container_formats
[10];
496 UINT count
, size
, tid
;
498 WICMetadataPattern
*patterns
;
500 hr
= get_component_info(&CLSID_WICUnknownMetadataReader
, &info2
);
501 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
502 IWICComponentInfo_Release(info2
);
504 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
505 &IID_IWICImagingFactory
, (void**)&factory
);
506 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
507 if (FAILED(hr
)) return;
509 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICUnknownMetadataReader
, &info
);
510 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
511 ok(info
== info2
, "info != info2\n");
513 thread
= CreateThread(NULL
, 0, cache_across_threads_test
, info
, 0, &tid
);
514 WaitForSingleObject(thread
, INFINITE
);
517 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
518 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
520 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
521 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
523 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
524 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
525 ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
527 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
528 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
529 ok(IsEqualGUID(&GUID_MetadataFormatUnknown
, &clsid
), "GetMetadataFormat returned wrong result\n");
531 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
532 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
535 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
536 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
537 ok(count
== 0, "unexpected count %d\n", count
);
539 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
540 0, NULL
, NULL
, NULL
);
541 ok(hr
== E_INVALIDARG
, "GetPatterns failed, hr=%x\n", hr
);
543 count
= size
= 0xdeadbeef;
544 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
545 0, NULL
, &count
, &size
);
546 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
547 "GetPatterns failed, hr=%x\n", hr
);
548 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
549 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
551 IWICMetadataReaderInfo_Release(reader_info
);
553 IWICComponentInfo_Release(info
);
555 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICXMPStructMetadataReader
, &info
);
557 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
561 IWICImagingFactory_Release(factory
);
565 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
566 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
568 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
569 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
571 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
572 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
573 ok(IsEqualGUID(&CLSID_WICXMPStructMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
575 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
576 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
577 ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct
, &clsid
), "GetMetadataFormat returned wrong result\n");
579 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
580 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
583 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
584 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
585 ok(count
>= 2, "unexpected count %d\n", count
);
588 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 1, container_formats
, &count
);
589 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
590 ok(count
== 1, "unexpected count %d\n", count
);
593 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 10, container_formats
, &count
);
594 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
595 ok(count
== min(count
, 10), "unexpected count %d\n", count
);
597 count
= size
= 0xdeadbeef;
598 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
599 0, NULL
, &count
, &size
);
600 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
601 "GetPatterns failed, hr=%x\n", hr
);
602 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
603 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
605 count
= size
= 0xdeadbeef;
606 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
607 0, NULL
, &count
, &size
);
608 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
609 ok(count
== 1, "unexpected count %d\n", count
);
610 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
614 patterns
= HeapAlloc(GetProcessHeap(), 0, size
);
616 count
= size
= 0xdeadbeef;
617 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
618 size
-1, patterns
, &count
, &size
);
619 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
620 ok(count
== 1, "unexpected count %d\n", count
);
621 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
623 count
= size
= 0xdeadbeef;
624 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
625 size
, patterns
, &count
, &size
);
626 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
627 ok(count
== 1, "unexpected count %d\n", count
);
628 ok(size
== sizeof(WICMetadataPattern
) + patterns
->Length
* 2, "unexpected size %d\n", size
);
630 HeapFree(GetProcessHeap(), 0, patterns
);
633 IWICMetadataReaderInfo_Release(reader_info
);
635 IWICComponentInfo_Release(info
);
637 IWICImagingFactory_Release(factory
);
642 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
646 test_pixelformat_info();