ole32/tests: Rewrite and expand test_data_cache_updatecache().

Instead of testing calls to IDataObject::GetData() and
IDataObject::QueryGetData(), actually test whether the cache contains the
updated data that we expose after calling IOleCache2::UpdateCache(). Fixes
test failures with Windows 10.

Signed-off-by: Zebediah Figura <z.figura12@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2019-12-26 10:32:26 -06:00 committed by Alexandre Julliard
parent a3c0a1d571
commit 91d4caa4cd
1 changed files with 253 additions and 280 deletions

View File

@ -118,7 +118,8 @@ static HRESULT g_QIFailsWith;
static UINT cf_test_1, cf_test_2, cf_test_3;
static FORMATETC *g_dataobject_fmts;
static FORMATETC *data_object_format;
static const BYTE *data_object_dib;
/****************************************************************************
* PresentationDataHeader
@ -182,8 +183,7 @@ static void inline check_expected_method_fmt(const char *method_name, const FORM
ok(!expected_method_list->method, "Method sequence starting from %s not called\n", expected_method_list->method); \
} while (0)
/* 2 x 1 x 32 bpp dib. PelsPerMeter = 200x400 */
static const BYTE dib[] =
static const BYTE dib_white[] =
{
0x28, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00,
0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x20, 0x00,
@ -193,14 +193,24 @@ static const BYTE dib[] =
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
static const BYTE dib_black[] =
{
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,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
};
static void create_dib( STGMEDIUM *med )
{
void *ptr;
med->tymed = TYMED_HGLOBAL;
U(med)->hGlobal = GlobalAlloc( GMEM_MOVEABLE, sizeof(dib) );
U(med)->hGlobal = GlobalAlloc(GMEM_MOVEABLE, sizeof(dib_white));
ptr = GlobalLock( U(med)->hGlobal );
memcpy( ptr, dib, sizeof(dib) );
memcpy(ptr, dib_white, sizeof(dib_white));
GlobalUnlock( U(med)->hGlobal );
med->pUnkForRelease = NULL;
}
@ -1361,34 +1371,33 @@ static inline BOOL fmtetc_equal( const FORMATETC *a, const FORMATETC *b )
}
static HRESULT WINAPI DataObject_GetData( IDataObject *iface, FORMATETC *fmt_in,
STGMEDIUM *med )
static HRESULT WINAPI DataObject_GetData(IDataObject *iface, FORMATETC *format, STGMEDIUM *medium)
{
FORMATETC *fmt;
if (winetest_debug > 1) trace("IDataObject::GetData(cf %u)\n", format->cfFormat);
CHECK_EXPECTED_METHOD_FMT("DataObject_GetData", fmt_in);
for (fmt = g_dataobject_fmts; fmt && fmt->cfFormat != 0; fmt++)
if (data_object_format && fmtetc_equal(format, data_object_format))
{
if (fmtetc_equal( fmt_in, fmt ))
{
switch (fmt->cfFormat)
switch (format->cfFormat)
{
case CF_DIB:
create_dib( med );
medium->tymed = TYMED_HGLOBAL;
medium->pUnkForRelease = NULL;
U(*medium).hGlobal = GlobalAlloc(GMEM_MOVEABLE, sizeof(dib_white));
memcpy(GlobalLock(U(*medium).hGlobal), data_object_dib, sizeof(dib_white));
GlobalUnlock(U(*medium).hGlobal);
return S_OK;
case CF_BITMAP:
create_bitmap( med );
create_bitmap(medium);
return S_OK;
case CF_ENHMETAFILE:
create_emf( med );
create_emf(medium);
return S_OK;
case CF_METAFILEPICT:
create_mfpict(medium);
return S_OK;
case CF_TEXT:
create_text( med );
create_text(medium);
return S_OK;
default:
trace( "unhandled fmt %d\n", fmt->cfFormat );
}
}
}
@ -1404,16 +1413,11 @@ static HRESULT WINAPI DataObject_GetDataHere(
return E_NOTIMPL;
}
static HRESULT WINAPI DataObject_QueryGetData( IDataObject *iface, FORMATETC *fmt_in )
static HRESULT WINAPI DataObject_QueryGetData(IDataObject *iface, FORMATETC *format)
{
FORMATETC *fmt;
if (winetest_debug > 1) trace("IDataObject::QueryGetData(cf %u)\n", format->cfFormat);
CHECK_EXPECTED_METHOD_FMT("DataObject_QueryGetData", fmt_in);
for (fmt = g_dataobject_fmts; fmt && fmt->cfFormat != 0; fmt++)
if (fmtetc_equal( fmt_in, fmt )) return S_OK;
return S_FALSE;
return (data_object_format && fmtetc_equal(format, data_object_format)) ? S_OK : S_FALSE;
}
static HRESULT WINAPI DataObject_GetCanonicalFormatEtc(
@ -1606,9 +1610,6 @@ static void test_data_cache(void)
{ "draw_continue", 1 },
{ "draw_continue", 1 },
{ "draw_continue", 1 },
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_THUMBNAIL, -1, TYMED_HGLOBAL} },
{ "DataObject_GetData", 0, { CF_BITMAP, NULL, DVASPECT_THUMBNAIL, -1, TYMED_GDI} },
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_ICON, -1, TYMED_MFPICT} },
{ NULL, 0 }
};
static const struct expected_method methods_cachethenrun[] =
@ -2042,7 +2043,7 @@ static void test_data_cache_dib_contents_stream(int num)
hr = IDataObject_GetData( data, &fmt, &med );
ok( SUCCEEDED(hr), "got %08x\n", hr );
ok( med.tymed == TYMED_HGLOBAL, "got %x\n", med.tymed );
ok( GlobalSize( U(med).hGlobal ) >= sizeof(dib) - sizeof(BITMAPFILEHEADER),
ok( GlobalSize( U(med).hGlobal ) >= sizeof(dib_white) - sizeof(BITMAPFILEHEADER),
"got %lu\n", GlobalSize( U(med).hGlobal ) );
ptr = GlobalLock( U(med).hGlobal );
@ -2518,84 +2519,26 @@ static void test_data_cache_initnew(void)
IOleCache2_Release( cache );
}
static BOOL compare_global(HGLOBAL handle, const void *data, SIZE_T size)
{
const void *mem = GlobalLock(handle);
BOOL ret = GlobalSize(handle) == size && !memcmp(data, mem, size);
GlobalUnlock(handle);
return ret;
}
static void test_data_cache_updatecache( void )
{
FORMATETC dib_fmt = {CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
FORMATETC emf_fmt = {CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF};
FORMATETC wmf_fmt = {CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT};
FORMATETC view_fmt = {0, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
IDataObject *data;
HRESULT hr;
IOleCache2 *cache;
FORMATETC fmt;
STGMEDIUM medium;
DWORD conn[4];
static const struct expected_method methods_dib[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_GetData", 0, { CF_BITMAP, NULL, DVASPECT_CONTENT, -1, TYMED_GDI } },
{ NULL }
};
static const struct expected_method methods_dib_emf[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_GetData", 0, { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ NULL }
};
static const struct expected_method methods_dib_wmf[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ NULL }
};
static const struct expected_method methods_viewcache[] =
{
{ "DataObject_QueryGetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ "DataObject_QueryGetData", 0, { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
{ "DataObject_QueryGetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_QueryGetData", 0, { CF_BITMAP, NULL, DVASPECT_CONTENT, -1, TYMED_GDI } },
{ NULL }
};
static const struct expected_method methods_viewcache_with_dib[] =
{
{ "DataObject_QueryGetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ "DataObject_QueryGetData", 0, { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
{ "DataObject_QueryGetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ NULL }
};
static const struct expected_method methods_flags_all[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_GetData", 0, { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ NULL }
};
static const struct expected_method methods_flags_ifblank_1[] =
{
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ NULL }
};
static const struct expected_method methods_flags_ifblank_2[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ NULL }
};
static const struct expected_method methods_flags_normal[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ NULL }
};
static const struct expected_method methods_initcache[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ "DataObject_GetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_MFPICT } },
{ NULL }
};
static const struct expected_method methods_empty[] =
{
{ NULL }
};
static STATDATA view_cache[] =
{
{{ 0, 0, DVASPECT_CONTENT, -1, TYMED_HGLOBAL }, 0, NULL, 0 }
@ -2606,216 +2549,276 @@ static void test_data_cache_updatecache( void )
{{ CF_BITMAP, 0, DVASPECT_CONTENT, -1, TYMED_GDI }, 0, NULL, 0 }
};
static FORMATETC dib_fmt[] =
{
{ CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
{ 0 }
};
hr = CreateDataCache( NULL, &CLSID_WineTestOld, &IID_IOleCache2, (void **)&cache );
ok( hr == S_OK, "got %08x\n", hr );
IOleCache2_QueryInterface(cache, &IID_IDataObject, (void **)&data);
/* No cache slots */
g_dataobject_fmts = NULL;
expected_method_list = NULL;
data_object_format = NULL;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
/* A dib cache slot */
fmt.cfFormat = CF_DIB;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_HGLOBAL;
hr = IOleCache2_Cache( cache, &fmt, 0, &conn[0] );
hr = IOleCache2_Cache( cache, &dib_fmt, 0, &conn[0] );
ok( hr == S_OK, "got %08x\n", hr );
expected_method_list = methods_dib;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == CACHE_E_NOCACHE_UPDATED, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
/* Now with a dib available */
g_dataobject_fmts = dib_fmt;
expected_method_list = methods_dib;
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &dib_fmt;
data_object_dib = dib_white;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
/* Add an EMF cache slot */
fmt.cfFormat = CF_ENHMETAFILE;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_ENHMF;
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
ok(compare_global(U(medium).hGlobal, dib_white, sizeof(dib_white)), "Media didn't match.\n");
hr = IOleCache2_Cache( cache, &fmt, 0, &conn[1] );
hr = IOleCache2_Cache(cache, &emf_fmt, 0, &conn[1]);
ok( hr == S_OK, "got %08x\n", hr );
g_dataobject_fmts = dib_fmt;
expected_method_list = methods_dib_emf;
/* Two slots to fill, only the dib will succeed */
data_object_dib = dib_black;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
ok(compare_global(U(medium).hGlobal, dib_black, sizeof(dib_black)), "Media didn't match.\n");
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &wmf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &emf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_ENHMF, "Got unexpected tymed %u.\n", medium.tymed);
hr = IDataObject_GetData(data, &wmf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &wmf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_ENHMF, "Got unexpected tymed %u.\n", medium.tymed);
hr = IDataObject_GetData(data, &wmf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
/* Replace the emf slot with a wmf */
hr = IOleCache2_Uncache( cache, conn[1] );
ok( hr == S_OK, "got %08x\n", hr );
fmt.cfFormat = CF_METAFILEPICT;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_MFPICT;
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &wmf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IOleCache2_Cache( cache, &fmt, 0, &conn[1] );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IOleCache2_Cache( cache, &wmf_fmt, 0, &conn[1] );
ok( hr == S_OK, "got %08x\n", hr );
g_dataobject_fmts = dib_fmt;
expected_method_list = methods_dib_wmf;
data_object_format = &emf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == CACHE_E_NOCACHE_UPDATED, "got %08x\n", hr );
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &wmf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &wmf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &wmf_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IOleCache2_Uncache( cache, conn[1] );
ok( hr == S_OK, "got %08x\n", hr );
hr = IOleCache2_Uncache( cache, conn[0] );
ok( hr == S_OK, "got %08x\n", hr );
/* View caching */
fmt.cfFormat = 0;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_HGLOBAL;
/* Test view caching. */
hr = IOleCache2_Cache( cache, &fmt, 0, &conn[0] );
hr = IOleCache2_Cache( cache, &view_fmt, 0, &conn[0] );
ok( hr == S_OK, "got %08x\n", hr );
view_cache[0].dwConnection = conn[0];
g_dataobject_fmts = NULL;
expected_method_list = methods_viewcache;
data_object_format = NULL;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == CACHE_E_NOCACHE_UPDATED, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
check_enum_cache( cache, view_cache, 1 );
g_dataobject_fmts = dib_fmt;
expected_method_list = methods_viewcache_with_dib;
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &view_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &dib_fmt;
data_object_dib = dib_white;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
view_cache_after_dib[0].dwConnection = view_cache_after_dib[1].dwConnection = view_cache[0].dwConnection;
check_enum_cache( cache, view_cache_after_dib, 2 );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
ok(compare_global(U(medium).hGlobal, dib_white, sizeof(dib_white)), "Media didn't match.\n");
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &view_fmt, &medium);
todo_wine ok(hr == DV_E_CLIPFORMAT, "Got hr %#x.\n", hr);
data_object_format = &emf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == CACHE_E_NOCACHE_UPDATED, "got %08x\n", hr );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IOleCache2_Uncache( cache, conn[0] );
ok( hr == S_OK, "got %08x\n", hr );
/* Try some different flags */
fmt.cfFormat = CF_DIB;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_HGLOBAL;
hr = IOleCache2_Cache( cache, &fmt, 0, &conn[0] );
hr = IOleCache2_Cache( cache, &dib_fmt, 0, &conn[0] );
ok( hr == S_OK, "got %08x\n", hr );
fmt.cfFormat = CF_ENHMETAFILE;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_ENHMF;
hr = IOleCache2_Cache( cache, &fmt, ADVF_NODATA, &conn[1] );
hr = IOleCache2_Cache( cache, &emf_fmt, ADVF_NODATA, &conn[1] );
ok( hr == S_OK, "got %08x\n", hr );
fmt.cfFormat = CF_METAFILEPICT;
fmt.ptd = NULL;
fmt.dwAspect = DVASPECT_CONTENT;
fmt.lindex = -1;
fmt.tymed = TYMED_MFPICT;
data_object_format = &dib_fmt;
data_object_dib = dib_white;
hr = IOleCache2_UpdateCache(cache, &DataObject, UPDFCACHE_IFBLANK, NULL);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IOleCache2_Cache( cache, &fmt, ADVFCACHE_ONSAVE, &conn[2] );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
ok(compare_global(U(medium).hGlobal, dib_white, sizeof(dib_white)), "Media didn't match.\n");
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_dib = dib_black;
hr = IOleCache2_UpdateCache(cache, &DataObject, UPDFCACHE_IFBLANK, NULL);
ok( hr == S_OK, "got %08x\n", hr );
g_dataobject_fmts = dib_fmt;
expected_method_list = methods_flags_all;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
CHECK_NO_EXTRA_METHODS();
expected_method_list = methods_flags_all;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ALL, NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
expected_method_list = methods_flags_ifblank_1;
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
ok(compare_global(U(medium).hGlobal, dib_white, sizeof(dib_white)), "Media didn't match.\n");
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &emf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_IFBLANK , NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
ok(medium.tymed == TYMED_HGLOBAL, "Got unexpected tymed %u.\n", medium.tymed);
ok(compare_global(U(medium).hGlobal, dib_white, sizeof(dib_white)), "Media didn't match.\n");
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IOleCache2_DiscardCache( cache, DISCARDCACHE_NOSAVE );
ok( hr == S_OK, "got %08x\n", hr );
expected_method_list = methods_flags_ifblank_2;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_IFBLANK , NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
hr = IOleCache2_DiscardCache( cache, DISCARDCACHE_NOSAVE );
ok( hr == S_OK, "got %08x\n", hr );
expected_method_list = methods_flags_all;
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &emf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_IFBLANK | UPDFCACHE_NODATACACHE, NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
expected_method_list = methods_empty;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ONLYIFBLANK | UPDFCACHE_NORMALCACHE, NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IOleCache2_DiscardCache( cache, DISCARDCACHE_NOSAVE );
ok( hr == S_OK, "got %08x\n", hr );
expected_method_list = methods_flags_normal;
data_object_format = &dib_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ONLYIFBLANK | UPDFCACHE_NORMALCACHE, NULL );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
expected_method_list = methods_initcache;
data_object_format = &emf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ONLYIFBLANK | UPDFCACHE_NORMALCACHE, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_IFBLANK | UPDFCACHE_NORMALCACHE, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
hr = IOleCache2_DiscardCache( cache, DISCARDCACHE_NOSAVE );
ok( hr == S_OK, "got %08x\n", hr );
data_object_format = &dib_fmt;
hr = IOleCache2_InitCache( cache, &DataObject );
ok( hr == S_OK, "got %08x\n", hr );
CHECK_NO_EXTRA_METHODS();
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
data_object_format = &emf_fmt;
hr = IOleCache2_UpdateCache( cache, &DataObject, UPDFCACHE_ONLYIFBLANK | UPDFCACHE_NORMALCACHE, NULL );
ok( hr == S_OK, "got %08x\n", hr );
hr = IDataObject_GetData(data, &dib_fmt, &medium);
ok(hr == S_OK, "Got hr %#x.\n", hr);
hr = IDataObject_GetData(data, &emf_fmt, &medium);
ok(hr == OLE_E_BLANK, "Got hr %#x.\n", hr);
IDataObject_Release(data);
IOleCache2_Release( cache );
}
@ -4130,18 +4133,18 @@ static void get_stgdef(struct storage_def *stg_def, CLIPFORMAT cf, STGMEDIUM *st
switch (cf)
{
case CF_DIB:
data_size = sizeof(dib);
data_size = sizeof(dib_white);
if (!strcmp(stg_def->stream[stm_idx].name, "CONTENTS"))
{
data_size += sizeof(dib_inf);
data = HeapAlloc(GetProcessHeap(), 0, data_size);
memcpy(data, dib_inf, sizeof(dib_inf));
memcpy(data + sizeof(dib_inf), dib, sizeof(dib));
memcpy(data + sizeof(dib_inf), dib_white, sizeof(dib_white));
}
else
{
data = HeapAlloc(GetProcessHeap(), 0, data_size);
memcpy(data, dib, sizeof(dib));
memcpy(data, dib_white, sizeof(dib_white));
}
stg_def->stream[stm_idx].data = data;
stg_def->stream[stm_idx].data_size = data_size;
@ -4484,6 +4487,9 @@ todo_wine_if(!(test_data[i].in == &stg_def_0 || test_data[i].in == &stg_def_4 ||
static void test_OleCreateStaticFromData(void)
{
FORMATETC dib_fmt = {CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
FORMATETC emf_fmt = {CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF};
FORMATETC text_fmt = {CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
HRESULT hr;
IOleObject *ole_obj = NULL;
IStorage *storage;
@ -4493,41 +4499,10 @@ static void test_OleCreateStaticFromData(void)
STATSTG statstg;
int enumerated_streams, matched_streams;
STGMEDIUM stgmed;
static FORMATETC dib_fmt[] =
{
{ CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
{ 0 }
};
static FORMATETC emf_fmt[] =
{
{ CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF },
{ 0 }
};
static FORMATETC text_fmt[] =
{
{ CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL },
{ 0 }
};
static const struct expected_method methods_create_from_dib[] =
{
{ "DataObject_EnumFormatEtc", TEST_TODO },
{ "DataObject_GetDataHere", 0 },
{ "DataObject_QueryGetData", 0, { CF_METAFILEPICT, NULL, DVASPECT_CONTENT, -1, TYMED_ISTORAGE } },
{ NULL }
};
static const struct expected_method methods_createstatic_from_dib[] =
{
{ "DataObject_GetData", 0, { CF_DIB, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ NULL }
};
static const struct expected_method methods_createstatic_from_emf[] =
{
{ "DataObject_GetData", 0, { CF_ENHMETAFILE, NULL, DVASPECT_CONTENT, -1, TYMED_ENHMF } },
{ NULL }
};
static const struct expected_method methods_createstatic_from_text[] =
{
{ "DataObject_GetData", 0, { CF_TEXT, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL } },
{ NULL }
};
static struct storage_def stg_def_dib =
@ -4554,18 +4529,18 @@ static void test_OleCreateStaticFromData(void)
ILockBytes_Release(ilb);
hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
dib_fmt, NULL, NULL, (void **)&ole_obj);
&dib_fmt, NULL, NULL, (void **)&ole_obj);
ok(hr == E_INVALIDARG, "OleCreateStaticFromData should fail: 0x%08x.\n", hr);
hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
dib_fmt, NULL, storage, NULL);
&dib_fmt, NULL, storage, NULL);
ok(hr == E_INVALIDARG, "OleCreateStaticFromData should fail: 0x%08x.\n", hr);
/* CF_DIB */
g_dataobject_fmts = dib_fmt;
expected_method_list = methods_createstatic_from_dib;
data_object_format = &dib_fmt;
data_object_dib = dib_white;
hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
dib_fmt, NULL, storage, (void **)&ole_obj);
&dib_fmt, NULL, storage, (void **)&ole_obj);
ok(hr == S_OK, "OleCreateStaticFromData failed: 0x%08x.\n", hr);
hr = IOleObject_QueryInterface(ole_obj, &IID_IPersist, (void **)&persist);
ok(hr == S_OK, "IOleObject_QueryInterface failed: 0x%08x.\n", hr);
@ -4596,10 +4571,9 @@ static void test_OleCreateStaticFromData(void)
0, &storage);
ok(hr == S_OK, "StgCreateDocfileOnILockBytes failed: 0x%08x.\n", hr);
ILockBytes_Release(ilb);
g_dataobject_fmts = emf_fmt;
expected_method_list = methods_createstatic_from_emf;
data_object_format = &emf_fmt;
hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
emf_fmt, NULL, storage, (void **)&ole_obj);
&emf_fmt, NULL, storage, (void **)&ole_obj);
ok(hr == S_OK, "OleCreateStaticFromData failed: 0x%08x.\n", hr);
hr = IOleObject_QueryInterface(ole_obj, &IID_IPersist, (void **)&persist);
ok(hr == S_OK, "IOleObject_QueryInterface failed: 0x%08x.\n", hr);
@ -4630,10 +4604,9 @@ static void test_OleCreateStaticFromData(void)
0, &storage);
ok(hr == S_OK, "StgCreateDocfileOnILockBytes failed: 0x%08x.\n", hr);
ILockBytes_Release(ilb);
g_dataobject_fmts = text_fmt;
expected_method_list = methods_createstatic_from_text;
data_object_format = &text_fmt;
hr = OleCreateStaticFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT,
text_fmt, NULL, storage, (void **)&ole_obj);
&text_fmt, NULL, storage, (void **)&ole_obj);
ok(hr == DV_E_CLIPFORMAT, "OleCreateStaticFromData should fail: 0x%08x.\n", hr);
IStorage_Release(storage);
@ -4643,9 +4616,9 @@ static void test_OleCreateStaticFromData(void)
0, &storage);
ok(hr == S_OK, "StgCreateDocfileOnILockBytes failed: 0x%08x.\n", hr);
ILockBytes_Release(ilb);
g_dataobject_fmts = dib_fmt;
data_object_format = &dib_fmt;
expected_method_list = methods_create_from_dib;
hr = OleCreateFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT, dib_fmt, NULL,
hr = OleCreateFromData(&DataObject, &IID_IOleObject, OLERENDER_FORMAT, &dib_fmt, NULL,
storage, (void **)&ole_obj);
todo_wine ok(hr == DV_E_FORMATETC, "OleCreateFromData should failed: 0x%08x.\n", hr);
IStorage_Release(storage);