From d6bfc17ba345047b83068612f4c44587d481e73c Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Fri, 13 Jan 2006 13:54:30 +0100 Subject: [PATCH] advpack: Add initial tests for AdvInstallFile. --- dlls/advpack/tests/files.c | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/dlls/advpack/tests/files.c b/dlls/advpack/tests/files.c index 640ecb11aa9..960e4e7ff74 100644 --- a/dlls/advpack/tests/files.c +++ b/dlls/advpack/tests/files.c @@ -20,6 +20,7 @@ #include #include +#include #include #include "wine/test.h" @@ -30,6 +31,7 @@ /* function pointers */ HMODULE hAdvPack; static HRESULT (WINAPI *pExtractFiles)(LPCSTR, LPCSTR, DWORD, LPCSTR, LPVOID, DWORD); +static HRESULT (WINAPI *pAdvInstallFile)(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,DWORD,DWORD); CHAR CURR_DIR[MAX_PATH]; @@ -40,6 +42,7 @@ static void init_function_pointers() if (hAdvPack) { pExtractFiles = (void *)GetProcAddress(hAdvPack, "ExtractFiles"); + pAdvInstallFile = (void*)GetProcAddress(hAdvPack, "AdvInstallFile"); } } @@ -372,6 +375,53 @@ static void test_ExtractFiles() ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n"); } +static void test_AdvInstallFile(void) +{ + HRESULT hr; + char CURR_DIR[MAX_PATH]; + char destFolder[MAX_PATH]; + + GetCurrentDirectoryA(MAX_PATH, CURR_DIR); + + lstrcpyA(destFolder, CURR_DIR); + lstrcatA(destFolder, "\\"); + lstrcatA(destFolder, "dest"); + + createTestFile("source.txt"); + + /* try invalid source directory */ + hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr); + ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n"); + + /* try invalid source file */ + hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr); + ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n"); + + /* try invalid destination directory */ + hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0); + ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr); + ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n"); + + /* try copying to nonexistent destination directory */ + hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0); + ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); + ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n"); + + /* native windows screws up if the source file doesn't exist */ + + /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */ + createTestFile("dest\\destination.txt"); + hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, + "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0); + ok(hr == S_OK, "Expected S_OK, got %ld\n", hr); + ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n"); + ok(RemoveDirectoryA("dest"), "Expected dest to exist\n"); + + DeleteFileA("source.txt"); +} + START_TEST(files) { init_function_pointers(); @@ -379,6 +429,7 @@ START_TEST(files) create_cab_file(); test_ExtractFiles(); + test_AdvInstallFile(); delete_test_files(); }