From ee55546d340386325f39399eb059e305e51caae4 Mon Sep 17 00:00:00 2001 From: Mike McCormack Date: Wed, 11 Oct 2006 16:26:54 +0900 Subject: [PATCH] msi: Check that transforms return the correct data. --- dlls/msi/tests/db.c | 166 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 131 insertions(+), 35 deletions(-) diff --git a/dlls/msi/tests/db.c b/dlls/msi/tests/db.c index b8215cfa06e..3f65c5899cd 100644 --- a/dlls/msi/tests/db.c +++ b/dlls/msi/tests/db.c @@ -17,22 +17,23 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ + +#define COBJMACROS + #include #include #include #include +#include + #include "wine/test.h" static const char *msifile = "winetest.msi"; static const char *msifile2 = "winetst2.msi"; static const char *mstfile = "winetst.mst"; -#ifndef ERROR_INSTALL_TRANSFORM_FAILURE -#define ERROR_INSTALL_TRANSFORM_FAILURE 1624 -#endif - static void test_msidatabase(void) { MSIHANDLE hdb = 0, hdb2 = 0; @@ -1691,16 +1692,12 @@ static void test_handle_limit(void) ok( r == ERROR_SUCCESS, "failed to close database\n"); } -static void test_generate_transform(void) +static void generate_transform(void) { MSIHANDLE hdb1, hdb2; LPCSTR query; UINT r; - DeleteFile(msifile); - DeleteFile(msifile2); - DeleteFile(mstfile); - /* create an empty database */ r = MsiOpenDatabase(msifile, MSIDBOPEN_CREATE, &hdb1 ); ok( r == ERROR_SUCCESS , "Failed to create database\n" ); @@ -1709,12 +1706,9 @@ static void test_generate_transform(void) ok( r == ERROR_SUCCESS , "Failed to commit database\n" ); /* create another empty database */ - r = MsiOpenDatabase(msifile2, MSIDBOPEN_CREATE, &hdb2 ); + r = MsiOpenDatabase(msifile2, MSIDBOPEN_READONLY, &hdb2 ); ok( r == ERROR_SUCCESS , "Failed to create database\n" ); - r = MsiDatabaseCommit( hdb2 ); - ok( r == ERROR_SUCCESS , "Failed to commit database\n" ); - /* the transform between two empty database should be empty */ r = MsiDatabaseGenerateTransform(hdb1, hdb2, NULL, 0, 0); todo_wine { @@ -1733,13 +1727,6 @@ static void test_generate_transform(void) r = run_query(hdb1, 0, query); ok(r == ERROR_SUCCESS, "failed to add row 2\n"); - todo_wine { - r = MsiDatabaseGenerateTransform(hdb1, hdb2, NULL, 0, 0); - ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r ); - - r = MsiDatabaseGenerateTransform(hdb1, hdb2, mstfile, 0, 0); - ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r ); - /* database needs to be committed */ MsiDatabaseCommit(hdb1); @@ -1747,33 +1734,142 @@ static void test_generate_transform(void) ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r ); MsiCloseHandle( hdb1 ); + MsiCloseHandle( hdb2 ); +} - r = MsiDatabaseApplyTransform( hdb2, mstfile, 0 ); - ok( r == ERROR_SUCCESS, "return code %d, should be ERROR_SUCCESS\n", r ); +static const WCHAR name1[] = { 0x4840, 0x3a8a, 0x481b, 0 }; /* AAR */ +static const WCHAR name2[] = { 0x4840, 0x3b3f, 0x43f2, 0x4438, 0x45b1, 0 }; /* _Columns */ +static const WCHAR name3[] = { 0x4840, 0x3f7f, 0x4164, 0x422f, 0x4836, 0 }; /* _Tables */ +static const WCHAR name4[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3b6a, 0x45e4, 0x4824, 0 }; /* _StringData */ +static const WCHAR name5[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0x482f, 0 }; /* _StringPool */ - MsiDatabaseCommit(hdb2); +static const WCHAR data1[] = { /* AAR */ + 0x0201, 0x0004, 0x8001, + 0x0201, 0x0005, 0x8002, +}; +static const WCHAR data2[] = { /* _Columns */ + 0x0401, 0x0001, 0x0000, 0x0002, 0xbdff, + 0x0401, 0x0001, 0x0000, 0x0003, 0x8502, +}; +static const WCHAR data3[] = { /* _Tables */ + 0x0101, 0x0001, +}; +static const char data4[] = /* _StringData */ + "AARCARBARvwbmw"; +static const WCHAR data5[] = { /* _StringPool */ +/* len, refs */ + 0, 0, + 3, 3, /* string 1 */ + 3, 1, /* string 2 */ + 3, 1, /* string 3 */ + 2, 1, /* string 4 */ + 3, 1, /* string 5 */ +}; - /* apply the same transform again? */ - r = MsiDatabaseApplyTransform( hdb2, mstfile, 0 ); - ok( r == ERROR_INSTALL_TRANSFORM_FAILURE, - "return code %d, should be ERROR_INSTALL_TRANSFORM_FAILURE\n", r ); +static const struct { + LPCWSTR name; + const void *data; + DWORD size; +} table_transform_data[] = +{ + { name1, data1, sizeof data1 }, + { name2, data2, sizeof data2 }, + { name3, data3, sizeof data3 }, + { name4, data4, sizeof data4 }, + { name5, data5, sizeof data5 }, +}; + +#define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0]) + +static void generate_transform_manual(void) +{ + IStorage *stg = NULL; + IStream *stm; + WCHAR name[0x20]; + HRESULT r; + DWORD i, count; + const DWORD mode = STGM_CREATE|STGM_READWRITE|STGM_DIRECT|STGM_SHARE_EXCLUSIVE; + + const CLSID CLSID_MsiTransform = { 0xc1082,0,0,{0xc0,0,0,0,0,0,0,0x46}}; + + MultiByteToWideChar(CP_ACP, 0, mstfile, -1, name, 0x20); + + r = StgCreateDocfile(name, mode, 0, &stg); + ok(r == S_OK, "failed to create storage\n"); + if (!stg) + return; + + r = IStorage_SetClass( stg, &CLSID_MsiTransform ); + ok(r == S_OK, "failed to set storage type\n"); + + for (i=0; i