For bug #18070.
Signed-off-by: Zebediah Figura z.figura12@gmail.com --- dlls/msi/tests/custom.dll/Makefile.in | 2 +- dlls/msi/tests/custom.dll/custom.spec | 1 + dlls/msi/tests/custom.dll/main.c | 41 +++++++++++++++++++++++++++++++++++ dlls/msi/tests/install.c | 30 ++++++++++++++++++++++++- 4 files changed, 72 insertions(+), 2 deletions(-)
diff --git a/dlls/msi/tests/custom.dll/Makefile.in b/dlls/msi/tests/custom.dll/Makefile.in index c606b22..1e7babe 100644 --- a/dlls/msi/tests/custom.dll/Makefile.in +++ b/dlls/msi/tests/custom.dll/Makefile.in @@ -1,5 +1,5 @@ RESOURCE = custom.dll -IMPORTS = msi +IMPORTS = msi uuid ole32
C_SRCS = \ main.c diff --git a/dlls/msi/tests/custom.dll/custom.spec b/dlls/msi/tests/custom.dll/custom.spec index 2a01b3d..9d1e821 100644 --- a/dlls/msi/tests/custom.dll/custom.spec +++ b/dlls/msi/tests/custom.dll/custom.spec @@ -1 +1,2 @@ +@ stdcall main_test(long) @ stdcall test_retval(long) diff --git a/dlls/msi/tests/custom.dll/main.c b/dlls/msi/tests/custom.dll/main.c index 7a970bf..d174c6e 100644 --- a/dlls/msi/tests/custom.dll/main.c +++ b/dlls/msi/tests/custom.dll/main.c @@ -23,14 +23,55 @@
#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__) + BOOL WINAPI DllMain(HINSTANCE hinst, DWORD reason, void *reserved) { return TRUE; }
+/* 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/install.c b/dlls/msi/tests/install.c index cc1b536..118530f 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" @@ -4087,6 +4089,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; @@ -4096,6 +4119,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);
@@ -6092,6 +6119,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();