James Hawkins : msi: Add more tests for the Installer.OpenPackage method.
Alexandre Julliard
julliard at winehq.org
Mon Dec 7 10:26:12 CST 2009
Module: wine
Branch: master
Commit: b61405289562191d12017e6adfbf1de0b80bac0c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=b61405289562191d12017e6adfbf1de0b80bac0c
Author: James Hawkins <truiken at gmail.com>
Date: Fri Dec 4 17:16:07 2009 -0800
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.
---
dlls/msi/tests/automation.c | 172 +++++++++++++++++++++++++++++++++++++++----
1 files changed, 158 insertions(+), 14 deletions(-)
diff --git a/dlls/msi/tests/automation.c b/dlls/msi/tests/automation.c
index b792fa7..6c6c303 100644
--- a/dlls/msi/tests/automation.c
+++ b/dlls/msi/tests/automation.c
@@ -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);
+ 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);
More information about the wine-cvs
mailing list