Commit a6a91a44 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Implement and test IPropertySetStorage.

parent 2f254604
......@@ -34,6 +34,7 @@ C_SRCS = \
regsvr.c \
rpc.c \
stg_bigblockfile.c \
stg_prop.c \
stg_stream.c \
storage32.c \
stubmanager.c
......
......@@ -222,7 +222,7 @@ static IEnumSTATSTGVtbl IEnumSTATSTGImpl_Vtbl =
IEnumSTATSTGImpl_Clone
};
extern IPropertySetStorageVtbl IPropertySetStorage_Vtbl;
......@@ -266,6 +266,10 @@ HRESULT WINAPI StorageBaseImpl_QueryInterface(
{
*ppvObject = (IStorage*)This;
}
else if (memcmp(&IID_IPropertySetStorage, riid, sizeof(IID_IPropertySetStorage)) == 0)
{
*ppvObject = (IStorage*)&This->pssVtbl;
}
/*
* Check that we obtained an interface.
......@@ -2214,6 +2218,7 @@ HRESULT StorageImpl_Construct(
* Initialize the virtual function table.
*/
This->lpVtbl = &Storage32Impl_Vtbl;
This->pssVtbl = &IPropertySetStorage_Vtbl;
This->v_destructor = &StorageImpl_Destroy;
/*
......
......@@ -207,6 +207,8 @@ struct StorageBaseImpl
IStorageVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this in a Storage32 pointer */
IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
/*
* Reference count of this object
*/
......@@ -301,6 +303,8 @@ struct StorageImpl
IStorageVtbl *lpVtbl; /* Needs to be the first item in the struct
* since we want to cast this in a Storage32 pointer */
IPropertySetStorageVtbl *pssVtbl; /* interface for adding a properties stream */
/*
* Declare the member of the Storage32BaseImpl class to allow
* casting as a Storage32BaseImpl
......
......@@ -309,10 +309,126 @@ void test_open_storage(void)
ok(r, "file didn't exist\n");
}
void test_storage_suminfo(void)
{
static const WCHAR szDot[] = { '.',0 };
static const WCHAR szPrefix[] = { 's','t','g',0 };
WCHAR filename[MAX_PATH];
IStorage *stg = NULL;
IPropertySetStorage *propset = NULL;
IPropertyStorage *ps = NULL;
HRESULT r;
if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
return;
DeleteFileW(filename);
/* create the file */
r = StgCreateDocfile( filename, STGM_CREATE | STGM_SHARE_EXCLUSIVE |
STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
ok(r==S_OK, "StgCreateDocfile failed\n");
r = IStorage_QueryInterface( stg, &IID_IPropertySetStorage, (LPVOID) &propset );
ok(r == S_OK, "query interface failed\n");
/* delete it */
r = IPropertySetStorage_Delete( propset, &FMTID_SummaryInformation );
ok(r == STG_E_FILENOTFOUND, "deleted property set storage\n");
r = IPropertySetStorage_Open( propset, &FMTID_SummaryInformation,
STGM_READ | STGM_SHARE_EXCLUSIVE, &ps );
ok(r == STG_E_FILENOTFOUND, "opened property set storage\n");
r = IPropertySetStorage_Create( propset, &FMTID_SummaryInformation, NULL, 0,
STGM_READ | STGM_SHARE_EXCLUSIVE, &ps );
ok(r == STG_E_INVALIDFLAG, "created property set storage\n");
r = IPropertySetStorage_Create( propset, &FMTID_SummaryInformation, NULL, 0,
STGM_READ, &ps );
ok(r == STG_E_INVALIDFLAG, "created property set storage\n");
r = IPropertySetStorage_Create( propset, &FMTID_SummaryInformation, NULL, 0, 0, &ps );
ok(r == STG_E_INVALIDFLAG, "created property set storage\n");
r = IPropertySetStorage_Create( propset, &FMTID_SummaryInformation, NULL, 0,
STGM_WRITE|STGM_SHARE_EXCLUSIVE, &ps );
ok(r == STG_E_INVALIDFLAG, "created property set storage\n");
r = IPropertySetStorage_Create( propset, &FMTID_SummaryInformation, NULL, 0,
STGM_CREATE|STGM_WRITE|STGM_SHARE_EXCLUSIVE, &ps );
ok(r == STG_E_INVALIDFLAG, "created property set storage\n");
/* now try really creating a a property set */
r = IPropertySetStorage_Create( propset, &FMTID_SummaryInformation, NULL, 0,
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &ps );
ok(r == S_OK, "failed to create property set storage\n");
if( ps )
IPropertyStorage_Release(ps);
/* now try creating the same thing again */
r = IPropertySetStorage_Create( propset, &FMTID_SummaryInformation, NULL, 0,
STGM_CREATE|STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &ps );
ok(r == S_OK, "failed to create property set storage\n");
if( ps )
IPropertyStorage_Release(ps);
/* should be able to open it */
r = IPropertySetStorage_Open( propset, &FMTID_SummaryInformation,
STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &ps);
ok(r == S_OK, "open failed\n");
if(r == S_OK)
IPropertyStorage_Release(ps);
/* delete it */
r = IPropertySetStorage_Delete( propset, &FMTID_SummaryInformation );
ok(r == S_OK, "failed to delete property set storage\n");
/* try opening with an invalid FMTID */
r = IPropertySetStorage_Open( propset, NULL,
STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &ps);
ok(r == E_INVALIDARG, "open succeeded\n");
if(r == S_OK)
IPropertyStorage_Release(ps);
/* try a bad guid */
r = IPropertySetStorage_Open( propset, &IID_IStorage,
STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &ps);
ok(r == STG_E_FILENOTFOUND, "open succeeded\n");
if(r == S_OK)
IPropertyStorage_Release(ps);
/* try some invalid flags */
r = IPropertySetStorage_Open( propset, &FMTID_SummaryInformation,
STGM_CREATE | STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &ps);
ok(r == STG_E_INVALIDFLAG, "open succeeded\n");
if(r == S_OK)
IPropertyStorage_Release(ps);
/* after deleting it, it should be gone */
r = IPropertySetStorage_Open( propset, &FMTID_SummaryInformation,
STGM_READWRITE|STGM_SHARE_EXCLUSIVE, &ps);
ok(r == STG_E_FILENOTFOUND, "open failed\n");
if(r == S_OK)
IPropertyStorage_Release(ps);
printf("r = %08lx\n",r);
r = IPropertySetStorage_Release( propset );
ok(r == 1, "ref count wrong\n");
r = IStorage_Release(stg);
ok(r == 0, "ref count wrong\n");
DeleteFileW(filename);
}
START_TEST(storage32)
{
test_hglobal_storage_stat();
test_create_storage_modes();
test_storage_stream();
test_open_storage();
test_storage_suminfo();
}
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