comctl32: A couple fixes for tab icon offsets.
[wine] / dlls / advpack / tests / files.c
1 /*
2  * Unit tests for advpack.dll file functions
3  *
4  * Copyright (C) 2006 James Hawkins
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  */
20
21 #include <stdio.h>
22 #include <windows.h>
23 #include <advpub.h>
24 #include <fci.h>
25 #include "wine/test.h"
26
27 /* make the max size large so there is only one cab file */
28 #define MEDIA_SIZE          999999999
29 #define FOLDER_THRESHOLD    900000
30
31 /* function pointers */
32 HMODULE hAdvPack;
33 static HRESULT (WINAPI *pAddDelBackupEntry)(LPCSTR, LPCSTR, LPCSTR, DWORD);
34 static HRESULT (WINAPI *pExtractFiles)(LPCSTR, LPCSTR, DWORD, LPCSTR, LPVOID, DWORD);
35 static HRESULT (WINAPI *pAdvInstallFile)(HWND,LPCSTR,LPCSTR,LPCSTR,LPCSTR,DWORD,DWORD);
36
37 CHAR CURR_DIR[MAX_PATH];
38
39 static void init_function_pointers(void)
40 {
41     hAdvPack = LoadLibraryA("advpack.dll");
42
43     if (hAdvPack)
44     {
45         pAddDelBackupEntry = (void *)GetProcAddress(hAdvPack, "AddDelBackupEntry");
46         pExtractFiles = (void *)GetProcAddress(hAdvPack, "ExtractFiles");
47         pAdvInstallFile = (void*)GetProcAddress(hAdvPack, "AdvInstallFile");
48     }
49 }
50
51 /* creates a file with the specified name for tests */
52 static void createTestFile(const CHAR *name)
53 {
54     HANDLE file;
55     DWORD written;
56
57     file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
58     ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
59     WriteFile(file, name, strlen(name), &written, NULL);
60     WriteFile(file, "\n", strlen("\n"), &written, NULL);
61     CloseHandle(file);
62 }
63
64 static void create_test_files(void)
65 {
66     int len;
67
68     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
69     len = lstrlenA(CURR_DIR);
70
71     if(len && (CURR_DIR[len-1] == '\\'))
72         CURR_DIR[len-1] = 0;
73
74     createTestFile("a.txt");
75     createTestFile("b.txt");
76     CreateDirectoryA("testdir", NULL);
77     createTestFile("testdir\\c.txt");
78     createTestFile("testdir\\d.txt");
79     CreateDirectoryA("dest", NULL);
80 }
81
82 static void delete_test_files(void)
83 {
84     DeleteFileA("a.txt");
85     DeleteFileA("b.txt");
86     DeleteFileA("testdir\\c.txt");
87     DeleteFileA("testdir\\d.txt");
88     RemoveDirectoryA("testdir");
89     RemoveDirectoryA("dest");
90
91     DeleteFileA("extract.cab");
92 }
93
94 static BOOL check_ini_file_attr(LPSTR filename)
95 {
96     BOOL ret;
97     DWORD expected = FILE_ATTRIBUTE_HIDDEN | FILE_ATTRIBUTE_READONLY;
98     DWORD attr = GetFileAttributesA(filename);
99
100     ret = (attr & expected) && (attr != INVALID_FILE_ATTRIBUTES);
101     SetFileAttributesA(filename, FILE_ATTRIBUTE_NORMAL);
102
103     return ret;
104 }
105
106 #define FIELD_LEN   16
107
108 static BOOL check_ini_contents(LPSTR filename, BOOL add)
109 {
110     CHAR field[FIELD_LEN];
111     BOOL ret = TRUE, match;
112
113     GetPrivateProfileStringA("backup", "one", NULL, field, FIELD_LEN, filename);
114     match = !lstrcmpA(field, "-1,0,0,0,0,0,-1");
115     if ((add && !match) || (!add && match))
116         ret = FALSE;
117
118     GetPrivateProfileStringA("backup", "two", NULL, field, FIELD_LEN, filename);
119     if (lstrcmpA(field, "-1,0,0,0,0,0,-1"))
120         ret = FALSE;
121
122     GetPrivateProfileStringA("backup", "three", NULL, field, FIELD_LEN, filename);
123     match = !lstrcmpA(field, "-1,0,0,0,0,0,-1");
124     if ((add && !match) || (!add && match))
125         ret = FALSE;
126
127     return ret;
128 }
129
130 static void test_AddDelBackupEntry()
131 {
132     HRESULT res;
133     CHAR path[MAX_PATH];
134
135     lstrcpyA(path, CURR_DIR);
136     lstrcatA(path, "\\backup\\basename.INI");
137
138     /* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
139
140     /* try a NULL file list */
141     res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
142     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
143     ok(!DeleteFileA(path), "Expected path to not exist\n");
144
145     lstrcpyA(path, CURR_DIR);
146     lstrcatA(path, "\\backup\\.INI");
147
148     /* try an empty base name */
149     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
150     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
151     ok(!DeleteFileA(path), "Expected path to not exist\n");
152
153     lstrcpyA(path, CURR_DIR);
154     lstrcatA(path, "\\basename.INI");
155
156     /* try an invalid flag */
157     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
158     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
159     ok(!DeleteFileA(path), "Expected path to not exist\n");
160
161     lstrcpyA(path, "c:\\basename.INI");
162
163     /* create the INF file */
164     res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
165     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
166     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
167     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
168     ok(DeleteFileA(path), "Expected path to exist\n");
169
170     lstrcpyA(path, CURR_DIR);
171     lstrcatA(path, "\\backup\\basename.INI");
172
173     /* try to create the INI file in a nonexistent directory */
174     RemoveDirectoryA("backup");
175     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
176     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
177     ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
178     ok(!check_ini_contents(path, TRUE), "Expected ini contents to not match\n");
179     ok(!DeleteFileA(path), "Expected path to not exist\n");
180
181     /* try an existent, relative backup directory */
182     CreateDirectoryA("backup", NULL);
183     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
184     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
185     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
186     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
187     ok(DeleteFileA(path), "Expected path to exist\n");
188     RemoveDirectoryA("backup");
189
190     lstrcpyA(path, "c:\\windows\\basename.INI");
191
192     /* try a NULL backup dir, INI is created in c:\windows */
193     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
194     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
195     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
196
197     /* remove the entries with AADBE_DEL_ENTRY */
198     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
199     res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
200     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
201     ok(res == S_OK, "Expected S_OK, got %ld\n", res);
202     ok(check_ini_contents(path, FALSE), "Expected ini contents to match\n");
203     ok(DeleteFileA(path), "Expected path to exist\n");
204 }
205
206 /* the FCI callbacks */
207
208 static void *mem_alloc(ULONG cb)
209 {
210     return HeapAlloc(GetProcessHeap(), 0, cb);
211 }
212
213 static void mem_free(void *memory)
214 {
215     HeapFree(GetProcessHeap(), 0, memory);
216 }
217
218 static BOOL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
219 {
220     return TRUE;
221 }
222
223 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
224 {
225     return 0;
226 }
227
228 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
229                        BOOL fContinuation, void *pv)
230 {
231     return 0;
232 }
233
234 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
235 {
236     HANDLE handle;
237     DWORD dwAccess = 0;
238     DWORD dwShareMode = 0;
239     DWORD dwCreateDisposition = OPEN_EXISTING;
240     
241     dwAccess = GENERIC_READ | GENERIC_WRITE;
242     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE;
243
244     if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
245         dwCreateDisposition = OPEN_EXISTING;
246     else
247         dwCreateDisposition = CREATE_NEW;
248
249     handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
250                          dwCreateDisposition, 0, NULL);
251
252     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
253
254     return (INT_PTR)handle;
255 }
256
257 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
258 {
259     HANDLE handle = (HANDLE)hf;
260     DWORD dwRead;
261     BOOL res;
262     
263     res = ReadFile(handle, memory, cb, &dwRead, NULL);
264     ok(res, "Failed to ReadFile\n");
265
266     return dwRead;
267 }
268
269 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
270 {
271     HANDLE handle = (HANDLE)hf;
272     DWORD dwWritten;
273     BOOL res;
274
275     res = WriteFile(handle, memory, cb, &dwWritten, NULL);
276     ok(res, "Failed to WriteFile\n");
277
278     return dwWritten;
279 }
280
281 static int fci_close(INT_PTR hf, int *err, void *pv)
282 {
283     HANDLE handle = (HANDLE)hf;
284     ok(CloseHandle(handle), "Failed to CloseHandle\n");
285
286     return 0;
287 }
288
289 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
290 {
291     HANDLE handle = (HANDLE)hf;
292     DWORD ret;
293     
294     ret = SetFilePointer(handle, dist, NULL, seektype);
295     ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
296
297     return ret;
298 }
299
300 static int fci_delete(char *pszFile, int *err, void *pv)
301 {
302     BOOL ret = DeleteFileA(pszFile);
303     ok(ret, "Failed to DeleteFile %s\n", pszFile);
304
305     return 0;
306 }
307
308 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
309 {
310     LPSTR tempname;
311
312     tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
313     GetTempFileNameA(".", "xx", 0, tempname);
314
315     if (tempname && (strlen(tempname) < (unsigned)cbTempName))
316     {
317         lstrcpyA(pszTempName, tempname);
318         HeapFree(GetProcessHeap(), 0, tempname);
319         return TRUE;
320     }
321
322     HeapFree(GetProcessHeap(), 0, tempname);
323
324     return FALSE;
325 }
326
327 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
328                              USHORT *pattribs, int *err, void *pv)
329 {
330     BY_HANDLE_FILE_INFORMATION finfo;
331     FILETIME filetime;
332     HANDLE handle;
333     DWORD attrs;
334     BOOL res;
335
336     handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
337                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
338
339     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
340
341     res = GetFileInformationByHandle(handle, &finfo);
342     ok(res, "Expected GetFileInformationByHandle to succeed\n");
343    
344     FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
345     FileTimeToDosDateTime(&filetime, pdate, ptime);
346
347     attrs = GetFileAttributes(pszName);
348     ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
349
350     return (INT_PTR)handle;
351 }
352
353 static void add_file(HFCI hfci, char *file)
354 {
355     char path[MAX_PATH];
356     BOOL res;
357
358     lstrcpyA(path, CURR_DIR);
359     lstrcatA(path, "\\");
360     lstrcatA(path, file);
361
362     res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
363                      get_open_info, tcompTYPE_MSZIP);
364     ok(res, "Expected FCIAddFile to succeed\n");
365 }
366
367 static void set_cab_parameters(PCCAB pCabParams)
368 {
369     ZeroMemory(pCabParams, sizeof(CCAB));
370
371     pCabParams->cb = MEDIA_SIZE;
372     pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
373     pCabParams->setID = 0xbeef;
374     lstrcpyA(pCabParams->szCabPath, CURR_DIR);
375     lstrcatA(pCabParams->szCabPath, "\\");
376     lstrcpyA(pCabParams->szCab, "extract.cab");
377 }
378
379 static void create_cab_file(void)
380 {
381     CCAB cabParams;
382     HFCI hfci;
383     ERF erf;
384     BOOL res;
385
386     set_cab_parameters(&cabParams);
387
388     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
389                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
390                       get_temp_file, &cabParams, NULL);
391
392     ok(hfci != NULL, "Failed to create an FCI context\n");
393
394     add_file(hfci, "a.txt");
395     add_file(hfci, "b.txt");
396     add_file(hfci, "testdir\\c.txt");
397     add_file(hfci, "testdir\\d.txt");
398
399     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
400     ok(res, "Failed to flush the cabinet\n");
401
402     res = FCIDestroy(hfci);
403     ok(res, "Failed to destroy the cabinet\n");
404 }
405
406 static void test_ExtractFiles(void)
407 {
408     HRESULT hr;
409     char destFolder[MAX_PATH];
410
411     lstrcpyA(destFolder, CURR_DIR);
412     lstrcatA(destFolder, "\\");
413     lstrcatA(destFolder, "dest");
414
415     /* try NULL cab file */
416     hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
417     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
418     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
419     
420     /* try NULL destination */
421     hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
422     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
423     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
424
425     /* extract all files in the cab to nonexistent destination directory */
426     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
427     ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND),
428        "Expected %ld, got %ld\n", HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), hr);
429     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
430     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
431     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
432     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
433
434     /* extract all files in the cab to the destination directory */
435     CreateDirectoryA("dest", NULL);
436     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
437     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
438     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
439     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
440     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
441     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
442     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
443
444     /* extract all files to a relative destination directory */
445     hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
446     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
447     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
448     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
449     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
450     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
451     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
452
453     /* only extract two of the files from the cab */
454     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
455     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
456     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
457     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
458     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
459     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
460     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
461
462     /* use valid chars before and after file list */
463     hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt  \t:", NULL, 0);
464     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
465     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
466     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
467     ok(RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to exist\n");
468     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
469     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
470
471     /* use invalid chars before and after file list */
472     hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt  a_:", NULL, 0);
473     ok(hr == E_FAIL, "Expected E_FAIL, got %ld\n", hr);
474     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
475     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
476     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
477
478     /* try an empty file list */
479     hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
480     ok(hr == E_FAIL, "Expected E_FAIL, got %ld\n", hr);
481     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
482     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
483
484     /* try a nonexistent file in the file list */
485     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
486     ok(hr == E_FAIL, "Expected E_FAIL, got %ld\n", hr);
487     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
488     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
489     ok(!RemoveDirectoryA("dest\\testdir"), "Exepected dest\\testdir to not exist\n");
490 }
491
492 static void test_AdvInstallFile(void)
493 {
494     HRESULT hr;
495     char CURR_DIR[MAX_PATH];
496     char destFolder[MAX_PATH];
497
498     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
499
500     lstrcpyA(destFolder, CURR_DIR);
501     lstrcatA(destFolder, "\\");
502     lstrcatA(destFolder, "dest");
503
504     createTestFile("source.txt");
505
506     /* try invalid source directory */
507     hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0);
508     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
509     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
510
511     /* try invalid source file */
512     hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0);
513     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
514     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
515
516     /* try invalid destination directory */
517     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0);
518     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %ld\n", hr);
519     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
520
521     /* try copying to nonexistent destination directory */
522     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0);
523     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
524     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
525
526     /* native windows screws up if the source file doesn't exist */
527
528     /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */
529     createTestFile("dest\\destination.txt");
530     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder,
531                          "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0);
532     ok(hr == S_OK, "Expected S_OK, got %ld\n", hr);
533     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
534     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
535
536     DeleteFileA("source.txt");
537 }
538
539 START_TEST(files)
540 {
541     init_function_pointers();
542     create_test_files();
543     create_cab_file();
544
545     test_AddDelBackupEntry();
546     test_ExtractFiles();
547     test_AdvInstallFile();
548
549     delete_test_files();
550 }