ole32: Add a test showing IStorage_CopyTo ignores open objects in the source.
authorVincent Povirk <vincent@codeweavers.com>
Tue, 2 Mar 2010 22:07:07 +0000 (16:07 -0600)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 3 Mar 2010 10:49:27 +0000 (11:49 +0100)
dlls/ole32/tests/storage32.c

index e598fe00d59258b2781f71ba15a2fc229d12d29d..7cbfd4911c47f6418cbcbc24ece5a710600247d5 100644 (file)
@@ -2720,6 +2720,57 @@ static void test_substorage_enum(void)
     ok( r == TRUE, "deleted file\n");
 }
 
+static void test_copyto_locking(void)
+{
+    IStorage *stg, *stg2, *stg3, *stg4;
+    IStream *stm;
+    HRESULT r;
+    static const WCHAR stgname[] = { 'S','T','G','1',0 };
+    static const WCHAR stgname2[] = { 'S','T','G','2',0 };
+    static const WCHAR stmname[] = { 'C','O','N','T','E','N','T','S',0 };
+
+    DeleteFileA(filenameA);
+
+    /* create the file */
+    r = StgCreateDocfile( filename, STGM_CREATE | STGM_SHARE_EXCLUSIVE |
+                            STGM_READWRITE, 0, &stg);
+    ok(r==S_OK, "StgCreateDocfile failed\n");
+
+    /* create a substorage */
+    r = IStorage_CreateStorage(stg, stgname, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg2);
+    ok(r==S_OK, "IStorage->CreateStorage failed, hr=%08x\n", r);
+
+    /* create another substorage */
+    r = IStorage_CreateStorage(stg, stgname2, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg3);
+    ok(r==S_OK, "IStorage->CreateStorage failed, hr=%08x\n", r);
+
+    /* add a stream, and leave it open */
+    r = IStorage_CreateStream(stg2, stmname, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stm);
+    ok(r==S_OK, "IStorage->CreateStream failed, hr=%08x\n", r);
+
+    /* Try to copy the storage while the stream is open */
+    r = IStorage_CopyTo(stg2, 0, NULL, NULL, stg3);
+    todo_wine ok(r==S_OK, "IStorage->CopyTo failed, hr=%08x\n", r);
+
+    IStream_Release(stm);
+
+    /* create a substorage */
+    r = IStorage_CreateStorage(stg2, stgname, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg4);
+    ok(r==S_OK, "IStorage->CreateStorage failed, hr=%08x\n", r);
+
+    /* Try to copy the storage while the substorage is open */
+    r = IStorage_CopyTo(stg2, 0, NULL, NULL, stg3);
+    todo_wine ok(r==S_OK, "IStorage->CopyTo failed, hr=%08x\n", r);
+
+    IStorage_Release(stg4);
+    IStorage_Release(stg3);
+    IStorage_Release(stg2);
+    IStorage_Release(stg);
+
+    r = DeleteFileA(filenameA);
+    ok( r == TRUE, "deleted file\n");
+}
+
 START_TEST(storage32)
 {
     CHAR temp[MAX_PATH];
@@ -2759,4 +2810,5 @@ START_TEST(storage32)
     test_rename();
     test_toplevel_stat();
     test_substorage_enum();
+    test_copyto_locking();
 }