ReactOS 0.4.15-dev-7906-g1b85a5f
icoformat.c File Reference
#include <stdarg.h>
#include <math.h>
#include "windef.h"
#include "objbase.h"
#include "wincodec.h"
#include "wine/test.h"
#include "pshpack1.h"
#include "poppack.h"
Include dependency graph for icoformat.c:

Go to the source code of this file.

Classes

struct  ICONHEADER
 
struct  ICONDIRENTRY
 
struct  test_ico
 

Macros

#define COBJMACROS
 
#define test_ico_data(a, b, c)   test_ico_data_(a, b, c, 0, __LINE__)
 
#define test_ico_data_todo(a, b, c)   test_ico_data_(a, b, c, 1, __LINE__)
 

Functions

static void test_ico_data_ (void *data, DWORD data_size, HRESULT init_hr, int todo, unsigned int line)
 
static void test_decoder (void)
 
 START_TEST (icoformat)
 

Variables

static const struct test_ico ico_1
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 22 of file icoformat.c.

◆ test_ico_data

#define test_ico_data (   a,
  b,
  c 
)    test_ico_data_(a, b, c, 0, __LINE__)

Definition at line 134 of file icoformat.c.

◆ test_ico_data_todo

#define test_ico_data_todo (   a,
  b,
  c 
)    test_ico_data_(a, b, c, 1, __LINE__)

Definition at line 135 of file icoformat.c.

Function Documentation

◆ START_TEST()

START_TEST ( icoformat  )

Definition at line 241 of file icoformat.c.

242{
244
245 test_decoder();
246
248}
#define NULL
Definition: types.h:112
HRESULT WINAPI DECLSPEC_HOTPATCH CoInitializeEx(LPVOID lpReserved, DWORD dwCoInit)
Definition: compobj.c:2002
void WINAPI DECLSPEC_HOTPATCH CoUninitialize(void)
Definition: compobj.c:2067
static void test_decoder(void)
Definition: icoformat.c:208
@ COINIT_APARTMENTTHREADED
Definition: objbase.h:278

◆ test_decoder()

static void test_decoder ( void  )
static

Definition at line 208 of file icoformat.c.

209{
210 struct test_ico ico;
211
212 /* Icon size specified in ICONDIRENTRY does not match bitmap header. */
213 ico = ico_1;
214 ico.direntry.bWidth = 2;
215 ico.direntry.bHeight = 2;
216 test_ico_data(&ico, sizeof(ico), S_OK);
217
218 /* Invalid DIRENTRY data size/offset. */
219 ico = ico_1;
220 ico.direntry.dwDIBOffset = sizeof(ico);
221 test_ico_data(&ico, sizeof(ico), WINCODEC_ERR_BADIMAGE);
222
223 ico = ico_1;
224 ico.direntry.dwDIBSize = sizeof(ico);
225 test_ico_data(&ico, sizeof(ico), WINCODEC_ERR_BADIMAGE);
226
227 /* Header fields validation. */
228 ico = ico_1;
229 ico.header.idReserved = 1;
230 test_ico_data_todo(&ico, sizeof(ico), S_OK);
231 ico.header.idReserved = 0;
232 ico.header.idType = 100;
233 test_ico_data_todo(&ico, sizeof(ico), S_OK);
234
235 /* Premature end of data. */
236 ico = ico_1;
237 test_ico_data(&ico, sizeof(ico.header) - 1, WINCODEC_ERR_STREAMREAD);
238 test_ico_data(&ico, sizeof(ico.header) + sizeof(ico.direntry) - 1, WINCODEC_ERR_BADIMAGE);
239}
#define S_OK
Definition: intsafe.h:52
static const struct test_ico ico_1
Definition: icoformat.c:58
#define test_ico_data_todo(a, b, c)
Definition: icoformat.c:135
#define test_ico_data(a, b, c)
Definition: icoformat.c:134
#define WINCODEC_ERR_BADIMAGE
Definition: winerror.h:3299
#define WINCODEC_ERR_STREAMREAD
Definition: winerror.h:3305

Referenced by START_TEST().

◆ test_ico_data_()

static void test_ico_data_ ( void data,
DWORD  data_size,
HRESULT  init_hr,
int  todo,
unsigned int  line 
)
static

Definition at line 136 of file icoformat.c.

137{
138 IWICBitmapDecoder *decoder;
140 HRESULT hr;
141 IWICStream *icostream;
142 IWICBitmapFrameDecode *framedecode = NULL;
143
144 hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
145 &IID_IWICImagingFactory, (void**)&factory);
146 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
147 if (FAILED(hr)) return;
148
149 hr = IWICImagingFactory_CreateStream(factory, &icostream);
150 ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr);
151 if (SUCCEEDED(hr))
152 {
153 hr = IWICStream_InitializeFromMemory(icostream, data, data_size);
154 ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr);
155
156 if (SUCCEEDED(hr))
157 {
158 hr = CoCreateInstance(&CLSID_WICIcoDecoder, NULL, CLSCTX_INPROC_SERVER,
159 &IID_IWICBitmapDecoder, (void**)&decoder);
160 ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
161 }
162
163 if (SUCCEEDED(hr))
164 {
165 hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)icostream,
168 ok_(__FILE__, line)(hr == init_hr, "Initialize failed, hr=%x\n", hr);
169
170 if (SUCCEEDED(hr))
171 {
172 hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
173 ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
174 }
175
176 if (SUCCEEDED(hr))
177 {
179 IWICBitmapSource *thumbnail;
180
181 width = height = 0;
182 hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
183 ok(hr == S_OK, "GetFrameSize failed, hr=%x\n", hr);
184 ok(width == 16 && height == 16, "framesize=%ux%u\n", width, height);
185
186 hr = IWICBitmapFrameDecode_GetThumbnail(framedecode, &thumbnail);
187 ok(hr == S_OK, "GetThumbnail failed, hr=%x\n", hr);
188 if (hr == S_OK)
189 {
190 width = height = 0;
191 hr = IWICBitmapSource_GetSize(thumbnail, &width, &height);
192 ok(hr == S_OK, "GetFrameSize failed, hr=%x\n", hr);
193 ok(width == 16 && height == 16, "framesize=%ux%u\n", width, height);
194 IWICBitmapSource_Release(thumbnail);
195 }
196 IWICBitmapFrameDecode_Release(framedecode);
197 }
198
199 IWICBitmapDecoder_Release(decoder);
200 }
201
202 IWICStream_Release(icostream);
203 }
204
205 IWICImagingFactory_Release(factory);
206}
#define ok(value,...)
Definition: atltest.h:57
#define ok_(x1, x2)
Definition: atltest.h:61
HRESULT WINAPI DECLSPEC_HOTPATCH CoCreateInstance(REFCLSID rclsid, LPUNKNOWN pUnkOuter, DWORD dwClsContext, REFIID iid, LPVOID *ppv)
Definition: compobj.c:3325
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
#define SUCCEEDED(hr)
Definition: intsafe.h:50
#define FAILED(hr)
Definition: intsafe.h:51
BOOL todo
Definition: filedlg.c:313
#define todo_wine_if(is_todo)
Definition: custom.c:76
unsigned int UINT
Definition: ndis.h:50
HRESULT hr
Definition: shlfolder.c:183
Definition: main.c:439
Definition: parser.c:49
@ WICDecodeMetadataCacheOnDemand
Definition: wincodec.idl:28

Variable Documentation

◆ ico_1

const struct test_ico ico_1
static

Definition at line 58 of file icoformat.c.

Referenced by test_decoder().