ole32/tests: Add tests for StgCreatePropStg and StgOpenPropStg.
Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
37097ce95c
commit
6e012b52cd
|
@ -33,6 +33,8 @@ DEFINE_GUID(FMTID_UserDefinedProperties,0xD5CDD505,0x2E9C,0x101B,0x93,0x97,0x08,
|
||||||
static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
|
static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
|
||||||
static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
|
static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
|
||||||
static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
|
static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
|
||||||
|
static HRESULT (WINAPI *pStgCreatePropStg)(IUnknown *, REFFMTID, const CLSID *, DWORD, DWORD, IPropertyStorage **);
|
||||||
|
static HRESULT (WINAPI *pStgOpenPropStg)(IUnknown *, REFFMTID, DWORD, DWORD, IPropertyStorage **);
|
||||||
|
|
||||||
static void init_function_pointers(void)
|
static void init_function_pointers(void)
|
||||||
{
|
{
|
||||||
|
@ -40,20 +42,25 @@ static void init_function_pointers(void)
|
||||||
pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
|
pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
|
||||||
pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
|
pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
|
||||||
pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
|
pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
|
||||||
|
pStgCreatePropStg = (void*)GetProcAddress(hmod, "StgCreatePropStg");
|
||||||
|
pStgOpenPropStg = (void*)GetProcAddress(hmod, "StgOpenPropStg");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: this creates an ANSI storage, try to find conditions under which
|
/* FIXME: this creates an ANSI storage, try to find conditions under which
|
||||||
* Unicode translation fails
|
* Unicode translation fails
|
||||||
*/
|
*/
|
||||||
static void testProps(void)
|
static void testPropsHelper(IPropertySetStorage **propSetStorage)
|
||||||
{
|
{
|
||||||
static const WCHAR szDot[] = { '.',0 };
|
static const WCHAR szDot[] = { '.',0 };
|
||||||
static const WCHAR szPrefix[] = { 's','t','g',0 };
|
static const WCHAR szPrefix[] = { 's','t','g',0 };
|
||||||
|
static const WCHAR szSummaryInfo[] = { 5,'S','u','m','m','a','r','y',
|
||||||
|
'I','n','f','o','r','m','a','t','i','o','n',0 };
|
||||||
static WCHAR propName[] = { 'p','r','o','p',0 };
|
static WCHAR propName[] = { 'p','r','o','p',0 };
|
||||||
static char val[] = "l33t auth0r";
|
static char val[] = "l33t auth0r";
|
||||||
WCHAR filename[MAX_PATH];
|
WCHAR filename[MAX_PATH];
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
IStorage *storage = NULL;
|
IStorage *storage = NULL;
|
||||||
IPropertySetStorage *propSetStorage = NULL;
|
IStream *stream = NULL;
|
||||||
IPropertyStorage *propertyStorage = NULL;
|
IPropertyStorage *propertyStorage = NULL;
|
||||||
PROPSPEC spec;
|
PROPSPEC spec;
|
||||||
PROPVARIANT var;
|
PROPVARIANT var;
|
||||||
|
@ -62,6 +69,11 @@ static void testProps(void)
|
||||||
GUID anyOldGuid = { 0x12345678,0xdead,0xbeef, {
|
GUID anyOldGuid = { 0x12345678,0xdead,0xbeef, {
|
||||||
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07 } };
|
0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07 } };
|
||||||
|
|
||||||
|
if(propSetStorage)
|
||||||
|
trace("Testing property storage with a set...\n");
|
||||||
|
else
|
||||||
|
trace("Testing property storage without a set...\n");
|
||||||
|
|
||||||
if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
|
if(!GetTempFileNameW(szDot, szPrefix, 0, filename))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -71,20 +83,40 @@ static void testProps(void)
|
||||||
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
|
||||||
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
if(!pStgCreatePropSetStg)
|
if(propSetStorage)
|
||||||
{
|
{
|
||||||
IStorage_Release(storage);
|
if(!pStgCreatePropSetStg)
|
||||||
DeleteFileW(filename);
|
{
|
||||||
return;
|
IStorage_Release(storage);
|
||||||
}
|
DeleteFileW(filename);
|
||||||
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
|
return;
|
||||||
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
}
|
||||||
|
hr = pStgCreatePropSetStg(storage, 0, propSetStorage);
|
||||||
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
hr = IPropertySetStorage_Create(propSetStorage,
|
hr = IPropertySetStorage_Create(*propSetStorage,
|
||||||
&FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
|
&FMTID_SummaryInformation, NULL, PROPSETFLAG_ANSI,
|
||||||
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
|
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
|
||||||
&propertyStorage);
|
&propertyStorage);
|
||||||
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = IStorage_CreateStream(storage, szSummaryInfo,
|
||||||
|
STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
|
||||||
|
ok(hr == S_OK, "IStorage_CreateStream failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
|
if(!pStgCreatePropStg)
|
||||||
|
{
|
||||||
|
IStorage_Release(storage);
|
||||||
|
IUnknown_Release(stream);
|
||||||
|
DeleteFileW(filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hr = pStgCreatePropStg((IUnknown *)stream, &FMTID_SummaryInformation,
|
||||||
|
NULL, PROPSETFLAG_ANSI, 0, &propertyStorage);
|
||||||
|
ok(hr == S_OK, "StgCreatePropStg failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
|
||||||
hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
|
hr = IPropertyStorage_WriteMultiple(propertyStorage, 0, NULL, NULL, 0);
|
||||||
ok(hr == S_OK, "WriteMultiple with 0 args failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "WriteMultiple with 0 args failed: 0x%08x\n", hr);
|
||||||
|
@ -252,23 +284,41 @@ static void testProps(void)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
IPropertyStorage_Release(propertyStorage);
|
IPropertyStorage_Release(propertyStorage);
|
||||||
propertyStorage = NULL;
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
||||||
IPropertySetStorage_Release(propSetStorage);
|
|
||||||
propSetStorage = NULL;
|
|
||||||
IStorage_Release(storage);
|
IStorage_Release(storage);
|
||||||
storage = NULL;
|
if(stream) IUnknown_Release(stream);
|
||||||
|
|
||||||
/* now open it again */
|
/* now open it again */
|
||||||
hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
|
hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
|
||||||
NULL, 0, &storage);
|
NULL, 0, &storage);
|
||||||
ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
|
if(propSetStorage)
|
||||||
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
{
|
||||||
|
hr = pStgCreatePropSetStg(storage, 0, propSetStorage);
|
||||||
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation,
|
hr = IPropertySetStorage_Open(*propSetStorage, &FMTID_SummaryInformation,
|
||||||
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
|
||||||
ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = IStorage_OpenStream(storage, szSummaryInfo,
|
||||||
|
0, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
|
||||||
|
ok(hr == S_OK, "IStorage_OpenStream failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
|
if(!pStgOpenPropStg)
|
||||||
|
{
|
||||||
|
IStorage_Release(storage);
|
||||||
|
IUnknown_Release(stream);
|
||||||
|
DeleteFileW(filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
hr = pStgOpenPropStg((IUnknown *)stream, &FMTID_SummaryInformation,
|
||||||
|
PROPSETFLAG_DEFAULT, 0, &propertyStorage);
|
||||||
|
ok(hr == S_OK, "StgOpenPropStg failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
|
||||||
/* check properties again */
|
/* check properties again */
|
||||||
spec.ulKind = PRSPEC_LPWSTR;
|
spec.ulKind = PRSPEC_LPWSTR;
|
||||||
|
@ -288,8 +338,9 @@ static void testProps(void)
|
||||||
PropVariantClear(&var);
|
PropVariantClear(&var);
|
||||||
|
|
||||||
IPropertyStorage_Release(propertyStorage);
|
IPropertyStorage_Release(propertyStorage);
|
||||||
IPropertySetStorage_Release(propSetStorage);
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
||||||
IStorage_Release(storage);
|
IStorage_Release(storage);
|
||||||
|
if(stream) IUnknown_Release(stream);
|
||||||
|
|
||||||
DeleteFileW(filename);
|
DeleteFileW(filename);
|
||||||
|
|
||||||
|
@ -298,20 +349,27 @@ static void testProps(void)
|
||||||
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
|
||||||
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "StgCreateDocfile failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
if(!pStgCreatePropSetStg)
|
if(propSetStorage)
|
||||||
{
|
{
|
||||||
IStorage_Release(storage);
|
hr = pStgCreatePropSetStg(storage, 0, propSetStorage);
|
||||||
DeleteFileW(filename);
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
||||||
return;
|
|
||||||
}
|
|
||||||
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
|
|
||||||
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
|
||||||
|
|
||||||
hr = IPropertySetStorage_Create(propSetStorage,
|
hr = IPropertySetStorage_Create(*propSetStorage,
|
||||||
&anyOldGuid, NULL, PROPSETFLAG_ANSI,
|
&anyOldGuid, NULL, PROPSETFLAG_ANSI,
|
||||||
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
|
STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE,
|
||||||
&propertyStorage);
|
&propertyStorage);
|
||||||
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "IPropertySetStorage_Create failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = IStorage_CreateStream(storage, szSummaryInfo,
|
||||||
|
STGM_CREATE | STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &stream);
|
||||||
|
ok(hr == S_OK, "IStorage_CreateStream failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = pStgCreatePropStg((IUnknown *)stream, &anyOldGuid, NULL,
|
||||||
|
PROPSETFLAG_DEFAULT, 0, &propertyStorage);
|
||||||
|
ok(hr == S_OK, "StgCreatePropStg failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
|
||||||
spec.ulKind = PRSPEC_PROPID;
|
spec.ulKind = PRSPEC_PROPID;
|
||||||
U(spec).propid = PID_FIRST_USABLE;
|
U(spec).propid = PID_FIRST_USABLE;
|
||||||
|
@ -324,21 +382,34 @@ static void testProps(void)
|
||||||
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "Commit failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
IPropertyStorage_Release(propertyStorage);
|
IPropertyStorage_Release(propertyStorage);
|
||||||
IPropertySetStorage_Release(propSetStorage);
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
||||||
IStorage_Release(storage);
|
IStorage_Release(storage);
|
||||||
propertyStorage = NULL;
|
if(stream) IUnknown_Release(stream);
|
||||||
|
|
||||||
/* now open it again */
|
/* now open it again */
|
||||||
hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
|
hr = StgOpenStorage(filename, NULL, STGM_READWRITE | STGM_SHARE_EXCLUSIVE,
|
||||||
NULL, 0, &storage);
|
NULL, 0, &storage);
|
||||||
ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "StgOpenStorage failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
|
if(propSetStorage)
|
||||||
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
{
|
||||||
|
hr = pStgCreatePropSetStg(storage, 0, propSetStorage);
|
||||||
|
ok(hr == S_OK, "StgCreatePropSetStg failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
hr = IPropertySetStorage_Open(propSetStorage, &anyOldGuid,
|
hr = IPropertySetStorage_Open(*propSetStorage, &anyOldGuid,
|
||||||
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
|
STGM_READWRITE | STGM_SHARE_EXCLUSIVE, &propertyStorage);
|
||||||
ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
|
ok(hr == S_OK, "IPropertySetStorage_Open failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hr = IStorage_OpenStream(storage, szSummaryInfo,
|
||||||
|
0, STGM_READWRITE | STGM_SHARE_EXCLUSIVE, 0, &stream);
|
||||||
|
ok(hr == S_OK, "IStorage_OpenStream failed: 0x%08x\n", hr);
|
||||||
|
|
||||||
|
hr = pStgOpenPropStg((IUnknown *)stream, &anyOldGuid,
|
||||||
|
PROPSETFLAG_DEFAULT, 0, &propertyStorage);
|
||||||
|
ok(hr == S_OK, "StgOpenPropStg failed: 0x%08x\n", hr);
|
||||||
|
}
|
||||||
|
|
||||||
spec.ulKind = PRSPEC_PROPID;
|
spec.ulKind = PRSPEC_PROPID;
|
||||||
U(spec).propid = PID_FIRST_USABLE;
|
U(spec).propid = PID_FIRST_USABLE;
|
||||||
|
@ -350,12 +421,21 @@ static void testProps(void)
|
||||||
var.vt, U(var).lVal);
|
var.vt, U(var).lVal);
|
||||||
|
|
||||||
IPropertyStorage_Release(propertyStorage);
|
IPropertyStorage_Release(propertyStorage);
|
||||||
IPropertySetStorage_Release(propSetStorage);
|
if(propSetStorage) IPropertySetStorage_Release(*propSetStorage);
|
||||||
IStorage_Release(storage);
|
IStorage_Release(storage);
|
||||||
|
if(stream) IUnknown_Release(stream);
|
||||||
|
|
||||||
DeleteFileW(filename);
|
DeleteFileW(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void testProps(void)
|
||||||
|
{
|
||||||
|
IPropertySetStorage *propSetStorage = NULL;
|
||||||
|
|
||||||
|
testPropsHelper(&propSetStorage);
|
||||||
|
testPropsHelper(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void testCodepage(void)
|
static void testCodepage(void)
|
||||||
{
|
{
|
||||||
static const WCHAR szDot[] = { '.',0 };
|
static const WCHAR szDot[] = { '.',0 };
|
||||||
|
|
Loading…
Reference in New Issue