Also remove old windows version tests.
From: Ziqing Hui zhui@codeweavers.com
Also remove old windows version tests. --- dlls/shell32/tests/shlfileop.c | 156 +++++++++++---------------------- 1 file changed, 49 insertions(+), 107 deletions(-)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index 828637b39d1..c1e8fcaf60f 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -780,156 +780,98 @@ static void test_delete(void) /* tests the FO_RENAME action */ static void test_rename(void) { - SHFILEOPSTRUCTA shfo, shfo2; - CHAR from[5*MAX_PATH]; - CHAR to[5*MAX_PATH]; - DWORD retval; - - shfo.hwnd = NULL; - shfo.wFunc = FO_RENAME; - shfo.pFrom = from; - shfo.pTo = to; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - shfo.hNameMappings = NULL; - shfo.lpszProgressTitle = NULL; + char from[5 * MAX_PATH], to[5 * MAX_PATH];
+ /* Rename a file to a dir. */ set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(to, "test4.txt\0"); - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_ALREADY_EXISTS || - retval == DE_FILEDESTISFLD || /* Vista */ - broken(retval == ERROR_INVALID_NAME), /* Win9x, NT4 */ - "Expected ERROR_ALREADY_EXISTS or DE_FILEDESTISFLD, got %ld\n", retval); + check_file_operation(FO_RENAME, FOF_NO_UI, from, to, + DE_FILEDESTISFLD, FALSE, TRUE, FALSE); ok(file_exists("test1.txt"), "The file is renamed\n");
set_curr_dir_path(from, "test3.txt\0"); set_curr_dir_path(to, "test4.txt\test1.txt\0"); - retval = SHFileOperationA(&shfo); - if (retval == DE_DIFFDIR) - { - /* Vista and W2K8 (broken or new behavior ?) */ - ok(!file_exists("test4.txt\test1.txt"), "The file is renamed\n"); - } - else - { - ok(retval == ERROR_SUCCESS, "File is renamed moving to other directory\n"); - ok(file_exists("test4.txt\test1.txt"), "The file is not renamed\n"); - } + check_file_operation(FO_RENAME, FOF_NO_UI, from, to, + DE_DIFFDIR, FALSE, TRUE, FALSE); + todo_wine + ok(!file_exists("test4.txt\test1.txt"), "The file is renamed\n");
+ /* Multiple sources and targets, 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"); - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_GEN_FAILURE || - retval == DE_MANYSRC1DEST || /* Vista */ - broken(retval == ERROR_SUCCESS), /* Win9x */ - "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST , got %ld\n", retval); + check_file_operation(FO_RENAME, FOF_NO_UI, from, to, + DE_MANYSRC1DEST, FALSE, TRUE, FALSE); ok(file_exists("test1.txt"), "The file is renamed - many files are specified\n");
- memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA)); - shfo2.fFlags |= FOF_MULTIDESTFILES; - + /* Multiple sources and targets, with 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"); - retval = SHFileOperationA(&shfo2); - ok(retval == ERROR_GEN_FAILURE || - retval == DE_MANYSRC1DEST || /* Vista */ - broken(retval == ERROR_SUCCESS), /* Win9x */ - "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST files, got %ld\n", retval); + check_file_operation(FO_RENAME, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + DE_MANYSRC1DEST, FALSE, TRUE, FALSE); ok(file_exists("test1.txt"), "The file is not renamed - many files are specified\n");
+ /* Rename a file. */ set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(to, "test6.txt\0"); - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Rename file failed, retval = %ld\n", retval); + check_file_operation(FO_RENAME, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!file_exists("test1.txt"), "The file is not renamed\n"); ok(file_exists("test6.txt"), "The file is not renamed\n");
set_curr_dir_path(from, "test6.txt\0"); set_curr_dir_path(to, "test1.txt\0"); - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Rename file back failed, retval = %ld\n", retval); + check_file_operation(FO_RENAME, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
+ /* Rename a dir. */ set_curr_dir_path(from, "test4.txt\0"); set_curr_dir_path(to, "test6.txt\0"); - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Rename dir failed, retval = %ld\n", retval); + check_file_operation(FO_RENAME, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!dir_exists("test4.txt"), "The dir is not renamed\n"); ok(dir_exists("test6.txt"), "The dir is not renamed\n");
set_curr_dir_path(from, "test6.txt\0"); set_curr_dir_path(to, "test4.txt\0"); - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_SUCCESS, "Rename dir back failed, retval = %ld\n", retval); + check_file_operation(FO_RENAME, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(dir_exists("test4.txt"), "The dir is not renamed\n");
- /* try to rename more than one file to a single file */ - shfo.pFrom = "test1.txt\0test2.txt\0"; - shfo.pTo = "a.txt\0"; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_GEN_FAILURE || - retval == DE_MANYSRC1DEST || /* Vista */ - broken(retval == ERROR_SUCCESS), /* Win9x */ - "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST, got %ld\n", retval); + /* Rename multiple files to a single file. */ + check_file_operation(FO_RENAME, FOF_NO_UI, + "test1.txt\0test2.txt\0", "a.txt\0", + DE_MANYSRC1DEST, FALSE, TRUE, FALSE); ok(file_exists("test1.txt"), "Expected test1.txt to exist\n"); ok(file_exists("test2.txt"), "Expected test2.txt to exist\n"); ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
- /* pFrom doesn't exist */ - shfo.pFrom = "idontexist\0"; - shfo.pTo = "newfile\0"; - retval = SHFileOperationA(&shfo); - ok(retval == 1026 || - retval == ERROR_FILE_NOT_FOUND || /* Vista */ - broken(retval == ERROR_SUCCESS), /* NT4 */ - "Expected 1026 or ERROR_FILE_NOT_FOUND, got %ld\n", retval); + /* Rename a nonexistent file. */ + check_file_operation(FO_RENAME, FOF_NO_UI, + "idontexist\0", "newfile\0", + ERROR_FILE_NOT_FOUND, FALSE, TRUE, FALSE); ok(!file_exists("newfile"), "Expected newfile to not exist\n");
- /* pTo already exist */ - shfo.pFrom = "test1.txt\0"; - shfo.pTo = "test2.txt\0"; - if (old_shell32) - shfo.fFlags |= FOF_NOCONFIRMMKDIR; - retval = SHFileOperationA(&shfo); - if (retval == ERROR_SUCCESS) - { - /* Vista and W2K8 (broken or new behavior ?) */ - createTestFile("test1.txt"); - } - else - { - ok(retval == ERROR_ALREADY_EXISTS || - broken(retval == DE_OPCANCELLED) || /* NT4 */ - broken(retval == ERROR_INVALID_NAME), /* Win9x */ - "Expected ERROR_ALREADY_EXISTS, got %ld\n", retval); - } + /* Target already exists. */ + check_file_operation(FO_RENAME, FOF_NO_UI, + "test1.txt\0", "test2.txt\0", + ERROR_SUCCESS, FALSE, TRUE, FALSE);
- /* pFrom is valid, but pTo is empty */ - shfo.pFrom = "test1.txt\0"; - shfo.pTo = "\0"; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_CANCELLED || - retval == DE_DIFFDIR || /* Vista */ - retval == DE_FILEDESTISFLD || /* Vista, running from c: */ - broken(retval == DE_OPCANCELLED) || /* Win9x */ - broken(retval == 65652), /* NT4 */ - "Expected ERROR_CANCELLED or DE_DIFFDIR, got %lu\n", retval); + /* Empty target. */ + createTestFile("test1.txt"); + check_file_operation(FO_RENAME, FOF_NO_UI, + "test1.txt\0", "\0", + DE_DIFFDIR, FALSE, TRUE, TRUE); ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
- /* pFrom is empty */ - shfo.pFrom = "\0"; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_ACCESS_DENIED || - retval == DE_MANYSRC1DEST || /* Vista */ - broken(retval == ERROR_SUCCESS), /* Win9x */ - "Expected ERROR_ACCESS_DENIED or DE_MANYSRC1DEST, got %ld\n", retval); + /* Empty source. */ + check_file_operation(FO_RENAME, FOF_NO_UI, + "\0", "\0", + DE_MANYSRC1DEST, FALSE, TRUE, TRUE);
- /* pFrom is NULL, commented out because it crashes on nt 4.0 */ - if (0) - { - shfo.pFrom = NULL; - retval = SHFileOperationA(&shfo); - ok(retval == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", retval); - } + /* pFrom is NULL. */ + check_file_operation(FO_RENAME, FOF_NO_UI, + NULL, "\0", + ERROR_INVALID_PARAMETER, 0xdeadbeef, FALSE, FALSE); }
/* tests the FO_COPY action */
From: Ziqing Hui zhui@codeweavers.com
Also remove old windows version tests. --- dlls/shell32/tests/shlfileop.c | 184 ++++++++++++--------------------- 1 file changed, 66 insertions(+), 118 deletions(-)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index c1e8fcaf60f..368bd86c3c8 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -613,166 +613,114 @@ void check_file_operation_(unsigned int line, UINT func, FILEOP_FLAGS flags, con /* tests the FO_DELETE action */ static void test_delete(void) { - SHFILEOPSTRUCTA shfo; - DWORD ret; - CHAR buf[sizeof(CURR_DIR)+sizeof("/test?.txt")+1]; - - sprintf(buf, "%s\%s", CURR_DIR, "test?.txt"); - buf[strlen(buf) + 1] = '\0'; - - shfo.hwnd = NULL; - shfo.wFunc = FO_DELETE; - shfo.pFrom = buf; - shfo.pTo = NULL; - shfo.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_SILENT; - shfo.hNameMappings = NULL; - shfo.lpszProgressTitle = NULL; + char from[MAX_PATH * 5];
- ok(!SHFileOperationA(&shfo), "Deletion was not successful\n"); + /* Wildcard source, with FOF_FILESONLY. */ + set_curr_dir_path(from, "test?.txt\0"); + check_file_operation(FO_DELETE, FOF_NO_UI | FOF_FILESONLY, from, NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(dir_exists("test4.txt"), "Directory should not have been removed\n"); ok(!file_exists("test1.txt"), "File should have been removed\n"); ok(!file_exists("test2.txt"), "File should have been removed\n"); ok(!file_exists("test3.txt"), "File should have been removed\n");
- ret = SHFileOperationA(&shfo); - ok(ret == ERROR_SUCCESS, "Directory exists, but is not removed, ret=%ld\n", ret); + set_curr_dir_path(from, "test?.txt\0"); + check_file_operation(FO_DELETE, FOF_NO_UI | FOF_FILESONLY, from, NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(dir_exists("test4.txt"), "Directory should not have been removed\n");
- shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - - ok(!SHFileOperationA(&shfo), "Directory is not removed\n"); + /* Wildcard source, no FOF_FILESONLY. */ + set_curr_dir_path(from, "test?.txt\0"); + check_file_operation(FO_DELETE, FOF_NO_UI, from, NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!dir_exists("test4.txt"), "Directory should have been removed\n");
- ret = SHFileOperationA(&shfo); - ok(!ret, "The requested file does not exist, ret=%ld\n", ret); + /* Nonexistent wildcard source. */ + set_curr_dir_path(from, "test?.txt\0"); + check_file_operation(FO_DELETE, FOF_NO_UI, from, NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
+ /* Delete a dir with a file inside. */ init_shfo_tests(); - sprintf(buf, "%s\%s", CURR_DIR, "test4.txt"); - buf[strlen(buf) + 1] = '\0'; + set_curr_dir_path(from, "test4.txt\0"); ok(MoveFileA("test1.txt", "test4.txt\test1.txt"), "Filling the subdirectory failed\n"); - ok(!SHFileOperationA(&shfo), "Directory is not removed\n"); + check_file_operation(FO_DELETE, FOF_NO_UI, from, NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!dir_exists("test4.txt"), "Directory is not removed\n");
+ /* Remove a dir and a file. */ init_shfo_tests(); - shfo.pFrom = "test1.txt\0test4.txt\0"; - ok(!SHFileOperationA(&shfo), "Directory and a file are not removed\n"); + check_file_operation(FO_DELETE, FOF_NO_UI, "test1.txt\0test4.txt\0", NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!file_exists("test1.txt"), "The file should have been removed\n"); ok(!dir_exists("test4.txt"), "Directory should have been removed\n"); ok(file_exists("test2.txt"), "This file should not have been removed\n");
- /* FOF_FILESONLY does not delete a dir matching a wildcard */ + /* Wildcard source, with FOF_FILESONLY. */ init_shfo_tests(); - shfo.fFlags |= FOF_FILESONLY; - shfo.pFrom = "*.txt\0"; - ok(!SHFileOperationA(&shfo), "Failed to delete files\n"); + check_file_operation(FO_DELETE, FOF_NO_UI | FOF_FILESONLY, "*.txt\0", NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!file_exists("test1.txt"), "test1.txt should have been removed\n"); ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n"); ok(dir_exists("test4.txt"), "test4.txt should not have been removed\n");
- /* FOF_FILESONLY only deletes a dir if explicitly specified */ + /* Explicitly specify a dir, with FOF_FILESONLY. */ init_shfo_tests(); - shfo.pFrom = "test_?.txt\0test4.txt\0"; - ok(!SHFileOperationA(&shfo), "Failed to delete files and directory\n"); - ok(!dir_exists("test4.txt") || - broken(dir_exists("test4.txt")), /* NT4 */ - "test4.txt should have been removed\n"); + check_file_operation(FO_DELETE, FOF_NO_UI | FOF_FILESONLY, "test_?.txt\0test4.txt\0", NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); + ok(!dir_exists("test4.txt"), "test4.txt should have been removed\n"); ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n"); ok(file_exists("test1.txt"), "test1.txt should not have been removed\n");
- /* try to delete an invalid filename */ - if (0) { - /* this crashes on win9x */ - init_shfo_tests(); - shfo.pFrom = "\0"; - shfo.fFlags &= ~FOF_FILESONLY; - shfo.fAnyOperationsAborted = FALSE; - ret = SHFileOperationA(&shfo); - ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %ld\n", ret); - ok(!shfo.fAnyOperationsAborted, "Expected no aborted operations\n"); - ok(file_exists("test1.txt"), "Expected test1.txt to exist\n"); - } + /* Empty filename. */ + init_shfo_tests(); + check_file_operation(FO_DELETE, FOF_NO_UI, "\0", NULL, + ERROR_SUCCESS, FALSE, TRUE, TRUE); + ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
- /* try an invalid function */ + /* Invalid function. */ init_shfo_tests(); - shfo.pFrom = "test1.txt\0"; - shfo.wFunc = 0; - ret = SHFileOperationA(&shfo); - ok(ret == ERROR_INVALID_PARAMETER || - broken(ret == ERROR_SUCCESS), /* Win9x, NT4 */ - "Expected ERROR_INVALID_PARAMETER, got %ld\n", ret); + check_file_operation(0, FOF_NO_UI, "test1.txt\0", NULL, + ERROR_INVALID_PARAMETER, FALSE, FALSE, FALSE); ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
- /* try an invalid list, only one null terminator */ - if (0) { - /* this crashes on win9x */ - init_shfo_tests(); - shfo.pFrom = ""; - shfo.wFunc = FO_DELETE; - ret = SHFileOperationA(&shfo); - ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %ld\n", ret); - ok(file_exists("test1.txt"), "Expected test1.txt to exist\n"); - } + /* Empty filename, only one null terminator */ + init_shfo_tests(); + check_file_operation(FO_DELETE, FOF_NO_UI, "", NULL, + ERROR_SUCCESS, FALSE, TRUE, TRUE); + ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
- /* delete a nonexistent file */ - shfo.pFrom = "nonexistent.txt\0"; - shfo.wFunc = FO_DELETE; - ret = SHFileOperationA(&shfo); - ok(ret == 1026 || - ret == ERROR_FILE_NOT_FOUND || /* Vista */ - broken(ret == ERROR_SUCCESS), /* NT4 */ - "Expected 1026 or ERROR_FILE_NOT_FOUND, got %ld\n", ret); - - /* delete a dir, and then a file inside the dir, same as - * deleting a nonexistent file - */ - if (ret != ERROR_FILE_NOT_FOUND) - { - /* Vista would throw up a dialog box that we can't suppress */ - init_shfo_tests(); - shfo.pFrom = "testdir2\0testdir2\one.txt\0"; - ret = SHFileOperationA(&shfo); - ok(ret == ERROR_PATH_NOT_FOUND || - broken(ret == ERROR_SUCCESS), /* NT4 */ - "Expected ERROR_PATH_NOT_FOUND, got %ld\n", ret); - ok(!dir_exists("testdir2"), "Expected testdir2 to not exist\n"); - ok(!file_exists("testdir2\one.txt"), "Expected testdir2\one.txt to not exist\n"); - } - else - skip("Test would show a dialog box\n"); + /* Nonexistent file. */ + check_file_operation(FO_DELETE, FOF_NO_UI, "nonexistent.txt\0", NULL, + ERROR_FILE_NOT_FOUND, FALSE, FALSE, FALSE);
- /* delete an existent file and a nonexistent file */ + /* Delete a dir, and then a file inside the dir, + * same as deleting a nonexistent file. */ init_shfo_tests(); - shfo.pFrom = "test1.txt\0nonexistent.txt\0test2.txt\0"; - shfo.wFunc = FO_DELETE; - ret = SHFileOperationA(&shfo); - ok(ret == 1026 || - ret == ERROR_FILE_NOT_FOUND || /* Vista */ - broken(ret == ERROR_SUCCESS), /* NT4 */ - "Expected 1026 or ERROR_FILE_NOT_FOUND, got %ld\n", ret); + check_file_operation(FO_DELETE, FOF_NO_UI, "testdir2\0testdir2\one.txt\0", NULL, + DE_INVALIDFILES, FALSE, TRUE, FALSE); + ok(!dir_exists("testdir2"), "Expected testdir2 to not exist\n"); + ok(!file_exists("testdir2\one.txt"), "Expected testdir2\one.txt to not exist\n"); + + /* Delete an existent file and a nonexistent file. */ + init_shfo_tests(); + check_file_operation(FO_DELETE, FOF_NO_UI, "test1.txt\0nonexistent.txt\0test2.txt\0", NULL, + ERROR_FILE_NOT_FOUND, FALSE, FALSE, FALSE); todo_wine ok(file_exists("test1.txt"), "Expected test1.txt to exist\n"); ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
- /* delete a nonexistent file in an existent dir or a nonexistent dir */ + /* Delete a nonexistent file in an existent dir or a nonexistent dir. */ init_shfo_tests(); - shfo.pFrom = "testdir2\nonexistent.txt\0"; - ret = SHFileOperationA(&shfo); - ok(ret == ERROR_FILE_NOT_FOUND || /* Vista */ - broken(ret == 0x402) || /* XP */ - broken(ret == ERROR_SUCCESS), /* NT4 */ - "Expected 0x402 or ERROR_FILE_NOT_FOUND, got %lx\n", ret); - shfo.pFrom = "nonexistent\one.txt\0"; - ret = SHFileOperationA(&shfo); - ok(ret == DE_INVALIDFILES || /* Vista or later */ - broken(ret == 0x402), /* XP */ - "Expected 0x402 or DE_INVALIDFILES, got %lx\n", ret); - - /* try the FOF_NORECURSION flag, continues deleting subdirs */ + check_file_operation(FO_DELETE, FOF_NO_UI, "testdir2\nonexistent.txt\0", NULL, + ERROR_FILE_NOT_FOUND, FALSE, FALSE, FALSE); + check_file_operation(FO_DELETE, FOF_NO_UI, "nonexistent\one.txt\0", NULL, + DE_INVALIDFILES, FALSE, FALSE, FALSE); + + /* With FOF_NORECURSION, subdirs are still deleted. */ init_shfo_tests(); - shfo.pFrom = "testdir2\0"; - shfo.fFlags |= FOF_NORECURSION; - ret = SHFileOperationA(&shfo); - ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", ret); + check_file_operation(FO_DELETE, FOF_NO_UI | FOF_NORECURSION, "testdir2\0", NULL, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!file_exists("testdir2\one.txt"), "Expected testdir2\one.txt to not exist\n"); ok(!dir_exists("testdir2\nested"), "Expected testdir2\nested to not exist\n"); }
From: Ziqing Hui zhui@codeweavers.com
--- dlls/shell32/tests/shlfileop.c | 194 +++++++++++++-------------------- 1 file changed, 78 insertions(+), 116 deletions(-)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index 368bd86c3c8..cc765da9ee1 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -1584,28 +1584,15 @@ static void test_copy(void) /* tests the FO_MOVE action */ static void test_move(void) { - SHFILEOPSTRUCTA shfo, shfo2; - CHAR from[5*MAX_PATH]; - CHAR to[5*MAX_PATH]; - DWORD retval; + char from[MAX_PATH * 5], to[MAX_PATH * 5];
clean_after_shfo_tests(); init_shfo_tests();
- shfo.hwnd = NULL; - shfo.wFunc = FO_MOVE; - shfo.pFrom = from; - shfo.pTo = to; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR; - shfo.hNameMappings = NULL; - shfo.lpszProgressTitle = NULL; - shfo.fAnyOperationsAborted = FALSE; - set_curr_dir_path(from, "testdir2\*.*\0"); set_curr_dir_path(to, "test4.txt\*.*\0"); - retval = SHFileOperationA(&shfo); - ok(retval != 0, "SHFileOperation should fail\n"); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_INVALID_NAME, FALSE, TRUE, FALSE);
ok(file_exists("testdir2"), "dir should not be moved\n"); ok(file_exists("testdir2\one.txt"), "file should not be moved\n"); @@ -1614,9 +1601,8 @@ static void test_move(void)
set_curr_dir_path(from, "testdir2\*.*\0"); set_curr_dir_path(to, "test4.txt\0"); - retval = SHFileOperationA(&shfo); - ok(!retval, "SHFileOperation error %#lx\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(file_exists("testdir2"), "dir should not be moved\n"); ok(!file_exists("testdir2\one.txt"), "file should be moved\n"); @@ -1634,9 +1620,8 @@ static void test_move(void) /* same tests above, but with / */ set_curr_dir_path(from, "testdir2/*.*\0"); set_curr_dir_path(to, "test4.txt\0"); - retval = SHFileOperationA(&shfo); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(dir_exists("testdir2"), "dir should not be moved\n"); ok(!file_exists("testdir2\one.txt"), "file should be moved\n"); @@ -1650,17 +1635,11 @@ static void test_move(void) clean_after_shfo_tests(); init_shfo_tests();
- shfo.hwnd = NULL; - shfo.wFunc = FO_MOVE; - shfo.pFrom = from; - shfo.pTo = to; - shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI; - shfo.hNameMappings = NULL; - shfo.lpszProgressTitle = NULL; - + /* Prepare test to check how directories are moved recursively. */ set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(to, "test4.txt\0"); - ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are moved recursively\n"); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!file_exists("test1.txt"), "test1.txt should not exist\n"); ok(file_exists("test4.txt\test1.txt"), "The file is not moved\n");
@@ -1668,7 +1647,8 @@ static void test_move(void) set_curr_dir_path(to, "testdir2\0"); ok(!file_exists("testdir2\test2.txt"), "The file is not moved yet\n"); ok(!file_exists("testdir2\test4.txt"), "The directory is not moved yet\n"); - ok(!SHFileOperationA(&shfo), "Files and directories are moved to directory\n"); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(file_exists("testdir2\test2.txt"), "The file is moved\n"); ok(file_exists("testdir2\test4.txt"), "The directory is moved\n"); ok(file_exists("testdir2\test4.txt\test1.txt"), "The file in subdirectory is moved\n"); @@ -1679,9 +1659,8 @@ static void test_move(void) /* test moving dir to destination containing dir of the same name */ set_curr_dir_path(from, "testdir2\nested\0"); set_curr_dir_path(to, "testdir4\0"); - retval = SHFileOperationA(&shfo); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(!dir_exists("testdir2\nested"), "dir should be moved\n"); ok(!file_exists("testdir2\nested\two.txt"), "file should be moved\n"); @@ -1697,9 +1676,8 @@ static void test_move(void) DeleteFileA("testdir2\nested\two.txt"); set_curr_dir_path(from, "testdir2\nested\0"); set_curr_dir_path(to, "testdir4\0"); - retval = SHFileOperationA(&shfo); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(!dir_exists("testdir2\nested"), "dir should be moved\n");
@@ -1712,9 +1690,8 @@ static void test_move(void) /* test moving multiple dirs to destination containing dir of the same name */ set_curr_dir_path(from, "testdir2\nested\0testdir4\nested\0"); set_curr_dir_path(to, "testdir6\0"); - retval = SHFileOperationA(&shfo); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(!dir_exists("testdir2\nested"), "dir should be moved\n"); ok(!file_exists("testdir2\nested\two.txt"), "file should be moved\n"); @@ -1733,15 +1710,11 @@ static void test_move(void) clean_after_shfo_tests(); init_shfo_tests();
- memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA)); - shfo2.fFlags |= FOF_MULTIDESTFILES; - /* test moving dir to destination containing dir of the same name with FOF_MULTIDESTFILES set */ set_curr_dir_path(from, "testdir2\nested\0"); set_curr_dir_path(to, "testdir6\0"); - retval = SHFileOperationA(&shfo2); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(!dir_exists("testdir2\nested"), "dir should be moved\n"); ok(!file_exists("testdir2\nested\two.txt"), "file should be moved\n"); @@ -1756,9 +1729,8 @@ static void test_move(void) /* same as above, without 'nested' in from path */ set_curr_dir_path(from, "testdir2\0"); set_curr_dir_path(to, "testdir6\0"); - retval = SHFileOperationA(&shfo2); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(!dir_exists("testdir2\nested"), "dir should be moved\n"); ok(!file_exists("testdir2\nested\two.txt"), "file should be moved\n"); @@ -1773,9 +1745,8 @@ static void test_move(void) /* test moving multiple dirs to multiple destinations containing dir of the same name */ set_curr_dir_path(from, "testdir2\nested\0testdir4\nested\0"); set_curr_dir_path(to, "testdir6\0testdir8\0"); - retval = SHFileOperationA(&shfo2); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(!dir_exists("testdir2\nested"), "dir should be moved\n"); ok(!file_exists("testdir2\nested\two.txt"), "file should be moved\n"); @@ -1803,9 +1774,8 @@ static void test_move(void) /* same as above, but include subdir in destinations */ set_curr_dir_path(from, "testdir2\nested\0testdir4\nested\0"); set_curr_dir_path(to, "testdir6\nested\0testdir8\nested\0"); - retval = SHFileOperationA(&shfo2); - ok(!retval, "got %ld\n", retval); - ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
ok(!dir_exists("testdir2\nested"), "dir should be moved\n"); ok(!file_exists("testdir2\nested\two.txt"), "file should be moved\n"); @@ -1829,9 +1799,11 @@ static void test_move(void) clean_after_shfo_tests(); init_shfo_tests();
+ /* Move many files. */ set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); - ok(!SHFileOperationA(&shfo2), "Move many files\n"); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("test6.txt"), "The file is not moved - many files are " "specified as a target\n"); ok(DeleteFileA("test7.txt"), "The file is not moved\n"); @@ -1839,39 +1811,33 @@ static void test_move(void)
init_shfo_tests();
- /* number of sources does not correspond to number of targets, - include directories */ + /* Sources outnumber targets. */ set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0"); - retval = SHFileOperationA(&shfo2); - ok(retval == DE_DESTSAMETREE, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + DE_DESTSAMETREE, FALSE, FALSE, FALSE); ok(DeleteFileA("test6.txt\test1.txt"), "The file is not moved\n"); RemoveDirectoryA("test6.txt"); ok(DeleteFileA("test7.txt\test2.txt"), "The file is not moved\n"); RemoveDirectoryA("test7.txt");
init_shfo_tests(); - /* number of sources does not correspond to number of targets, - files only, - from exceeds to */ set_curr_dir_path(from, "test1.txt\0test2.txt\0test3.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0"); - retval = SHFileOperationA(&shfo2); - ok(retval == DE_SAMEFILE, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + DE_SAMEFILE, FALSE, FALSE, FALSE); ok(DeleteFileA("test6.txt\test1.txt"), "The file is not moved\n"); RemoveDirectoryA("test6.txt"); ok(DeleteFileA("test7.txt\test2.txt"), "The file is not moved\n"); RemoveDirectoryA("test7.txt"); ok(file_exists("test3.txt"), "File should not be moved\n");
+ /* Targets outnumber sources. */ init_shfo_tests(); - /* number of sources does not correspond to number of targets, - files only, - too exceeds from */ set_curr_dir_path(from, "test1.txt\0test2.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); - retval = SHFileOperationA(&shfo2); - ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("test6.txt\test1.txt"),"The file is not moved\n"); ok(DeleteFileA("test7.txt\test2.txt"),"The file is not moved\n"); ok(!dir_exists("test8.txt") && !file_exists("test8.txt"), "Directory should not be created\n"); @@ -1879,46 +1845,44 @@ static void test_move(void) RemoveDirectoryA("test7.txt");
init_shfo_tests(); - /* number of sources does not correspond to number of targets, - target directories */ set_curr_dir_path(from, "test1.txt\0test2.txt\0test3.txt\0"); set_curr_dir_path(to, "test4.txt\0test5.txt\0"); - retval = SHFileOperationA(&shfo2); - ok(retval == DE_SAMEFILE, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + DE_SAMEFILE, FALSE, FALSE, FALSE); ok(DeleteFileA("test4.txt\test1.txt"),"The file is not moved\n"); ok(DeleteFileA("test5.txt\test2.txt"),"The file is not moved\n"); ok(file_exists("test3.txt"), "The file is not moved\n"); RemoveDirectoryA("test4.txt"); RemoveDirectoryA("test5.txt");
- + /* Empty source. */ init_shfo_tests(); - /* 0 incoming files */ set_curr_dir_path(from, "\0\0"); set_curr_dir_path(to, "test6.txt\0\0"); - retval = SHFileOperationA(&shfo2); - todo_wine ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_SUCCESS, FALSE, TRUE, TRUE); ok(!file_exists("test6.txt"), "The file should not exist\n");
+ /* Empty target. */ init_shfo_tests(); - /* 0 outgoing files */ set_curr_dir_path(from, "test1\0\0"); set_curr_dir_path(to, "\0\0"); - retval = SHFileOperationA(&shfo2); - ok(retval == ERROR_FILE_NOT_FOUND, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, from, to, + ERROR_FILE_NOT_FOUND, FALSE, FALSE, FALSE); ok(!file_exists("test6.txt"), "The file should not exist\n");
init_shfo_tests();
set_curr_dir_path(from, "test3.txt\0"); set_curr_dir_path(to, "test4.txt\test1.txt\0"); - ok(!SHFileOperationA(&shfo), "Can't move file to other directory\n"); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(file_exists("test4.txt\test1.txt"), "The file is not moved\n");
set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); - retval = SHFileOperationA(&shfo); - todo_wine ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, TRUE, TRUE); todo_wine ok(DeleteFileA("test6.txt\test1.txt"), "The file is not moved. Many files are specified\n"); todo_wine ok(DeleteFileA("test6.txt\test2.txt"), "The file is not moved. Many files are specified\n"); todo_wine ok(DeleteFileA("test6.txt\test4.txt\test1.txt"), "The file is not moved. Many files are specified\n"); @@ -1928,37 +1892,39 @@ static void test_move(void)
set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(to, "test6.txt\0"); - ok(!SHFileOperationA(&shfo), "Move file failed\n"); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!file_exists("test1.txt"), "The file is not moved\n"); ok(file_exists("test6.txt"), "The file is not moved\n"); set_curr_dir_path(from, "test6.txt\0"); set_curr_dir_path(to, "test1.txt\0"); - ok(!SHFileOperationA(&shfo), "Move file back failed\n"); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
set_curr_dir_path(from, "test4.txt\0"); set_curr_dir_path(to, "test6.txt\0"); - ok(!SHFileOperationA(&shfo), "Move dir failed\n"); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!dir_exists("test4.txt"), "The dir is not moved\n"); ok(dir_exists("test6.txt"), "The dir is moved\n"); set_curr_dir_path(from, "test6.txt\0"); set_curr_dir_path(to, "test4.txt\0"); - ok(!SHFileOperationA(&shfo), "Move dir back failed\n"); + check_file_operation(FO_MOVE, FOF_NO_UI, from, to, + ERROR_SUCCESS, FALSE, FALSE, FALSE);
/* move one file to two others */ init_shfo_tests(); - shfo.pFrom = "test1.txt\0"; - shfo.pTo = "a.txt\0b.txt\0"; - retval = SHFileOperationA(&shfo); - ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI, + "test1.txt\0", "a.txt\0b.txt\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("a.txt"), "Expected a.txt to exist\n"); ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n"); ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
/* move two files to one other */ - shfo.pFrom = "test2.txt\0test3.txt\0"; - shfo.pTo = "test1.txt\0"; - retval = SHFileOperationA(&shfo); - todo_wine ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI, + "test2.txt\0test3.txt\0", "test1.txt\0", + ERROR_SUCCESS, FALSE, TRUE, TRUE); todo_wine ok(DeleteFileA("test1.txt\test2.txt"), "Expected test1.txt\test2.txt to exist\n"); todo_wine ok(DeleteFileA("test1.txt\test3.txt"), "Expected test1.txt\test3.txt to exist\n"); RemoveDirectoryA("test1.txt"); @@ -1966,18 +1932,16 @@ static void test_move(void) createTestFile("test3.txt");
/* move a directory into itself */ - shfo.pFrom = "test4.txt\0"; - shfo.pTo = "test4.txt\b.txt\0"; - retval = SHFileOperationA(&shfo); - todo_wine ok(retval == DE_DESTSUBTREE, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI, + "test4.txt\0", "test4.txt\b.txt\0", + DE_DESTSUBTREE, FALSE, TRUE, FALSE); ok(!RemoveDirectoryA("test4.txt\b.txt"), "Expected test4.txt\b.txt to not exist\n"); ok(dir_exists("test4.txt"), "Expected test4.txt to exist\n");
/* move many files without FOF_MULTIDESTFILES */ - shfo.pFrom = "test2.txt\0test3.txt\0"; - shfo.pTo = "d.txt\0e.txt\0"; - retval = SHFileOperationA(&shfo); - todo_wine ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI, + "test2.txt\0test3.txt\0", "d.txt\0e.txt\0", + ERROR_SUCCESS, FALSE, TRUE, TRUE); todo_wine ok(DeleteFileA("d.txt\test2.txt"), "Expected d.txt\test2.txt to exist\n"); todo_wine ok(DeleteFileA("d.txt\test3.txt"), "Expected d.txt\test3.txt to exist\n"); RemoveDirectoryA("d.txt"); @@ -1985,29 +1949,27 @@ static void test_move(void) createTestFile("test3.txt");
/* number of sources != number of targets */ - shfo.pTo = "d.txt\0"; - shfo.fFlags |= FOF_MULTIDESTFILES; - retval = SHFileOperationA(&shfo); - ok(retval == DE_SAMEFILE, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, + "test2.txt\0test3.txt\0", "d.txt\0", + DE_SAMEFILE, FALSE, FALSE, FALSE); ok(DeleteFileA("d.txt\test2.txt"), "Expected d.txt\test2.txt to exist\n"); ok(!file_exists("d.txt\test3.txt"), "Expected d.txt\test3.txt to not exist\n"); RemoveDirectoryA("d.txt"); createTestFile("test2.txt");
/* FO_MOVE does not create dest directories */ - shfo.pFrom = "test2.txt\0"; - shfo.pTo = "dir1\dir2\test2.txt\0"; - retval = SHFileOperationA(&shfo); - ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, + "test2.txt\0", "dir1\dir2\test2.txt\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(DeleteFileA("dir1\dir2\test2.txt"), "Expected dir1\dir2\test2.txt to exist\n"); RemoveDirectoryA("dir1\dir2"); RemoveDirectoryA("dir1"); createTestFile("test2.txt");
/* try to overwrite an existing file */ - shfo.pTo = "test3.txt\0"; - retval = SHFileOperationA(&shfo); - ok(!retval, "got %ld\n", retval); + check_file_operation(FO_MOVE, FOF_NO_UI | FOF_MULTIDESTFILES, + "test2.txt\0", "test3.txt\0", + ERROR_SUCCESS, FALSE, FALSE, FALSE); ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n"); ok(file_exists("test3.txt"), "Expected test3.txt to exist\n"); }