Damjan Jovanovic : windowscodecs: Test that ICO GetSize returns the BITMAPINFOHEADER size instead of the ICONDIRENTRY size .
Alexandre Julliard
julliard at winehq.org
Wed Sep 8 13:32:12 CDT 2010
Module: wine
Branch: master
Commit: f68333cb6b35fe19421e856f5f1103a3b1aee2a3
URL: http://source.winehq.org/git/wine.git/?a=commit;h=f68333cb6b35fe19421e856f5f1103a3b1aee2a3
Author: Damjan Jovanovic <damjan.jov at gmail.com>
Date: Wed Sep 8 09:45:37 2010 +0200
windowscodecs: Test that ICO GetSize returns the BITMAPINFOHEADER size instead of the ICONDIRENTRY size.
---
dlls/windowscodecs/tests/Makefile.in | 1 +
dlls/windowscodecs/tests/icoformat.c | 159 ++++++++++++++++++++++++++++++++++
2 files changed, 160 insertions(+), 0 deletions(-)
diff --git a/dlls/windowscodecs/tests/Makefile.in b/dlls/windowscodecs/tests/Makefile.in
index e274d3c..165f935 100644
--- a/dlls/windowscodecs/tests/Makefile.in
+++ b/dlls/windowscodecs/tests/Makefile.in
@@ -8,6 +8,7 @@ IMPORTS = ole32 windowscodecs
C_SRCS = \
bmpformat.c \
converter.c \
+ icoformat.c \
info.c \
palette.c \
stream.c
diff --git a/dlls/windowscodecs/tests/icoformat.c b/dlls/windowscodecs/tests/icoformat.c
new file mode 100644
index 0000000..dc34f40
--- /dev/null
+++ b/dlls/windowscodecs/tests/icoformat.c
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2010 Damjan Jovanovic
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+#include <stdarg.h>
+#include <math.h>
+
+#define COBJMACROS
+
+#include "windef.h"
+#include "objbase.h"
+#include "wincodec.h"
+#include "wine/test.h"
+
+static unsigned char testico_bad_icondirentry_size[] = {
+ /* ICONDIR */
+ 0, 0, /* reserved */
+ 1, 0, /* type */
+ 1, 0, /* count */
+ /* ICONDIRENTRY */
+ 2, /* width */
+ 2, /* height */
+ 2, /* colorCount */
+ 0, /* reserved */
+ 1,0, /* planes */
+ 8,0, /* bitCount */
+ (40+2*4+16*16+16*4) & 0xFF,((40+2*4+16*16+16*4) >> 8) & 0xFF,0,0, /* bytesInRes */
+ 22,0,0,0, /* imageOffset */
+ /* BITMAPINFOHEADER */
+ 40,0,0,0, /* header size */
+ 16,0,0,0, /* width */
+ 2*16,0,0,0, /* height (XOR+AND rows) */
+ 1,0, /* planes */
+ 8,0, /* bit count */
+ 0,0,0,0, /* compression */
+ 0,0,0,0, /* sizeImage */
+ 0,0,0,0, /* x pels per meter */
+ 0,0,0,0, /* y pels per meter */
+ 2,0,0,0, /* clrUsed */
+ 0,0,0,0, /* clrImportant */
+ /* palette */
+ 0,0,0,0,
+ 0xFF,0xFF,0xFF,0,
+ /* XOR mask */
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
+ 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
+ 0,1,0,0,0,0,0,0,0,0,0,0,0,1,0,0,
+ 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,
+ 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,
+ 0,0,1,0,0,0,0,0,0,0,0,0,1,0,0,0,
+ 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
+ 0,0,0,1,0,0,0,0,0,0,0,1,0,0,0,0,
+ 0,0,0,1,0,0,0,1,0,0,0,1,0,0,0,0,
+ 0,0,0,0,1,0,1,0,1,0,1,0,0,0,0,0,
+ 0,0,0,0,0,1,0,0,0,1,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ /* AND mask */
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0,
+ 0,0,0,0
+};
+
+static void test_bad_icondirentry_size(void)
+{
+ IWICBitmapDecoder *decoder;
+ IWICImagingFactory *factory;
+ HRESULT hr;
+ IWICStream *icostream;
+ IWICBitmapFrameDecode *framedecode = NULL;
+
+ hr = CoCreateInstance(&CLSID_WICImagingFactory, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IWICImagingFactory, (void**)&factory);
+ ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
+ if (FAILED(hr)) return;
+
+ hr = IWICImagingFactory_CreateStream(factory, &icostream);
+ ok(hr == S_OK, "CreateStream failed, hr=%x\n", hr);
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICStream_InitializeFromMemory(icostream, testico_bad_icondirentry_size,
+ sizeof(testico_bad_icondirentry_size));
+ ok(hr == S_OK, "InitializeFromMemory failed, hr=%x\n", hr);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = CoCreateInstance(&CLSID_WICIcoDecoder, NULL, CLSCTX_INPROC_SERVER,
+ &IID_IWICBitmapDecoder, (void**)&decoder);
+ ok(hr == S_OK, "CoCreateInstance failed, hr=%x\n", hr);
+ }
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICBitmapDecoder_Initialize(decoder, (IStream*)icostream,
+ WICDecodeMetadataCacheOnDemand);
+ ok(hr == S_OK, "Initialize failed, hr=%x\n", hr);
+
+ if (SUCCEEDED(hr))
+ {
+ hr = IWICBitmapDecoder_GetFrame(decoder, 0, &framedecode);
+ ok(hr == S_OK, "GetFrame failed, hr=%x\n", hr);
+ }
+
+ if (SUCCEEDED(hr))
+ {
+ UINT width = 0, height = 0;
+ hr = IWICBitmapFrameDecode_GetSize(framedecode, &width, &height);
+ ok(hr == S_OK, "GetFrameSize failed, hr=%x\n", hr);
+ todo_wine ok(width == 16 && height == 16, "framesize=%ux%u\n", width, height);
+ IWICBitmapFrameDecode_Release(framedecode);
+ }
+
+ IWICBitmapDecoder_Release(decoder);
+ }
+
+ IWICStream_Release(icostream);
+ }
+
+ IWICImagingFactory_Release(factory);
+}
+
+START_TEST(icoformat)
+{
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+
+ test_bad_icondirentry_size();
+
+ CoUninitialize();
+}
More information about the wine-cvs
mailing list