1c2c66affSColin Finck /*
2c2c66affSColin Finck * Copyright 2009 Vincent Povirk for CodeWeavers
3c2c66affSColin Finck *
4c2c66affSColin Finck * This library is free software; you can redistribute it and/or
5c2c66affSColin Finck * modify it under the terms of the GNU Lesser General Public
6c2c66affSColin Finck * License as published by the Free Software Foundation; either
7c2c66affSColin Finck * version 2.1 of the License, or (at your option) any later version.
8c2c66affSColin Finck *
9c2c66affSColin Finck * This library is distributed in the hope that it will be useful,
10c2c66affSColin Finck * but WITHOUT ANY WARRANTY; without even the implied warranty of
11c2c66affSColin Finck * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12c2c66affSColin Finck * Lesser General Public License for more details.
13c2c66affSColin Finck *
14c2c66affSColin Finck * You should have received a copy of the GNU Lesser General Public
15c2c66affSColin Finck * License along with this library; if not, write to the Free Software
16c2c66affSColin Finck * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17c2c66affSColin Finck */
18c2c66affSColin Finck
1923ec1e5eSAmine Khaldi #include <stdio.h>
2023ec1e5eSAmine Khaldi #include <stdarg.h>
2123ec1e5eSAmine Khaldi #include <math.h>
22c2c66affSColin Finck
2323ec1e5eSAmine Khaldi #define COBJMACROS
2423ec1e5eSAmine Khaldi
2523ec1e5eSAmine Khaldi #include "windef.h"
2623ec1e5eSAmine Khaldi #include "objbase.h"
2723ec1e5eSAmine Khaldi #include "wincodec.h"
2823ec1e5eSAmine Khaldi #include "wincodecsdk.h"
2923ec1e5eSAmine Khaldi #include "wine/test.h"
3023ec1e5eSAmine Khaldi
3123ec1e5eSAmine Khaldi #include "initguid.h"
32c2c66affSColin Finck DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
33c2c66affSColin Finck
get_component_info(const GUID * clsid,IWICComponentInfo ** result)34c2c66affSColin Finck static HRESULT get_component_info(const GUID *clsid, IWICComponentInfo **result)
35c2c66affSColin Finck {
36c2c66affSColin Finck IWICImagingFactory *factory;
37c2c66affSColin Finck HRESULT hr;
38c2c66affSColin Finck
39c2c66affSColin Finck hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
40c2c66affSColin Finck &IID_IWICImagingFactory, (void**)&factory);
41c2c66affSColin Finck ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
42c2c66affSColin Finck if (FAILED(hr)) return hr;
43c2c66affSColin Finck
44c2c66affSColin Finck hr = IWICImagingFactory_CreateComponentInfo(factory, clsid, result);
45c2c66affSColin Finck
46c2c66affSColin Finck IWICImagingFactory_Release(factory);
47c2c66affSColin Finck
48c2c66affSColin Finck return hr;
49c2c66affSColin Finck }
50c2c66affSColin Finck
is_pixelformat(GUID * format)51c2c66affSColin Finck static BOOL is_pixelformat(GUID *format)
52c2c66affSColin Finck {
53c2c66affSColin Finck IWICComponentInfo *info;
54c2c66affSColin Finck HRESULT hr;
55c2c66affSColin Finck WICComponentType componenttype;
56c2c66affSColin Finck
57c2c66affSColin Finck hr = get_component_info(format, &info);
58c2c66affSColin Finck if (FAILED(hr))
59c2c66affSColin Finck return FALSE;
60c2c66affSColin Finck
61c2c66affSColin Finck hr = IWICComponentInfo_GetComponentType(info, &componenttype);
62c2c66affSColin Finck
63c2c66affSColin Finck IWICComponentInfo_Release(info);
64c2c66affSColin Finck
65c2c66affSColin Finck return SUCCEEDED(hr) && componenttype == WICPixelFormat;
66c2c66affSColin Finck }
67c2c66affSColin Finck
test_decoder_info(void)68c2c66affSColin Finck static void test_decoder_info(void)
69c2c66affSColin Finck {
7023ec1e5eSAmine Khaldi struct decoder_info_test
7123ec1e5eSAmine Khaldi {
7223ec1e5eSAmine Khaldi const CLSID *clsid;
7323ec1e5eSAmine Khaldi const char *mimetype;
7423ec1e5eSAmine Khaldi const char *extensions;
7523ec1e5eSAmine Khaldi unsigned int todo;
7623ec1e5eSAmine Khaldi } decoder_info_tests[] =
7723ec1e5eSAmine Khaldi {
7823ec1e5eSAmine Khaldi {
7923ec1e5eSAmine Khaldi &CLSID_WICBmpDecoder,
8023ec1e5eSAmine Khaldi "image/bmp",
8123ec1e5eSAmine Khaldi ".bmp,.dib,.rle"
8223ec1e5eSAmine Khaldi },
8323ec1e5eSAmine Khaldi {
8423ec1e5eSAmine Khaldi &CLSID_WICGifDecoder,
8523ec1e5eSAmine Khaldi "image/gif",
8623ec1e5eSAmine Khaldi ".gif"
8723ec1e5eSAmine Khaldi },
8823ec1e5eSAmine Khaldi {
8923ec1e5eSAmine Khaldi &CLSID_WICIcoDecoder,
9023ec1e5eSAmine Khaldi "image/ico,image/x-icon",
9123ec1e5eSAmine Khaldi ".ico,.icon",
9223ec1e5eSAmine Khaldi 1
9323ec1e5eSAmine Khaldi },
9423ec1e5eSAmine Khaldi {
9523ec1e5eSAmine Khaldi &CLSID_WICJpegDecoder,
9623ec1e5eSAmine Khaldi "image/jpeg,image/jpe,image/jpg",
9723ec1e5eSAmine Khaldi ".jpeg,.jpe,.jpg,.jfif,.exif",
9823ec1e5eSAmine Khaldi 1
9923ec1e5eSAmine Khaldi },
10023ec1e5eSAmine Khaldi {
10123ec1e5eSAmine Khaldi &CLSID_WICPngDecoder,
10223ec1e5eSAmine Khaldi "image/png",
10323ec1e5eSAmine Khaldi ".png"
10423ec1e5eSAmine Khaldi },
10523ec1e5eSAmine Khaldi {
10623ec1e5eSAmine Khaldi &CLSID_WICTiffDecoder,
10723ec1e5eSAmine Khaldi "image/tiff,image/tif",
10823ec1e5eSAmine Khaldi ".tiff,.tif",
10923ec1e5eSAmine Khaldi 1
11023ec1e5eSAmine Khaldi },
11123ec1e5eSAmine Khaldi };
11223ec1e5eSAmine Khaldi IWICBitmapDecoderInfo *decoder_info, *decoder_info2;
113c2c66affSColin Finck IWICComponentInfo *info;
114c2c66affSColin Finck HRESULT hr;
115c2c66affSColin Finck ULONG len;
116c2c66affSColin Finck WCHAR value[256];
117c2c66affSColin Finck CLSID clsid;
11823ec1e5eSAmine Khaldi GUID pixelformats[32];
119c2c66affSColin Finck UINT num_formats, count;
12023ec1e5eSAmine Khaldi int i, j;
121c2c66affSColin Finck
122*eea81f52SAmine Khaldi for (i = 0; i < ARRAY_SIZE(decoder_info_tests); i++)
12323ec1e5eSAmine Khaldi {
12423ec1e5eSAmine Khaldi struct decoder_info_test *test = &decoder_info_tests[i];
12523ec1e5eSAmine Khaldi IWICBitmapDecoder *decoder, *decoder2;
12623ec1e5eSAmine Khaldi WCHAR extensionsW[64];
12723ec1e5eSAmine Khaldi WCHAR mimetypeW[64];
12823ec1e5eSAmine Khaldi
12923ec1e5eSAmine Khaldi hr = CoCreateInstance(test->clsid, NULL, CLSCTX_INPROC_SERVER, &IID_IWICBitmapDecoder, (void **)&decoder);
13023ec1e5eSAmine Khaldi ok(SUCCEEDED(hr), "Failed to create decoder, hr %#x.\n", hr);
13123ec1e5eSAmine Khaldi
13223ec1e5eSAmine Khaldi decoder_info = NULL;
13323ec1e5eSAmine Khaldi hr = IWICBitmapDecoder_GetDecoderInfo(decoder, &decoder_info);
13423ec1e5eSAmine Khaldi ok(hr == S_OK || broken(IsEqualCLSID(&CLSID_WICBmpDecoder, test->clsid) && FAILED(hr)) /* Fails on Windows */,
13523ec1e5eSAmine Khaldi "%u: failed to get decoder info, hr %#x.\n", i, hr);
13623ec1e5eSAmine Khaldi
13723ec1e5eSAmine Khaldi if (hr == S_OK)
13823ec1e5eSAmine Khaldi {
13923ec1e5eSAmine Khaldi decoder_info2 = NULL;
14023ec1e5eSAmine Khaldi hr = IWICBitmapDecoder_GetDecoderInfo(decoder, &decoder_info2);
14123ec1e5eSAmine Khaldi ok(hr == S_OK, "Failed to get decoder info, hr %#x.\n", hr);
14223ec1e5eSAmine Khaldi ok(decoder_info == decoder_info2, "Unexpected decoder info instance.\n");
14323ec1e5eSAmine Khaldi
14423ec1e5eSAmine Khaldi hr = IWICBitmapDecoderInfo_QueryInterface(decoder_info, &IID_IWICBitmapDecoder, (void **)&decoder2);
14523ec1e5eSAmine Khaldi ok(hr == E_NOINTERFACE, "Unexpected hr %#x.\n", hr);
14623ec1e5eSAmine Khaldi
14723ec1e5eSAmine Khaldi IWICBitmapDecoderInfo_Release(decoder_info);
14823ec1e5eSAmine Khaldi IWICBitmapDecoderInfo_Release(decoder_info2);
14923ec1e5eSAmine Khaldi }
15023ec1e5eSAmine Khaldi IWICBitmapDecoder_Release(decoder);
15123ec1e5eSAmine Khaldi
152*eea81f52SAmine Khaldi MultiByteToWideChar(CP_ACP, 0, test->mimetype, -1, mimetypeW, ARRAY_SIZE(mimetypeW));
153*eea81f52SAmine Khaldi MultiByteToWideChar(CP_ACP, 0, test->extensions, -1, extensionsW, ARRAY_SIZE(extensionsW));
15423ec1e5eSAmine Khaldi
15523ec1e5eSAmine Khaldi hr = get_component_info(test->clsid, &info);
156c2c66affSColin Finck ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
157c2c66affSColin Finck
158c2c66affSColin Finck hr = IWICComponentInfo_QueryInterface(info, &IID_IWICBitmapDecoderInfo, (void **)&decoder_info);
159c2c66affSColin Finck ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
160c2c66affSColin Finck
161c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, NULL);
162c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
163c2c66affSColin Finck
164c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, &clsid);
165c2c66affSColin Finck ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
16623ec1e5eSAmine Khaldi ok(IsEqualGUID(test->clsid, &clsid), "GetCLSID returned wrong result\n");
167c2c66affSColin Finck
168c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, NULL);
169c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
170c2c66affSColin Finck
17123ec1e5eSAmine Khaldi len = 0;
172c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, NULL, &len);
173c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
17423ec1e5eSAmine Khaldi todo_wine_if(test->todo)
17523ec1e5eSAmine Khaldi ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
176c2c66affSColin Finck
177c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, NULL);
178c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
179c2c66affSColin Finck
18023ec1e5eSAmine Khaldi len = 0;
181c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, &len);
182c2c66affSColin Finck ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
18323ec1e5eSAmine Khaldi todo_wine_if(test->todo)
18423ec1e5eSAmine Khaldi ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
185c2c66affSColin Finck
186c2c66affSColin Finck value[0] = 0;
187c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, &len);
188c2c66affSColin Finck ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
18923ec1e5eSAmine Khaldi todo_wine_if(test->todo) {
19023ec1e5eSAmine Khaldi ok(lstrcmpW(value, mimetypeW) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
19123ec1e5eSAmine Khaldi ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
19223ec1e5eSAmine Khaldi }
193c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, value, &len);
194c2c66affSColin Finck ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetMimeType failed, hr=%x\n", hr);
19523ec1e5eSAmine Khaldi todo_wine_if(test->todo)
19623ec1e5eSAmine Khaldi ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
197c2c66affSColin Finck
198c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 256, value, &len);
199c2c66affSColin Finck ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
20023ec1e5eSAmine Khaldi todo_wine_if(test->todo) {
20123ec1e5eSAmine Khaldi ok(lstrcmpW(value, mimetypeW) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
20223ec1e5eSAmine Khaldi ok(len == lstrlenW(mimetypeW) + 1, "GetMimeType returned wrong len %i\n", len);
20323ec1e5eSAmine Khaldi }
204c2c66affSColin Finck num_formats = 0xdeadbeef;
205c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, NULL, &num_formats);
206c2c66affSColin Finck ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
20723ec1e5eSAmine Khaldi ok((num_formats <= 21 && num_formats >= 1) ||
20823ec1e5eSAmine Khaldi broken(IsEqualCLSID(test->clsid, &CLSID_WICIcoDecoder) && num_formats == 0) /* WinXP */,
20923ec1e5eSAmine Khaldi "%u: got %d formats\n", i, num_formats);
210c2c66affSColin Finck
211c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, NULL, NULL);
212c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
213c2c66affSColin Finck
214c2c66affSColin Finck count = 0xdeadbeef;
215c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 0, pixelformats, &count);
216c2c66affSColin Finck ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
217c2c66affSColin Finck ok(count == 0, "got %d formats\n", count);
218c2c66affSColin Finck
219c2c66affSColin Finck count = 0xdeadbeef;
220c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, 1, pixelformats, &count);
221c2c66affSColin Finck ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
22223ec1e5eSAmine Khaldi ok((count == 1) || broken(IsEqualCLSID(test->clsid, &CLSID_WICIcoDecoder) && count == 0) /* WinXP */,
22323ec1e5eSAmine Khaldi "%u: got %d formats\n", i, num_formats);
224c2c66affSColin Finck ok(is_pixelformat(&pixelformats[0]), "got invalid pixel format\n");
225c2c66affSColin Finck
226c2c66affSColin Finck count = 0xdeadbeef;
227c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, num_formats, pixelformats, &count);
228c2c66affSColin Finck ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
229c2c66affSColin Finck ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
23023ec1e5eSAmine Khaldi for (j = 0; j < num_formats; j++)
23123ec1e5eSAmine Khaldi ok(is_pixelformat(&pixelformats[j]), "got invalid pixel format\n");
232c2c66affSColin Finck
233c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, num_formats, pixelformats, NULL);
234c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetPixelFormats failed, hr=%x\n", hr);
235c2c66affSColin Finck
236c2c66affSColin Finck count = 0xdeadbeef;
237*eea81f52SAmine Khaldi hr = IWICBitmapDecoderInfo_GetPixelFormats(decoder_info, ARRAY_SIZE(pixelformats),
23823ec1e5eSAmine Khaldi pixelformats, &count);
239c2c66affSColin Finck ok(hr == S_OK, "GetPixelFormats failed, hr=%x\n", hr);
240c2c66affSColin Finck ok(count == num_formats, "got %d formats, expected %d\n", count, num_formats);
241c2c66affSColin Finck
242c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 0, NULL, NULL);
243c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%x\n", hr);
244c2c66affSColin Finck
245c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 1, NULL, &len);
246c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%x\n", hr);
24723ec1e5eSAmine Khaldi todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
24823ec1e5eSAmine Khaldi ok(len == lstrlenW(extensionsW) + 1, "%u: GetFileExtensions returned wrong len %i\n", i, len);
249c2c66affSColin Finck
250c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, len, value, NULL);
251c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetFileExtensions failed, hr=%x\n", hr);
252c2c66affSColin Finck
253c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 0, NULL, &len);
254c2c66affSColin Finck ok(hr == S_OK, "GetFileExtensions failed, hr=%x\n", hr);
25523ec1e5eSAmine Khaldi todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
25623ec1e5eSAmine Khaldi ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
257c2c66affSColin Finck
258c2c66affSColin Finck value[0] = 0;
259c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, len, value, &len);
260c2c66affSColin Finck ok(hr == S_OK, "GetFileExtensions failed, hr=%x\n", hr);
26123ec1e5eSAmine Khaldi todo_wine_if(test->todo)
26223ec1e5eSAmine Khaldi ok(lstrcmpW(value, extensionsW) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value));
26323ec1e5eSAmine Khaldi todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
26423ec1e5eSAmine Khaldi ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
265c2c66affSColin Finck
266c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 1, value, &len);
267c2c66affSColin Finck ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetFileExtensions failed, hr=%x\n", hr);
26823ec1e5eSAmine Khaldi todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
26923ec1e5eSAmine Khaldi ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
270c2c66affSColin Finck
271c2c66affSColin Finck hr = IWICBitmapDecoderInfo_GetFileExtensions(decoder_info, 256, value, &len);
272c2c66affSColin Finck ok(hr == S_OK, "GetFileExtensions failed, hr=%x\n", hr);
27323ec1e5eSAmine Khaldi todo_wine_if(test->todo)
27423ec1e5eSAmine Khaldi ok(lstrcmpW(value, extensionsW) == 0, "GetFileExtensions returned wrong value %s\n", wine_dbgstr_w(value));
27523ec1e5eSAmine Khaldi todo_wine_if(test->todo && !IsEqualCLSID(test->clsid, &CLSID_WICTiffDecoder))
27623ec1e5eSAmine Khaldi ok(len == lstrlenW(extensionsW) + 1, "GetFileExtensions returned wrong len %i\n", len);
277c2c66affSColin Finck
278c2c66affSColin Finck IWICBitmapDecoderInfo_Release(decoder_info);
279c2c66affSColin Finck IWICComponentInfo_Release(info);
280c2c66affSColin Finck }
28123ec1e5eSAmine Khaldi }
282c2c66affSColin Finck
test_pixelformat_info(void)283c2c66affSColin Finck static void test_pixelformat_info(void)
284c2c66affSColin Finck {
285c2c66affSColin Finck IWICComponentInfo *info;
286c2c66affSColin Finck IWICPixelFormatInfo *pixelformat_info;
287c2c66affSColin Finck IWICPixelFormatInfo2 *pixelformat_info2;
288c2c66affSColin Finck HRESULT hr;
289c2c66affSColin Finck ULONG len, known_len;
290c2c66affSColin Finck WCHAR value[256];
291c2c66affSColin Finck GUID guid;
292c2c66affSColin Finck WICComponentType componenttype;
293c2c66affSColin Finck WICPixelFormatNumericRepresentation numericrepresentation;
294c2c66affSColin Finck DWORD signing;
295c2c66affSColin Finck UINT uiresult;
296c2c66affSColin Finck BYTE abbuffer[256];
297c2c66affSColin Finck BOOL supportstransparency;
298c2c66affSColin Finck
299c2c66affSColin Finck hr = get_component_info(&GUID_WICPixelFormat32bppBGRA, &info);
300c2c66affSColin Finck ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
301c2c66affSColin Finck
302c2c66affSColin Finck if (FAILED(hr))
303c2c66affSColin Finck return;
304c2c66affSColin Finck
305c2c66affSColin Finck hr = IWICComponentInfo_GetAuthor(info, 0, NULL, 0);
306c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetAuthor failed, hr=%x\n", hr);
307c2c66affSColin Finck
308c2c66affSColin Finck len = 0xdeadbeef;
309c2c66affSColin Finck hr = IWICComponentInfo_GetAuthor(info, 0, NULL, &len);
310c2c66affSColin Finck ok(hr == S_OK, "GetAuthor failed, hr=%x\n", hr);
311c2c66affSColin Finck ok(len < 255 && len > 0, "invalid length 0x%x\n", len);
312c2c66affSColin Finck known_len = len;
313c2c66affSColin Finck
314c2c66affSColin Finck memset(value, 0xaa, 256 * sizeof(WCHAR));
315c2c66affSColin Finck hr = IWICComponentInfo_GetAuthor(info, len-1, value, NULL);
316c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetAuthor failed, hr=%x\n", hr);
317c2c66affSColin Finck ok(value[0] == 0xaaaa, "string modified\n");
318c2c66affSColin Finck
319c2c66affSColin Finck len = 0xdeadbeef;
320c2c66affSColin Finck memset(value, 0xaa, 256 * sizeof(WCHAR));
321c2c66affSColin Finck hr = IWICComponentInfo_GetAuthor(info, known_len-1, value, &len);
322c2c66affSColin Finck ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetAuthor failed, hr=%x\n", hr);
323c2c66affSColin Finck ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
324c2c66affSColin Finck ok(value[known_len-1] == 0xaaaa, "string modified past given length\n");
325c2c66affSColin Finck ok(value[0] == 0xaaaa, "string modified\n");
326c2c66affSColin Finck
327c2c66affSColin Finck len = 0xdeadbeef;
328c2c66affSColin Finck memset(value, 0xaa, 256 * sizeof(WCHAR));
329c2c66affSColin Finck hr = IWICComponentInfo_GetAuthor(info, known_len, value, &len);
330c2c66affSColin Finck ok(hr == S_OK, "GetAuthor failed, hr=%x\n", hr);
331c2c66affSColin Finck ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
332c2c66affSColin Finck ok(value[known_len-1] == 0, "string not terminated at expected length\n");
333c2c66affSColin Finck ok(value[known_len-2] != 0xaaaa, "string not modified at given length\n");
334c2c66affSColin Finck
335c2c66affSColin Finck len = 0xdeadbeef;
336c2c66affSColin Finck memset(value, 0xaa, 256 * sizeof(WCHAR));
337c2c66affSColin Finck hr = IWICComponentInfo_GetAuthor(info, known_len+1, value, &len);
338c2c66affSColin Finck ok(hr == S_OK, "GetAuthor failed, hr=%x\n", hr);
339c2c66affSColin Finck ok(len == known_len, "got length of 0x%x, expected 0x%x\n", len, known_len);
340c2c66affSColin Finck ok(value[known_len] == 0xaaaa, "string modified past end\n");
341c2c66affSColin Finck ok(value[known_len-1] == 0, "string not terminated at expected length\n");
342c2c66affSColin Finck ok(value[known_len-2] != 0xaaaa, "string not modified at given length\n");
343c2c66affSColin Finck
344c2c66affSColin Finck hr = IWICComponentInfo_GetCLSID(info, NULL);
345c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
346c2c66affSColin Finck
347c2c66affSColin Finck memset(&guid, 0xaa, sizeof(guid));
348c2c66affSColin Finck hr = IWICComponentInfo_GetCLSID(info, &guid);
349c2c66affSColin Finck ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
350c2c66affSColin Finck ok(IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA), "unexpected CLSID %s\n", wine_dbgstr_guid(&guid));
351c2c66affSColin Finck
352c2c66affSColin Finck hr = IWICComponentInfo_GetComponentType(info, NULL);
353c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetComponentType failed, hr=%x\n", hr);
354c2c66affSColin Finck
355c2c66affSColin Finck hr = IWICComponentInfo_GetComponentType(info, &componenttype);
356c2c66affSColin Finck ok(hr == S_OK, "GetComponentType failed, hr=%x\n", hr);
357c2c66affSColin Finck ok(componenttype == WICPixelFormat, "unexpected component type 0x%x\n", componenttype);
358c2c66affSColin Finck
359c2c66affSColin Finck len = 0xdeadbeef;
360c2c66affSColin Finck hr = IWICComponentInfo_GetFriendlyName(info, 0, NULL, &len);
361c2c66affSColin Finck ok(hr == S_OK, "GetFriendlyName failed, hr=%x\n", hr);
362c2c66affSColin Finck ok(len < 255 && len > 0, "invalid length 0x%x\n", len);
363c2c66affSColin Finck
364c2c66affSColin Finck hr = IWICComponentInfo_GetSigningStatus(info, NULL);
365c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetSigningStatus failed, hr=%x\n", hr);
366c2c66affSColin Finck
367c2c66affSColin Finck hr = IWICComponentInfo_GetSigningStatus(info, &signing);
368c2c66affSColin Finck ok(hr == S_OK, "GetSigningStatus failed, hr=%x\n", hr);
369c2c66affSColin Finck ok(signing == WICComponentSigned, "unexpected signing status 0x%x\n", signing);
370c2c66affSColin Finck
371c2c66affSColin Finck len = 0xdeadbeef;
372c2c66affSColin Finck hr = IWICComponentInfo_GetSpecVersion(info, 0, NULL, &len);
373c2c66affSColin Finck ok(hr == S_OK, "GetSpecVersion failed, hr=%x\n", hr);
374c2c66affSColin Finck ok(len == 0, "invalid length 0x%x\n", len); /* spec version does not apply to pixel formats */
375c2c66affSColin Finck
376c2c66affSColin Finck memset(&guid, 0xaa, sizeof(guid));
377c2c66affSColin Finck hr = IWICComponentInfo_GetVendorGUID(info, &guid);
378c2c66affSColin Finck ok(hr == S_OK, "GetVendorGUID failed, hr=%x\n", hr);
379c2c66affSColin Finck ok(IsEqualGUID(&guid, &GUID_VendorMicrosoft) ||
380c2c66affSColin Finck broken(IsEqualGUID(&guid, &GUID_NULL)) /* XP */, "unexpected GUID %s\n", wine_dbgstr_guid(&guid));
381c2c66affSColin Finck
382c2c66affSColin Finck len = 0xdeadbeef;
383c2c66affSColin Finck hr = IWICComponentInfo_GetVersion(info, 0, NULL, &len);
384c2c66affSColin Finck ok(hr == S_OK, "GetVersion failed, hr=%x\n", hr);
385c2c66affSColin Finck ok(len == 0, "invalid length 0x%x\n", len); /* version does not apply to pixel formats */
386c2c66affSColin Finck
387c2c66affSColin Finck hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo, (void**)&pixelformat_info);
388c2c66affSColin Finck ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
389c2c66affSColin Finck
390c2c66affSColin Finck if (SUCCEEDED(hr))
391c2c66affSColin Finck {
392c2c66affSColin Finck hr = IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info, NULL);
393c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetBitsPerPixel failed, hr=%x\n", hr);
394c2c66affSColin Finck
395c2c66affSColin Finck hr = IWICPixelFormatInfo_GetBitsPerPixel(pixelformat_info, &uiresult);
396c2c66affSColin Finck ok(hr == S_OK, "GetBitsPerPixel failed, hr=%x\n", hr);
397c2c66affSColin Finck ok(uiresult == 32, "unexpected bpp %i\n", uiresult);
398c2c66affSColin Finck
399c2c66affSColin Finck hr = IWICPixelFormatInfo_GetChannelCount(pixelformat_info, &uiresult);
400c2c66affSColin Finck ok(hr == S_OK, "GetChannelCount failed, hr=%x\n", hr);
401c2c66affSColin Finck ok(uiresult == 4, "unexpected channel count %i\n", uiresult);
402c2c66affSColin Finck
403c2c66affSColin Finck hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 0, NULL, NULL);
404c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%x\n", hr);
405c2c66affSColin Finck
406c2c66affSColin Finck uiresult = 0xdeadbeef;
407c2c66affSColin Finck hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 0, NULL, &uiresult);
408c2c66affSColin Finck ok(hr == S_OK, "GetChannelMask failed, hr=%x\n", hr);
409c2c66affSColin Finck ok(uiresult == 4, "unexpected length %i\n", uiresult);
410c2c66affSColin Finck
411c2c66affSColin Finck memset(abbuffer, 0xaa, sizeof(abbuffer));
412c2c66affSColin Finck hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, known_len, abbuffer, NULL);
413c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%x\n", hr);
414c2c66affSColin Finck ok(abbuffer[0] == 0xaa, "buffer modified\n");
415c2c66affSColin Finck
416c2c66affSColin Finck uiresult = 0xdeadbeef;
417c2c66affSColin Finck memset(abbuffer, 0xaa, sizeof(abbuffer));
418c2c66affSColin Finck hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 3, abbuffer, &uiresult);
419c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetChannelMask failed, hr=%x\n", hr);
420c2c66affSColin Finck ok(abbuffer[0] == 0xaa, "buffer modified\n");
421c2c66affSColin Finck ok(uiresult == 4, "unexpected length %i\n", uiresult);
422c2c66affSColin Finck
423c2c66affSColin Finck memset(abbuffer, 0xaa, sizeof(abbuffer));
424c2c66affSColin Finck hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 4, abbuffer, &uiresult);
425c2c66affSColin Finck ok(hr == S_OK, "GetChannelMask failed, hr=%x\n", hr);
426c2c66affSColin Finck ok(*((ULONG*)abbuffer) == 0xff, "unexpected mask 0x%x\n", *((ULONG*)abbuffer));
427c2c66affSColin Finck ok(uiresult == 4, "unexpected length %i\n", uiresult);
428c2c66affSColin Finck
429c2c66affSColin Finck memset(abbuffer, 0xaa, sizeof(abbuffer));
430c2c66affSColin Finck hr = IWICPixelFormatInfo_GetChannelMask(pixelformat_info, 0, 5, abbuffer, &uiresult);
431c2c66affSColin Finck ok(hr == S_OK, "GetChannelMask failed, hr=%x\n", hr);
432c2c66affSColin Finck ok(*((ULONG*)abbuffer) == 0xff, "unexpected mask 0x%x\n", *((ULONG*)abbuffer));
433c2c66affSColin Finck ok(abbuffer[4] == 0xaa, "buffer modified past actual length\n");
434c2c66affSColin Finck ok(uiresult == 4, "unexpected length %i\n", uiresult);
435c2c66affSColin Finck
436c2c66affSColin Finck memset(&guid, 0xaa, sizeof(guid));
437c2c66affSColin Finck hr = IWICPixelFormatInfo_GetFormatGUID(pixelformat_info, &guid);
438c2c66affSColin Finck ok(hr == S_OK, "GetFormatGUID failed, hr=%x\n", hr);
439c2c66affSColin Finck ok(IsEqualGUID(&guid, &GUID_WICPixelFormat32bppBGRA), "unexpected GUID %s\n", wine_dbgstr_guid(&guid));
440c2c66affSColin Finck
441c2c66affSColin Finck IWICPixelFormatInfo_Release(pixelformat_info);
442c2c66affSColin Finck }
443c2c66affSColin Finck
444c2c66affSColin Finck hr = IWICComponentInfo_QueryInterface(info, &IID_IWICPixelFormatInfo2, (void**)&pixelformat_info2);
445c2c66affSColin Finck
446c2c66affSColin Finck if (FAILED(hr))
447c2c66affSColin Finck win_skip("IWICPixelFormatInfo2 not supported\n");
448c2c66affSColin Finck else
449c2c66affSColin Finck {
450c2c66affSColin Finck hr = IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2, NULL);
451c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetNumericRepresentation failed, hr=%x\n", hr);
452c2c66affSColin Finck
453c2c66affSColin Finck numericrepresentation = 0xdeadbeef;
454c2c66affSColin Finck hr = IWICPixelFormatInfo2_GetNumericRepresentation(pixelformat_info2, &numericrepresentation);
455c2c66affSColin Finck ok(hr == S_OK, "GetNumericRepresentation failed, hr=%x\n", hr);
456c2c66affSColin Finck ok(numericrepresentation == WICPixelFormatNumericRepresentationUnsignedInteger, "unexpected numeric representation %i\n", numericrepresentation);
457c2c66affSColin Finck
458c2c66affSColin Finck hr = IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2, NULL);
459c2c66affSColin Finck ok(hr == E_INVALIDARG, "SupportsTransparency failed, hr=%x\n", hr);
460c2c66affSColin Finck
461c2c66affSColin Finck supportstransparency = 0xdeadbeef;
462c2c66affSColin Finck hr = IWICPixelFormatInfo2_SupportsTransparency(pixelformat_info2, &supportstransparency);
463c2c66affSColin Finck ok(hr == S_OK, "SupportsTransparency failed, hr=%x\n", hr);
464c2c66affSColin Finck ok(supportstransparency == 1, "unexpected value %i\n", supportstransparency);
465c2c66affSColin Finck
466c2c66affSColin Finck IWICPixelFormatInfo2_Release(pixelformat_info2);
467c2c66affSColin Finck }
468c2c66affSColin Finck
469c2c66affSColin Finck IWICComponentInfo_Release(info);
470c2c66affSColin Finck }
471c2c66affSColin Finck
cache_across_threads_test(void * arg)472da5f3d5aSAmine Khaldi static DWORD WINAPI cache_across_threads_test(void *arg)
473da5f3d5aSAmine Khaldi {
474da5f3d5aSAmine Khaldi IWICComponentInfo *info;
475da5f3d5aSAmine Khaldi HRESULT hr;
476da5f3d5aSAmine Khaldi
477da5f3d5aSAmine Khaldi CoInitialize(NULL);
478da5f3d5aSAmine Khaldi
479da5f3d5aSAmine Khaldi hr = get_component_info(&CLSID_WICUnknownMetadataReader, &info);
480da5f3d5aSAmine Khaldi ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
481da5f3d5aSAmine Khaldi ok(info == arg, "unexpected info pointer %p\n", info);
482da5f3d5aSAmine Khaldi IWICComponentInfo_Release(info);
483da5f3d5aSAmine Khaldi
484da5f3d5aSAmine Khaldi CoUninitialize();
485da5f3d5aSAmine Khaldi return 0;
486da5f3d5aSAmine Khaldi }
487da5f3d5aSAmine Khaldi
test_reader_info(void)488c2c66affSColin Finck static void test_reader_info(void)
489c2c66affSColin Finck {
490c2c66affSColin Finck IWICImagingFactory *factory;
491da5f3d5aSAmine Khaldi IWICComponentInfo *info, *info2;
492c2c66affSColin Finck IWICMetadataReaderInfo *reader_info;
493c2c66affSColin Finck HRESULT hr;
494c2c66affSColin Finck CLSID clsid;
495c2c66affSColin Finck GUID container_formats[10];
496da5f3d5aSAmine Khaldi UINT count, size, tid;
497da5f3d5aSAmine Khaldi HANDLE thread;
498c2c66affSColin Finck WICMetadataPattern *patterns;
499c2c66affSColin Finck
500da5f3d5aSAmine Khaldi hr = get_component_info(&CLSID_WICUnknownMetadataReader, &info2);
501da5f3d5aSAmine Khaldi ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
502da5f3d5aSAmine Khaldi IWICComponentInfo_Release(info2);
503da5f3d5aSAmine Khaldi
504c2c66affSColin Finck hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
505c2c66affSColin Finck &IID_IWICImagingFactory, (void**)&factory);
506c2c66affSColin Finck ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
507c2c66affSColin Finck if (FAILED(hr)) return;
508c2c66affSColin Finck
509c2c66affSColin Finck hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICUnknownMetadataReader, &info);
510c2c66affSColin Finck ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
511da5f3d5aSAmine Khaldi ok(info == info2, "info != info2\n");
512da5f3d5aSAmine Khaldi
513da5f3d5aSAmine Khaldi thread = CreateThread(NULL, 0, cache_across_threads_test, info, 0, &tid);
514da5f3d5aSAmine Khaldi WaitForSingleObject(thread, INFINITE);
515da5f3d5aSAmine Khaldi CloseHandle(thread);
516c2c66affSColin Finck
517c2c66affSColin Finck hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
518c2c66affSColin Finck ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
519c2c66affSColin Finck
520c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
521c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
522c2c66affSColin Finck
523c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
524c2c66affSColin Finck ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
525c2c66affSColin Finck ok(IsEqualGUID(&CLSID_WICUnknownMetadataReader, &clsid), "GetCLSID returned wrong result\n");
526c2c66affSColin Finck
527c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
528c2c66affSColin Finck ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
529c2c66affSColin Finck ok(IsEqualGUID(&GUID_MetadataFormatUnknown, &clsid), "GetMetadataFormat returned wrong result\n");
530c2c66affSColin Finck
531c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
532c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
533c2c66affSColin Finck
534c2c66affSColin Finck count = 0xdeadbeef;
535c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
536c2c66affSColin Finck ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
537c2c66affSColin Finck ok(count == 0, "unexpected count %d\n", count);
538c2c66affSColin Finck
539c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
540c2c66affSColin Finck 0, NULL, NULL, NULL);
541c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetPatterns failed, hr=%x\n", hr);
542c2c66affSColin Finck
543c2c66affSColin Finck count = size = 0xdeadbeef;
544c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
545c2c66affSColin Finck 0, NULL, &count, &size);
546c2c66affSColin Finck ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
547c2c66affSColin Finck "GetPatterns failed, hr=%x\n", hr);
548c2c66affSColin Finck ok(count == 0xdeadbeef, "unexpected count %d\n", count);
549c2c66affSColin Finck ok(size == 0xdeadbeef, "unexpected size %d\n", size);
550c2c66affSColin Finck
551c2c66affSColin Finck IWICMetadataReaderInfo_Release(reader_info);
552c2c66affSColin Finck
553c2c66affSColin Finck IWICComponentInfo_Release(info);
554c2c66affSColin Finck
555c2c66affSColin Finck hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICXMPStructMetadataReader, &info);
556c2c66affSColin Finck todo_wine
557c2c66affSColin Finck ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
558c2c66affSColin Finck
559c2c66affSColin Finck if (FAILED(hr))
560c2c66affSColin Finck {
561c2c66affSColin Finck IWICImagingFactory_Release(factory);
562c2c66affSColin Finck return;
563c2c66affSColin Finck }
564c2c66affSColin Finck
565c2c66affSColin Finck hr = IWICComponentInfo_QueryInterface(info, &IID_IWICMetadataReaderInfo, (void**)&reader_info);
566c2c66affSColin Finck ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
567c2c66affSColin Finck
568c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetCLSID(reader_info, NULL);
569c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
570c2c66affSColin Finck
571c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetCLSID(reader_info, &clsid);
572c2c66affSColin Finck ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
573c2c66affSColin Finck ok(IsEqualGUID(&CLSID_WICXMPStructMetadataReader, &clsid), "GetCLSID returned wrong result\n");
574c2c66affSColin Finck
575c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetMetadataFormat(reader_info, &clsid);
576c2c66affSColin Finck ok(hr == S_OK, "GetMetadataFormat failed, hr=%x\n", hr);
577c2c66affSColin Finck ok(IsEqualGUID(&GUID_MetadataFormatXMPStruct, &clsid), "GetMetadataFormat returned wrong result\n");
578c2c66affSColin Finck
579c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, NULL);
580c2c66affSColin Finck ok(hr == E_INVALIDARG, "GetContainerFormats failed, hr=%x\n", hr);
581c2c66affSColin Finck
582c2c66affSColin Finck count = 0xdeadbeef;
583c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 0, NULL, &count);
584c2c66affSColin Finck ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
585c2c66affSColin Finck ok(count >= 2, "unexpected count %d\n", count);
586c2c66affSColin Finck
587c2c66affSColin Finck count = 0xdeadbeef;
588c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 1, container_formats, &count);
589c2c66affSColin Finck ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
590c2c66affSColin Finck ok(count == 1, "unexpected count %d\n", count);
591c2c66affSColin Finck
592c2c66affSColin Finck count = 0xdeadbeef;
593c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetContainerFormats(reader_info, 10, container_formats, &count);
594c2c66affSColin Finck ok(hr == S_OK, "GetContainerFormats failed, hr=%x\n", hr);
595c2c66affSColin Finck ok(count == min(count, 10), "unexpected count %d\n", count);
596c2c66affSColin Finck
597c2c66affSColin Finck count = size = 0xdeadbeef;
598c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_ContainerFormatPng,
599c2c66affSColin Finck 0, NULL, &count, &size);
600c2c66affSColin Finck ok(hr == WINCODEC_ERR_COMPONENTNOTFOUND || broken(hr == S_OK) /* Windows XP */,
601c2c66affSColin Finck "GetPatterns failed, hr=%x\n", hr);
602c2c66affSColin Finck ok(count == 0xdeadbeef, "unexpected count %d\n", count);
603c2c66affSColin Finck ok(size == 0xdeadbeef, "unexpected size %d\n", size);
604c2c66affSColin Finck
605c2c66affSColin Finck count = size = 0xdeadbeef;
606c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
607c2c66affSColin Finck 0, NULL, &count, &size);
608c2c66affSColin Finck ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
609c2c66affSColin Finck ok(count == 1, "unexpected count %d\n", count);
610c2c66affSColin Finck ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
611c2c66affSColin Finck
612c2c66affSColin Finck if (hr == S_OK)
613c2c66affSColin Finck {
614c2c66affSColin Finck patterns = HeapAlloc(GetProcessHeap(), 0, size);
615c2c66affSColin Finck
616c2c66affSColin Finck count = size = 0xdeadbeef;
617c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
618c2c66affSColin Finck size-1, patterns, &count, &size);
619c2c66affSColin Finck ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
620c2c66affSColin Finck ok(count == 1, "unexpected count %d\n", count);
621c2c66affSColin Finck ok(size > sizeof(WICMetadataPattern), "unexpected size %d\n", size);
622c2c66affSColin Finck
623c2c66affSColin Finck count = size = 0xdeadbeef;
624c2c66affSColin Finck hr = IWICMetadataReaderInfo_GetPatterns(reader_info, &GUID_MetadataFormatXMP,
625c2c66affSColin Finck size, patterns, &count, &size);
626c2c66affSColin Finck ok(hr == S_OK, "GetPatterns failed, hr=%x\n", hr);
627c2c66affSColin Finck ok(count == 1, "unexpected count %d\n", count);
628c2c66affSColin Finck ok(size == sizeof(WICMetadataPattern) + patterns->Length * 2, "unexpected size %d\n", size);
629c2c66affSColin Finck
630c2c66affSColin Finck HeapFree(GetProcessHeap(), 0, patterns);
631c2c66affSColin Finck }
632c2c66affSColin Finck
633c2c66affSColin Finck IWICMetadataReaderInfo_Release(reader_info);
634c2c66affSColin Finck
635c2c66affSColin Finck IWICComponentInfo_Release(info);
636c2c66affSColin Finck
637c2c66affSColin Finck IWICImagingFactory_Release(factory);
638c2c66affSColin Finck }
639c2c66affSColin Finck
test_imagingfactory_interfaces(void)640*eea81f52SAmine Khaldi static void test_imagingfactory_interfaces(void)
641*eea81f52SAmine Khaldi {
642*eea81f52SAmine Khaldi IWICComponentFactory *component_factory;
643*eea81f52SAmine Khaldi IWICImagingFactory2 *factory2;
644*eea81f52SAmine Khaldi IWICImagingFactory *factory;
645*eea81f52SAmine Khaldi HRESULT hr;
646*eea81f52SAmine Khaldi
647*eea81f52SAmine Khaldi hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
648*eea81f52SAmine Khaldi &IID_IWICImagingFactory2, (void **)&factory2);
649*eea81f52SAmine Khaldi if (FAILED(hr))
650*eea81f52SAmine Khaldi {
651*eea81f52SAmine Khaldi win_skip("IWICImagingFactory2 is not supported.\n");
652*eea81f52SAmine Khaldi return;
653*eea81f52SAmine Khaldi }
654*eea81f52SAmine Khaldi
655*eea81f52SAmine Khaldi hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICComponentFactory, (void **)&component_factory);
656*eea81f52SAmine Khaldi ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
657*eea81f52SAmine Khaldi
658*eea81f52SAmine Khaldi hr = IWICComponentFactory_QueryInterface(component_factory, &IID_IWICImagingFactory, (void **)&factory);
659*eea81f52SAmine Khaldi ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
660*eea81f52SAmine Khaldi ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
661*eea81f52SAmine Khaldi IWICImagingFactory_Release(factory);
662*eea81f52SAmine Khaldi
663*eea81f52SAmine Khaldi hr = IWICImagingFactory2_QueryInterface(factory2, &IID_IWICImagingFactory, (void **)&factory);
664*eea81f52SAmine Khaldi ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
665*eea81f52SAmine Khaldi ok(factory == (IWICImagingFactory *)component_factory, "Unexpected factory pointer.\n");
666*eea81f52SAmine Khaldi
667*eea81f52SAmine Khaldi IWICComponentFactory_Release(component_factory);
668*eea81f52SAmine Khaldi IWICImagingFactory2_Release(factory2);
669*eea81f52SAmine Khaldi IWICImagingFactory_Release(factory);
670*eea81f52SAmine Khaldi }
671*eea81f52SAmine Khaldi
START_TEST(info)672c2c66affSColin Finck START_TEST(info)
673c2c66affSColin Finck {
674c2c66affSColin Finck CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
675c2c66affSColin Finck
676c2c66affSColin Finck test_decoder_info();
677c2c66affSColin Finck test_reader_info();
678c2c66affSColin Finck test_pixelformat_info();
679*eea81f52SAmine Khaldi test_imagingfactory_interfaces();
680c2c66affSColin Finck
681c2c66affSColin Finck CoUninitialize();
682c2c66affSColin Finck }
683