msi: Add more tests for the Installer.OpenPackage method.
The following series fixes a few leaks reported by valgrind. We were leaking exception info caused by Installer.OpenPackage failing when we didn't expected it.
This commit is contained in:
parent
89b2cde891
commit
b614052895
|
@ -271,6 +271,27 @@ static void create_database(const CHAR *name, const msi_table *tables, int num_t
|
|||
MsiCloseHandle(db);
|
||||
}
|
||||
|
||||
static BOOL create_package(LPWSTR path)
|
||||
{
|
||||
DWORD len;
|
||||
|
||||
/* Prepare package */
|
||||
create_database(msifile, tables,
|
||||
sizeof(tables) / sizeof(msi_table), summary_info,
|
||||
sizeof(summary_info) / sizeof(msi_summary_info));
|
||||
|
||||
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED,
|
||||
CURR_DIR, -1, path, MAX_PATH);
|
||||
ok(len, "MultiByteToWideChar returned error %d\n", GetLastError());
|
||||
if (!len)
|
||||
return FALSE;
|
||||
|
||||
/* lstrcatW does not work on win95 */
|
||||
path[len - 1] = '\\';
|
||||
memcpy(&path[len], szMsifile, sizeof(szMsifile));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*
|
||||
* Installation helpers
|
||||
*/
|
||||
|
@ -592,7 +613,8 @@ static void test_dispatch(void)
|
|||
DISPID dispid;
|
||||
OLECHAR *name;
|
||||
VARIANT varresult;
|
||||
VARIANTARG vararg[2];
|
||||
VARIANTARG vararg[3];
|
||||
WCHAR path[MAX_PATH];
|
||||
DISPPARAMS dispparams = {NULL, NULL, 0, 0};
|
||||
|
||||
/* Test getting ID of a function name that does not exist */
|
||||
|
@ -629,15 +651,148 @@ static void test_dispatch(void)
|
|||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
todo_wine ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
|
||||
/* Try one parameter, function requires two */
|
||||
/* Try two empty parameters */
|
||||
dispparams.cArgs = 2;
|
||||
VariantInit(&vararg[0]);
|
||||
VariantInit(&vararg[1]);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
todo_wine ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
|
||||
/* Try one parameter, the required BSTR. Second parameter is optional.
|
||||
* NOTE: The specified package does not exist, which is why the call fails.
|
||||
*/
|
||||
dispparams.cArgs = 1;
|
||||
VariantInit(&vararg[0]);
|
||||
V_VT(&vararg[0]) = VT_BSTR;
|
||||
V_BSTR(&vararg[0]) = SysAllocString(szMsifile);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
VariantClear(&vararg[0]);
|
||||
|
||||
ok(hr == DISP_E_EXCEPTION, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
ok_exception(hr, szOpenPackageException);
|
||||
VariantClear(&vararg[0]);
|
||||
|
||||
/* Provide the required BSTR and an empty second parameter.
|
||||
* NOTE: The specified package does not exist, which is why the call fails.
|
||||
*/
|
||||
dispparams.cArgs = 2;
|
||||
VariantInit(&vararg[1]);
|
||||
V_VT(&vararg[1]) = VT_BSTR;
|
||||
V_BSTR(&vararg[1]) = SysAllocString(szMsifile);
|
||||
VariantInit(&vararg[0]);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == DISP_E_EXCEPTION, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
ok_exception(hr, szOpenPackageException);
|
||||
VariantClear(&vararg[1]);
|
||||
|
||||
/* Provide the required BSTR and two empty parameters.
|
||||
* NOTE: The specified package does not exist, which is why the call fails.
|
||||
*/
|
||||
dispparams.cArgs = 3;
|
||||
VariantInit(&vararg[2]);
|
||||
V_VT(&vararg[2]) = VT_BSTR;
|
||||
V_BSTR(&vararg[2]) = SysAllocString(szMsifile);
|
||||
VariantInit(&vararg[1]);
|
||||
VariantInit(&vararg[0]);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == DISP_E_EXCEPTION, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
ok_exception(hr, szOpenPackageException);
|
||||
VariantClear(&vararg[2]);
|
||||
|
||||
/* Provide the required BSTR and a second parameter with the wrong type. */
|
||||
dispparams.cArgs = 2;
|
||||
VariantInit(&vararg[1]);
|
||||
V_VT(&vararg[1]) = VT_BSTR;
|
||||
V_BSTR(&vararg[1]) = SysAllocString(szMsifile);
|
||||
VariantInit(&vararg[0]);
|
||||
V_VT(&vararg[0]) = VT_BSTR;
|
||||
V_BSTR(&vararg[0]) = SysAllocString(szMsifile);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
VariantClear(&vararg[0]);
|
||||
VariantClear(&vararg[1]);
|
||||
|
||||
/* Create a proper installer package. */
|
||||
create_package(path);
|
||||
|
||||
/* Try one parameter, the required BSTR. Second parameter is optional.
|
||||
* Proper installer package exists. Path to the package is relative.
|
||||
*/
|
||||
dispparams.cArgs = 1;
|
||||
VariantInit(&vararg[0]);
|
||||
V_VT(&vararg[0]) = VT_BSTR;
|
||||
V_BSTR(&vararg[0]) = SysAllocString(szMsifile);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == DISP_E_EXCEPTION, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
ok_exception(hr, szOpenPackageException);
|
||||
VariantClear(&vararg[0]);
|
||||
|
||||
/* Try one parameter, the required BSTR. Second parameter is optional.
|
||||
* Proper installer package exists. Path to the package is absolute.
|
||||
*/
|
||||
dispparams.cArgs = 1;
|
||||
VariantInit(&vararg[0]);
|
||||
V_VT(&vararg[0]) = VT_BSTR;
|
||||
V_BSTR(&vararg[0]) = SysAllocString(path);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
todo_wine ok(hr == S_OK, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
VariantClear(&vararg[0]);
|
||||
VariantClear(&varresult);
|
||||
|
||||
/* Provide the required BSTR and an empty second parameter. Proper
|
||||
* installation package exists.
|
||||
*/
|
||||
dispparams.cArgs = 2;
|
||||
VariantInit(&vararg[1]);
|
||||
V_VT(&vararg[1]) = VT_BSTR;
|
||||
V_BSTR(&vararg[1]) = SysAllocString(path);
|
||||
VariantInit(&vararg[0]);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == S_OK, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
VariantClear(&vararg[1]);
|
||||
VariantClear(&varresult);
|
||||
|
||||
/* Provide the required BSTR and two empty parameters. Proper
|
||||
* installation package exists.
|
||||
*/
|
||||
dispparams.cArgs = 3;
|
||||
VariantInit(&vararg[2]);
|
||||
V_VT(&vararg[2]) = VT_BSTR;
|
||||
V_BSTR(&vararg[2]) = SysAllocString(path);
|
||||
VariantInit(&vararg[1]);
|
||||
VariantInit(&vararg[0]);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == S_OK, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
VariantClear(&vararg[2]);
|
||||
VariantClear(&varresult);
|
||||
|
||||
/* Provide the required BSTR and a second parameter with the wrong type. */
|
||||
dispparams.cArgs = 2;
|
||||
VariantInit(&vararg[1]);
|
||||
V_VT(&vararg[1]) = VT_BSTR;
|
||||
V_BSTR(&vararg[1]) = SysAllocString(path);
|
||||
VariantInit(&vararg[0]);
|
||||
V_VT(&vararg[0]) = VT_BSTR;
|
||||
V_BSTR(&vararg[0]) = SysAllocString(path);
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == DISP_E_TYPEMISMATCH, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
VariantClear(&vararg[0]);
|
||||
VariantClear(&vararg[1]);
|
||||
|
||||
/* Provide the required BSTR and a second parameter that can be coerced to
|
||||
* VT_I4.
|
||||
*/
|
||||
dispparams.cArgs = 2;
|
||||
VariantInit(&vararg[1]);
|
||||
V_VT(&vararg[1]) = VT_BSTR;
|
||||
V_BSTR(&vararg[1]) = SysAllocString(path);
|
||||
VariantInit(&vararg[0]);
|
||||
V_VT(&vararg[0]) = VT_I2;
|
||||
V_BSTR(&vararg[0]) = 0;
|
||||
hr = IDispatch_Invoke(pInstaller, dispid, &IID_NULL, LOCALE_NEUTRAL, DISPATCH_METHOD, &dispparams, &varresult, &excepinfo, NULL);
|
||||
ok(hr == S_OK, "IDispatch::Invoke returned 0x%08x\n", hr);
|
||||
VariantClear(&vararg[1]);
|
||||
VariantClear(&varresult);
|
||||
|
||||
DeleteFileW(path);
|
||||
|
||||
/* Test invoking a method as a DISPATCH_PROPERTYGET or DISPATCH_PROPERTYPUT */
|
||||
VariantInit(&vararg[0]);
|
||||
|
@ -2353,7 +2508,6 @@ static void test_Installer(void)
|
|||
static WCHAR szIntegerDataException[] = { 'I','n','t','e','g','e','r','D','a','t','a',',','F','i','e','l','d',0 };
|
||||
WCHAR szPath[MAX_PATH];
|
||||
HRESULT hr;
|
||||
UINT len;
|
||||
IDispatch *pSession = NULL, *pDatabase = NULL, *pRecord = NULL, *pStringList = NULL;
|
||||
int iValue, iCount;
|
||||
|
||||
|
@ -2404,17 +2558,7 @@ static void test_Installer(void)
|
|||
IDispatch_Release(pRecord);
|
||||
}
|
||||
|
||||
/* Prepare package */
|
||||
create_database(msifile, tables, sizeof(tables) / sizeof(msi_table),
|
||||
summary_info, sizeof(summary_info) / sizeof(msi_summary_info));
|
||||
|
||||
len = MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, CURR_DIR, -1, szPath, MAX_PATH);
|
||||
ok(len, "MultiByteToWideChar returned error %d\n", GetLastError());
|
||||
if (!len) return;
|
||||
|
||||
/* lstrcatW does not work on win95 */
|
||||
szPath[len - 1] = '\\';
|
||||
memcpy(&szPath[len], szMsifile, sizeof(szMsifile));
|
||||
create_package(szPath);
|
||||
|
||||
/* Installer::OpenPackage */
|
||||
hr = Installer_OpenPackage(szPath, 0, &pSession);
|
||||
|
|
Loading…
Reference in New Issue