ReactOS 0.4.16-dev-91-g764881a
info.c
Go to the documentation of this file.
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 COBJMACROS
24
25#include "windef.h"
26#include "objbase.h"
27#include "wincodec.h"
28#include "wincodecsdk.h"
29#include "wine/test.h"
30
31#include "initguid.h"
32DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
33
35{
37 HRESULT hr;
38
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;
43
44 hr = IWICImagingFactory_CreateComponentInfo(factory, clsid, result);
45
46 IWICImagingFactory_Release(factory);
47
48 return hr;
49}
50
52{
54 HRESULT hr;
55 WICComponentType componenttype;
56
58 if (FAILED(hr))
59 return FALSE;
60
61 hr = IWICComponentInfo_GetComponentType(info, &componenttype);
62
63 IWICComponentInfo_Release(info);
64
65 return SUCCEEDED(hr) && componenttype == WICPixelFormat;
66}
67
68static void test_decoder_info(void)
69{
70 struct decoder_info_test
71 {
72 const CLSID *clsid;
73 const char *mimetype;
74 const char *extensions;
75 unsigned int todo;
76 } decoder_info_tests[] =
77 {
78 {
79 &CLSID_WICBmpDecoder,
80 "image/bmp",
81 ".bmp,.dib,.rle"
82 },
83 {
84 &CLSID_WICGifDecoder,
85 "image/gif",
86 ".gif"
87 },
88 {
89 &CLSID_WICIcoDecoder,
90 "image/ico,image/x-icon",
91 ".ico,.icon",
92 1
93 },
94 {
95 &CLSID_WICJpegDecoder,
96 "image/jpeg,image/jpe,image/jpg",
97 ".jpeg,.jpe,.jpg,.jfif,.exif",
98 1
99 },
100 {
101 &CLSID_WICPngDecoder,
102 "image/png",
103 ".png"
104 },
105 {
106 &CLSID_WICTiffDecoder,
107 "image/tiff,image/tif",
108 ".tiff,.tif",
109 1
110 },
111 };
112 IWICBitmapDecoderInfo *decoder_info, *decoder_info2;
114 HRESULT hr;
115 ULONG len;
116 WCHAR value[256];
117 CLSID clsid;
118 GUID pixelformats[32];
119 UINT num_formats, count;
120 int i, j;
121
122 for (i = 0; i < ARRAY_SIZE(decoder_info_tests); i++)
123 {
124 struct decoder_info_test *test = &decoder_info_tests[i];
125 IWICBitmapDecoder *decoder, *decoder2;
126 WCHAR extensionsW[64];
127 WCHAR mimetypeW[64];
128
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);
131
132 decoder_info = NULL;
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);
136
137 if (hr == S_OK)
138 {
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");
143
144 hr = IWICBitmapDecoderInfo_QueryInterface(decoder_info, &IID_IWICBitmapDecoder, (void **)&decoder2);
145 ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
146
147 IWICBitmapDecoderInfo_Release(decoder_info);
148 IWICBitmapDecoderInfo_Release(decoder_info2);
149 }
150 IWICBitmapDecoder_Release(decoder);
151
152 MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, ARRAY_SIZE(mimetypeW));
153 MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, ARRAY_SIZE(extensionsW));
154
155 hr = get_component_info(test->clsid, &info);
156 ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
157
158 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICBitmapDecoderInfo, (void **)&decoder_info);
159 ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
160
161 hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, NULL);
162 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
163
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");
167
168 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, NULL);
169 ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
170
171 len = 0;
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);
176
177 hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, NULL);
178 ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
179
180 len = 0;
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);
185
186 value[0] = 0;
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);
192 }
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);
197
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);
203 }
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);
210
211 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, NULL, NULL);
212 ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
213
214 count = 0xdeadbeef;
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);
218
219 count = 0xdeadbeef;
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");
225
226 count = 0xdeadbeef;
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");
232
233 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, num_formats, pixelformats, NULL);
234 ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
235
236 count = 0xdeadbeef;
237 hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, ARRAY_SIZE(pixelformats),
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);
241
242 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 0, NULL, NULL);
243 ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%x\n", hr);
244
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);
249
250 hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, len, value, NULL);
251 ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%x\n", hr);
252
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);
257
258 value[0] = 0;
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);
265
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);
270
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);
277
278 IWICBitmapDecoderInfo_Release(decoder_info);
279 IWICComponentInfo_Release(info);
280 }
281}
282
283static void test_pixelformat_info(void)
284{
286 IWICPixelFormatInfo *pixelformat_info;
287 IWICPixelFormatInfo2 *pixelformat_info2;
288 HRESULT hr;
289 ULONG len, known_len;
290 WCHAR value[256];
291 GUID guid;
292 WICComponentType componenttype;
293 WICPixelFormatNumericRepresentation numericrepresentation;
294 DWORD signing;
295 UINT uiresult;
296 BYTE abbuffer[256];
297 BOOL supportstransparency;
298
299 hr = get_component_info(&GUID_WICPixelFormat32bppBGRA, &info);
300 ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
301
302 if (FAILED(hr))
303 return;
304
305 hr = IWICComponentInfo_GetAuthor(info, 0, NULL, 0);
306 ok(hr == E_INVALIDARG, "GetAuthor failed, hr=%x\n", hr);
307
308 len = 0xdeadbeef;
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);
312 known_len = len;
313
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");
318
319 len = 0xdeadbeef;
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");
326
327 len = 0xdeadbeef;
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");
334
335 len = 0xdeadbeef;
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");
343
344 hr = IWICComponentInfo_GetCLSID(info, NULL);
345 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
346
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));
351
352 hr = IWICComponentInfo_GetComponentType(info, NULL);
353 ok(hr == E_INVALIDARG, "GetComponentType failed, hr=%x\n", hr);
354
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);
358
359 len = 0xdeadbeef;
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);
363
364 hr = IWICComponentInfo_GetSigningStatus(info, NULL);
365 ok(hr == E_INVALIDARG, "GetSigningStatus failed, hr=%x\n", hr);
366
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);
370
371 len = 0xdeadbeef;
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 */
375
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));
381
382 len = 0xdeadbeef;
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 */
386
387 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void**)&pixelformat_info);
388 ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
389
390 if (SUCCEEDED(hr))
391 {
392 hr = IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info, NULL);
393 ok(hr == E_INVALIDARG, "GetBitsPerPixel failed, hr=%x\n", hr);
394
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);
398
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);
402
403 hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 0, NULL, NULL);
404 ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%x\n", hr);
405
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);
410
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");
415
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);
422
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);
428
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);
435
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));
440
441 IWICPixelFormatInfo_Release(pixelformat_info);
442 }
443
444 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void**)&pixelformat_info2);
445
446 if (FAILED(hr))
447 win_skip("IWICPixelFormatInfo2 not supported\n");
448 else
449 {
450 hr = IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2, NULL);
451 ok(hr == E_INVALIDARG, "GetNumericRepresentation failed, hr=%x\n", hr);
452
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);
457
458 hr = IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2, NULL);
459 ok(hr == E_INVALIDARG, "SupportsTransparency failed, hr=%x\n", hr);
460
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);
465
466 IWICPixelFormatInfo2_Release(pixelformat_info2);
467 }
468
469 IWICComponentInfo_Release(info);
470}
471
473{
475 HRESULT hr;
476
478
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);
483
485 return 0;
486}
487
488static void test_reader_info(void)
489{
491 IWICComponentInfo *info, *info2;
492 IWICMetadataReaderInfo *reader_info;
493 HRESULT hr;
494 CLSID clsid;
495 GUID container_formats[10];
496 UINT count, size, tid;
498 WICMetadataPattern *patterns;
499
500 hr = get_component_info(&CLSID_WICUnknownMetadataReader, &info2);
501 ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
502 IWICComponentInfo_Release(info2);
503
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;
508
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");
512
516
517 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
518 ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
519
520 hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
521 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
522
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");
526
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");
530
531 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
532 ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
533
534 count = 0xdeadbeef;
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);
538
539 hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
540 0, NULL, NULL, NULL);
541 ok(hr == E_INVALIDARG, "GetPatterns failed, hr=%x\n", hr);
542
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);
550
551 IWICMetadataReaderInfo_Release(reader_info);
552
553 IWICComponentInfo_Release(info);
554
555 hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICXMPStructMetadataReader, &info);
557 ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
558
559 if (FAILED(hr))
560 {
561 IWICImagingFactory_Release(factory);
562 return;
563 }
564
565 hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
566 ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
567
568 hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
569 ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
570
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");
574
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");
578
579 hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
580 ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
581
582 count = 0xdeadbeef;
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);
586
587 count = 0xdeadbeef;
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);
591
592 count = 0xdeadbeef;
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);
596
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);
604
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);
611
612 if (hr == S_OK)
613 {
614 patterns = HeapAlloc(GetProcessHeap(), 0, size);
615
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);
622
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);
629
630 HeapFree(GetProcessHeap(), 0, patterns);
631 }
632
633 IWICMetadataReaderInfo_Release(reader_info);
634
635 IWICComponentInfo_Release(info);
636
637 IWICImagingFactory_Release(factory);
638}
639
641{
642 IWICComponentFactory *component_factory;
643 IWICImagingFactory2 *factory2;
645 HRESULT hr;
646
647 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
648 &IID_IWICImagingFactory2, (void **)&factory2);
649 if (FAILED(hr))
650 {
651 win_skip("IWICImagingFactory2 is not supported.\n");
652 return;
653 }
654
655 hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICComponentFactory, (void **)&component_factory);
656 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
657
658 hr = IWICComponentFactory_QueryInterface(component_factory, &IID_IWICImagingFactory, (void **)&factory);
659 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
660 ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
661 IWICImagingFactory_Release(factory);
662
663 hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICImagingFactory, (void **)&factory);
664 ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
665 ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
666
667 IWICComponentFactory_Release(component_factory);
668 IWICImagingFactory2_Release(factory2);
669 IWICImagingFactory_Release(factory);
670}
671
673{
675
680
682}
#define ok(value,...)
Definition: atltest.h:57
#define broken(x)
Definition: atltest.h:178
#define START_TEST(x)
Definition: atltest.h:75
#define ARRAY_SIZE(A)
Definition: main.h:20
static HANDLE thread
Definition: service.c:33
DDPIXELFORMAT pixelformats[]
#define E_INVALIDARG
Definition: ddrawi.h:101
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define CloseHandle
Definition: compat.h:739
#define GetProcessHeap()
Definition: compat.h:736
#define CP_ACP
Definition: compat.h:109
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define MultiByteToWideChar
Definition: compat.h:110
#define lstrlenW
Definition: compat.h:750
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4242
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
HRESULT WINAPI CoInitialize(LPVOID lpReserved)
Definition: compobj.c:1964
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
#define INFINITE
Definition: serial.h:102
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLenum GLsizei len
Definition: glext.h:6722
GLuint64EXT * result
Definition: glext.h:11304
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
#define S_OK
Definition: intsafe.h:52
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
#define wine_dbgstr_w
Definition: kernel32.h:34
#define GUID_NULL
Definition: ks.h:106
const GUID * guid
BOOL todo
Definition: filedlg.c:313
static TfClientId tid
#define todo_wine_if(is_todo)
Definition: custom.c:86
#define todo_wine
Definition: custom.c:89
static void test_imagingfactory_interfaces(void)
Definition: info.c:640
static DWORD WINAPI cache_across_threads_test(void *arg)
Definition: info.c:472
static void test_decoder_info(void)
Definition: info.c:68
static void test_pixelformat_info(void)
Definition: info.c:283
static HRESULT get_component_info(const GUID *clsid, IWICComponentInfo **result)
Definition: info.c:34
static BOOL is_pixelformat(GUID *format)
Definition: info.c:51
static void test_reader_info(void)
Definition: info.c:488
#define min(a, b)
Definition: monoChain.cc:55
REFCLSID clsid
Definition: msctf.c:82
unsigned int UINT
Definition: ndis.h:50
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278
#define DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8)
Definition: guiddef.h:68
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define IsEqualCLSID(rclsid1, rclsid2)
Definition: guiddef.h:96
#define test
Definition: rosglue.h:37
static __inline const char * wine_dbgstr_guid(const GUID *id)
Definition: debug.h:197
#define win_skip
Definition: test.h:163
#define memset(x, y, z)
Definition: compat.h:39
HRESULT hr
Definition: shlfolder.c:183
Definition: main.c:439
Definition: format.c:58
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
uint32_t ULONG
Definition: typedefs.h:59
Definition: pdh_main.c:94
@ WICComponentSigned
Definition: wincodec.idl:135
WICPixelFormatNumericRepresentation
Definition: wincodec.idl:157
@ WICPixelFormatNumericRepresentationUnsignedInteger
Definition: wincodec.idl:160
WICComponentType
Definition: wincodec.idl:124
@ WICPixelFormat
Definition: wincodec.idl:130
#define WINAPI
Definition: msvc.h:6
#define WINCODEC_ERR_COMPONENTNOTFOUND
Definition: winerror.h:3296
#define E_NOINTERFACE
Definition: winerror.h:2364
#define WINCODEC_ERR_INSUFFICIENTBUFFER
Definition: winerror.h:3311
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193