ole32: Fix some tests that fail on NT4 and Win9x.

Round the expected sizes up to the alignment used by HeapSize, which
is 4 on Win9x and NT4 but 1 in more recent versions.

Additionally fix an IGlobalInterfaceTable test which erroneously
succeeds on these older OSs.
This commit is contained in:
Rob Shearman 2009-01-28 12:48:40 +00:00 committed by Alexandre Julliard
parent a1b4ee8866
commit 9353dff5b3
2 changed files with 37 additions and 8 deletions

View File

@ -2040,6 +2040,19 @@ static void test_WM_QUIT_handling(void)
}
}
static SIZE_T round_heap_size(SIZE_T size)
{
static SIZE_T heap_size_alignment = -1;
if (heap_size_alignment == -1)
{
void *p = HeapAlloc(GetProcessHeap(), 0, 1);
heap_size_alignment = HeapSize(GetProcessHeap(), 0, p);
HeapFree(GetProcessHeap(), 0, p);
}
return ((size + heap_size_alignment - 1) & ~(heap_size_alignment - 1));
}
static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *ptr, DWORD mshlflags)
{
HGLOBAL hglobal;
@ -2056,7 +2069,7 @@ static void test_freethreadedmarshaldata(IStream *pStream, MSHCTX mshctx, void *
if (mshctx == MSHCTX_INPROC)
{
DWORD expected_size = 3*sizeof(DWORD) + sizeof(GUID);
DWORD expected_size = round_heap_size(3*sizeof(DWORD) + sizeof(GUID));
ok(size == expected_size, "size should have been %d instead of %d\n", expected_size, size);
ok(*(DWORD *)marshal_data == mshlflags, "expected 0x%x, but got 0x%x for mshctx\n", mshlflags, *(DWORD *)marshal_data);
@ -2715,9 +2728,12 @@ static DWORD CALLBACK get_global_interface_proc(LPVOID pv)
hr = IGlobalInterfaceTable_GetInterfaceFromGlobal(params->git, params->cookie, &IID_IClassFactory, (void **)&cf);
ok(hr == CO_E_NOTINITIALIZED ||
hr == E_UNEXPECTED, /* win2k */
broken(hr == E_UNEXPECTED) /* win2k */ ||
broken(hr == S_OK) /* NT 4 */,
"IGlobalInterfaceTable_GetInterfaceFromGlobal should have failed with error CO_E_NOTINITIALIZED or E_UNEXPECTED instead of 0x%08x\n",
hr);
if (hr == S_OK)
IClassFactory_Release(cf);
CoInitialize(NULL);

View File

@ -82,6 +82,19 @@ static void UnlockModule(void)
InterlockedDecrement(&cLocks);
}
static SIZE_T round_heap_size(SIZE_T size)
{
static SIZE_T heap_size_alignment = -1;
if (heap_size_alignment == -1)
{
void *p = HeapAlloc(GetProcessHeap(), 0, 1);
heap_size_alignment = HeapSize(GetProcessHeap(), 0, p);
HeapFree(GetProcessHeap(), 0, p);
}
return ((size + heap_size_alignment - 1) & ~(heap_size_alignment - 1));
}
static HRESULT WINAPI Test_IClassFactory_QueryInterface(
LPCLASSFACTORY iface,
REFIID riid,
@ -1204,12 +1217,12 @@ static void test_moniker(
moniker_data = GlobalLock(hglobal);
/* first check we have the right amount of data */
ok(moniker_size == sizeof_expected_moniker_saved_data,
ok(moniker_size == round_heap_size(sizeof_expected_moniker_saved_data),
"%s: Size of saved data differs (expected %d, actual %d)\n",
testname, sizeof_expected_moniker_saved_data, moniker_size);
testname, (DWORD)round_heap_size(sizeof_expected_moniker_saved_data), moniker_size);
/* then do a byte-by-byte comparison */
for (i = 0; i < min(moniker_size, sizeof_expected_moniker_saved_data); i++)
for (i = 0; i < min(moniker_size, round_heap_size(sizeof_expected_moniker_saved_data)); i++)
{
if (expected_moniker_saved_data[i] != moniker_data[i])
{
@ -1250,14 +1263,14 @@ static void test_moniker(
moniker_data = GlobalLock(hglobal);
/* first check we have the right amount of data */
ok(moniker_size == sizeof_expected_moniker_marshal_data,
ok(moniker_size == round_heap_size(sizeof_expected_moniker_marshal_data),
"%s: Size of marshaled data differs (expected %d, actual %d)\n",
testname, sizeof_expected_moniker_marshal_data, moniker_size);
testname, (DWORD)round_heap_size(sizeof_expected_moniker_marshal_data), moniker_size);
/* then do a byte-by-byte comparison */
if (expected_moniker_marshal_data)
{
for (i = 0; i < min(moniker_size, sizeof_expected_moniker_marshal_data); i++)
for (i = 0; i < min(moniker_size, round_heap_size(sizeof_expected_moniker_marshal_data)); i++)
{
if (expected_moniker_marshal_data[i] != moniker_data[i])
{