Rob Shearman : ole32: Fix the HMETAFILEPICT user marshaling test to use the size

Alexandre Julliard julliard at wine.codeweavers.com
Tue Dec 19 10:05:05 CST 2006


Module: wine
Branch: master
Commit: 307ab51793a2d436956a5eac277fdc00bf3bc86a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=307ab51793a2d436956a5eac277fdc00bf3bc86a

Author: Rob Shearman <rob at codeweavers.com>
Date:   Tue Dec 19 13:03:33 2006 +0000

ole32: Fix the HMETAFILEPICT user marshaling test to use the size
derived from the return value of HMETAFILEPICT_UserMarshal instead of
the value returned by HMETAFILEPICT_UserSize, as the latter
over-estimates the size on Windows.

Remove some unnecessary casts.

---

 dlls/ole32/tests/usrmarshal.c |   20 ++++++++++----------
 1 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/dlls/ole32/tests/usrmarshal.c b/dlls/ole32/tests/usrmarshal.c
index 2ce7384..28c6687 100644
--- a/dlls/ole32/tests/usrmarshal.c
+++ b/dlls/ole32/tests/usrmarshal.c
@@ -204,7 +204,7 @@ static void test_marshal_HENHMETAFILE(vo
 
     size = HENHMETAFILE_UserSize(&flags, 0, &hemf);
     ok(size == 8, "size should be 8 bytes, not %d\n", size);
-    buffer = (unsigned char *)HeapAlloc(GetProcessHeap(), 0, size);
+    buffer = HeapAlloc(GetProcessHeap(), 0, size);
     HENHMETAFILE_UserMarshal(&flags, buffer, &hemf);
     wirehemf = buffer;
     ok(*(DWORD *)wirehemf == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehemf);
@@ -239,7 +239,7 @@ static void test_marshal_HMETAFILE(void)
 
     size = HMETAFILE_UserSize(&flags, 0, &hmf);
     ok(size > 20, "size should be at least 20 bytes, not %d\n", size);
-    buffer = (unsigned char *)HeapAlloc(GetProcessHeap(), 0, size);
+    buffer = HeapAlloc(GetProcessHeap(), 0, size);
     HMETAFILE_UserMarshal(&flags, buffer, &hmf);
     wirehmf = buffer;
     ok(*(DWORD *)wirehmf == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehmf);
@@ -266,7 +266,7 @@ static void test_marshal_HMETAFILE(void)
 
     size = HMETAFILE_UserSize(&flags, 0, &hmf);
     ok(size == 8, "size should be 8 bytes, not %d\n", size);
-    buffer = (unsigned char *)HeapAlloc(GetProcessHeap(), 0, size);
+    buffer = HeapAlloc(GetProcessHeap(), 0, size);
     HMETAFILE_UserMarshal(&flags, buffer, &hmf);
     wirehmf = buffer;
     ok(*(DWORD *)wirehmf == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehmf);
@@ -286,7 +286,7 @@ static void test_marshal_HMETAFILE(void)
 
 static void test_marshal_HMETAFILEPICT(void)
 {
-    unsigned char *buffer;
+    unsigned char *buffer, *buffer_end;
     ULONG size;
     ULONG flags = MAKELONG(MSHCTX_DIFFERENTMACHINE, NDR_LOCAL_DATA_REPRESENTATION);
     HMETAFILEPICT hmfp;
@@ -305,8 +305,8 @@ static void test_marshal_HMETAFILEPICT(v
     size = HMETAFILEPICT_UserSize(&flags, 0, &hmfp);
     ok(size > 20, "size should be at least 20 bytes, not %d\n", size);
     trace("size is %d\n", size);
-    buffer = (unsigned char *)HeapAlloc(GetProcessHeap(), 0, size);
-    HMETAFILEPICT_UserMarshal(&flags, buffer, &hmfp);
+    buffer = HeapAlloc(GetProcessHeap(), 0, size);
+    buffer_end = HMETAFILEPICT_UserMarshal(&flags, buffer, &hmfp);
     wirehmfp = buffer;
     ok(*(DWORD *)wirehmfp == WDT_REMOTE_CALL, "wirestgm + 0x0 should be WDT_REMOTE_CALL instead of 0x%08x\n", *(DWORD *)wirehmfp);
     wirehmfp += sizeof(DWORD);
@@ -326,12 +326,12 @@ static void test_marshal_HMETAFILEPICT(v
     ok(*(DWORD *)wirehmfp == (DWORD)(DWORD_PTR)pmfp->hMF, "wirestgm + 0x1c should be pmfp->hMF instead of 0x%08x\n", *(DWORD *)wirehmfp);
     GlobalUnlock(hmfp);
     wirehmfp += sizeof(DWORD);
-    todo_wine {
-    ok(*(DWORD *)wirehmfp == (size - 0x34), "wirestgm + 0x20 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp);
+    /* Note use (buffer_end - buffer) instead of size here, because size is an
+     * overestimate with native */
+    ok(*(DWORD *)wirehmfp == (buffer_end - buffer - 0x28), "wirestgm + 0x20 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp);
     wirehmfp += sizeof(DWORD);
-    ok(*(DWORD *)wirehmfp == (size - 0x34), "wirestgm + 0x24 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp);
+    ok(*(DWORD *)wirehmfp == (buffer_end - buffer - 0x28), "wirestgm + 0x24 should be size - 0x34 instead of 0x%08x\n", *(DWORD *)wirehmfp);
     wirehmfp += sizeof(DWORD);
-    }
     ok(*(WORD *)wirehmfp == 1, "wirehmfp + 0x28 should be 1 instead of 0x%08x\n", *(DWORD *)wirehmfp);
     wirehmfp += sizeof(DWORD);
     /* ... rest of data not tested - refer to tests for GetMetaFileBits




More information about the wine-cvs mailing list