msi: Add tests for adding properties in a transform.

This commit is contained in:
James Hawkins 2007-07-11 00:11:10 -07:00 committed by Alexandre Julliard
parent 5a8e0e8c1d
commit 1093eb83cd

View file

@ -1833,6 +1833,15 @@ static void generate_transform(void)
r = run_query(hdb1, 0, query); r = run_query(hdb1, 0, query);
ok(r == ERROR_SUCCESS, "failed to modify row\n"); ok(r == ERROR_SUCCESS, "failed to modify row\n");
query = "CREATE TABLE `Property` ( `Property` CHAR(72) NOT NULL, "
"`Value` CHAR(0) PRIMARY KEY `Property`)";
r = run_query(hdb1, 0, query);
ok(r == ERROR_SUCCESS, "failed to add property table\n");
query = "INSERT INTO `Property` ( `Property`, `Value` ) VALUES ( 'prop', 'val' )";
r = run_query(hdb1, 0, query);
ok(r == ERROR_SUCCESS, "failed to add property\n");
/* database needs to be committed */ /* database needs to be committed */
MsiDatabaseCommit(hdb1); MsiDatabaseCommit(hdb1);
@ -1856,6 +1865,7 @@ static const WCHAR name5[] = { 0x4840, 0x3f3f, 0x4577, 0x446c, 0x3e6a, 0x44b2, 0
static const WCHAR name6[] = { 0x4840, 0x3e16, 0x4818, 0}; /* MOO */ static const WCHAR name6[] = { 0x4840, 0x3e16, 0x4818, 0}; /* MOO */
static const WCHAR name7[] = { 0x4840, 0x3c8b, 0x3a97, 0x409b, 0 }; /* BINARY */ static const WCHAR name7[] = { 0x4840, 0x3c8b, 0x3a97, 0x409b, 0 }; /* BINARY */
static const WCHAR name8[] = { 0x3c8b, 0x3a97, 0x409b, 0x387e, 0 }; /* BINARY.1 */ static const WCHAR name8[] = { 0x3c8b, 0x3a97, 0x409b, 0x387e, 0 }; /* BINARY.1 */
static const WCHAR name9[] = { 0x4840, 0x4559, 0x44f2, 0x4568, 0x4737, 0 }; /* Property */
/* data in each table */ /* data in each table */
static const WCHAR data1[] = { /* AAR */ static const WCHAR data1[] = { /* AAR */
@ -1867,12 +1877,15 @@ static const WCHAR data2[] = { /* _Columns */
0x0401, 0x0001, 0x8004, 0x0003, 0x9502, 0x0401, 0x0001, 0x8004, 0x0003, 0x9502,
0x0401, 0x0005, 0x0000, 0x0006, 0xbdff, /* 0x0401 = add row (1), 4 shorts */ 0x0401, 0x0005, 0x0000, 0x0006, 0xbdff, /* 0x0401 = add row (1), 4 shorts */
0x0401, 0x0005, 0x0000, 0x0007, 0x8502, 0x0401, 0x0005, 0x0000, 0x0007, 0x8502,
0x0401, 0x000a, 0x0000, 0x000a, 0xad48,
0x0401, 0x000a, 0x0000, 0x000b, 0x9d00,
}; };
static const WCHAR data3[] = { /* _Tables */ static const WCHAR data3[] = { /* _Tables */
0x0101, 0x0005, /* 0x0101 = add row (1), 1 short */ 0x0101, 0x0005, /* 0x0101 = add row (1), 1 short */
0x0101, 0x000a,
}; };
static const char data4[] = /* _StringData */ static const char data4[] = /* _StringData */
"MOOCOWPIGcAARCARBARvwbmw"; /* all the strings squashed together */ "MOOCOWPIGcAARCARBARvwbmwPropertyValuepropval"; /* all the strings squashed together */
static const WCHAR data5[] = { /* _StringPool */ static const WCHAR data5[] = { /* _StringPool */
/* len, refs */ /* len, refs */
0, 0, /* string 0 '' */ 0, 0, /* string 0 '' */
@ -1885,6 +1898,10 @@ static const WCHAR data5[] = { /* _StringPool */
3, 1, /* string 7 'BAR' */ 3, 1, /* string 7 'BAR' */
2, 1, /* string 8 'vw' */ 2, 1, /* string 8 'vw' */
3, 1, /* string 9 'bmw' */ 3, 1, /* string 9 'bmw' */
8, 4, /* string 10 'Property' */
5, 1, /* string 11 'Value' */
4, 1, /* string 12 'prop' */
3, 1, /* string 13 'val' */
}; };
/* update row, 0x0002 is a bitmask of present column data, keys are excluded */ /* update row, 0x0002 is a bitmask of present column data, keys are excluded */
static const WCHAR data6[] = { /* MOO */ static const WCHAR data6[] = { /* MOO */
@ -1899,6 +1916,10 @@ static const WCHAR data7[] = { /* BINARY */
static const char data8[] = /* stream data for the BINARY table */ static const char data8[] = /* stream data for the BINARY table */
"naengmyon"; "naengmyon";
static const WCHAR data9[] = { /* Property */
0x0201, 0x000c, 0x000d,
};
static const struct { static const struct {
LPCWSTR name; LPCWSTR name;
const void *data; const void *data;
@ -1913,6 +1934,7 @@ static const struct {
{ name6, data6, sizeof data6 }, { name6, data6, sizeof data6 },
{ name7, data7, sizeof data7 }, { name7, data7, sizeof data7 },
{ name8, data8, sizeof data8 - 1 }, { name8, data8, sizeof data8 - 1 },
{ name9, data9, sizeof data9 },
}; };
#define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0]) #define NUM_TRANSFORM_TABLES (sizeof table_transform_data/sizeof table_transform_data[0])
@ -1958,21 +1980,94 @@ static void generate_transform_manual(void)
IStorage_Release(stg); IStorage_Release(stg);
} }
static UINT set_summary_info(MSIHANDLE hdb)
{
UINT res;
MSIHANDLE suminfo;
/* build summmary info */
res = MsiGetSummaryInformation(hdb, NULL, 7, &suminfo);
ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
res = MsiSummaryInfoSetProperty(suminfo,2, VT_LPSTR, 0,NULL,
"Installation Database");
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo,3, VT_LPSTR, 0,NULL,
"Installation Database");
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo,4, VT_LPSTR, 0,NULL,
"Wine Hackers");
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo,7, VT_LPSTR, 0,NULL,
";1033");
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo,9, VT_LPSTR, 0,NULL,
"{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo, 14, VT_I4, 100, NULL, NULL);
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoSetProperty(suminfo, 15, VT_I4, 0, NULL, NULL);
ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
res = MsiSummaryInfoPersist(suminfo);
ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
res = MsiCloseHandle( suminfo);
ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
return res;
}
static MSIHANDLE create_package_db(LPCSTR filename)
{
MSIHANDLE hdb = 0;
UINT res;
DeleteFile(msifile);
/* create an empty database */
res = MsiOpenDatabase(filename, MSIDBOPEN_CREATE, &hdb );
ok( res == ERROR_SUCCESS , "Failed to create database\n" );
if( res != ERROR_SUCCESS )
return hdb;
res = MsiDatabaseCommit( hdb );
ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
res = set_summary_info(hdb);
res = run_query( hdb, 0,
"CREATE TABLE `Directory` ( "
"`Directory` CHAR(255) NOT NULL, "
"`Directory_Parent` CHAR(255), "
"`DefaultDir` CHAR(255) NOT NULL "
"PRIMARY KEY `Directory`)" );
ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
return hdb;
}
static void test_try_transform(void) static void test_try_transform(void)
{ {
MSIHANDLE hdb, hview, hrec; MSIHANDLE hdb, hview, hrec, hpkg;
LPCSTR query; LPCSTR query;
UINT r; UINT r;
DWORD sz; DWORD sz;
char buffer[0x10]; char buffer[MAX_PATH];
DeleteFile(msifile); DeleteFile(msifile);
DeleteFile(msifile2); DeleteFile(msifile2);
DeleteFile(mstfile); DeleteFile(mstfile);
/* create an empty database */ /* create the database */
r = MsiOpenDatabase(msifile2, MSIDBOPEN_CREATE, &hdb ); hdb = create_package_db(msifile2);
ok( r == ERROR_SUCCESS , "Failed to create database\n" ); ok(hdb, "Failed to create package db\n");
query = "CREATE TABLE `MOO` ( `NOO` SHORT NOT NULL, `OOO` CHAR(255) PRIMARY KEY `NOO`)"; query = "CREATE TABLE `MOO` ( `NOO` SHORT NOT NULL, `OOO` CHAR(255) PRIMARY KEY `NOO`)";
r = run_query(hdb, 0, query); r = run_query(hdb, 0, query);
@ -2134,6 +2229,17 @@ static void test_try_transform(void)
MsiCloseHandle(hview); MsiCloseHandle(hview);
MsiCloseHandle(hdb); MsiCloseHandle(hdb);
/* check that the property was added */
r = MsiOpenPackage(msifile2, &hpkg);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
sz = MAX_PATH;
r = MsiGetProperty(hpkg, "prop", buffer, &sz);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmp(buffer, "val"), "Expected val, got %s\n", buffer);
MsiCloseHandle(hpkg);
DeleteFile(msifile); DeleteFile(msifile);
DeleteFile(msifile2); DeleteFile(msifile2);
DeleteFile(mstfile); DeleteFile(mstfile);