msi: Consolidate and add more SourceDir tests.

This commit is contained in:
James Hawkins 2008-07-08 00:09:45 -05:00 committed by Alexandre Julliard
parent 26ae658986
commit e59b3fa864
1 changed files with 334 additions and 164 deletions

View File

@ -4754,168 +4754,6 @@ static void test_installprops(void)
DeleteFile(msifile);
}
static void test_sourcedirprop(void)
{
MSIHANDLE hpkg, hdb;
CHAR source_dir[MAX_PATH];
CHAR path[MAX_PATH];
DWORD size;
UINT r;
hdb = create_package_db();
ok ( hdb, "failed to create package database\n" );
r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
hpkg = package_from_db( hdb );
ok( hpkg, "failed to create package\n");
MsiCloseHandle( hdb );
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
r = MsiDoAction( hpkg, "CostInitialize");
ok( r == ERROR_SUCCESS, "cost init failed\n");
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
r = MsiDoAction( hpkg, "ResolveSource");
ok( r == ERROR_SUCCESS, "file cost failed\n");
GetCurrentDirectory(MAX_PATH, path);
lstrcatA(path, "\\");
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SourceDir", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SOURCEDIR", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrcmpA(source_dir, path), "Expected %s, got %s\n", path, source_dir);
size = MAX_PATH;
r = MsiGetProperty( hpkg, "SoUrCeDiR", source_dir, &size );
ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
ok( !lstrlenA(source_dir), "Expected emtpy source dir, got %s\n", source_dir);
MsiCloseHandle(hpkg);
DeleteFileA(msifile);
}
static void test_prop_path(void)
{
MSIHANDLE hpkg, hdb;
char buffer[MAX_PATH], cwd[MAX_PATH];
DWORD sz;
UINT r;
GetCurrentDirectory(MAX_PATH, cwd);
strcat(cwd, "\\");
hdb = create_package_db();
ok( hdb, "failed to create database\n");
r = add_directory_entry( hdb, "'TARGETDIR','','SourceDir'" );
ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
r = add_directory_entry( hdb, "'foo','TARGETDIR','foosrc:footgt'" );
ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
hpkg = package_from_db(hdb);
ok( hpkg, "failed to create package\n");
r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
ok( r == ERROR_DIRECTORY, "failed to get source path\n");
r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
ok( r == ERROR_DIRECTORY, "failed to get source path\n");
r = MsiDoAction( hpkg, "CostInitialize");
ok( r == ERROR_SUCCESS, "cost init failed\n");
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
ok( r == ERROR_SUCCESS, "property not set\n");
ok( !buffer[0], "SourceDir should be empty\n");
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
ok( r == ERROR_SUCCESS, "property not set\n");
ok( !buffer[0], "SourceDir should be empty\n");
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
ok( r == ERROR_SUCCESS, "failed to get source path\n");
ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
ok( r == ERROR_SUCCESS, "property not set\n");
todo_wine {
ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
}
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetSourcePath(hpkg, "SOURCEDIR", buffer, &sz );
ok( r == ERROR_DIRECTORY, "failed to get source path\n");
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetProperty(hpkg, "SOURCEDIR", buffer, &sz);
ok( r == ERROR_SUCCESS, "property not set\n");
todo_wine {
ok( !lstrcmpi(cwd, buffer), "SourceDir (%s) should be current dir (%s)\n", buffer, cwd);
}
r = MsiSetProperty(hpkg, "SourceDir", "goo");
ok( r == ERROR_SUCCESS, "property not set\n");
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
ok( r == ERROR_SUCCESS, "property not set\n");
ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetSourcePath(hpkg, "SourceDir", buffer, &sz );
ok( r == ERROR_SUCCESS, "failed to get source path\n");
ok( !lstrcmpi(buffer, cwd), "SourceDir (%s) should be goo\n", buffer);
sz = sizeof buffer;
buffer[0] = 0;
r = MsiGetProperty(hpkg, "SourceDir", buffer, &sz);
ok( r == ERROR_SUCCESS, "property not set\n");
ok( !lstrcmpi(buffer, "goo"), "SourceDir (%s) should be goo\n", buffer);
MsiCloseHandle( hpkg );
DeleteFile(msifile);
}
static void test_launchconditions(void)
{
MSIHANDLE hpkg;
@ -5791,6 +5629,339 @@ static void test_shortlongsource(void)
DeleteFileA(msifile);
}
static void test_sourcedir(void)
{
MSIHANDLE hdb, hpkg;
CHAR package[10];
CHAR path[MAX_PATH];
CHAR cwd[MAX_PATH];
CHAR subsrc[MAX_PATH];
DWORD size;
UINT r;
lstrcpyA(cwd, CURR_DIR);
lstrcatA(cwd, "\\");
lstrcpyA(subsrc, cwd);
lstrcatA(subsrc, "long");
lstrcatA(subsrc, "\\");
hdb = create_package_db();
ok( hdb, "failed to create database\n");
r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
ok(r == S_OK, "failed\n");
sprintf(package, "#%li", hdb);
r = MsiOpenPackage(package, &hpkg);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
/* properties only */
/* SourceDir prop */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
/* SOURCEDIR prop */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
r = MsiDoAction(hpkg, "CostInitialize");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after CostInitialize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
/* SOURCEDIR after CostInitialize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
r = MsiDoAction(hpkg, "FileCost");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after FileCost */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
/* SOURCEDIR after FileCost */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
r = MsiDoAction(hpkg, "CostFinalize");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after CostFinalize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
/* SOURCEDIR after CostFinalize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
r = MsiDoAction(hpkg, "ResolveSource");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after ResolveSource */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR after ResolveSource */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* random casing */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SoUrCeDiR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
MsiCloseHandle(hpkg);
/* reset the package state */
sprintf(package, "#%li", hdb);
r = MsiOpenPackage(package, &hpkg);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
/* test how MsiGetSourcePath affects the properties */
/* SourceDir prop */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
}
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
ok(!lstrcmpA(path, "kiwi"),
"Expected path to be unchanged, got \"%s\"\n", path);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
/* SourceDir after MsiGetSourcePath */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
}
/* SOURCEDIR prop */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
}
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
ok(!lstrcmpA(path, "kiwi"),
"Expected path to be unchanged, got \"%s\"\n", path);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
/* SOURCEDIR prop after MsiGetSourcePath */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
}
r = MsiDoAction(hpkg, "CostInitialize");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after CostInitialize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
todo_wine
{
ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
ok(size == 0, "Expected 0, got %d\n", size);
}
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetSourcePath(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SourceDir after MsiGetSourcePath */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR after CostInitialize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR source path still does not exist */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
ok(!lstrcmpA(path, "kiwi"),
"Expected path to be unchanged, got \"%s\"\n", path);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
r = MsiDoAction(hpkg, "FileCost");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after FileCost */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR after FileCost */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR source path still does not exist */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
ok(!lstrcmpA(path, "kiwi"),
"Expected path to be unchanged, got \"%s\"\n", path);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
r = MsiDoAction(hpkg, "CostFinalize");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after CostFinalize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR after CostFinalize */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR source path still does not exist */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
ok(!lstrcmpA(path, "kiwi"),
"Expected path to be unchanged, got \"%s\"\n", path);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
r = MsiDoAction(hpkg, "ResolveSource");
ok(r == ERROR_SUCCESS, "file cost failed\n");
/* SourceDir after ResolveSource */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SourceDir", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR after ResolveSource */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetProperty(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
/* SOURCEDIR source path still does not exist */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
ok(!lstrcmpA(path, "kiwi"),
"Expected path to be unchanged, got \"%s\"\n", path);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
MsiCloseHandle(hdb);
MsiCloseHandle(hpkg);
DeleteFileA(msifile);
}
START_TEST(package)
{
GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
@ -5810,11 +5981,10 @@ START_TEST(package)
test_appsearch();
test_featureparents();
test_installprops();
test_sourcedirprop();
test_prop_path();
test_launchconditions();
test_ccpsearch();
test_complocator();
test_MsiGetSourcePath();
test_shortlongsource();
test_sourcedir();
}