[PATCH 3/5] msi/tests: Add the custom action DLL in create_database_wordcount().

Zebediah Figura z.figura12 at gmail.com
Mon May 14 00:29:00 CDT 2018


The change to msi.c is necessary since this sets the UI handler.

Signed-off-by: Zebediah Figura <z.figura12 at gmail.com>
---
 dlls/msi/tests/install.c | 142 +++++++++++++++++++++++------------------------
 dlls/msi/tests/msi.c     |   2 +-
 2 files changed, 69 insertions(+), 75 deletions(-)

diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index a2b95d1..f0e4857 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -2551,6 +2551,73 @@ static void write_msi_summary_info(MSIHANDLE db, INT version, INT wordcount,
     MsiCloseHandle(summary);
 }
 
+static char *load_resource(const char *name)
+{
+    static char path[MAX_PATH];
+    DWORD written;
+    HANDLE file;
+    HRSRC res;
+    void *ptr;
+
+    GetTempFileNameA(".", name, 0, path);
+
+    file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
+    ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", path, GetLastError());
+
+    res = FindResourceA(NULL, name, "TESTDLL");
+    ok( res != 0, "couldn't find resource\n" );
+    ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
+    WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
+    ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
+    CloseHandle( file );
+
+    return path;
+}
+
+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 add_custom_dll(MSIHANDLE hdb)
+{
+    MSIHANDLE record;
+    UINT res;
+
+    if (!customdll)
+        customdll = load_resource("custom.dll");
+
+    MsiSetExternalUIRecord(ok_callback, INSTALLLOGMODE_USER, NULL, NULL);
+
+    res = run_query(hdb, 0, "CREATE TABLE `Binary` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL PRIMARY KEY `Name`)");
+    ok(res == ERROR_SUCCESS, "failed to create Binary table: %u\n", res);
+
+    record = MsiCreateRecord(1);
+    res = MsiRecordSetStreamA(record, 1, customdll);
+    ok(res == ERROR_SUCCESS, "failed to add %s to stream: %u\n", customdll, res);
+
+    res = run_query(hdb, record, "INSERT INTO `Binary` (`Name`, `Data`) VALUES ('custom.dll', ?)");
+    ok(res == ERROR_SUCCESS, "failed to insert into Binary table: %u\n", res);
+
+    MsiCloseHandle(record);
+}
+
 void create_database_wordcount(const CHAR *name, const msi_table *tables, int num_tables,
     INT version, INT wordcount, const char *template, const char *packagecode)
 {
@@ -2580,6 +2647,7 @@ void create_database_wordcount(const CHAR *name, const msi_table *tables, int nu
     }
 
     write_msi_summary_info(db, version, wordcount, template, packagecode);
+    add_custom_dll(db);
 
     r = MsiDatabaseCommit(db);
     ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
@@ -2634,29 +2702,6 @@ static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
     return RegDeleteKeyA( key, subkey );
 }
 
-static char *load_resource(const char *name)
-{
-    static char path[MAX_PATH];
-    DWORD written;
-    HANDLE file;
-    HRSRC res;
-    void *ptr;
-
-    GetTempFileNameA(".", name, 0, path);
-
-    file = CreateFileA(path, GENERIC_READ|GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, 0);
-    ok(file != INVALID_HANDLE_VALUE, "file creation failed, at %s, error %d\n", path, GetLastError());
-
-    res = FindResourceA(NULL, name, "TESTDLL");
-    ok( res != 0, "couldn't find resource\n" );
-    ptr = LockResource( LoadResource( GetModuleHandleA(NULL), res ));
-    WriteFile( file, ptr, SizeofResource( GetModuleHandleA(NULL), res ), &written, NULL );
-    ok( written == SizeofResource( GetModuleHandleA(NULL), res ), "couldn't write resource\n" );
-    CloseHandle( file );
-
-    return path;
-}
-
 static void test_MsiInstallProduct(void)
 {
     UINT r;
@@ -4082,52 +4127,6 @@ error:
     DeleteFileA("augustus");
 }
 
-static void add_custom_dll(void)
-{
-    MSIHANDLE hdb = 0, record;
-    UINT res;
-
-    res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb);
-    ok(res == ERROR_SUCCESS, "failed to open db: %u\n", res);
-
-    res = run_query(hdb, 0, "CREATE TABLE `Binary` (`Name` CHAR(72) NOT NULL, `Data` OBJECT NOT NULL PRIMARY KEY `Name`)");
-    ok(res == ERROR_SUCCESS, "failed to create Binary table: %u\n", res);
-
-    record = MsiCreateRecord(1);
-    res = MsiRecordSetStreamA(record, 1, customdll);
-    ok(res == ERROR_SUCCESS, "failed to add %s to stream: %u\n", customdll, res);
-
-    res = run_query(hdb, record, "INSERT INTO `Binary` (`Name`, `Data`) VALUES ('custom.dll', ?)");
-    ok(res == ERROR_SUCCESS, "failed to insert into Binary table: %u\n", res);
-
-    res = MsiDatabaseCommit(hdb);
-    ok(res == ERROR_SUCCESS, "failed to commit database: %u\n", res);
-
-    MsiCloseHandle(record);
-    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)
 {
     MSIHANDLE hdb, record;
@@ -4135,7 +4134,6 @@ static void test_customaction1(void)
 
     create_test_files();
     create_database(msifile, ca1_tables, sizeof(ca1_tables) / sizeof(msi_table));
-    add_custom_dll();
 
     /* create a test table */
     MsiOpenDatabaseW(msifileW, MSIDBOPEN_TRANSACT, &hdb);
@@ -6106,7 +6104,6 @@ static void test_deferred_action(void)
     sprintf(buffer, "TESTPATH=\"%s\"", file);
 
     create_database(msifile, da_tables, sizeof(da_tables) / sizeof(da_tables[0]));
-    add_custom_dll();
 
     MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
 
@@ -6234,9 +6231,6 @@ START_TEST(install)
     lstrcatA(log_file, "\\msitest.log");
     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();
     test_MsiSetComponentState();
diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c
index 3778019..21a0358 100644
--- a/dlls/msi/tests/msi.c
+++ b/dlls/msi/tests/msi.c
@@ -14442,6 +14442,7 @@ START_TEST(msi)
     test_getcomponentpath();
     test_MsiGetFileHash();
     test_MsiSetInternalUI();
+    test_MsiSetExternalUI();
 
     if (!pConvertSidToStringSidA)
         win_skip("ConvertSidToStringSidA not implemented\n");
@@ -14474,7 +14475,6 @@ START_TEST(msi)
     test_MsiConfigureProductEx();
     test_MsiSetFeatureAttributes();
     test_MsiGetFeatureInfo();
-    test_MsiSetExternalUI();
     test_lastusedsource();
     test_setpropertyfolder();
     test_sourcedir_props();
-- 
2.7.4




More information about the wine-devel mailing list