From 34202629c92f3a723fd85d7b5f6591beecaa264c Mon Sep 17 00:00:00 2001 From: Nicolas Le Cam Date: Tue, 21 Apr 2009 02:09:24 +0200 Subject: [PATCH] msi/tests: Add empty dir test for the DrLocator part of the AppSearch action. --- dlls/msi/tests/package.c | 51 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dlls/msi/tests/package.c b/dlls/msi/tests/package.c index c5c3b67013..876626037e 100644 --- a/dlls/msi/tests/package.c +++ b/dlls/msi/tests/package.c @@ -8555,6 +8555,42 @@ static void test_appsearch_inilocator(void) DeleteFileA(msifile); } +/* + * MSI AppSearch action on DrLocator table always returns absolute paths. + * If a relative path was set, it returns the first absolute path that + * matches or an empty string if it didn't find anything. + * This helper function replicates this behaviour. + */ +static void search_absolute_directory(LPSTR absolute, LPCSTR relative) +{ + int i, size; + DWORD attr, drives; + + size = lstrlenA(relative); + drives = GetLogicalDrives(); + lstrcpyA(absolute, "A:\\"); + for (i = 0; i < 26; absolute[0] = '\0', i++) + { + if (!(drives & (1 << i))) + continue; + + absolute[0] = 'A' + i; + if (GetDriveType(absolute) != DRIVE_FIXED) + continue; + + lstrcpynA(absolute + 3, relative, size + 1); + attr = GetFileAttributesA(absolute); + if (attr != INVALID_FILE_ATTRIBUTES && + (attr & FILE_ATTRIBUTE_DIRECTORY)) + { + if (absolute[3 + size - 1] != '\\') + lstrcatA(absolute, "\\"); + break; + } + absolute[3] = '\0'; + } +} + static void test_appsearch_drlocator(void) { MSIHANDLE hpkg, hdb; @@ -8617,6 +8653,9 @@ static void test_appsearch_drlocator(void) r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'"); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'"); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + r = create_drlocator_table(hdb); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); @@ -8670,6 +8709,11 @@ static void test_appsearch_drlocator(void) r = add_drlocator_entry(hdb, path); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + /* no parent, relative empty path, depth 0, no signature */ + sprintf(path, "'NewSignature11', '', '', 0"); + r = add_drlocator_entry(hdb, path); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + r = create_signature_table(hdb); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); @@ -8770,6 +8814,13 @@ static void test_appsearch_drlocator(void) ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop); } + size = MAX_PATH; + search_absolute_directory(path, ""); + r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size); + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + todo_wine + ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop); + DeleteFileA("FileName1"); DeleteFileA("FileName3.dll"); DeleteFileA("FileName4.dll"); -- 2.32.0.93.g670b81a890