Commit 950d678c authored by Stefan Leichter's avatar Stefan Leichter Committed by Alexandre Julliard

Make ole32 tests loadable on NT4.

parent 569db3c8
...@@ -26,6 +26,21 @@ ...@@ -26,6 +26,21 @@
# define U(x) (x) # define U(x) (x)
#endif #endif
static HRESULT (WINAPI *pFmtIdToPropStgName)(const FMTID *, LPOLESTR);
static HRESULT (WINAPI *pPropStgNameToFmtId)(const LPOLESTR, FMTID *);
static HRESULT (WINAPI *pStgCreatePropSetStg)(IStorage *, DWORD, IPropertySetStorage **);
static void init_function_pointers(void)
{
HMODULE hmod = GetModuleHandleA("ole32.dll");
if(hmod)
{
pFmtIdToPropStgName = (void*)GetProcAddress(hmod, "FmtIdToPropStgName");
pPropStgNameToFmtId = (void*)GetProcAddress(hmod, "PropStgNameToFmtId");
pStgCreatePropSetStg = (void*)GetProcAddress(hmod, "StgCreatePropSetStg");
}
}
/* 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
*/ */
...@@ -52,7 +67,8 @@ static void testProps(void) ...@@ -52,7 +67,8 @@ static void testProps(void)
STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage); STGM_READWRITE | STGM_SHARE_EXCLUSIVE | STGM_CREATE, 0, &storage);
ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "StgCreateDocfile failed: 0x%08lx\n", hr);
hr = StgCreatePropSetStg(storage, 0, &propSetStorage); if(!pStgCreatePropSetStg) return;
hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
hr = IPropertySetStorage_Create(propSetStorage, hr = IPropertySetStorage_Create(propSetStorage,
...@@ -214,7 +230,7 @@ static void testProps(void) ...@@ -214,7 +230,7 @@ static void testProps(void)
NULL, 0, &storage); NULL, 0, &storage);
ok(SUCCEEDED(hr), "StgOpenStorage failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "StgOpenStorage failed: 0x%08lx\n", hr);
hr = StgCreatePropSetStg(storage, 0, &propSetStorage); hr = pStgCreatePropSetStg(storage, 0, &propSetStorage);
ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "StgCreatePropSetStg failed: 0x%08lx\n", hr);
hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation, hr = IPropertySetStorage_Open(propSetStorage, &FMTID_SummaryInformation,
...@@ -258,63 +274,68 @@ static void testFmtId(void) ...@@ -258,63 +274,68 @@ static void testFmtId(void)
FMTID fmtid; FMTID fmtid;
HRESULT hr; HRESULT hr;
hr = FmtIdToPropStgName(NULL, name); if (pFmtIdToPropStgName) {
hr = pFmtIdToPropStgName(NULL, name);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = FmtIdToPropStgName(&FMTID_SummaryInformation, NULL); hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = FmtIdToPropStgName(&FMTID_SummaryInformation, name); hr = pFmtIdToPropStgName(&FMTID_SummaryInformation, name);
ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) * ok(!memcmp(name, szSummaryInfo, (lstrlenW(szSummaryInfo) + 1) *
sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n"); sizeof(WCHAR)), "Got wrong name for FMTID_SummaryInformation\n");
hr = FmtIdToPropStgName(&FMTID_DocSummaryInformation, name); hr = pFmtIdToPropStgName(&FMTID_DocSummaryInformation, name);
ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) * ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n"); sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
hr = FmtIdToPropStgName(&FMTID_UserDefinedProperties, name); hr = pFmtIdToPropStgName(&FMTID_UserDefinedProperties, name);
ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) * ok(!memcmp(name, szDocSummaryInfo, (lstrlenW(szDocSummaryInfo) + 1) *
sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n"); sizeof(WCHAR)), "Got wrong name for FMTID_DocSummaryInformation\n");
hr = FmtIdToPropStgName(&IID_IPropertySetStorage, name); hr = pFmtIdToPropStgName(&IID_IPropertySetStorage, name);
ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "FmtIdToPropStgName failed: 0x%08lx\n", hr);
ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) * ok(!memcmp(name, szIID_IPropSetStg, (lstrlenW(szIID_IPropSetStg) + 1) *
sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n"); sizeof(WCHAR)), "Got wrong name for IID_IPropertySetStorage\n");
}
if(pPropStgNameToFmtId) {
/* test args first */ /* test args first */
hr = PropStgNameToFmtId(NULL, NULL); hr = pPropStgNameToFmtId(NULL, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = PropStgNameToFmtId(NULL, &fmtid); hr = pPropStgNameToFmtId(NULL, &fmtid);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
hr = PropStgNameToFmtId(szDocSummaryInfo, NULL); hr = pPropStgNameToFmtId(szDocSummaryInfo, NULL);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr); ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got 0x%08lx\n", hr);
/* test the known format IDs */ /* test the known format IDs */
hr = PropStgNameToFmtId(szSummaryInfo, &fmtid); hr = pPropStgNameToFmtId(szSummaryInfo, &fmtid);
ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)), ok(!memcmp(&fmtid, &FMTID_SummaryInformation, sizeof(fmtid)),
"Got unexpected FMTID, expected FMTID_SummaryInformation\n"); "Got unexpected FMTID, expected FMTID_SummaryInformation\n");
hr = PropStgNameToFmtId(szDocSummaryInfo, &fmtid); hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)), ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
"Got unexpected FMTID, expected FMTID_DocSummaryInformation\n"); "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
/* test another GUID */ /* test another GUID */
hr = PropStgNameToFmtId(szIID_IPropSetStg, &fmtid); hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)), ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
"Got unexpected FMTID, expected IID_IPropertySetStorage\n"); "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
/* now check case matching */ /* now check case matching */
CharUpperW(szDocSummaryInfo + 1); CharUpperW(szDocSummaryInfo + 1);
hr = PropStgNameToFmtId(szDocSummaryInfo, &fmtid); hr = pPropStgNameToFmtId(szDocSummaryInfo, &fmtid);
ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)), ok(!memcmp(&fmtid, &FMTID_DocSummaryInformation, sizeof(fmtid)),
"Got unexpected FMTID, expected FMTID_DocSummaryInformation\n"); "Got unexpected FMTID, expected FMTID_DocSummaryInformation\n");
CharUpperW(szIID_IPropSetStg + 1); CharUpperW(szIID_IPropSetStg + 1);
hr = PropStgNameToFmtId(szIID_IPropSetStg, &fmtid); hr = pPropStgNameToFmtId(szIID_IPropSetStg, &fmtid);
ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr); ok(SUCCEEDED(hr), "PropStgNameToFmtId failed: 0x%08lx\n", hr);
ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)), ok(!memcmp(&fmtid, &IID_IPropertySetStorage, sizeof(fmtid)),
"Got unexpected FMTID, expected IID_IPropertySetStorage\n"); "Got unexpected FMTID, expected IID_IPropertySetStorage\n");
} }
}
START_TEST(stg_prop) START_TEST(stg_prop)
{ {
init_function_pointers();
testProps(); testProps();
testFmtId(); testFmtId();
} }
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