Zebediah Figura : msi/tests: Add a test for creating MTA objects from a custom action.
Alexandre Julliard
julliard at winehq.org
Mon Feb 19 13:52:01 CST 2018
Module: wine
Branch: master
Commit: 77e6bd13b60ca2a6c1793687be60c1efaf0d9967
URL: https://source.winehq.org/git/wine.git/?a=commit;h=77e6bd13b60ca2a6c1793687be60c1efaf0d9967
Author: Zebediah Figura <z.figura12 at gmail.com>
Date: Wed Feb 14 20:54:55 2018 -0600
msi/tests: Add a test for creating MTA objects from a custom action.
Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/msi/tests/Makefile.in | 2 +-
dlls/msi/tests/custom.c | 42 ++++++++++++++++++++++++++++++++++++++++++
dlls/msi/tests/custom.spec | 1 +
dlls/msi/tests/install.c | 30 +++++++++++++++++++++++++++++-
4 files changed, 73 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/tests/Makefile.in b/dlls/msi/tests/Makefile.in
index 70080ea..9c991d6 100644
--- a/dlls/msi/tests/Makefile.in
+++ b/dlls/msi/tests/Makefile.in
@@ -1,7 +1,7 @@
TESTDLL = msi.dll
IMPORTS = cabinet msi shell32 ole32 oleaut32 user32 advapi32 version
-custom_IMPORTS = msi
+custom_IMPORTS = uuid msi ole32
SOURCES = \
action.c \
diff --git a/dlls/msi/tests/custom.c b/dlls/msi/tests/custom.c
index d68d082..c00b7aa 100644
--- a/dlls/msi/tests/custom.c
+++ b/dlls/msi/tests/custom.c
@@ -23,9 +23,51 @@
#include <windef.h>
#include <winbase.h>
+#define COBJMACROS
+#include <objbase.h>
+#include <unknwn.h>
#include <msi.h>
#include <msiquery.h>
+static void ok_(MSIHANDLE hinst, int todo, const char *file, int line, int condition, const char *msg, ...)
+{
+ static char buffer[2000];
+ MSIHANDLE record;
+ va_list valist;
+
+ va_start(valist, msg);
+ vsprintf(buffer, msg, valist);
+ va_end(valist);
+
+ record = MsiCreateRecord(5);
+ MsiRecordSetInteger(record, 1, todo);
+ MsiRecordSetStringA(record, 2, file);
+ MsiRecordSetInteger(record, 3, line);
+ MsiRecordSetInteger(record, 4, condition);
+ MsiRecordSetStringA(record, 5, buffer);
+ MsiProcessMessage(hinst, INSTALLMESSAGE_USER, record);
+ MsiCloseHandle(record);
+}
+#define ok(hinst, condition, ...) ok_(hinst, 0, __FILE__, __LINE__, condition, __VA_ARGS__)
+#define todo_wine_ok(hinst, condition, ...) ok_(hinst, 1, __FILE__, __LINE__, condition, __VA_ARGS__)
+
+
+/* Main test. Anything that doesn't depend on a specific install configuration
+ * or have undesired side effects should go here. */
+UINT WINAPI main_test(MSIHANDLE hinst)
+{
+ IUnknown *unk = NULL;
+ HRESULT hres;
+
+ /* Test for an MTA apartment */
+ hres = CoCreateInstance(&CLSID_Picture_Metafile, NULL, CLSCTX_INPROC_SERVER, &IID_IUnknown, (void **)&unk);
+ todo_wine_ok(hinst, hres == S_OK, "CoCreateInstance failed with %08x\n", hres);
+
+ if (unk) IUnknown_Release(unk);
+
+ return ERROR_SUCCESS;
+}
+
UINT WINAPI test_retval(MSIHANDLE hinst)
{
char prop[10];
diff --git a/dlls/msi/tests/custom.spec b/dlls/msi/tests/custom.spec
index 2a01b3d..9d1e821 100644
--- a/dlls/msi/tests/custom.spec
+++ b/dlls/msi/tests/custom.spec
@@ -1 +1,2 @@
+@ stdcall main_test(long)
@ stdcall test_retval(long)
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 9ba4f07..55d83d4 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -695,11 +695,13 @@ static const CHAR wrv_component_dat[] = "Component\tComponentId\tDirectory_\tAtt
static const CHAR ca1_install_exec_seq_dat[] = "Action\tCondition\tSequence\n"
"s72\tS255\tI2\n"
"InstallExecuteSequence\tAction\n"
- "testretval\t\t710\n";
+ "maintest\tMAIN_TEST\t700\n"
+ "testretval\tTEST_RETVAL\t710\n";
static const CHAR ca1_custom_action_dat[] = "Action\tType\tSource\tTarget\n"
"s72\ti2\tS64\tS0\n"
"CustomAction\tAction\n"
+ "maintest\t1\tcustom.dll\tmain_test\n"
"testretval\t1\tcustom.dll\ttest_retval\n";
static const CHAR ca51_component_dat[] = "Component\tComponentId\tDirectory_\tAttributes\tCondition\tKeyPath\n"
@@ -4081,6 +4083,27 @@ static void add_custom_dll(void)
MsiCloseHandle(hdb);
}
+static INT CALLBACK ok_callback(void *context, UINT message_type, MSIHANDLE record)
+{
+ if (message_type == INSTALLMESSAGE_USER)
+ {
+ char file[200];
+ char msg[2000];
+ DWORD len;
+
+ len = sizeof(file);
+ MsiRecordGetStringA(record, 2, file, &len);
+ len = sizeof(msg);
+ MsiRecordGetStringA(record, 5, msg, &len);
+
+ todo_wine_if(MsiRecordGetInteger(record, 1))
+ ok_(file, MsiRecordGetInteger(record, 3)) (MsiRecordGetInteger(record, 4), "%s", msg);
+
+ return 1;
+ }
+ return 0;
+}
+
static void test_customaction1(void)
{
UINT r;
@@ -4090,6 +4113,10 @@ static void test_customaction1(void)
MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
+ r = MsiInstallProductA(msifile, "MAIN_TEST=1");
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+
+ /* Test return values */
r = MsiInstallProductA(msifile, "TEST_RETVAL=0");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
@@ -6083,6 +6110,7 @@ START_TEST(install)
MsiEnableLogA(INSTALLLOGMODE_FATALEXIT, log_file, 0);
customdll = load_resource("custom.dll");
+ MsiSetExternalUIRecord(ok_callback, INSTALLLOGMODE_USER, NULL, NULL);
if (pSRSetRestorePointA) /* test has side-effects on win2k3 that cause failures in following tests */
test_MsiInstallProduct();
More information about the wine-cvs
mailing list