James Hawkins : msi: Test getting the source path from a package with compressed files.
Alexandre Julliard
julliard at winehq.org
Tue Jul 22 09:35:44 CDT 2008
Module: wine
Branch: master
Commit: e806a285ef4c961a5fa80f06834d0707120fdce5
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e806a285ef4c961a5fa80f06834d0707120fdce5
Author: James Hawkins <jhawkins at codeweavers.com>
Date: Tue Jul 22 00:50:24 2008 -0500
msi: Test getting the source path from a package with compressed files.
---
dlls/msi/tests/package.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++
include/msidefs.h | 8 +++
2 files changed, 149 insertions(+), 0 deletions(-)
diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c
index e94845e..ec2b590 100644
--- a/dlls/msi/tests/package.c
+++ b/dlls/msi/tests/package.c
@@ -5237,12 +5237,30 @@ static void test_complocator(void)
DeleteFileA(msifile);
}
+static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
+{
+ MSIHANDLE summary;
+ UINT r;
+
+ r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ r = MsiSummaryInfoPersist(summary);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
+
+ MsiCloseHandle(summary);
+}
+
static void test_MsiGetSourcePath(void)
{
MSIHANDLE hdb, hpkg;
CHAR path[MAX_PATH];
CHAR cwd[MAX_PATH];
CHAR subsrc[MAX_PATH];
+ CHAR sub2[MAX_PATH];
DWORD size;
UINT r;
@@ -5253,15 +5271,29 @@ static void test_MsiGetSourcePath(void)
lstrcatA(subsrc, "subsource");
lstrcatA(subsrc, "\\");
+ lstrcpyA(sub2, subsrc);
+ lstrcatA(sub2, "sub2");
+ lstrcatA(sub2, "\\");
+
+ /* uncompressed source */
+
hdb = create_package_db();
ok( hdb, "failed to create database\n");
+ set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
+
r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
ok(r == S_OK, "failed\n");
r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
ok(r == S_OK, "failed\n");
+ r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
+ ok(r == S_OK, "failed\n");
+
+ r = MsiDatabaseCommit(hdb);
+ ok(r == ERROR_SUCCESS , "Failed to commit database\n");
+
hpkg = package_from_db(hdb);
ok(hpkg, "failed to create package\n");
@@ -5340,6 +5372,15 @@ static void test_MsiGetSourcePath(void)
"Expected path to be unchanged, got \"%s\"\n", path);
ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
+ /* try SubDir2 */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SubDir2", 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, "CostInitialize");
ok(r == ERROR_SUCCESS, "cost init failed\n");
@@ -5387,6 +5428,14 @@ static void test_MsiGetSourcePath(void)
ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
+ /* try SubDir2 after CostInitialize */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
+ ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
+
r = MsiDoAction(hpkg, "ResolveSource");
ok(r == ERROR_SUCCESS, "file cost failed\n");
@@ -5431,6 +5480,14 @@ static void test_MsiGetSourcePath(void)
ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
+ /* try SubDir2 after ResolveSource */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
+ ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
+
r = MsiDoAction(hpkg, "FileCost");
ok(r == ERROR_SUCCESS, "file cost failed\n");
@@ -5467,6 +5524,14 @@ static void test_MsiGetSourcePath(void)
ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
+ /* try SubDir2 after FileCost */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
+ ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
+
r = MsiDoAction(hpkg, "CostFinalize");
ok(r == ERROR_SUCCESS, "file cost failed\n");
@@ -5503,6 +5568,14 @@ static void test_MsiGetSourcePath(void)
ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
+ /* try SubDir2 after CostFinalize */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
+ ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
+
/* nonexistent directory */
size = MAX_PATH;
lstrcpyA(path, "kiwi");
@@ -5553,6 +5626,74 @@ static void test_MsiGetSourcePath(void)
ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
MsiCloseHandle(hpkg);
+
+ /* compressed source */
+
+ r = MsiOpenDatabase(msifile, MSIDBOPEN_DIRECT, &hdb);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
+
+ hpkg = package_from_db(hdb);
+ ok(hpkg, "failed to create package\n");
+
+ r = MsiDoAction(hpkg, "CostInitialize");
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ r = MsiDoAction(hpkg, "FileCost");
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ r = MsiDoAction(hpkg, "CostFinalize");
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+
+ /* try TARGETDIR after CostFinalize */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "TARGETDIR", 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);
+
+ /* try SourceDir after CostFinalize */
+ 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);
+
+ /* try SOURCEDIR after CostFinalize */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SOURCEDIR", path, &size);
+ todo_wine
+ {
+ 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);
+ }
+
+ /* try SubDir after CostFinalize */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SubDir", path, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ todo_wine
+ {
+ ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
+ ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
+ }
+
+ /* try SubDir2 after CostFinalize */
+ size = MAX_PATH;
+ lstrcpyA(path, "kiwi");
+ r = MsiGetSourcePath(hpkg, "SubDir2", path, &size);
+ ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
+ todo_wine
+ {
+ ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
+ ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
+ }
+
+ MsiCloseHandle(hpkg);
DeleteFile(msifile);
}
diff --git a/include/msidefs.h b/include/msidefs.h
index 12b607d..141e203 100644
--- a/include/msidefs.h
+++ b/include/msidefs.h
@@ -207,6 +207,14 @@ enum msidbAssemblyAttributes
msidbAssemblyAttributesWin32 = 0x00000001,
};
+enum msidbSumInfoSourceType
+{
+ msidbSumInfoSourceTypeSFN = 0x00000001,
+ msidbSumInfoSourceTypeCompressed = 0x00000002,
+ msidbSumInfoSourceTypeAdminImage = 0x00000004,
+ msidbSumInfoSourceTypeLUAPackage = 0x00000008,
+};
+
/*
* Windows SDK braindamage alert
*
More information about the wine-cvs
mailing list