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"
31 static HRESULT
get_component_info(const GUID
*clsid
, IWICComponentInfo
**result
)
33 IWICImagingFactory
*factory
;
36 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
37 &IID_IWICImagingFactory
, (void**)&factory
);
38 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
39 if (FAILED(hr
)) return hr
;
41 hr
= IWICImagingFactory_CreateComponentInfo(factory
, clsid
, result
);
43 IWICImagingFactory_Release(factory
);
48 static BOOL
is_pixelformat(GUID
*format
)
50 IWICComponentInfo
*info
;
52 WICComponentType componenttype
;
54 hr
= get_component_info(format
, &info
);
58 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
60 IWICComponentInfo_Release(info
);
62 return SUCCEEDED(hr
) && componenttype
== WICPixelFormat
;
65 static void test_decoder_info(void)
67 struct decoder_info_test
71 const char *extensions
;
73 } decoder_info_tests
[] =
87 "image/ico,image/x-icon",
92 &CLSID_WICJpegDecoder
,
93 "image/jpeg,image/jpe,image/jpg",
94 ".jpeg,.jpe,.jpg,.jfif,.exif",
103 &CLSID_WICTiffDecoder
,
104 "image/tiff,image/tif",
109 &CLSID_WICDdsDecoder
,
114 IWICBitmapDecoderInfo
*decoder_info
, *decoder_info2
;
115 IWICComponentInfo
*info
;
120 GUID pixelformats
[32];
121 UINT num_formats
, count
;
124 for (i
= 0; i
< ARRAY_SIZE(decoder_info_tests
); i
++)
126 struct decoder_info_test
*test
= &decoder_info_tests
[i
];
127 IWICBitmapDecoder
*decoder
, *decoder2
;
128 WCHAR extensionsW
[64];
131 hr
= CoCreateInstance(test
->clsid
, NULL
, CLSCTX_INPROC_SERVER
, &IID_IWICBitmapDecoder
, (void **)&decoder
);
132 if (test
->clsid
== &CLSID_WICDdsDecoder
&& hr
!= S_OK
) {
133 win_skip("DDS decoder is not supported\n");
136 ok(SUCCEEDED(hr
), "Failed to create decoder, hr %#x.\n", hr
);
139 hr
= IWICBitmapDecoder_GetDecoderInfo(decoder
, &decoder_info
);
140 ok(hr
== S_OK
|| broken(IsEqualCLSID(&CLSID_WICBmpDecoder
, test
->clsid
) && FAILED(hr
)) /* Fails on Windows */,
141 "%u: failed to get decoder info, hr %#x.\n", i
, hr
);
145 decoder_info2
= NULL
;
146 hr
= IWICBitmapDecoder_GetDecoderInfo(decoder
, &decoder_info2
);
147 ok(hr
== S_OK
, "Failed to get decoder info, hr %#x.\n", hr
);
148 ok(decoder_info
== decoder_info2
, "Unexpected decoder info instance.\n");
150 hr
= IWICBitmapDecoderInfo_QueryInterface(decoder_info
, &IID_IWICBitmapDecoder
, (void **)&decoder2
);
151 ok(hr
== E_NOINTERFACE
, "Unexpected hr %#x.\n", hr
);
153 IWICBitmapDecoderInfo_Release(decoder_info
);
154 IWICBitmapDecoderInfo_Release(decoder_info2
);
156 IWICBitmapDecoder_Release(decoder
);
158 MultiByteToWideChar(CP_ACP
, 0, test
->mimetype
, -1, mimetypeW
, ARRAY_SIZE(mimetypeW
));
159 MultiByteToWideChar(CP_ACP
, 0, test
->extensions
, -1, extensionsW
, ARRAY_SIZE(extensionsW
));
161 hr
= get_component_info(test
->clsid
, &info
);
162 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
164 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICBitmapDecoderInfo
, (void **)&decoder_info
);
165 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
167 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, NULL
);
168 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
170 hr
= IWICBitmapDecoderInfo_GetCLSID(decoder_info
, &clsid
);
171 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
172 ok(IsEqualGUID(test
->clsid
, &clsid
), "GetCLSID returned wrong result\n");
174 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, NULL
);
175 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
178 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, NULL
, &len
);
179 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
180 todo_wine_if(test
->todo
)
181 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
183 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, NULL
);
184 ok(hr
== E_INVALIDARG
, "GetMimeType failed, hr=%x\n", hr
);
187 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 0, NULL
, &len
);
188 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
189 todo_wine_if(test
->todo
)
190 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
193 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, len
, value
, &len
);
194 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
195 todo_wine_if(test
->todo
) {
196 ok(lstrcmpW(value
, mimetypeW
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
197 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
199 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 1, value
, &len
);
200 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetMimeType failed, hr=%x\n", hr
);
201 todo_wine_if(test
->todo
)
202 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
204 hr
= IWICBitmapDecoderInfo_GetMimeTypes(decoder_info
, 256, value
, &len
);
205 ok(hr
== S_OK
, "GetMimeType failed, hr=%x\n", hr
);
206 todo_wine_if(test
->todo
) {
207 ok(lstrcmpW(value
, mimetypeW
) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value
));
208 ok(len
== lstrlenW(mimetypeW
) + 1, "GetMimeType returned wrong len %i\n", len
);
210 num_formats
= 0xdeadbeef;
211 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, &num_formats
);
212 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
213 ok((num_formats
<= 21 && num_formats
>= 1) ||
214 broken(IsEqualCLSID(test
->clsid
, &CLSID_WICIcoDecoder
) && num_formats
== 0) /* WinXP */,
215 "%u: got %d formats\n", i
, num_formats
);
217 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, NULL
, NULL
);
218 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
221 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 0, pixelformats
, &count
);
222 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
223 ok(count
== 0, "got %d formats\n", count
);
226 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, 1, pixelformats
, &count
);
227 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
228 ok((count
== 1) || broken(IsEqualCLSID(test
->clsid
, &CLSID_WICIcoDecoder
) && count
== 0) /* WinXP */,
229 "%u: got %d formats\n", i
, num_formats
);
230 ok(is_pixelformat(&pixelformats
[0]), "got invalid pixel format\n");
233 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, &count
);
234 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
235 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
236 for (j
= 0; j
< num_formats
; j
++)
237 ok(is_pixelformat(&pixelformats
[j
]), "got invalid pixel format\n");
239 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, num_formats
, pixelformats
, NULL
);
240 ok(hr
== E_INVALIDARG
, "GetPixelFormats failed, hr=%x\n", hr
);
243 hr
= IWICBitmapDecoderInfo_GetPixelFormats(decoder_info
, ARRAY_SIZE(pixelformats
),
244 pixelformats
, &count
);
245 ok(hr
== S_OK
, "GetPixelFormats failed, hr=%x\n", hr
);
246 ok(count
== num_formats
, "got %d formats, expected %d\n", count
, num_formats
);
248 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 0, NULL
, NULL
);
249 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
251 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 1, NULL
, &len
);
252 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
253 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
254 ok(len
== lstrlenW(extensionsW
) + 1, "%u: GetFileExtensions returned wrong len %i\n", i
, len
);
256 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, len
, value
, NULL
);
257 ok(hr
== E_INVALIDARG
, "GetFileExtensions failed, hr=%x\n", hr
);
259 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 0, NULL
, &len
);
260 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
261 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
262 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
265 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, len
, value
, &len
);
266 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
267 todo_wine_if(test
->todo
)
268 ok(lstrcmpW(value
, extensionsW
) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value
));
269 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
270 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
272 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 1, value
, &len
);
273 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetFileExtensions failed, hr=%x\n", hr
);
274 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
275 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
277 hr
= IWICBitmapDecoderInfo_GetFileExtensions(decoder_info
, 256, value
, &len
);
278 ok(hr
== S_OK
, "GetFileExtensions failed, hr=%x\n", hr
);
279 todo_wine_if(test
->todo
)
280 ok(lstrcmpW(value
, extensionsW
) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value
));
281 todo_wine_if(test
->todo
&& !IsEqualCLSID(test
->clsid
, &CLSID_WICTiffDecoder
))
282 ok(len
== lstrlenW(extensionsW
) + 1, "GetFileExtensions returned wrong len %i\n", len
);
284 IWICBitmapDecoderInfo_Release(decoder_info
);
285 IWICComponentInfo_Release(info
);
289 static void test_pixelformat_info(void)
291 IWICComponentInfo
*info
;
292 IWICPixelFormatInfo
*pixelformat_info
;
293 IWICPixelFormatInfo2
*pixelformat_info2
;
295 ULONG len
, known_len
;
298 WICComponentType componenttype
;
299 WICPixelFormatNumericRepresentation numericrepresentation
;
303 BOOL supportstransparency
;
305 hr
= get_component_info(&GUID_WICPixelFormat32bppBGRA
, &info
);
306 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
311 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, 0);
312 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
315 hr
= IWICComponentInfo_GetAuthor(info
, 0, NULL
, &len
);
316 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
317 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
320 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
321 hr
= IWICComponentInfo_GetAuthor(info
, len
-1, value
, NULL
);
322 ok(hr
== E_INVALIDARG
, "GetAuthor failed, hr=%x\n", hr
);
323 ok(value
[0] == 0xaaaa, "string modified\n");
326 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
327 hr
= IWICComponentInfo_GetAuthor(info
, known_len
-1, value
, &len
);
328 ok(hr
== WINCODEC_ERR_INSUFFICIENTBUFFER
, "GetAuthor failed, hr=%x\n", hr
);
329 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
330 ok(value
[known_len
-1] == 0xaaaa, "string modified past given length\n");
331 ok(value
[0] == 0xaaaa, "string modified\n");
334 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
335 hr
= IWICComponentInfo_GetAuthor(info
, known_len
, value
, &len
);
336 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
337 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
338 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
339 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
342 memset(value
, 0xaa, 256 * sizeof(WCHAR
));
343 hr
= IWICComponentInfo_GetAuthor(info
, known_len
+1, value
, &len
);
344 ok(hr
== S_OK
, "GetAuthor failed, hr=%x\n", hr
);
345 ok(len
== known_len
, "got length of 0x%x, expected 0x%x\n", len
, known_len
);
346 ok(value
[known_len
] == 0xaaaa, "string modified past end\n");
347 ok(value
[known_len
-1] == 0, "string not terminated at expected length\n");
348 ok(value
[known_len
-2] != 0xaaaa, "string not modified at given length\n");
350 hr
= IWICComponentInfo_GetCLSID(info
, NULL
);
351 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
353 memset(&guid
, 0xaa, sizeof(guid
));
354 hr
= IWICComponentInfo_GetCLSID(info
, &guid
);
355 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
356 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected CLSID %s\n", wine_dbgstr_guid(&guid
));
358 hr
= IWICComponentInfo_GetComponentType(info
, NULL
);
359 ok(hr
== E_INVALIDARG
, "GetComponentType failed, hr=%x\n", hr
);
361 hr
= IWICComponentInfo_GetComponentType(info
, &componenttype
);
362 ok(hr
== S_OK
, "GetComponentType failed, hr=%x\n", hr
);
363 ok(componenttype
== WICPixelFormat
, "unexpected component type 0x%x\n", componenttype
);
366 hr
= IWICComponentInfo_GetFriendlyName(info
, 0, NULL
, &len
);
367 ok(hr
== S_OK
, "GetFriendlyName failed, hr=%x\n", hr
);
368 ok(len
< 255 && len
> 0, "invalid length 0x%x\n", len
);
370 hr
= IWICComponentInfo_GetSigningStatus(info
, NULL
);
371 ok(hr
== E_INVALIDARG
, "GetSigningStatus failed, hr=%x\n", hr
);
373 hr
= IWICComponentInfo_GetSigningStatus(info
, &signing
);
374 ok(hr
== S_OK
, "GetSigningStatus failed, hr=%x\n", hr
);
375 ok(signing
== WICComponentSigned
, "unexpected signing status 0x%x\n", signing
);
378 hr
= IWICComponentInfo_GetSpecVersion(info
, 0, NULL
, &len
);
379 ok(hr
== S_OK
, "GetSpecVersion failed, hr=%x\n", hr
);
380 ok(len
== 0, "invalid length 0x%x\n", len
); /* spec version does not apply to pixel formats */
382 memset(&guid
, 0xaa, sizeof(guid
));
383 hr
= IWICComponentInfo_GetVendorGUID(info
, &guid
);
384 ok(hr
== S_OK
, "GetVendorGUID failed, hr=%x\n", hr
);
385 ok(IsEqualGUID(&guid
, &GUID_VendorMicrosoft
) ||
386 broken(IsEqualGUID(&guid
, &GUID_NULL
)) /* XP */, "unexpected GUID %s\n", wine_dbgstr_guid(&guid
));
389 hr
= IWICComponentInfo_GetVersion(info
, 0, NULL
, &len
);
390 ok(hr
== S_OK
, "GetVersion failed, hr=%x\n", hr
);
391 ok(len
== 0, "invalid length 0x%x\n", len
); /* version does not apply to pixel formats */
393 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo
, (void**)&pixelformat_info
);
394 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
398 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, NULL
);
399 ok(hr
== E_INVALIDARG
, "GetBitsPerPixel failed, hr=%x\n", hr
);
401 hr
= IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info
, &uiresult
);
402 ok(hr
== S_OK
, "GetBitsPerPixel failed, hr=%x\n", hr
);
403 ok(uiresult
== 32, "unexpected bpp %i\n", uiresult
);
405 hr
= IWICPixelFormatInfo_GetChannelCount(pixelformat_info
, &uiresult
);
406 ok(hr
== S_OK
, "GetChannelCount failed, hr=%x\n", hr
);
407 ok(uiresult
== 4, "unexpected channel count %i\n", uiresult
);
409 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, NULL
);
410 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
412 uiresult
= 0xdeadbeef;
413 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 0, NULL
, &uiresult
);
414 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
415 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
417 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
418 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, known_len
, abbuffer
, NULL
);
419 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
420 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
422 uiresult
= 0xdeadbeef;
423 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
424 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 3, abbuffer
, &uiresult
);
425 ok(hr
== E_INVALIDARG
, "GetChannelMask failed, hr=%x\n", hr
);
426 ok(abbuffer
[0] == 0xaa, "buffer modified\n");
427 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
429 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
430 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 4, 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(uiresult
== 4, "unexpected length %i\n", uiresult
);
435 memset(abbuffer
, 0xaa, sizeof(abbuffer
));
436 hr
= IWICPixelFormatInfo_GetChannelMask(pixelformat_info
, 0, 5, abbuffer
, &uiresult
);
437 ok(hr
== S_OK
, "GetChannelMask failed, hr=%x\n", hr
);
438 ok(*((ULONG
*)abbuffer
) == 0xff, "unexpected mask 0x%x\n", *((ULONG
*)abbuffer
));
439 ok(abbuffer
[4] == 0xaa, "buffer modified past actual length\n");
440 ok(uiresult
== 4, "unexpected length %i\n", uiresult
);
442 memset(&guid
, 0xaa, sizeof(guid
));
443 hr
= IWICPixelFormatInfo_GetFormatGUID(pixelformat_info
, &guid
);
444 ok(hr
== S_OK
, "GetFormatGUID failed, hr=%x\n", hr
);
445 ok(IsEqualGUID(&guid
, &GUID_WICPixelFormat32bppBGRA
), "unexpected GUID %s\n", wine_dbgstr_guid(&guid
));
447 IWICPixelFormatInfo_Release(pixelformat_info
);
450 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICPixelFormatInfo2
, (void**)&pixelformat_info2
);
453 win_skip("IWICPixelFormatInfo2 not supported\n");
456 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, NULL
);
457 ok(hr
== E_INVALIDARG
, "GetNumericRepresentation failed, hr=%x\n", hr
);
459 numericrepresentation
= 0xdeadbeef;
460 hr
= IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2
, &numericrepresentation
);
461 ok(hr
== S_OK
, "GetNumericRepresentation failed, hr=%x\n", hr
);
462 ok(numericrepresentation
== WICPixelFormatNumericRepresentationUnsignedInteger
, "unexpected numeric representation %i\n", numericrepresentation
);
464 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, NULL
);
465 ok(hr
== E_INVALIDARG
, "SupportsTransparency failed, hr=%x\n", hr
);
467 supportstransparency
= 0xdeadbeef;
468 hr
= IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2
, &supportstransparency
);
469 ok(hr
== S_OK
, "SupportsTransparency failed, hr=%x\n", hr
);
470 ok(supportstransparency
== 1, "unexpected value %i\n", supportstransparency
);
472 IWICPixelFormatInfo2_Release(pixelformat_info2
);
475 IWICComponentInfo_Release(info
);
478 static DWORD WINAPI
cache_across_threads_test(void *arg
)
480 IWICComponentInfo
*info
;
485 hr
= get_component_info(&CLSID_WICUnknownMetadataReader
, &info
);
486 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
487 ok(info
== arg
, "unexpected info pointer %p\n", info
);
488 IWICComponentInfo_Release(info
);
494 static void test_reader_info(void)
496 IWICImagingFactory
*factory
;
497 IWICComponentInfo
*info
, *info2
;
498 IWICMetadataReaderInfo
*reader_info
;
501 GUID container_formats
[10];
502 UINT count
, size
, tid
;
504 WICMetadataPattern
*patterns
;
506 hr
= get_component_info(&CLSID_WICUnknownMetadataReader
, &info2
);
507 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
508 IWICComponentInfo_Release(info2
);
510 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
511 &IID_IWICImagingFactory
, (void**)&factory
);
512 ok(hr
== S_OK
, "CoCreateInstance failed, hr=%x\n", hr
);
513 if (FAILED(hr
)) return;
515 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICUnknownMetadataReader
, &info
);
516 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
517 ok(info
== info2
, "info != info2\n");
519 thread
= CreateThread(NULL
, 0, cache_across_threads_test
, info
, 0, &tid
);
520 WaitForSingleObject(thread
, INFINITE
);
523 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
524 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
526 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
527 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
529 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
530 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
531 ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
533 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
534 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
535 ok(IsEqualGUID(&GUID_MetadataFormatUnknown
, &clsid
), "GetMetadataFormat returned wrong result\n");
537 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
538 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
541 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
542 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
543 ok(count
== 0, "unexpected count %d\n", count
);
545 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
546 0, NULL
, NULL
, NULL
);
547 ok(hr
== E_INVALIDARG
, "GetPatterns failed, hr=%x\n", hr
);
549 count
= size
= 0xdeadbeef;
550 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
551 0, NULL
, &count
, &size
);
552 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
553 "GetPatterns failed, hr=%x\n", hr
);
554 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
555 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
557 IWICMetadataReaderInfo_Release(reader_info
);
559 IWICComponentInfo_Release(info
);
561 hr
= IWICImagingFactory_CreateComponentInfo(factory
, &CLSID_WICXMPStructMetadataReader
, &info
);
563 ok(hr
== S_OK
, "CreateComponentInfo failed, hr=%x\n", hr
);
567 IWICImagingFactory_Release(factory
);
571 hr
= IWICComponentInfo_QueryInterface(info
, &IID_IWICMetadataReaderInfo
, (void**)&reader_info
);
572 ok(hr
== S_OK
, "QueryInterface failed, hr=%x\n", hr
);
574 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, NULL
);
575 ok(hr
== E_INVALIDARG
, "GetCLSID failed, hr=%x\n", hr
);
577 hr
= IWICMetadataReaderInfo_GetCLSID(reader_info
, &clsid
);
578 ok(hr
== S_OK
, "GetCLSID failed, hr=%x\n", hr
);
579 ok(IsEqualGUID(&CLSID_WICXMPStructMetadataReader
, &clsid
), "GetCLSID returned wrong result\n");
581 hr
= IWICMetadataReaderInfo_GetMetadataFormat(reader_info
, &clsid
);
582 ok(hr
== S_OK
, "GetMetadataFormat failed, hr=%x\n", hr
);
583 ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct
, &clsid
), "GetMetadataFormat returned wrong result\n");
585 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, NULL
);
586 ok(hr
== E_INVALIDARG
, "GetContainerFormats failed, hr=%x\n", hr
);
589 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 0, NULL
, &count
);
590 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
591 ok(count
>= 2, "unexpected count %d\n", count
);
594 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 1, container_formats
, &count
);
595 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
596 ok(count
== 1, "unexpected count %d\n", count
);
599 hr
= IWICMetadataReaderInfo_GetContainerFormats(reader_info
, 10, container_formats
, &count
);
600 ok(hr
== S_OK
, "GetContainerFormats failed, hr=%x\n", hr
);
601 ok(count
== min(count
, 10), "unexpected count %d\n", count
);
603 count
= size
= 0xdeadbeef;
604 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_ContainerFormatPng
,
605 0, NULL
, &count
, &size
);
606 ok(hr
== WINCODEC_ERR_COMPONENTNOTFOUND
|| broken(hr
== S_OK
) /* Windows XP */,
607 "GetPatterns failed, hr=%x\n", hr
);
608 ok(count
== 0xdeadbeef, "unexpected count %d\n", count
);
609 ok(size
== 0xdeadbeef, "unexpected size %d\n", size
);
611 count
= size
= 0xdeadbeef;
612 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
613 0, NULL
, &count
, &size
);
614 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
615 ok(count
== 1, "unexpected count %d\n", count
);
616 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
620 patterns
= HeapAlloc(GetProcessHeap(), 0, size
);
622 count
= size
= 0xdeadbeef;
623 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
624 size
-1, patterns
, &count
, &size
);
625 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
626 ok(count
== 1, "unexpected count %d\n", count
);
627 ok(size
> sizeof(WICMetadataPattern
), "unexpected size %d\n", size
);
629 count
= size
= 0xdeadbeef;
630 hr
= IWICMetadataReaderInfo_GetPatterns(reader_info
, &GUID_MetadataFormatXMP
,
631 size
, patterns
, &count
, &size
);
632 ok(hr
== S_OK
, "GetPatterns failed, hr=%x\n", hr
);
633 ok(count
== 1, "unexpected count %d\n", count
);
634 ok(size
== sizeof(WICMetadataPattern
) + patterns
->Length
* 2, "unexpected size %d\n", size
);
636 HeapFree(GetProcessHeap(), 0, patterns
);
639 IWICMetadataReaderInfo_Release(reader_info
);
641 IWICComponentInfo_Release(info
);
643 IWICImagingFactory_Release(factory
);
646 static void test_imagingfactory_interfaces(void)
648 IWICComponentFactory
*component_factory
;
649 IWICImagingFactory2
*factory2
;
650 IWICImagingFactory
*factory
;
653 hr
= CoCreateInstance(&CLSID_WICImagingFactory
, NULL
, CLSCTX_INPROC_SERVER
,
654 &IID_IWICImagingFactory2
, (void **)&factory2
);
657 win_skip("IWICImagingFactory2 is not supported.\n");
661 hr
= IWICImagingFactory2_QueryInterface(factory2
, &IID_IWICComponentFactory
, (void **)&component_factory
);
662 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
664 hr
= IWICComponentFactory_QueryInterface(component_factory
, &IID_IWICImagingFactory
, (void **)&factory
);
665 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
666 ok(factory
== (IWICImagingFactory
*)component_factory
, "Unexpected factory pointer.\n");
667 IWICImagingFactory_Release(factory
);
669 hr
= IWICImagingFactory2_QueryInterface(factory2
, &IID_IWICImagingFactory
, (void **)&factory
);
670 ok(hr
== S_OK
, "Unexpected hr %#x.\n", hr
);
671 ok(factory
== (IWICImagingFactory
*)component_factory
, "Unexpected factory pointer.\n");
673 IWICComponentFactory_Release(component_factory
);
674 IWICImagingFactory2_Release(factory2
);
675 IWICImagingFactory_Release(factory
);
680 CoInitializeEx(NULL
, COINIT_APARTMENTTHREADED
);
684 test_pixelformat_info();
685 test_imagingfactory_interfaces();