ole32: Add test for freeing the parent of a storage.

This commit is contained in:
Vincent Povirk 2009-11-19 13:13:57 -06:00 committed by Alexandre Julliard
parent 9d9070ae3c
commit 3cd2a80eda
1 changed files with 20 additions and 2 deletions

View File

@ -1290,12 +1290,13 @@ static void test_revert(void)
static void test_parent_free(void) static void test_parent_free(void)
{ {
IStorage *stg = NULL, *stg2 = NULL; IStorage *stg = NULL, *stg2 = NULL, *stg3 = NULL;
HRESULT r; HRESULT r;
IStream *stm = NULL; IStream *stm = NULL;
static const WCHAR stmname[] = { 'C','O','N','T','E','N','T','S',0 }; static const WCHAR stmname[] = { 'C','O','N','T','E','N','T','S',0 };
static const WCHAR stgname[] = { 'P','E','R','M','S','T','G',0 }; static const WCHAR stgname[] = { 'P','E','R','M','S','T','G',0 };
ULONG ref; ULONG ref;
STATSTG statstg;
DeleteFileA(filenameA); DeleteFileA(filenameA);
@ -1304,7 +1305,7 @@ static void test_parent_free(void)
STGM_READWRITE |STGM_TRANSACTED, 0, &stg); STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
ok(r==S_OK, "StgCreateDocfile failed\n"); ok(r==S_OK, "StgCreateDocfile failed\n");
/* commit a new storage */ /* create a new storage */
r = IStorage_CreateStorage(stg, stgname, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg2); r = IStorage_CreateStorage(stg, stgname, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stg2);
ok(r==S_OK, "IStorage->CreateStorage failed, hr=%08x\n", r); ok(r==S_OK, "IStorage->CreateStorage failed, hr=%08x\n", r);
@ -1314,15 +1315,32 @@ static void test_parent_free(void)
r = IStorage_CreateStream(stg2, stmname, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm ); r = IStorage_CreateStream(stg2, stmname, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stm );
ok(r==S_OK, "IStorage->CreateStream failed\n"); ok(r==S_OK, "IStorage->CreateStream failed\n");
if (r == S_OK)
{
/* create a storage inside the new storage */
r = IStorage_CreateStorage(stg2, stgname, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, 0, &stg3 );
ok(r==S_OK, "IStorage->CreateStorage failed\n");
}
/* free the parent */
ref = IStorage_Release(stg2); ref = IStorage_Release(stg2);
ok(ref == 0, "IStorage still has %u references\n", ref); ok(ref == 0, "IStorage still has %u references\n", ref);
/* child objects are invalid */
if (r == S_OK) if (r == S_OK)
{ {
r = IStream_Write(stm, "this should fail\n", 17, NULL); r = IStream_Write(stm, "this should fail\n", 17, NULL);
ok(r==STG_E_REVERTED, "IStream->Write sould fail, hr=%x\n", r); ok(r==STG_E_REVERTED, "IStream->Write sould fail, hr=%x\n", r);
IStream_Release(stm); IStream_Release(stm);
r = IStorage_Stat(stg3, &statstg, STATFLAG_NONAME);
todo_wine ok(r==STG_E_REVERTED, "IStorage_Stat should fail %08x\n", r);
r = IStorage_SetStateBits(stg3, 1, 1);
todo_wine ok(r==STG_E_REVERTED, "IStorage_Stat should fail %08x\n", r);
IStorage_Release(stg3);
} }
} }