mirror of
git://source.winehq.org/git/wine.git
synced 2024-11-05 18:01:34 +00:00
ole32/tests: Add tests for loading from presentation streams to data cache.
Signed-off-by: Sergio Gómez Del Real <sdelreal@codeweavers.com> Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
33fd878728
commit
edb7f51209
1 changed files with 113 additions and 5 deletions
|
@ -4078,6 +4078,83 @@ static void check_storage_contents(IStorage *stg, const struct storage_def *stg_
|
|||
}
|
||||
}
|
||||
|
||||
static HRESULT stgmedium_cmp(const STGMEDIUM *med1, STGMEDIUM *med2)
|
||||
{
|
||||
BYTE *data1, *data2;
|
||||
ULONG datasize1, datasize2;
|
||||
|
||||
if (med1->tymed != med2->tymed)
|
||||
return E_FAIL;
|
||||
|
||||
if (med1->tymed == TYMED_MFPICT)
|
||||
{
|
||||
METAFILEPICT *mfpict1 = GlobalLock(U(med1)->hMetaFilePict);
|
||||
METAFILEPICT *mfpict2 = GlobalLock(U(med2)->hMetaFilePict);
|
||||
|
||||
datasize1 = GetMetaFileBitsEx(mfpict1->hMF, 0, NULL);
|
||||
datasize2 = GetMetaFileBitsEx(mfpict2->hMF, 0, NULL);
|
||||
if (datasize1 == datasize2)
|
||||
{
|
||||
data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
|
||||
data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
|
||||
GetMetaFileBitsEx(mfpict1->hMF, datasize1, data1);
|
||||
GetMetaFileBitsEx(mfpict2->hMF, datasize2, data2);
|
||||
}
|
||||
else return E_FAIL;
|
||||
}
|
||||
else if (med1->tymed == TYMED_ENHMF)
|
||||
{
|
||||
datasize1 = GetEnhMetaFileBits(med1->hEnhMetaFile, 0, NULL);
|
||||
datasize2 = GetEnhMetaFileBits(med2->hEnhMetaFile, 0, NULL);
|
||||
if (datasize1 == datasize2)
|
||||
{
|
||||
data1 = HeapAlloc(GetProcessHeap(), 0, datasize1);
|
||||
data2 = HeapAlloc(GetProcessHeap(), 0, datasize2);
|
||||
GetEnhMetaFileBits(med1->hEnhMetaFile, datasize1, data1);
|
||||
GetEnhMetaFileBits(med2->hEnhMetaFile, datasize2, data2);
|
||||
}
|
||||
else return E_FAIL;
|
||||
}
|
||||
else if (med1->tymed == TYMED_HGLOBAL)
|
||||
{
|
||||
datasize1 = GlobalSize(med1->hGlobal);
|
||||
datasize2 = GlobalSize(med2->hGlobal);
|
||||
|
||||
if (datasize1 == datasize2)
|
||||
{
|
||||
data1 = GlobalLock(med1->hGlobal);
|
||||
data2 = GlobalLock(med2->hGlobal);
|
||||
}
|
||||
else
|
||||
return E_FAIL;
|
||||
}
|
||||
else
|
||||
return E_NOTIMPL;
|
||||
|
||||
if (memcmp(data1, data2, datasize1) != 0)
|
||||
return E_FAIL;
|
||||
|
||||
if (med1->tymed == TYMED_HGLOBAL)
|
||||
{
|
||||
GlobalUnlock(U(med1)->hGlobal);
|
||||
GlobalUnlock(U(med2)->hGlobal);
|
||||
}
|
||||
else if (med1->tymed == TYMED_MFPICT)
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data1);
|
||||
HeapFree(GetProcessHeap(), 0, data2);
|
||||
GlobalUnlock(U(med1)->hMetaFilePict);
|
||||
GlobalUnlock(U(med2)->hMetaFilePict);
|
||||
}
|
||||
else
|
||||
{
|
||||
HeapFree(GetProcessHeap(), 0, data1);
|
||||
HeapFree(GetProcessHeap(), 0, data2);
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static IStorage *create_storage_from_def(const struct storage_def *stg_def)
|
||||
{
|
||||
HRESULT hr;
|
||||
|
@ -4250,8 +4327,10 @@ static void test_data_cache_save_data(void)
|
|||
IStorage *doc;
|
||||
IOleCache2 *cache;
|
||||
IPersistStorage *persist;
|
||||
IDataObject *odata;
|
||||
int enumerated_streams, matched_streams, i;
|
||||
DWORD dummy;
|
||||
STGMEDIUM stgmeds[MAX_FMTS];
|
||||
struct tests_data_cache
|
||||
{
|
||||
FORMATETC fmts[MAX_FMTS];
|
||||
|
@ -4366,9 +4445,9 @@ static void test_data_cache_save_data(void)
|
|||
ok(SUCCEEDED(hr), "unexpected %#x\n", hr);
|
||||
if (i < pdata->num_set)
|
||||
{
|
||||
get_stgmedium(pdata->fmts[i].cfFormat, &stgmed);
|
||||
get_stgdef(&pdata->stg_def, pdata->fmts[i].cfFormat, &stgmed, i);
|
||||
hr = IOleCache2_SetData(cache, &pdata->fmts[i], &stgmed, TRUE);
|
||||
get_stgmedium(pdata->fmts[i].cfFormat, &stgmeds[i]);
|
||||
get_stgdef(&pdata->stg_def, pdata->fmts[i].cfFormat, &stgmeds[i], i);
|
||||
hr = IOleCache2_SetData(cache, &pdata->fmts[i], &stgmeds[i], FALSE);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
}
|
||||
}
|
||||
|
@ -4399,12 +4478,41 @@ static void test_data_cache_save_data(void)
|
|||
ok(enumerated_streams == pdata->stg_def.stream_count, "created %d != def streams %d\n",
|
||||
enumerated_streams, pdata->stg_def.stream_count);
|
||||
|
||||
for (i = 0; i < pdata->num_set; i++)
|
||||
HeapFree(GetProcessHeap(), 0, (void *)pdata->stg_def.stream[i].data);
|
||||
IPersistStorage_Release(persist);
|
||||
IOleCache2_Release(cache);
|
||||
|
||||
/* now test _Load/_GetData using the storage we used for _Save */
|
||||
hr = CreateDataCache(NULL, pdata->clsid, &IID_IOleCache2, (void **)&cache);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
hr = IOleCache2_QueryInterface(cache, &IID_IPersistStorage, (void **)&persist);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
|
||||
hr = IStorage_SetClass(doc, pdata->clsid);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
trace("IPersistStorage_Load\n");
|
||||
hr = IPersistStorage_Load(persist, doc);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
|
||||
hr = IOleCache2_QueryInterface(cache, &IID_IDataObject, (void **)&odata);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
for (i = 0; i < pdata->num_set; i++)
|
||||
{
|
||||
hr = IDataObject_GetData(odata, &pdata->fmts[i], &stgmed);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
|
||||
hr = stgmedium_cmp(&stgmeds[i], &stgmed);
|
||||
ok(hr == S_OK, "unexpected %#x\n", hr);
|
||||
ReleaseStgMedium(&stgmed);
|
||||
ReleaseStgMedium(&stgmeds[i]);
|
||||
}
|
||||
|
||||
IDataObject_Release(odata);
|
||||
IPersistStorage_Release(persist);
|
||||
IStorage_Release(doc);
|
||||
IOleCache2_Release(cache);
|
||||
for (i = 0; i < pdata->num_set; i++)
|
||||
HeapFree(GetProcessHeap(), 0, (void *)pdata->stg_def.stream[i].data);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue