wined3d: Unify pixel format correction.
[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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, 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(void)
131 {
132     HRESULT res;
133     CHAR path[MAX_PATH];
134     CHAR windir[MAX_PATH];
135
136     lstrcpyA(path, CURR_DIR);
137     lstrcatA(path, "\\backup\\basename.INI");
138
139     /* native AddDelBackupEntry crashes if lpcszBaseName is NULL */
140
141     /* try a NULL file list */
142     res = pAddDelBackupEntry(NULL, "backup", "basename", AADBE_ADD_ENTRY);
143     ok(res == S_OK, "Expected S_OK, got %d\n", res);
144     ok(!DeleteFileA(path), "Expected path to not exist\n");
145
146     lstrcpyA(path, CURR_DIR);
147     lstrcatA(path, "\\backup\\.INI");
148
149     /* try an empty base name */
150     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "", AADBE_ADD_ENTRY);
151     ok(res == S_OK, "Expected S_OK, got %d\n", res);
152     ok(!DeleteFileA(path), "Expected path to not exist\n");
153
154     lstrcpyA(path, CURR_DIR);
155     lstrcatA(path, "\\basename.INI");
156
157     /* try an invalid flag */
158     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", 0);
159     ok(res == S_OK, "Expected S_OK, got %d\n", res);
160     ok(!DeleteFileA(path), "Expected path to not exist\n");
161
162     lstrcpyA(path, "c:\\basename.INI");
163
164     /* create the INF file */
165     res = pAddDelBackupEntry("one\0two\0three\0", "c:\\", "basename", AADBE_ADD_ENTRY);
166     ok(res == S_OK, "Expected S_OK, got %d\n", res);
167     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
168     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
169     ok(DeleteFileA(path), "Expected path to exist\n");
170
171     lstrcpyA(path, CURR_DIR);
172     lstrcatA(path, "\\backup\\basename.INI");
173
174     /* try to create the INI file in a nonexistent directory */
175     RemoveDirectoryA("backup");
176     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
177     ok(res == S_OK, "Expected S_OK, got %d\n", res);
178     ok(!check_ini_file_attr(path), "Expected ini file to not be hidden\n");
179     ok(!check_ini_contents(path, TRUE), "Expected ini contents to not match\n");
180     ok(!DeleteFileA(path), "Expected path to not exist\n");
181
182     /* try an existent, relative backup directory */
183     CreateDirectoryA("backup", NULL);
184     res = pAddDelBackupEntry("one\0two\0three\0", "backup", "basename", AADBE_ADD_ENTRY);
185     ok(res == S_OK, "Expected S_OK, got %d\n", res);
186     ok(check_ini_file_attr(path), "Expected ini file to be hidden\n");
187     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
188     ok(DeleteFileA(path), "Expected path to exist\n");
189     RemoveDirectoryA("backup");
190
191     GetWindowsDirectoryA(windir, sizeof(windir));
192     sprintf(path, "%s\\basename.INI", windir);
193
194     /* try a NULL backup dir, INI is created in the windows directory */
195     res = pAddDelBackupEntry("one\0two\0three\0", NULL, "basename", AADBE_ADD_ENTRY);
196     ok(res == S_OK, "Expected S_OK, got %d\n", res);
197     ok(check_ini_contents(path, TRUE), "Expected ini contents to match\n");
198
199     /* remove the entries with AADBE_DEL_ENTRY */
200     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
201     res = pAddDelBackupEntry("one\0three\0", NULL, "basename", AADBE_DEL_ENTRY);
202     SetFileAttributesA(path, FILE_ATTRIBUTE_NORMAL);
203     ok(res == S_OK, "Expected S_OK, got %d\n", res);
204     ok(check_ini_contents(path, FALSE), "Expected ini contents to match\n");
205     ok(DeleteFileA(path), "Expected path to exist\n");
206 }
207
208 /* the FCI callbacks */
209
210 static void *mem_alloc(ULONG cb)
211 {
212     return HeapAlloc(GetProcessHeap(), 0, cb);
213 }
214
215 static void mem_free(void *memory)
216 {
217     HeapFree(GetProcessHeap(), 0, memory);
218 }
219
220 static BOOL get_next_cabinet(PCCAB pccab, ULONG  cbPrevCab, void *pv)
221 {
222     return TRUE;
223 }
224
225 static long progress(UINT typeStatus, ULONG cb1, ULONG cb2, void *pv)
226 {
227     return 0;
228 }
229
230 static int file_placed(PCCAB pccab, char *pszFile, long cbFile,
231                        BOOL fContinuation, void *pv)
232 {
233     return 0;
234 }
235
236 static INT_PTR fci_open(char *pszFile, int oflag, int pmode, int *err, void *pv)
237 {
238     HANDLE handle;
239     DWORD dwAccess = 0;
240     DWORD dwShareMode = 0;
241     DWORD dwCreateDisposition = OPEN_EXISTING;
242     
243     dwAccess = GENERIC_READ | GENERIC_WRITE;
244     /* FILE_SHARE_DELETE is not supported by Windows Me/98/95 */
245     dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
246
247     if (GetFileAttributesA(pszFile) != INVALID_FILE_ATTRIBUTES)
248         dwCreateDisposition = OPEN_EXISTING;
249     else
250         dwCreateDisposition = CREATE_NEW;
251
252     handle = CreateFileA(pszFile, dwAccess, dwShareMode, NULL,
253                          dwCreateDisposition, 0, NULL);
254
255     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszFile);
256
257     return (INT_PTR)handle;
258 }
259
260 static UINT fci_read(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
261 {
262     HANDLE handle = (HANDLE)hf;
263     DWORD dwRead;
264     BOOL res;
265     
266     res = ReadFile(handle, memory, cb, &dwRead, NULL);
267     ok(res, "Failed to ReadFile\n");
268
269     return dwRead;
270 }
271
272 static UINT fci_write(INT_PTR hf, void *memory, UINT cb, int *err, void *pv)
273 {
274     HANDLE handle = (HANDLE)hf;
275     DWORD dwWritten;
276     BOOL res;
277
278     res = WriteFile(handle, memory, cb, &dwWritten, NULL);
279     ok(res, "Failed to WriteFile\n");
280
281     return dwWritten;
282 }
283
284 static int fci_close(INT_PTR hf, int *err, void *pv)
285 {
286     HANDLE handle = (HANDLE)hf;
287     ok(CloseHandle(handle), "Failed to CloseHandle\n");
288
289     return 0;
290 }
291
292 static long fci_seek(INT_PTR hf, long dist, int seektype, int *err, void *pv)
293 {
294     HANDLE handle = (HANDLE)hf;
295     DWORD ret;
296     
297     ret = SetFilePointer(handle, dist, NULL, seektype);
298     ok(ret != INVALID_SET_FILE_POINTER, "Failed to SetFilePointer\n");
299
300     return ret;
301 }
302
303 static int fci_delete(char *pszFile, int *err, void *pv)
304 {
305     BOOL ret = DeleteFileA(pszFile);
306     ok(ret, "Failed to DeleteFile %s\n", pszFile);
307
308     return 0;
309 }
310
311 static BOOL get_temp_file(char *pszTempName, int cbTempName, void *pv)
312 {
313     LPSTR tempname;
314
315     tempname = HeapAlloc(GetProcessHeap(), 0, MAX_PATH);
316     GetTempFileNameA(".", "xx", 0, tempname);
317
318     if (tempname && (strlen(tempname) < (unsigned)cbTempName))
319     {
320         lstrcpyA(pszTempName, tempname);
321         HeapFree(GetProcessHeap(), 0, tempname);
322         return TRUE;
323     }
324
325     HeapFree(GetProcessHeap(), 0, tempname);
326
327     return FALSE;
328 }
329
330 static INT_PTR get_open_info(char *pszName, USHORT *pdate, USHORT *ptime,
331                              USHORT *pattribs, int *err, void *pv)
332 {
333     BY_HANDLE_FILE_INFORMATION finfo;
334     FILETIME filetime;
335     HANDLE handle;
336     DWORD attrs;
337     BOOL res;
338
339     handle = CreateFile(pszName, GENERIC_READ, FILE_SHARE_READ, NULL,
340                         OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
341
342     ok(handle != INVALID_HANDLE_VALUE, "Failed to CreateFile %s\n", pszName);
343
344     res = GetFileInformationByHandle(handle, &finfo);
345     ok(res, "Expected GetFileInformationByHandle to succeed\n");
346    
347     FileTimeToLocalFileTime(&finfo.ftLastWriteTime, &filetime);
348     FileTimeToDosDateTime(&filetime, pdate, ptime);
349
350     attrs = GetFileAttributes(pszName);
351     ok(attrs != INVALID_FILE_ATTRIBUTES, "Failed to GetFileAttributes\n");
352
353     return (INT_PTR)handle;
354 }
355
356 static void add_file(HFCI hfci, char *file)
357 {
358     char path[MAX_PATH];
359     BOOL res;
360
361     lstrcpyA(path, CURR_DIR);
362     lstrcatA(path, "\\");
363     lstrcatA(path, file);
364
365     res = FCIAddFile(hfci, path, file, FALSE, get_next_cabinet, progress,
366                      get_open_info, tcompTYPE_MSZIP);
367     ok(res, "Expected FCIAddFile to succeed\n");
368 }
369
370 static void set_cab_parameters(PCCAB pCabParams)
371 {
372     ZeroMemory(pCabParams, sizeof(CCAB));
373
374     pCabParams->cb = MEDIA_SIZE;
375     pCabParams->cbFolderThresh = FOLDER_THRESHOLD;
376     pCabParams->setID = 0xbeef;
377     lstrcpyA(pCabParams->szCabPath, CURR_DIR);
378     lstrcatA(pCabParams->szCabPath, "\\");
379     lstrcpyA(pCabParams->szCab, "extract.cab");
380 }
381
382 static void create_cab_file(void)
383 {
384     CCAB cabParams;
385     HFCI hfci;
386     ERF erf;
387     static CHAR a_txt[] = "a.txt",
388                 b_txt[] = "b.txt",
389                 testdir_c_txt[] = "testdir\\c.txt",
390                 testdir_d_txt[] = "testdir\\d.txt";
391     BOOL res;
392
393     set_cab_parameters(&cabParams);
394
395     hfci = FCICreate(&erf, file_placed, mem_alloc, mem_free, fci_open,
396                       fci_read, fci_write, fci_close, fci_seek, fci_delete,
397                       get_temp_file, &cabParams, NULL);
398
399     ok(hfci != NULL, "Failed to create an FCI context\n");
400
401     add_file(hfci, a_txt);
402     add_file(hfci, b_txt);
403     add_file(hfci, testdir_c_txt);
404     add_file(hfci, testdir_d_txt);
405
406     res = FCIFlushCabinet(hfci, FALSE, get_next_cabinet, progress);
407     ok(res, "Failed to flush the cabinet\n");
408
409     res = FCIDestroy(hfci);
410     ok(res, "Failed to destroy the cabinet\n");
411 }
412
413 static void test_ExtractFiles(void)
414 {
415     HRESULT hr;
416     char destFolder[MAX_PATH];
417
418     lstrcpyA(destFolder, CURR_DIR);
419     lstrcatA(destFolder, "\\");
420     lstrcatA(destFolder, "dest");
421
422     /* try NULL cab file */
423     hr = pExtractFiles(NULL, destFolder, 0, NULL, NULL, 0);
424     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
425     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
426     
427     /* try NULL destination */
428     hr = pExtractFiles("extract.cab", NULL, 0, NULL, NULL, 0);
429     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
430     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
431
432     /* extract all files in the cab to nonexistent destination directory */
433     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
434     ok(hr == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND),
435        "Expected %d, got %d\n", HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), hr);
436     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
437     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
438     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
439     ok(!RemoveDirectoryA("dest"), "Expected dest to not exist\n");
440
441     /* extract all files in the cab to the destination directory */
442     CreateDirectoryA("dest", NULL);
443     hr = pExtractFiles("extract.cab", destFolder, 0, NULL, NULL, 0);
444     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
445     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
446     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
447     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
448     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
449     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
450
451     /* extract all files to a relative destination directory */
452     hr = pExtractFiles("extract.cab", "dest", 0, NULL, NULL, 0);
453     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
454     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
455     ok(DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to exist\n");
456     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
457     ok(DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to exist\n");
458     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
459
460     /* only extract two of the files from the cab */
461     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:testdir\\c.txt", NULL, 0);
462     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
463     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
464     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
465     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
466     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
467     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
468
469     /* use valid chars before and after file list */
470     hr = pExtractFiles("extract.cab", "dest", 0, " :\t: a.txt:testdir\\c.txt  \t:", NULL, 0);
471     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
472     ok(DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to exist\n");
473     ok(DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to exist\n");
474     ok(RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to exist\n");
475     ok(!DeleteFileA("dest\\b.txt"), "Expected dest\\b.txt to not exist\n");
476     ok(!DeleteFileA("dest\\testdir\\d.txt"), "Expected dest\\testdir\\d.txt to not exist\n");
477
478     /* use invalid chars before and after file list */
479     hr = pExtractFiles("extract.cab", "dest", 0, " +-\\ a.txt:testdir\\c.txt  a_:", NULL, 0);
480     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
481     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
482     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
483     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
484
485     /* try an empty file list */
486     hr = pExtractFiles("extract.cab", "dest", 0, "", NULL, 0);
487     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
488     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
489     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
490
491     /* try a nonexistent file in the file list */
492     hr = pExtractFiles("extract.cab", "dest", 0, "a.txt:idontexist:testdir\\c.txt", NULL, 0);
493     ok(hr == E_FAIL, "Expected E_FAIL, got %d\n", hr);
494     ok(!DeleteFileA("dest\\a.txt"), "Expected dest\\a.txt to not exist\n");
495     ok(!DeleteFileA("dest\\testdir\\c.txt"), "Expected dest\\testdir\\c.txt to not exist\n");
496     ok(!RemoveDirectoryA("dest\\testdir"), "Expected dest\\testdir to not exist\n");
497 }
498
499 static void test_AdvInstallFile(void)
500 {
501     HRESULT hr;
502     char CURR_DIR[MAX_PATH];
503     char destFolder[MAX_PATH];
504
505     GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
506
507     lstrcpyA(destFolder, CURR_DIR);
508     lstrcatA(destFolder, "\\");
509     lstrcatA(destFolder, "dest");
510
511     createTestFile("source.txt");
512
513     /* try invalid source directory */
514     hr = pAdvInstallFile(NULL, NULL, "source.txt", destFolder, "destination.txt", 0, 0);
515     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
516     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
517
518     /* try invalid source file */
519     hr = pAdvInstallFile(NULL, CURR_DIR, NULL, destFolder, "destination.txt", 0, 0);
520     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
521     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
522
523     /* try invalid destination directory */
524     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", NULL, "destination.txt", 0, 0);
525     ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %d\n", hr);
526     ok(!DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to not exist\n");
527
528     /* try copying to nonexistent destination directory */
529     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder, "destination.txt", 0, 0);
530     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
531     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
532
533     /* native windows screws up if the source file doesn't exist */
534
535     /* test AIF_NOOVERWRITE behavior, asks the user to overwrite if AIF_QUIET is not specified */
536     createTestFile("dest\\destination.txt");
537     hr = pAdvInstallFile(NULL, CURR_DIR, "source.txt", destFolder,
538                          "destination.txt", AIF_NOOVERWRITE | AIF_QUIET, 0);
539     ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
540     ok(DeleteFileA("dest\\destination.txt"), "Expected dest\\destination.txt to exist\n");
541     ok(RemoveDirectoryA("dest"), "Expected dest to exist\n");
542
543     DeleteFileA("source.txt");
544 }
545
546 START_TEST(files)
547 {
548     init_function_pointers();
549     create_test_files();
550     create_cab_file();
551
552     test_AddDelBackupEntry();
553     test_ExtractFiles();
554     test_AdvInstallFile();
555
556     delete_test_files();
557 }