Commit 82b4b642 authored by Huw Davies's avatar Huw Davies Committed by Alexandre Julliard

ole32/tests: Exercise the HGLOBAL marshaller over a range of block sizes.

parent 654c7e36
...@@ -162,7 +162,7 @@ static void test_marshal_HGLOBAL(void) ...@@ -162,7 +162,7 @@ static void test_marshal_HGLOBAL(void)
MIDL_STUB_MESSAGE stub_msg; MIDL_STUB_MESSAGE stub_msg;
RPC_MESSAGE rpc_msg; RPC_MESSAGE rpc_msg;
unsigned char *buffer; unsigned char *buffer;
ULONG size; ULONG size, block_size;
HGLOBAL hglobal; HGLOBAL hglobal;
HGLOBAL hglobal2; HGLOBAL hglobal2;
unsigned char *wirehglobal; unsigned char *wirehglobal;
...@@ -188,39 +188,52 @@ static void test_marshal_HGLOBAL(void) ...@@ -188,39 +188,52 @@ static void test_marshal_HGLOBAL(void)
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL);
HGLOBAL_UserFree(&umcb.Flags, &hglobal2); HGLOBAL_UserFree(&umcb.Flags, &hglobal2);
hglobal = GlobalAlloc(0, 4);
buffer = GlobalLock(hglobal); for(block_size = 0; block_size <= 17; block_size++)
for (i = 0; i < 4; i++) {
buffer[i] = i; ULONG actual_size, expected_size;
GlobalUnlock(hglobal);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL); hglobal = GlobalAlloc(0, block_size);
size = HGLOBAL_UserSize(&umcb.Flags, 0, &hglobal); buffer = GlobalLock(hglobal);
/* native is poorly programmed and allocates 4/8 bytes more than it needs to for (i = 0; i < block_size; i++)
* here - Wine doesn't have to emulate that */ buffer[i] = i;
ok((size == 24) || broken(size == 28) || broken(size == 32), "Size should be 24, instead of %d\n", size); GlobalUnlock(hglobal);
buffer = HeapAlloc(GetProcessHeap(), 0, size); actual_size = GlobalSize(hglobal);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); expected_size = actual_size + 5 * sizeof(DWORD);
HGLOBAL_UserMarshal(&umcb.Flags, buffer, &hglobal); trace("%d: actual size %d\n", block_size, actual_size);
wirehglobal = buffer; init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL);
ok(*(ULONG *)wirehglobal == WDT_REMOTE_CALL, "Context should be WDT_REMOTE_CALL instead of 0x%08x\n", *(ULONG *)wirehglobal); size = HGLOBAL_UserSize(&umcb.Flags, 0, &hglobal);
wirehglobal += sizeof(ULONG); /* native is poorly programmed and allocates 4/8 bytes more than it needs to
ok(*(ULONG *)wirehglobal == (ULONG)(ULONG_PTR)hglobal, "buffer+0x4 should be HGLOBAL\n"); * here - Wine doesn't have to emulate that */
wirehglobal += sizeof(ULONG); ok(size == expected_size ||
ok(*(ULONG *)wirehglobal == 4, "buffer+0x8 should be size of HGLOBAL instead of %d\n", *(ULONG *)wirehglobal); broken(size == expected_size + 4) ||
wirehglobal += sizeof(ULONG); broken(size == expected_size + 8),
ok(*(ULONG *)wirehglobal == (ULONG)(ULONG_PTR)hglobal, "buffer+0xc should be HGLOBAL\n"); "%d: got size %d\n", block_size, size);
wirehglobal += sizeof(ULONG); buffer = HeapAlloc(GetProcessHeap(), 0, size);
ok(*(ULONG *)wirehglobal == 4, "buffer+0x10 should be size of HGLOBAL instead of %d\n", *(ULONG *)wirehglobal); init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL);
wirehglobal += sizeof(ULONG); HGLOBAL_UserMarshal(&umcb.Flags, buffer, &hglobal);
for (i = 0; i < 4; i++) wirehglobal = buffer;
ok(wirehglobal[i] == i, "buffer+0x%x should be %d\n", 0x10 + i, i); ok(*(ULONG *)wirehglobal == WDT_REMOTE_CALL, "Context should be WDT_REMOTE_CALL instead of 0x%08x\n", *(ULONG *)wirehglobal);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL); wirehglobal += sizeof(ULONG);
HGLOBAL_UserUnmarshal(&umcb.Flags, buffer, &hglobal2); ok(*(ULONG *)wirehglobal == (ULONG)(ULONG_PTR)hglobal, "buffer+0x4 should be HGLOBAL\n");
ok(hglobal2 != NULL, "Didn't unmarshal properly\n"); wirehglobal += sizeof(ULONG);
HeapFree(GetProcessHeap(), 0, buffer); ok(*(ULONG *)wirehglobal == actual_size, "%d: buffer+0x8 %08x\n", block_size, *(ULONG *)wirehglobal);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL); wirehglobal += sizeof(ULONG);
HGLOBAL_UserFree(&umcb.Flags, &hglobal2); ok(*(ULONG *)wirehglobal == (ULONG)(ULONG_PTR)hglobal, "buffer+0xc should be HGLOBAL\n");
GlobalFree(hglobal); wirehglobal += sizeof(ULONG);
ok(*(ULONG *)wirehglobal == actual_size, "%d: buffer+0x10 %08x\n", block_size, *(ULONG *)wirehglobal);
wirehglobal += sizeof(ULONG);
for (i = 0; i < block_size; i++)
ok(wirehglobal[i] == i, "buffer+0x%x should be %d\n", 0x10 + i, i);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, buffer, size, MSHCTX_LOCAL);
HGLOBAL_UserUnmarshal(&umcb.Flags, buffer, &hglobal2);
ok(hglobal2 != NULL, "Didn't unmarshal properly\n");
HeapFree(GetProcessHeap(), 0, buffer);
init_user_marshal_cb(&umcb, &stub_msg, &rpc_msg, NULL, 0, MSHCTX_LOCAL);
HGLOBAL_UserFree(&umcb.Flags, &hglobal2);
GlobalFree(hglobal);
}
} }
static HENHMETAFILE create_emf(void) static HENHMETAFILE create_emf(void)
......
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