Commit f57e0899 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32/tests: Add tests for loading a dib 'CONTENTS' stream.

parent b0deb315
......@@ -31,6 +31,11 @@
#include "wine/test.h"
#include "initguid.h"
DEFINE_GUID(CLSID_Picture_Metafile,0x315,0,0,0xc0,0,0,0,0,0,0,0x46);
DEFINE_GUID(CLSID_Picture_Dib,0x316,0,0,0xc0,0,0,0,0,0,0,0x46);
#define ok_ole_success(hr, func) ok(hr == S_OK, func " failed with error 0x%08x\n", hr)
#define DEFINE_EXPECT(func) \
......@@ -1680,6 +1685,113 @@ static void test_data_cache(void)
IStorage_Release(pStorage);
}
static const WCHAR CONTENTS[] = {'C','O','N','T','E','N','T','S',0};
/* 2 x 1 x 32 bpp dib. PelsPerMeter = 200x400 */
static BYTE dib[] =
{
0x42, 0x4d, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x28, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x01, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x00,
0x00, 0x00, 0x90, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static IStorage *create_storage( int num )
{
IStorage *stg;
IStream *stm;
HRESULT hr;
ULONG written;
hr = StgCreateDocfile( NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE | STGM_DELETEONRELEASE, 0, &stg );
ok( hr == S_OK, "got %08x\n", hr);
hr = IStorage_SetClass( stg, &CLSID_Picture_Dib );
ok( hr == S_OK, "got %08x\n", hr);
hr = IStorage_CreateStream( stg, CONTENTS, STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, 0, &stm );
ok( hr == S_OK, "got %08x\n", hr);
if (num == 1) /* Set biXPelsPerMeter = 0 */
{
dib[0x26] = 0;
dib[0x27] = 0;
}
hr = IStream_Write( stm, dib, sizeof(dib), &written );
ok( hr == S_OK, "got %08x\n", hr);
IStream_Release( stm );
return stg;
}
static void test_data_cache_dib_contents_stream(int num)
{
HRESULT hr;
IUnknown *unk;
IPersistStorage *persist;
IDataObject *data;
IViewObject2 *view;
IStorage *stg;
FORMATETC fmt = {CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL };
STGMEDIUM med;
CLSID cls;
SIZEL sz;
hr = CreateDataCache( NULL, &CLSID_Picture_Metafile, &IID_IUnknown, (void *)&unk );
ok( SUCCEEDED(hr), "got %08x\n", hr );
hr = IUnknown_QueryInterface( unk, &IID_IPersistStorage, (void *)&persist );
ok( SUCCEEDED(hr), "got %08x\n", hr );
hr = IUnknown_QueryInterface( unk, &IID_IDataObject, (void *)&data );
ok( SUCCEEDED(hr), "got %08x\n", hr );
hr = IUnknown_QueryInterface( unk, &IID_IViewObject2, (void *)&view );
ok( SUCCEEDED(hr), "got %08x\n", hr );
stg = create_storage( num );
hr = IPersistStorage_Load( persist, stg );
ok( SUCCEEDED(hr), "got %08x\n", hr );
IStorage_Release( stg );
hr = IPersistStorage_GetClassID( persist, &cls );
ok( SUCCEEDED(hr), "got %08x\n", hr );
ok( IsEqualCLSID( &cls, &CLSID_Picture_Dib ), "class id mismatch\n" );
hr = IDataObject_GetData( data, &fmt, &med );
ok( SUCCEEDED(hr), "got %08x\n", hr );
if (SUCCEEDED(hr))
{
ok( med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed );
ReleaseStgMedium( &med );
}
hr = IViewObject2_GetExtent( view, DVASPECT_CONTENT, -1, NULL, &sz );
ok( SUCCEEDED(hr), "got %08x\n", hr );
if (num == 0)
{
ok( sz.cx == 1000, "got %d\n", sz.cx );
ok( sz.cy == 250, "got %d\n", sz.cy );
}
else
{
HDC hdc = GetDC( 0 );
LONG x = 2 * 2540 / GetDeviceCaps( hdc, LOGPIXELSX );
LONG y = 1 * 2540 / GetDeviceCaps( hdc, LOGPIXELSY );
ok( sz.cx == x, "got %d %d\n", sz.cx, x );
ok( sz.cy == y, "got %d %d\n", sz.cy, y );
ReleaseDC( 0, hdc );
}
IViewObject2_Release( view );
IDataObject_Release( data );
IPersistStorage_Release( persist );
IUnknown_Release( unk );
}
static void test_default_handler(void)
{
HRESULT hr;
......@@ -2385,6 +2497,8 @@ START_TEST(ole2)
ok_ole_success(hr, "CoRevokeClassObject");
test_data_cache();
test_data_cache_dib_contents_stream( 0 );
test_data_cache_dib_contents_stream( 1 );
test_default_handler();
test_runnable();
test_OleRun();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment