msi/tests: Fix some test failures on Win95 by using more A-functions.

oldstable
Paul Vriens 2009-06-19 10:48:55 +02:00 committed by Alexandre Julliard
parent 91e306579b
commit 9a1b829923
1 changed files with 34 additions and 15 deletions

View File

@ -364,14 +364,25 @@ static void delete_test_files(void)
/* ok-like statement which takes two unicode strings or one unicode and one ANSI string as arguments */
static CHAR string1[MAX_PATH], string2[MAX_PATH];
/* lstrcmpW is not supported on Win9x */
static int strcmp_ww(const WCHAR* str1, const WCHAR* str2)
{
CHAR str1A[MAX_PATH], str2A[MAX_PATH];
WideCharToMultiByte(CP_ACP, 0, str1, -1, str1A, MAX_PATH, NULL, NULL); \
WideCharToMultiByte(CP_ACP, 0, str2, -1, str2A, MAX_PATH, NULL, NULL); \
return lstrcmpA(str1A, str2A);
}
#define ok_w2(format, szString1, szString2) \
\
if (lstrcmpW(szString1, szString2) != 0) \
{ \
WideCharToMultiByte(CP_ACP, 0, szString1, -1, string1, MAX_PATH, NULL, NULL); \
WideCharToMultiByte(CP_ACP, 0, szString2, -1, string2, MAX_PATH, NULL, NULL); \
do { \
WideCharToMultiByte(CP_ACP, 0, szString1, -1, string1, MAX_PATH, NULL, NULL); \
WideCharToMultiByte(CP_ACP, 0, szString2, -1, string2, MAX_PATH, NULL, NULL); \
if (lstrcmpA(string1, string2) != 0) \
ok(0, format, string1, string2); \
}
} while(0);
#define ok_w2n(format, szString1, szString2, len) \
\
@ -759,7 +770,9 @@ static HRESULT Installer_RegistryValueW(HKEY hkey, LPCWSTR szKey, LPCWSTR szValu
V_BSTR(&vararg) = SysAllocString(szValue);
hr = Installer_RegistryValue(hkey, szKey, vararg, &varresult, VT_BSTR);
if (V_BSTR(&varresult)) lstrcpyW(szString, V_BSTR(&varresult));
if (V_BSTR(&varresult))
/* lstrcpyW is not implemented on Win95 (lstrlenW is though) */
memcpy(szString, V_BSTR(&varresult), (lstrlenW(V_BSTR(&varresult)) + 1) * sizeof(WCHAR));
VariantClear(&varresult);
return hr;
}
@ -775,7 +788,8 @@ static HRESULT Installer_RegistryValueI(HKEY hkey, LPCWSTR szKey, int iValue, LP
V_I4(&vararg) = iValue;
hr = Installer_RegistryValue(hkey, szKey, vararg, &varresult, vtResult);
if (SUCCEEDED(hr) && vtResult == VT_BSTR) lstrcpyW(szString, V_BSTR(&varresult));
if (SUCCEEDED(hr) && vtResult == VT_BSTR)
memcpy(szString, V_BSTR(&varresult), (lstrlenW(V_BSTR(&varresult)) + 1) * sizeof(WCHAR));
VariantClear(&varresult);
return hr;
}
@ -866,7 +880,8 @@ static HRESULT Installer_ProductInfo(LPCWSTR szProduct, LPCWSTR szAttribute, LPW
V_BSTR(&vararg[0]) = SysAllocString(szAttribute);
hr = invoke(pInstaller, "ProductInfo", DISPATCH_PROPERTYGET, &dispparams, &varresult, VT_BSTR);
if (V_BSTR(&varresult)) lstrcpyW(szString, V_BSTR(&varresult));
if (V_BSTR(&varresult))
memcpy(szString, V_BSTR(&varresult), (lstrlenW(V_BSTR(&varresult)) + 1) * sizeof(WCHAR));
VariantClear(&varresult);
return hr;
}
@ -905,7 +920,8 @@ static HRESULT Installer_VersionGet(LPWSTR szVersion)
HRESULT hr;
hr = invoke(pInstaller, "Version", DISPATCH_PROPERTYGET, &dispparams, &varresult, VT_BSTR);
if (V_BSTR(&varresult)) lstrcpyW(szVersion, V_BSTR(&varresult));
if (V_BSTR(&varresult))
memcpy(szVersion, V_BSTR(&varresult), (lstrlenW(V_BSTR(&varresult)) + 1) * sizeof(WCHAR));
VariantClear(&varresult);
return hr;
}
@ -933,7 +949,8 @@ static HRESULT Session_PropertyGet(IDispatch *pSession, LPCWSTR szName, LPWSTR s
V_BSTR(&vararg[0]) = SysAllocString(szName);
hr = invoke(pSession, "Property", DISPATCH_PROPERTYGET, &dispparams, &varresult, VT_BSTR);
if (V_BSTR(&varresult)) lstrcpyW(szReturn, V_BSTR(&varresult));
if (V_BSTR(&varresult))
memcpy(szReturn, V_BSTR(&varresult), (lstrlenW(V_BSTR(&varresult)) + 1) * sizeof(WCHAR));
VariantClear(&varresult);
return hr;
}
@ -1232,7 +1249,8 @@ static HRESULT Record_StringDataGet(IDispatch *pRecord, int iField, LPWSTR szStr
V_I4(&vararg[0]) = iField;
hr = invoke(pRecord, "StringData", DISPATCH_PROPERTYGET, &dispparams, &varresult, VT_BSTR);
if (V_BSTR(&varresult)) lstrcpyW(szString, V_BSTR(&varresult));
if (V_BSTR(&varresult))
memcpy(szString, V_BSTR(&varresult), (lstrlenW(V_BSTR(&varresult)) + 1) * sizeof(WCHAR));
VariantClear(&varresult);
return hr;
}
@ -1309,7 +1327,8 @@ static HRESULT StringList_Item(IDispatch *pStringList, int iIndex, LPWSTR szStri
V_I4(&vararg[0]) = iIndex;
hr = invoke(pStringList, "Item", DISPATCH_PROPERTYGET, &dispparams, &varresult, VT_BSTR);
if (V_BSTR(&varresult)) lstrcpyW(szString, V_BSTR(&varresult));
if (V_BSTR(&varresult))
memcpy(szString, V_BSTR(&varresult), (lstrlenW(V_BSTR(&varresult)) + 1) * sizeof(WCHAR));
VariantClear(&varresult);
return hr;
}
@ -1654,7 +1673,7 @@ static void test_Session(IDispatch *pSession)
memset(stringw, 0, sizeof(stringw));
hr = Session_PropertyGet(pSession, szProductName, stringw);
ok(hr == S_OK, "Session_PropertyGet failed, hresult 0x%08x\n", hr);
if (lstrcmpW(stringw, szMSITEST) != 0)
if (strcmp_ww(stringw, szMSITEST) != 0)
{
len = WideCharToMultiByte(CP_ACP, 0, stringw, -1, string, MAX_PATH, NULL, NULL);
ok(len, "WideCharToMultiByteChar returned error %d\n", GetLastError());
@ -1667,7 +1686,7 @@ static void test_Session(IDispatch *pSession)
memset(stringw, 0, sizeof(stringw));
hr = Session_PropertyGet(pSession, szProductName, stringw);
ok(hr == S_OK, "Session_PropertyGet failed, hresult 0x%08x\n", hr);
if (lstrcmpW(stringw, szProductName) != 0)
if (strcmp_ww(stringw, szProductName) != 0)
{
len = WideCharToMultiByte(CP_ACP, 0, stringw, -1, string, MAX_PATH, NULL, NULL);
ok(len, "WideCharToMultiByteChar returned error %d\n", GetLastError());
@ -2006,7 +2025,7 @@ static void test_Installer_Products(BOOL bProductInstalled)
ok(iValue == INSTALLSTATE_DEFAULT || iValue == INSTALLSTATE_ADVERTISED, "Installer_ProductState returned %d, expected %d or %d\n", iValue, INSTALLSTATE_DEFAULT, INSTALLSTATE_ADVERTISED);
/* Not found our product code yet? Check */
if (!bProductFound && !lstrcmpW(szString, szProductCode))
if (!bProductFound && !strcmp_ww(szString, szProductCode))
bProductFound = TRUE;
/* IEnumVARIANT::Next */