From: Ziqing Hui zhui@codeweavers.com
--- dlls/shell32/tests/shlfileop.c | 356 +++++++++++---------------------- 1 file changed, 113 insertions(+), 243 deletions(-)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index d69995d06eb..46d32390c8c 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -913,16 +913,10 @@ static void test_rename(void) static void test_copy(void) { char from[5 * MAX_PATH], to[5 * MAX_PATH]; - SHFILEOPSTRUCTA shfo; DWORD retval; LPSTR ptr; BOOL ret;
- shfo.hwnd = NULL; - shfo.wFunc = FO_COPY; - shfo.hNameMappings = NULL; - shfo.lpszProgressTitle = NULL; - /* Sources and targets have the same number, no FOF_MULTIDESTFILES. */ set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); @@ -1180,14 +1174,11 @@ static void test_copy(void) RemoveDirectoryA("c.txt"); }
- /* copy a directory with a file beneath it, plus some files */ + /* Copy a file and a dir containing file to another dir. */ createTestFile("test4.txt\a.txt"); - shfo.pFrom = "test4.txt\0test1.txt\0"; - shfo.pTo = "testdir2\0"; - shfo.fFlags &= ~FOF_MULTIDESTFILES; - shfo.fAnyOperationsAborted = FALSE; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, + "test4.txt\0test1.txt\0", "testdir2\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("testdir2\test1.txt"), "Expected testdir2\test1.txt to exist\n"); ok(DeleteFileA("testdir2\test4.txt\a.txt"), "Expected a.txt to exist\n"); ok(RemoveDirectoryA("testdir2\test4.txt"), "Expected testdir2\test4.txt to exist\n"); @@ -1210,214 +1201,146 @@ static void test_copy(void) RemoveDirectoryA("nonexistent"); DeleteFileA("test4.txt\a.txt");
- /* destination is same as source file */ - shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0"; - shfo.pTo = "b.txt\0test2.txt\0c.txt\0"; - shfo.fAnyOperationsAborted = FALSE; - shfo.fFlags = FOF_NOERRORUI | FOF_MULTIDESTFILES; - retval = SHFileOperationA(&shfo); - ok(retval == DE_SAMEFILE, "Expected DE_SAMEFILE, got %ld\n", retval); + /* Target file is same as source file. */ + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "test1.txt\0test2.txt\0test3.txt\0", "b.txt\0test2.txt\0c.txt\0", + DE_SAMEFILE, FALSE, FALSE, FALSE); ok(DeleteFileA("b.txt"), "Expected b.txt to exist\n"); - ok(!shfo.fAnyOperationsAborted, "Expected no operations to be aborted\n"); ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
- /* destination is same as source directory */ - shfo.pFrom = "test1.txt\0test4.txt\0test3.txt\0"; - shfo.pTo = "b.txt\0test4.txt\0c.txt\0"; - shfo.fAnyOperationsAborted = FALSE; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %ld\n", retval); + /* Target dir is same as source dir. */ + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "test1.txt\0test4.txt\0test3.txt\0", "b.txt\0test4.txt\0c.txt\0", + DE_DESTSAMETREE, FALSE, TRUE, FALSE); ok(DeleteFileA("b.txt"), "Expected b.txt to exist\n"); ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
- /* copy a directory into itself, error displayed in UI */ - shfo.pFrom = "test4.txt\0"; - shfo.pTo = "test4.txt\newdir\0"; - shfo.fFlags &= ~FOF_MULTIDESTFILES; - shfo.fAnyOperationsAborted = FALSE; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_DESTSUBTREE, "Expected DE_DESTSUBTREE, got %ld\n", retval); + /* Copy a dir into it's subdir. */ + check_file_operation(FO_COPY, FOF_NO_UI, + "test4.txt\0", "test4.txt\newdir\0", + DE_DESTSUBTREE, FALSE, TRUE, FALSE); ok(!RemoveDirectoryA("test4.txt\newdir"), "Expected test4.txt\newdir to not exist\n");
- /* copy a directory to itself, error displayed in UI */ - shfo.pFrom = "test4.txt\0"; - shfo.pTo = "test4.txt\0"; - shfo.fAnyOperationsAborted = FALSE; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_DESTSUBTREE, "Expected DE_DESTSUBTREE, got %ld\n", retval); + /* Copy a dir into itself. */ + check_file_operation(FO_COPY, FOF_NO_UI, "test4.txt\0", "test4.txt\0", + DE_DESTSUBTREE, FALSE, TRUE, FALSE);
- /* copy a file into a directory, and the directory into itself */ - shfo.pFrom = "test1.txt\0test4.txt\0"; - shfo.pTo = "test4.txt\0"; - shfo.fAnyOperationsAborted = FALSE; - shfo.fFlags |= FOF_NOCONFIRMATION; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_DESTSUBTREE, "Expected DE_DESTSUBTREE, got %ld\n", retval); + /* Copy a file into a dir, and the dir into itself. */ + check_file_operation(FO_COPY, FOF_NO_UI, + "test1.txt\0test4.txt\0", "test4.txt\0", + DE_DESTSUBTREE, FALSE, TRUE, FALSE); ok(DeleteFileA("test4.txt\test1.txt"), "Expected test4.txt\test1.txt to exist\n");
- /* copy a file to a file, and the directory into itself */ - shfo.pFrom = "test1.txt\0test4.txt\0"; - shfo.pTo = "test4.txt\a.txt\0"; - shfo.fAnyOperationsAborted = FALSE; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_DESTSUBTREE, "Expected DE_DESTSUBTREE, got %ld\n", retval); + /* Copy a file to a file, and the dir into it's subdir. */ + check_file_operation(FO_COPY, FOF_NO_UI, + "test1.txt\0test4.txt\0", "test4.txt\a.txt\0", + DE_DESTSUBTREE, FALSE, TRUE, TRUE); todo_wine ok(DeleteFileA("test4.txt\a.txt\test1.txt"), "Expected test4.txt\a.txt\test1.txt to exist\n"); RemoveDirectoryA("test4.txt\a.txt");
- /* copy a nonexistent file to a nonexistent directory */ - shfo.pFrom = "e.txt\0"; - shfo.pTo = "nonexistent\0"; - shfo.fAnyOperationsAborted = FALSE; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %ld\n", retval); + /* Copy a nonexistent file to a nonexistent dir. */ + check_file_operation(FO_COPY, FOF_NO_UI, "e.txt\0", "nonexistent\0", + ERROR_FILE_NOT_FOUND, FALSE, TRUE, FALSE); ok(!file_exists("nonexistent\e.txt"), "Expected nonexistent\e.txt to not exist\n"); ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n");
/* Overwrite tests */ clean_after_shfo_tests(); init_shfo_tests(); - shfo.fFlags = FOF_NOCONFIRMATION; - shfo.pFrom = "test1.txt\0"; - shfo.pTo = "test2.txt\0"; - shfo.fAnyOperationsAborted = 0xdeadbeef; - /* without FOF_NOCONFIRMATION the confirmation is Yes/No */ - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n"); + + /* Without FOF_NOCONFIRMATION the confirmation is Yes/No. */ + check_file_operation(FO_COPY, FOF_NOCONFIRMATION, "test1.txt\0", "test2.txt\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n");
- shfo.pFrom = "test3.txt\0test1.txt\0"; - shfo.pTo = "test2.txt\0one.txt\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_MULTIDESTFILES; - /* without FOF_NOCONFIRMATION the confirmation is Yes/Yes to All/No/Cancel */ - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + /* Without FOF_NOCONFIRMATION the confirmation is Yes/Yes to All/No/Cancel */ + check_file_operation(FO_COPY, FOF_NOCONFIRMATION | FOF_MULTIDESTFILES, + "test3.txt\0test1.txt\0", "test2.txt\0one.txt\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n");
- shfo.pFrom = "one.txt\0"; - shfo.pTo = "testdir2\0"; - shfo.fFlags = FOF_NOCONFIRMATION; - /* without FOF_NOCONFIRMATION the confirmation is Yes/No */ - retval = SHFileOperationA(&shfo); - ok(retval == 0, "Expected 0, got %ld\n", retval); + /* Without FOF_NOCONFIRMATION the confirmation is Yes/No */ + check_file_operation(FO_COPY, FOF_NOCONFIRMATION, "one.txt\0", "testdir2\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(file_has_content("testdir2\one.txt", "test1.txt\n"), "The file was not copied\n");
createTestFile("test4.txt\test1.txt"); - shfo.pFrom = "test4.txt\0"; - shfo.pTo = "testdir2\0"; - /* WinMe needs FOF_NOERRORUI */ - shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); - shfo.fFlags = FOF_NOCONFIRMATION; - if (ERROR_SUCCESS) - { - createTestFile("test4.txt\.\test1.txt"); /* modify the content of the file */ - /* without FOF_NOCONFIRMATION the confirmation is "This folder already contains a folder named ..." */ - retval = SHFileOperationA(&shfo); - ok(retval == 0, "Expected 0, got %ld\n", retval); - ok(file_has_content("testdir2\test4.txt\test1.txt", "test4.txt\.\test1.txt\n"), "The file was not copied\n"); - } + check_file_operation(FO_COPY, FOF_NOCONFIRMATION, "test4.txt\0", "testdir2\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE);
- createTestFile("one.txt"); + createTestFile("test4.txt\.\test1.txt"); /* Modify the content of the file. */ + /* Without FOF_NOCONFIRMATION the confirmation is "This folder already contains a folder named ...". */ + check_file_operation(FO_COPY, FOF_NOCONFIRMATION, "test4.txt\0", "testdir2\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); + ok(file_has_content("testdir2\test4.txt\test1.txt", "test4.txt\.\test1.txt\n"), "The file was not copied\n");
/* pFrom contains bogus 2nd name longer than MAX_PATH */ + createTestFile("one.txt"); memset(from, 'a', MAX_PATH*2); memset(from+MAX_PATH*2, 0, 2); lstrcpyA(from, "one.txt"); - shfo.pFrom = from; - shfo.pTo = "two.txt\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_INVALIDFILES, "Unexpected return value, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, from, "two.txt\0", + DE_INVALIDFILES, FALSE, TRUE, FALSE); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); todo_wine ok(RemoveDirectoryA("two.txt"), "Expected two.txt to exist\n");
+ /* pTo contains bogus 2nd name longer than MAX_PATH, no FOF_MULTIDESTFILES. */ createTestFile("one.txt"); - - /* pTo contains bogus 2nd name longer than MAX_PATH */ memset(to, 'a', MAX_PATH*2); memset(to+MAX_PATH*2, 0, 2); lstrcpyA(to, "two.txt"); - shfo.pFrom = "one.txt\0"; - shfo.pTo = to; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, "one.txt\0", to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(DeleteFileA("one.txt"), "Expected file to exist\n");
+ /* Copy one file to two files, no FOF_MULTIDESTFILES. */ createTestFile("one.txt"); - - /* no FOF_MULTIDESTFILES, two files in pTo */ - shfo.pFrom = "one.txt\0"; - shfo.pTo = "two.txt\0three.txt\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, + "one.txt\0", "two.txt\0three.txt\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); - - createTestFile("one.txt"); + ok(!DeleteFileA("three.txt"), "Expected file to not exist.\n");
/* both pFrom and pTo contain bogus 2nd names longer than MAX_PATH */ + createTestFile("one.txt"); memset(from, 'a', MAX_PATH*2); memset(from+MAX_PATH*2, 0, 2); memset(to, 'a', MAX_PATH*2); memset(to+MAX_PATH*2, 0, 2); lstrcpyA(from, "one.txt"); lstrcpyA(to, "two.txt"); - shfo.pFrom = from; - shfo.pTo = to; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_INVALIDFILES, "Unexpected return value, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, from, to, + DE_INVALIDFILES, FALSE, TRUE, FALSE); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); todo_wine ok(RemoveDirectoryA("two.txt"), "Expected two.txt to exist\n");
+ /* pTo contains bogus 2nd name longer than MAX_PATH, with FOF_MULTIDESTFILES. */ createTestFile("one.txt"); - - /* pTo contains bogus 2nd name longer than MAX_PATH, FOF_MULTIDESTFILES */ memset(to, 'a', MAX_PATH*2); memset(to+MAX_PATH*2, 0, 2); lstrcpyA(to, "two.txt"); - shfo.pFrom = "one.txt\0"; - shfo.pTo = to; - shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | - FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, "one.txt\0", to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(DeleteFileA("one.txt"), "Expected file to exist\n");
+ /* pTo contains bogus 2nd name longer than MAX_PATH, + * multiple source files, nonexistent target dir, no FOF_MULTIDESTFILES. */ createTestFile("one.txt"); createTestFile("two.txt"); - - /* pTo contains bogus 2nd name longer than MAX_PATH, - * multiple source files, - * dest directory does not exist - */ memset(to, 'a', 2 * MAX_PATH); memset(to+MAX_PATH*2, 0, 2); lstrcpyA(to, "threedir"); - shfo.pFrom = "one.txt\0two.txt\0"; - shfo.pTo = to; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); + check_file_operation(FO_COPY, FOF_NO_UI, + "one.txt\0two.txt\0", to, + ERROR_SUCCESS, FALSE, TRUE, TRUE); todo_wine { - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld.\n", retval); ok(DeleteFileA("threedir\one.txt"), "Expected threedir\one.txt to exist.\n"); ok(DeleteFileA("threedir\two.txt"), "Expected threedir\one.txt to exist.\n"); ok(RemoveDirectoryA("threedir"), "Expected threedir to exist.\n"); @@ -1425,71 +1348,52 @@ static void test_copy(void) ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n");
+ /* pTo contains bogus 2nd name longer than MAX_PATH, + * multiple source files, target dir exists, no FOF_MULTIDESTFILES. */ createTestFile("one.txt"); createTestFile("two.txt"); CreateDirectoryA("threedir", NULL); - - /* pTo contains bogus 2nd name longer than MAX_PATH, - * multiple source files, - * dest directory does exist - */ memset(to, 'a', 2 * MAX_PATH); memset(to+MAX_PATH*2, 0, 2); lstrcpyA(to, "threedir"); - shfo.pFrom = "one.txt\0two.txt\0"; - shfo.pTo = to; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, + "one.txt\0two.txt\0", to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("threedir\one.txt"), "Expected file to exist\n"); ok(DeleteFileA("threedir\two.txt"), "Expected file to exist\n"); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
+ /* pTo contains bogus 2nd name longer than MAX_PATH, + * multiple source files, nonexistent target dir, with FOF_MULTIDESTFILES. */ createTestFile("one.txt"); createTestFile("two.txt"); - - /* pTo contains bogus 2nd name longer than MAX_PATH, - * multiple source files, FOF_MULTIDESTFILES - * dest dir does not exist - */ memset(to, 'a', 2 * MAX_PATH); memset(to+MAX_PATH*2, 0, 2); lstrcpyA(to, "threedir"); - shfo.pFrom = "one.txt\0two.txt\0"; - shfo.pTo = to; - shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | - FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "one.txt\0two.txt\0", to, + ERROR_ACCESS_DENIED, FALSE, TRUE, TRUE); ok(!DeleteFileA("threedir\one.txt"), "Expected file to not exist\n"); ok(!DeleteFileA("threedir\two.txt"), "Expected file to not exist\n"); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
+ /* pTo contains bogus 2nd name longer than MAX_PATH, + * multiple source files, target dir exists, with FOF_MULTIDESTFILES. */ createTestFile("one.txt"); createTestFile("two.txt"); CreateDirectoryA("threedir", NULL); - - /* pTo contains bogus 2nd name longer than MAX_PATH, - * multiple source files, FOF_MULTIDESTFILES - * dest dir does exist - */ memset(to, 'a', 2 * MAX_PATH); memset(to+MAX_PATH*2, 0, 2); lstrcpyA(to, "threedir"); ptr = to + lstrlenA(to) + 1; lstrcpyA(ptr, "fourdir"); - shfo.pFrom = "one.txt\0two.txt\0"; - shfo.pTo = to; - shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | - FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "one.txt\0two.txt\0", to, + ERROR_SUCCESS, FALSE, TRUE, TRUE); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); todo_wine @@ -1501,21 +1405,13 @@ static void test_copy(void) todo_wine ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
+ /* Same number sources and targets, first target dir exists, with FOF_MULTIDESTFILES. */ createTestFile("one.txt"); createTestFile("two.txt"); CreateDirectoryA("threedir", NULL); - - /* multiple source files, FOF_MULTIDESTFILES - * multiple dest files, but first dest dir exists - * num files in lists is equal - */ - shfo.pFrom = "one.txt\0two.txt\0"; - shfo.pTo = "threedir\0fourdir\0"; - shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | - FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == DE_FILEDESTISFLD, "Expected DE_FILEDESTISFLD. got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "one.txt\0two.txt\0", "threedir\0fourdir\0", + DE_FILEDESTISFLD, FALSE, TRUE, FALSE); ok(!DeleteFileA("threedir\one.txt"), "Expected file to not exist\n"); ok(!DeleteFileA("threedir\two.txt"), "Expected file to not exist\n"); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); @@ -1526,21 +1422,13 @@ static void test_copy(void) ok(!DeleteFileA("fourdir"), "Expected file to not exist\n"); ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
+ /* Targets outnumber sources, first target dir exists, with FOF_MULTIDESTFILES. */ createTestFile("one.txt"); createTestFile("two.txt"); CreateDirectoryA("threedir", NULL); - - /* multiple source files, FOF_MULTIDESTFILES - * multiple dest files, but first dest dir exists - * num files in lists is not equal - */ - shfo.pFrom = "one.txt\0two.txt\0"; - shfo.pTo = "threedir\0fourdir\0five\0"; - shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION | - FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - todo_wine - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "one.txt\0two.txt\0", "threedir\0fourdir\0five\0", + ERROR_SUCCESS, FALSE, TRUE, TRUE); ok(DeleteFileA("one.txt"), "Expected file to exist\n"); ok(DeleteFileA("two.txt"), "Expected file to exist\n"); todo_wine @@ -1561,31 +1449,25 @@ static void test_copy(void) CreateDirectoryA("two", NULL);
/* Test with FOF_MULTIDESTFILES with a wildcard in pFrom and single output directory. */ - shfo.pFrom = "a*.txt\0"; - shfo.pTo = "one\0"; - shfo.fFlags |= FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_MULTIDESTFILES; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "a*.txt\0", "one\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("one\aa.txt"), "Expected file to exist\n"); ok(DeleteFileA("one\ab.txt"), "Expected file to exist\n");
- /* pFrom has a glob, pTo has more than one dest */ - shfo.pFrom = "a*.txt\0"; - shfo.pTo = "one\0two\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + /* pFrom has a glob, pTo has more than one dest, no FOF_MULTIDESTFILES. */ + check_file_operation(FO_COPY, FOF_NO_UI, + "a*.txt\0", "one\0two\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("one\aa.txt"), "Expected file to exist\n"); ok(DeleteFileA("one\ab.txt"), "Expected file to exist\n"); ok(!DeleteFileA("two\aa.txt"), "Expected file to not exist\n"); ok(!DeleteFileA("two\ab.txt"), "Expected file to not exist\n");
/* pFrom has more than one glob, pTo has more than one dest, without FOF_MULTIDESTFILES. */ - shfo.pFrom = "a*.txt\0*b.txt\0"; - shfo.pTo = "one\0two\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, + "a*.txt\0*b.txt\0", "one\0two\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("one\aa.txt"), "Expected file to exist\n"); ok(DeleteFileA("one\ab.txt"), "Expected file to exist\n"); ok(DeleteFileA("one\bb.txt"), "Expected file to exist\n"); @@ -1593,13 +1475,11 @@ static void test_copy(void) ok(!DeleteFileA("two\bb.txt"), "Expected file to exist\n");
/* pFrom has more than one glob, pTo has more than one dest, with FOF_MULTIDESTFILES. */ - shfo.pFrom = "a*.txt\0*b.txt\0"; - shfo.pTo = "one\0two\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_MULTIDESTFILES; - retval = SHFileOperationA(&shfo); + check_file_operation(FO_COPY, FOF_NO_UI | FOF_MULTIDESTFILES, + "a*.txt\0*b.txt\0", "one\0two\0", + ERROR_SUCCESS, FALSE, TRUE, TRUE); todo_wine { - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); ok(DeleteFileA("one\aa.txt"), "Expected file to exist\n"); ok(DeleteFileA("one\ab.txt"), "Expected file to exist\n"); ok(DeleteFileA("two\ab.txt"), "Expected file to exist\n"); @@ -1668,36 +1548,26 @@ static void test_copy(void) /* Check last error after a successful file operation. */ clean_after_shfo_tests(); init_shfo_tests(); - shfo.pFrom = "test1.txt\0"; - shfo.pTo = "testdir2\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; SetLastError(0xdeadbeef); - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "File copy failed with %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n"); + check_file_operation(FO_COPY, FOF_NO_UI, "test1.txt\0", "testdir2\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", GetLastError());
/* Check last error after a failed file operation. */ clean_after_shfo_tests(); init_shfo_tests(); - shfo.pFrom = "nonexistent\0"; - shfo.pTo = "testdir2\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; SetLastError(0xdeadbeef); - retval = SHFileOperationA(&shfo); - ok(retval != ERROR_SUCCESS, "Unexpected ERROR_SUCCESS\n"); - ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n"); + check_file_operation(FO_COPY, FOF_NO_UI, "nonexistence\0", "testdir2\0", + ERROR_FILE_NOT_FOUND, FALSE, TRUE, FALSE); ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", GetLastError());
/* test with / */ CreateDirectoryA("dir", NULL); CreateDirectoryA("dir\subdir", NULL); createTestFile("dir\subdir\aa.txt"); - shfo.pFrom = "dir/subdir/aa.txt\0"; - shfo.pTo = "dir\destdir/aa.txt\0"; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_SILENT | FOF_NOERRORUI; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval); + check_file_operation(FO_COPY, FOF_NO_UI, + "dir/subdir/aa.txt\0", "dir\destdir/aa.txt\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("dir\destdir\aa.txt"), "Expected file to exist\n"); ok(RemoveDirectoryA("dir\destdir"), "Expected dir to exist\n"); ok(DeleteFileA("dir\subdir\aa.txt"), "Expected file to exist\n");