Commit de388bbe authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

oleaut32/tests: Remove some workarounds for functions that are assumed to be available.

parent 8ab39efe
......@@ -46,11 +46,9 @@
static HMODULE hOleaut32;
static HRESULT (WINAPI *pSafeArrayAllocDescriptorEx)(VARTYPE,UINT,SAFEARRAY**);
static HRESULT (WINAPI *pSafeArrayCopyData)(SAFEARRAY*,SAFEARRAY*);
static HRESULT (WINAPI *pSafeArrayGetVartype)(SAFEARRAY*,VARTYPE*);
static HRESULT (WINAPI *pSafeArrayGetRecordInfo)(SAFEARRAY*,IRecordInfo**);
static SAFEARRAY* (WINAPI *pSafeArrayCreateEx)(VARTYPE,UINT,SAFEARRAYBOUND*,LPVOID);
static SAFEARRAY* (WINAPI *pSafeArrayCreateVector)(VARTYPE,LONG,ULONG);
#define GETPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func)
......@@ -616,13 +614,11 @@ static void test_safearray(void)
ok(broken(vt == VT_UNKNOWN) || vt == vttypes[i].vt, "SAGVT of array with vt %d returned %d\n", vttypes[i].vt, vt);
}
if (pSafeArrayCopyData) {
hres = pSafeArrayCopyData(a, c);
ok(hres == S_OK, "failed to copy safearray data of vt %d with hres %x\n", vttypes[i].vt, hres);
hres = SafeArrayCopyData(a, c);
ok(hres == S_OK, "failed to copy safearray data of vt %d with hres %x\n", vttypes[i].vt, hres);
hres = SafeArrayDestroyData(c);
ok(hres == S_OK,"SADD of copy of array with vt %d failed with hres %x\n", vttypes[i].vt, hres);
}
hres = SafeArrayDestroyData(c);
ok(hres == S_OK,"SADD of copy of array with vt %d failed with hres %x\n", vttypes[i].vt, hres);
hres = SafeArrayDestroy(c);
ok(hres == S_OK,"SAD failed with hres %x\n", hres);
......@@ -939,12 +935,7 @@ static void test_VectorCreateLockDestroy(void)
VARTYPE vt;
int element;
if (!pSafeArrayCreateVector)
{
win_skip("SafeArrayCreateVector not supported\n");
return;
}
sa = pSafeArrayCreateVector(VT_UI1, 0, 0);
sa = SafeArrayCreateVector(VT_UI1, 0, 0);
ok(sa != NULL, "SACV with 0 elements failed.\n");
hres = SafeArrayDestroy(sa);
......@@ -957,7 +948,7 @@ static void test_VectorCreateLockDestroy(void)
{
DWORD dwLen = SAFEARRAY_GetVTSize(vt);
sa = pSafeArrayCreateVector(vt, 0, element);
sa = SafeArrayCreateVector(vt, 0, element);
if (dwLen)
ok(sa != NULL, "VARTYPE %d (@%d elements) failed\n", vt, element);
......@@ -1040,10 +1031,10 @@ test_LockUnlock_Vector:
ok(hres == S_OK, "got 0x%08x\n", hres);
}
if (bVector == FALSE && pSafeArrayCreateVector)
if (bVector == FALSE)
{
/* Test again with a vector */
sa = pSafeArrayCreateVector(VT_UI1, 0, 100);
sa = SafeArrayCreateVector(VT_UI1, 0, 100);
bVector = TRUE;
goto test_LockUnlock_Vector;
}
......@@ -1376,12 +1367,6 @@ static void test_SafeArrayCopyData(void)
HRESULT hres;
int dimension, size = 1, i;
if (!pSafeArrayCopyData)
{
win_skip("SafeArrayCopyData not supported\n");
return;
}
for (dimension = 0; dimension < ARRAY_SIZE(sab); dimension++)
{
sab[dimension].lLbound = dimension * 2 + 2;
......@@ -1406,7 +1391,7 @@ static void test_SafeArrayCopyData(void)
data[dimension] = dimension;
}
hres = pSafeArrayCopyData(sa, sacopy);
hres = SafeArrayCopyData(sa, sacopy);
ok(hres == S_OK, "copy data failed hres 0x%x\n", hres);
if (hres == S_OK)
{
......@@ -1414,33 +1399,33 @@ static void test_SafeArrayCopyData(void)
}
/* Failure cases */
hres = pSafeArrayCopyData(NULL, sacopy);
hres = SafeArrayCopyData(NULL, sacopy);
ok(hres == E_INVALIDARG, "Null copy source hres 0x%x\n", hres);
hres = pSafeArrayCopyData(sa, NULL);
hres = SafeArrayCopyData(sa, NULL);
ok(hres == E_INVALIDARG, "Null copy hres 0x%x\n", hres);
sacopy->rgsabound[0].cElements += 1;
hres = pSafeArrayCopyData(sa, sacopy);
hres = SafeArrayCopyData(sa, sacopy);
ok(hres == E_INVALIDARG, "Bigger copy first dimension hres 0x%x\n", hres);
sacopy->rgsabound[0].cElements -= 2;
hres = pSafeArrayCopyData(sa, sacopy);
hres = SafeArrayCopyData(sa, sacopy);
ok(hres == E_INVALIDARG, "Smaller copy first dimension hres 0x%x\n", hres);
sacopy->rgsabound[0].cElements += 1;
sacopy->rgsabound[3].cElements += 1;
hres = pSafeArrayCopyData(sa, sacopy);
hres = SafeArrayCopyData(sa, sacopy);
ok(hres == E_INVALIDARG, "Bigger copy last dimension hres 0x%x\n", hres);
sacopy->rgsabound[3].cElements -= 2;
hres = pSafeArrayCopyData(sa, sacopy);
hres = SafeArrayCopyData(sa, sacopy);
ok(hres == E_INVALIDARG, "Smaller copy last dimension hres 0x%x\n", hres);
sacopy->rgsabound[3].cElements += 1;
hres = SafeArrayDestroy(sacopy);
ok(hres == S_OK, "got 0x%08x\n", hres);
sacopy = NULL;
hres = pSafeArrayCopyData(sa, sacopy);
hres = SafeArrayCopyData(sa, sacopy);
ok(hres == E_INVALIDARG, "->Null copy hres 0x%x\n", hres);
hres = SafeArrayCopy(sa, &sacopy);
......@@ -1828,32 +1813,30 @@ static void test_SafeArrayChangeTypeEx(void)
/* VT_VECTOR|VT_UI1 -> VT_BSTR */
hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
if (pSafeArrayCreateVector)
{
sa = pSafeArrayCreateVector(VT_UI1, 0, strlen(szHello)+1);
ok(sa != NULL, "CreateVector() failed.\n");
if (!sa)
return;
memcpy(sa->pvData, szHello, strlen(szHello)+1);
V_VT(&v) = VT_VECTOR|VT_UI1;
V_ARRAY(&v) = sa;
VariantInit(&v2);
sa = SafeArrayCreateVector(VT_UI1, 0, strlen(szHello)+1);
ok(sa != NULL, "CreateVector() failed.\n");
if (!sa)
return;
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_BSTR);
ok(hres == DISP_E_BADVARTYPE, "CTE VT_VECTOR|VT_UI1 returned %x\n", hres);
memcpy(sa->pvData, szHello, strlen(szHello)+1);
V_VT(&v) = VT_VECTOR|VT_UI1;
V_ARRAY(&v) = sa;
VariantInit(&v2);
/* (vector)VT_ARRAY|VT_UI1 -> VT_BSTR (In place) */
V_VT(&v) = VT_ARRAY|VT_UI1;
hres = VariantChangeTypeEx(&v, &v, 0, 0, VT_BSTR);
ok(hres == S_OK, "CTE VT_ARRAY|VT_UI1 -> VT_BSTR failed with %x\n", hres);
if (hres == S_OK)
{
ok(V_VT(&v) == VT_BSTR, "CTE VT_ARRAY|VT_UI1 -> VT_BSTR did not return VT_BSTR, but %d.\n",V_VT(&v));
ok(strcmp((char*)V_BSTR(&v),szHello) == 0,"Expected string '%s', got '%s'\n", szHello,
(char*)V_BSTR(&v));
VariantClear(&v);
}
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_BSTR);
ok(hres == DISP_E_BADVARTYPE, "CTE VT_VECTOR|VT_UI1 returned %x\n", hres);
/* (vector)VT_ARRAY|VT_UI1 -> VT_BSTR (In place) */
V_VT(&v) = VT_ARRAY|VT_UI1;
hres = VariantChangeTypeEx(&v, &v, 0, 0, VT_BSTR);
ok(hres == S_OK, "CTE VT_ARRAY|VT_UI1 -> VT_BSTR failed with %x\n", hres);
if (hres == S_OK)
{
ok(V_VT(&v) == VT_BSTR, "CTE VT_ARRAY|VT_UI1 -> VT_BSTR did not return VT_BSTR, but %d.\n",V_VT(&v));
ok(strcmp((char*)V_BSTR(&v),szHello) == 0,"Expected string '%s', got '%s'\n", szHello,
(char*)V_BSTR(&v));
VariantClear(&v);
}
/* To/from BSTR only works with arrays of VT_UI1 */
......@@ -1889,33 +1872,30 @@ static void test_SafeArrayChangeTypeEx(void)
/* Can't change an array of one type into array of another type , even
* if the other type is the same size
*/
if (pSafeArrayCreateVector)
{
sa = pSafeArrayCreateVector(VT_UI1, 0, 1);
ok(sa != NULL, "CreateVector() failed.\n");
if (!sa)
return;
sa = SafeArrayCreateVector(VT_UI1, 0, 1);
ok(sa != NULL, "CreateVector() failed.\n");
if (!sa)
return;
V_VT(&v) = VT_ARRAY|VT_UI1;
V_ARRAY(&v) = sa;
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_ARRAY|VT_I1);
ok(hres == DISP_E_TYPEMISMATCH, "CTE VT_ARRAY|VT_UI1->VT_ARRAY|VT_I1 returned %x\n", hres);
V_VT(&v) = VT_ARRAY|VT_UI1;
V_ARRAY(&v) = sa;
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_ARRAY|VT_I1);
ok(hres == DISP_E_TYPEMISMATCH, "CTE VT_ARRAY|VT_UI1->VT_ARRAY|VT_I1 returned %x\n", hres);
/* But can change to the same array type */
hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
sa = pSafeArrayCreateVector(VT_UI1, 0, 1);
ok(sa != NULL, "CreateVector() failed.\n");
if (!sa)
return;
V_VT(&v) = VT_ARRAY|VT_UI1;
V_ARRAY(&v) = sa;
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_ARRAY|VT_UI1);
ok(hres == S_OK, "CTE VT_ARRAY|VT_UI1->VT_ARRAY|VT_UI1 returned %x\n", hres);
hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
VariantClear(&v2);
}
/* But can change to the same array type */
hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
sa = SafeArrayCreateVector(VT_UI1, 0, 1);
ok(sa != NULL, "CreateVector() failed.\n");
if (!sa)
return;
V_VT(&v) = VT_ARRAY|VT_UI1;
V_ARRAY(&v) = sa;
hres = VariantChangeTypeEx(&v2, &v, 0, 0, VT_ARRAY|VT_UI1);
ok(hres == S_OK, "CTE VT_ARRAY|VT_UI1->VT_ARRAY|VT_UI1 returned %x\n", hres);
hres = SafeArrayDestroy(sa);
ok(hres == S_OK, "got 0x%08x\n", hres);
VariantClear(&v2);
/* NULL/EMPTY */
MKARRAY(0,1,VT_UI1);
......@@ -2090,10 +2070,8 @@ START_TEST(safearray)
has_i8 = GetProcAddress(hOleaut32, "VarI8FromI1") != NULL;
GETPTR(SafeArrayAllocDescriptorEx);
GETPTR(SafeArrayCopyData);
GETPTR(SafeArrayGetVartype);
GETPTR(SafeArrayCreateEx);
GETPTR(SafeArrayCreateVector);
GETPTR(SafeArrayGetRecordInfo);
check_for_VT_INT_PTR();
......
......@@ -36,9 +36,7 @@
# define V_U2(A) (*(A))
#endif
static HRESULT (WINAPI *pSafeArrayGetIID)(SAFEARRAY*,GUID*);
static HRESULT (WINAPI *pSafeArrayGetVartype)(SAFEARRAY*,VARTYPE*);
static HRESULT (WINAPI *pVarBstrCmp)(BSTR,BSTR,LCID,ULONG);
static inline SF_TYPE get_union_type(SAFEARRAY *psa)
{
......@@ -133,7 +131,7 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
return;
}
if (!pSafeArrayGetVartype || !pSafeArrayGetIID)
if (!pSafeArrayGetVartype)
return;
if(FAILED(pSafeArrayGetVartype(lpsa, &vt)))
......@@ -165,7 +163,7 @@ static void check_safearray(void *buffer, LPSAFEARRAY lpsa)
if(sftype == SF_HAVEIID)
{
GUID guid;
pSafeArrayGetIID(lpsa, &guid);
SafeArrayGetIID(lpsa, &guid);
ok(IsEqualGUID(&guid, wiresa), "guid mismatch\n");
wiresa += sizeof(GUID);
}
......@@ -474,8 +472,7 @@ static void test_marshal_LPSAFEARRAY(void)
ok(hr == S_OK, "Failed to get bstr element at hres 0x%x\n", hr);
if (hr == S_OK)
{
if (pVarBstrCmp)
ok(pVarBstrCmp(values[i], gotvalue, 0, 0) == VARCMP_EQ, "String %d does not match\n", i);
ok(VarBstrCmp(values[i], gotvalue, 0, 0) == VARCMP_EQ, "String %d does not match\n", i);
SysFreeString(gotvalue);
}
}
......@@ -1613,13 +1610,11 @@ START_TEST(usrmarshal)
{
HANDLE hOleaut32 = GetModuleHandleA("oleaut32.dll");
#define GETPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func)
GETPTR(SafeArrayGetIID);
GETPTR(SafeArrayGetVartype);
GETPTR(VarBstrCmp);
#undef GETPTR
if (!pSafeArrayGetIID || !pSafeArrayGetVartype)
win_skip("SafeArrayGetIID and/or SafeArrayGetVartype is not available, some tests will be skipped\n");
if (!pSafeArrayGetVartype)
win_skip("SafeArrayGetVartype is not available, some tests will be skipped\n");
CoInitialize(NULL);
......
......@@ -39,7 +39,6 @@
static HMODULE hOleaut32;
static HRESULT (WINAPI *pVarBstrCmp)(BSTR,BSTR,LCID,ULONG);
static HRESULT (WINAPI *pVarFormatNumber)(LPVARIANT,int,int,int,int,ULONG,BSTR*);
static HRESULT (WINAPI *pVarFormat)(LPVARIANT,LPOLESTR,int,int,ULONG,BSTR*);
static HRESULT (WINAPI *pVarWeekdayName)(int,int,int,ULONG,BSTR*);
......@@ -523,30 +522,27 @@ static void test_VarWeekdayName(void)
"Null pointer: expected E_INVALIDARG, got 0x%08x\n", hres);
/* Check all combinations */
pVarBstrCmp = (void*)GetProcAddress(hOleaut32, "VarBstrCmp");
if (pVarBstrCmp)
for (iWeekday = 1; iWeekday <= 7; ++iWeekday)
for (iWeekday = 1; iWeekday <= 7; ++iWeekday)
{
for (fAbbrev = 0; fAbbrev <= 1; ++fAbbrev)
{
for (fAbbrev = 0; fAbbrev <= 1; ++fAbbrev)
/* 0 = Default, 1 = Sunday, 2 = Monday, .. */
for (iFirstDay = 0; iFirstDay <= 7; ++iFirstDay)
{
/* 0 = Default, 1 = Sunday, 2 = Monday, .. */
for (iFirstDay = 0; iFirstDay <= 7; ++iFirstDay)
{
VARWDN_O(iWeekday, fAbbrev, iFirstDay, 0);
if (iFirstDay == 0)
firstDay = defaultFirstDay;
else
/* Translate from 0=Sunday to 0=Monday in the modulo 7 space */
firstDay = iFirstDay - 2;
day = (7 + iWeekday - 1 + firstDay) % 7;
ok(VARCMP_EQ == pVarBstrCmp(out, dayNames[day][fAbbrev],
LOCALE_USER_DEFAULT, 0),
"VarWeekdayName(%d,%d,%d): got wrong dayname: '%s'\n",
iWeekday, fAbbrev, iFirstDay, buff);
SysFreeString(out);
}
VARWDN_O(iWeekday, fAbbrev, iFirstDay, 0);
if (iFirstDay == 0)
firstDay = defaultFirstDay;
else
/* Translate from 0=Sunday to 0=Monday in the modulo 7 space */
firstDay = iFirstDay - 2;
day = (7 + iWeekday - 1 + firstDay) % 7;
ok(VARCMP_EQ == VarBstrCmp(out, dayNames[day][fAbbrev], LOCALE_USER_DEFAULT, 0),
"VarWeekdayName(%d,%d,%d): got wrong dayname: '%s'\n",
iWeekday, fAbbrev, iFirstDay, buff);
SysFreeString(out);
}
}
}
/* Cleanup */
for (day = 0; day <= 6; ++day)
......
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