Dmitry Timoshkov : ole32/tests: Add more tests for custom ILockBytes implementation.

Alexandre Julliard julliard at winehq.org
Fri Apr 2 16:10:11 CDT 2021


Module: wine
Branch: master
Commit: 6fdbec0890d34e2e98a811d8aa42031b0a6677ad
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=6fdbec0890d34e2e98a811d8aa42031b0a6677ad

Author: Dmitry Timoshkov <dmitry at baikal.ru>
Date:   Wed Mar 31 10:45:33 2021 +0300

ole32/tests: Add more tests for custom ILockBytes implementation.

Signed-off-by: Dmitry Timoshkov <dmitry at baikal.ru>
Signed-off-by: Esme Povirk <esme at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ole32/tests/storage32.c | 25 +++++++++++++++++++++++--
 1 file changed, 23 insertions(+), 2 deletions(-)

diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index eea78c6d3fe..44ff3a07a21 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -241,6 +241,9 @@ static void CreateTestLockBytes(TestLockBytes **This)
     {
         (*This)->ILockBytes_iface.lpVtbl = &TestLockBytes_Vtbl;
         (*This)->ref = 1;
+        (*This)->size = 0;
+        (*This)->buffer_size = 1024;
+        (*This)->contents = HeapAlloc(GetProcessHeap(), 0, (*This)->buffer_size);
     }
 }
 
@@ -3872,9 +3875,16 @@ static void test_custom_lockbytes(void)
     hr = IStorage_CreateStream(stg, stmname, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, 0, &stm);
     ok(hr==S_OK, "IStorage_CreateStream failed %x\n", hr);
 
+    IStream_Write(stm, "Hello World!", 12, NULL);
     IStream_Release(stm);
 
+    memset(lockbytes->contents, 0, lockbytes->buffer_size);
+
     hr = IStorage_Commit(stg, 0);
+    ok(hr==S_OK, "IStorage_Commit failed %x\n", hr);
+
+todo_wine
+    ok(*(DWORD *)lockbytes->contents == 0xe011cfd0, "contents: %08x\n", *(DWORD *)lockbytes->contents);
 
     IStorage_Release(stg);
 
@@ -3888,14 +3898,25 @@ static void test_custom_lockbytes(void)
     hr = IStorage_CreateStream(stg, stmname, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, 0, &stm);
     ok(hr==S_OK, "IStorage_CreateStream failed %x\n", hr);
 
+    IStream_Write(stm, "Hello World!", 12, NULL);
     IStream_Release(stm);
 
     hr = IStorage_Commit(stg, 0);
-
-    IStorage_Release(stg);
+    ok(hr==S_OK, "IStorage_Commit failed %x\n", hr);
 
     ok(lockbytes->lock_called, "expected LockRegion to be called\n");
 
+    ok(*(DWORD *)lockbytes->contents == 0xe011cfd0, "contents: %08x\n", *(DWORD *)lockbytes->contents);
+
+    memset(lockbytes->contents, 0, lockbytes->buffer_size);
+
+    hr = IStorage_Commit(stg, 0);
+    ok(hr==STG_E_INVALIDHEADER, "IStorage_Commit should fail: %x\n", hr);
+
+    ok(*(DWORD *)lockbytes->contents == 0, "contents: %08x\n", *(DWORD *)lockbytes->contents);
+
+    IStorage_Release(stg);
+
     lockbytes->lock_hr = STG_E_INVALIDFUNCTION;
 
     hr = StgCreateDocfileOnILockBytes(&lockbytes->ILockBytes_iface, STGM_CREATE|STGM_READWRITE|STGM_TRANSACTED, 0, &stg);




More information about the wine-cvs mailing list