windowscodecs/tests: Added test for GifFrameDecode_GetResolution.
[wine] / dlls / windowscodecs / tests / info.c
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 <stdarg.h>
20 #include <math.h>
21
22 #define COBJMACROS
23
24 #include "windef.h"
25 #include "objbase.h"
26 #include "wincodec.h"
27 #include "wine/test.h"
28
29 static void test_decoder_info(void)
30 {
31     IWICImagingFactory *factory;
32     IWICComponentInfo *info;
33     IWICBitmapDecoderInfo *decoder_info;
34     HRESULT hr;
35     ULONG len;
36     WCHAR value[256];
37     const WCHAR expected_mimetype[] = {'i','m','a','g','e','/','b','m','p',0};
38     CLSID clsid;
39
40     hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
41         &IID_IWICImagingFactory, (void**)&factory);
42     ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
43     if (FAILED(hr)) return;
44
45     hr = IWICImagingFactory_CreateComponentInfo(factory, &CLSID_WICBmpDecoder, &info);
46     ok(hr == S_OK, "CreateComponentInfo failed, hr=%x\n", hr);
47
48     hr = IWICComponentInfo_QueryInterface(info, &IID_IWICBitmapDecoderInfo, (void**)&decoder_info);
49     ok(hr == S_OK, "QueryInterface failed, hr=%x\n", hr);
50
51     hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, NULL);
52     ok(hr == E_INVALIDARG, "GetCLSID failed, hr=%x\n", hr);
53
54     hr = IWICBitmapDecoderInfo_GetCLSID(decoder_info, &clsid);
55     ok(hr == S_OK, "GetCLSID failed, hr=%x\n", hr);
56     ok(IsEqualGUID(&CLSID_WICBmpDecoder, &clsid), "GetCLSID returned wrong result\n");
57
58     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, NULL);
59     ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
60
61     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, NULL, &len);
62     ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
63     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
64
65     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, NULL);
66     ok(hr == E_INVALIDARG, "GetMimeType failed, hr=%x\n", hr);
67
68     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 0, NULL, &len);
69     ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
70     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
71
72     value[0] = 0;
73     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, len, value, &len);
74     ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
75     ok(lstrcmpW(value, expected_mimetype) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
76     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
77
78     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 1, value, &len);
79     ok(hr == WINCODEC_ERR_INSUFFICIENTBUFFER, "GetMimeType failed, hr=%x\n", hr);
80     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
81
82     hr = IWICBitmapDecoderInfo_GetMimeTypes(decoder_info, 256, value, &len);
83     ok(hr == S_OK, "GetMimeType failed, hr=%x\n", hr);
84     ok(lstrcmpW(value, expected_mimetype) == 0, "GetMimeType returned wrong value %s\n", wine_dbgstr_w(value));
85     ok(len == lstrlenW(expected_mimetype)+1, "GetMimeType returned wrong len %i\n", len);
86
87     IWICBitmapDecoderInfo_Release(decoder_info);
88
89     IWICComponentInfo_Release(info);
90
91     IWICImagingFactory_Release(factory);
92 }
93
94 START_TEST(info)
95 {
96     CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
97
98     test_decoder_info();
99
100     CoUninitialize();
101 }