shell32/tests: Cope with Vista's behavior.

This commit is contained in:
Paul Vriens 2008-12-22 15:29:51 +01:00 committed by Alexandre Julliard
parent e39a471aac
commit 7f752f7c9c
1 changed files with 191 additions and 57 deletions

View File

@ -559,6 +559,8 @@ static void test_delete(void)
/* delete a dir, and then a file inside the dir, same as /* delete a dir, and then a file inside the dir, same as
* deleting a nonexistent file * deleting a nonexistent file
*
* FIXME: Vista throws up a dialog window to ask if one.txt should be created
*/ */
init_shfo_tests(); init_shfo_tests();
shfo.pFrom = "testdir2\0testdir2\\one.txt\0"; shfo.pFrom = "testdir2\0testdir2\\one.txt\0";
@ -710,9 +712,23 @@ static void test_copy(void)
set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
ok(SHFileOperationA(&shfo), "Can't copy many files\n"); retval = SHFileOperationA(&shfo);
ok(!file_exists("test6.txt"), "The file is not copied - many files are " if (retval == ERROR_SUCCESS)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(file_exists("test6.txt\\test1.txt"), "The file is not copied - many files "
"are specified as a target");
DeleteFileA("test6.txt\\test1.txt");
DeleteFileA("test6.txt\\test2.txt");
RemoveDirectoryA("test6.txt\\test4.txt");
RemoveDirectoryA("test6.txt");
}
else
{
ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
ok(!file_exists("test6.txt"), "The file is copied - many files are "
"specified as a target\n"); "specified as a target\n");
}
memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA)); memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
shfo2.fFlags |= FOF_MULTIDESTFILES; shfo2.fFlags |= FOF_MULTIDESTFILES;
@ -720,7 +736,7 @@ static void test_copy(void)
set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
ok(!SHFileOperationA(&shfo2), "Can't copy many files\n"); ok(!SHFileOperationA(&shfo2), "Can't copy many files\n");
ok(file_exists("test6.txt"), "The file is copied - many files are " ok(file_exists("test6.txt"), "The file is not copied - many files are "
"specified as a target\n"); "specified as a target\n");
DeleteFileA("test6.txt"); DeleteFileA("test6.txt");
DeleteFileA("test7.txt"); DeleteFileA("test7.txt");
@ -729,9 +745,25 @@ static void test_copy(void)
/* number of sources do not correspond to number of targets */ /* number of sources do not correspond to number of targets */
set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
set_curr_dir_path(to, "test6.txt\0test7.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0");
ok(SHFileOperationA(&shfo2), "Can't copy many files\n"); retval = SHFileOperationA(&shfo2);
ok(!file_exists("test6.txt"), "The file is not copied - many files are " if (retval == ERROR_NO_VOLUME_LABEL)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(file_exists("test6.txt\\test1.txt"), "The file is not copied - many files "
"are specified as a target");
ok(file_exists("test7.txt\\test2.txt"), "The file is not copied - many files "
"are specified as a target");
DeleteFileA("test6.txt\\test1.txt");
DeleteFileA("test7.txt\\test2.txt");
RemoveDirectoryA("test6.txt");
RemoveDirectoryA("test7.txt");
}
else
{
ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
ok(!file_exists("test6.txt"), "The file is copied - many files are "
"specified as a target\n"); "specified as a target\n");
}
set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(from, "test1.txt\0");
set_curr_dir_path(to, "test4.txt\0"); set_curr_dir_path(to, "test4.txt\0");
@ -774,13 +806,15 @@ static void test_copy(void)
ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n"); ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n"); ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
retval = SHFileOperationA(&shfo); retval = SHFileOperationA(&shfo);
if (!retval) if (retval == ERROR_SUCCESS)
/* Win 95/NT returns success but copies only the files up to the nonexistent source */ /* Win 95/NT returns success but copies only the files up to the nonexistent source */
ok(file_exists("testdir2\\test1.txt"), "The file is not copied\n"); ok(file_exists("testdir2\\test1.txt"), "The file is not copied\n");
else else
{ {
/* Win 98/ME/2K/XP fail the entire operation with return code 1026 if one source file does not exist */ /* Failure if one source file does not exist */
ok(retval == 1026, "Files are copied to other directory\n"); ok(retval == 1026 || /* Win 98/ME/2K/XP */
retval == ERROR_FILE_NOT_FOUND, /* Vista and W2K8 */
"Files are copied to other directory\n");
ok(!file_exists("testdir2\\test1.txt"), "The file is copied\n"); ok(!file_exists("testdir2\\test1.txt"), "The file is copied\n");
} }
ok(!file_exists("testdir2\\test2.txt"), "The file is copied\n"); ok(!file_exists("testdir2\\test2.txt"), "The file is copied\n");
@ -837,18 +871,43 @@ static void test_copy(void)
shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0"; shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
shfo.fFlags |= FOF_NOERRORUI | FOF_MULTIDESTFILES; shfo.fFlags |= FOF_NOERRORUI | FOF_MULTIDESTFILES;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_SUCCESS)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n");
RemoveDirectory("testdir2\\a.txt");
ok(DeleteFile("testdir2\\b.txt\\test2.txt"), "Expected testdir2\\b.txt\\test2.txt to exist\n");
RemoveDirectory("testdir2\\b.txt");
ok(DeleteFile("testdir2\\c.txt\\test3.txt"), "Expected testdir2\\c.txt\\test3.txt to exist\n");
RemoveDirectory("testdir2\\c.txt");
ok(!file_exists("testdir2\\d.txt"), "Expected testdir2\\d.txt to not exist\n");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n"); ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n");
}
/* send in FOF_MULTIDESTFILES with too many destination files */ /* send in FOF_MULTIDESTFILES with too many destination files */
shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0"; shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
shfo.pTo = "e.txt\0f.txt\0"; shfo.pTo = "e.txt\0f.txt\0";
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_NO_MORE_SEARCH_HANDLES)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("e.txt\\test1.txt"), "Expected e.txt\\test1.txt to exist\n");
RemoveDirectory("e.txt");
ok(DeleteFile("f.txt\\test2.txt"), "Expected f.txt\\test2.txt to exist\n");
RemoveDirectory("f.txt");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
ok(!file_exists("e.txt"), "Expected e.txt to not exist\n"); ok(!file_exists("e.txt"), "Expected e.txt to not exist\n");
}
/* use FOF_MULTIDESTFILES with files and a source directory */ /* use FOF_MULTIDESTFILES with files and a source directory */
shfo.pFrom = "test1.txt\0test2.txt\0test4.txt\0"; shfo.pFrom = "test1.txt\0test2.txt\0test4.txt\0";
@ -866,8 +925,19 @@ static void test_copy(void)
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
shfo.fFlags &= ~FOF_MULTIDESTFILES; shfo.fFlags &= ~FOF_MULTIDESTFILES;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_SUCCESS)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("a.txt\\test1.txt"), "Expected a.txt\\test1.txt to exist\n");
ok(DeleteFile("a.txt\\test2.txt"), "Expected a.txt\\test2.txt to exist\n");
ok(DeleteFile("a.txt\\test3.txt"), "Expected a.txt\\test3.txt to exist\n");
RemoveDirectory("a.txt");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(!file_exists("a.txt"), "Expected a.txt to not exist\n"); ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
}
/* try a glob */ /* try a glob */
shfo.pFrom = "test?.txt\0"; shfo.pFrom = "test?.txt\0";
@ -896,9 +966,21 @@ static void test_copy(void)
shfo.fFlags &= ~FOF_FILESONLY; shfo.fFlags &= ~FOF_FILESONLY;
shfo.fFlags |= FOF_MULTIDESTFILES; shfo.fFlags |= FOF_MULTIDESTFILES;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_SUCCESS)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n");
ok(DeleteFile("testdir2\\a.txt\\test2.txt"), "Expected testdir2\\a.txt\\test2.txt to exist\n");
ok(DeleteFile("testdir2\\a.txt\\test3.txt"), "Expected testdir2\\a.txt\\test3.txt to exist\n");
ok(RemoveDirectory("testdir2\\a.txt\\test4.txt"), "Expected testdir2\\a.txt\\test4.txt to exist\n");
RemoveDirectory("testdir2\\a.txt");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n"); ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n"); ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n");
}
ok(!RemoveDirectory("b.txt"), "b.txt should not exist\n"); ok(!RemoveDirectory("b.txt"), "b.txt should not exist\n");
/* copy one file to two others, second is ignored */ /* copy one file to two others, second is ignored */
@ -916,19 +998,41 @@ static void test_copy(void)
shfo.pFrom = "test1.txt\0test2.txt\0"; shfo.pFrom = "test1.txt\0test2.txt\0";
shfo.pTo = "b.txt\0c.txt\0d.txt\0"; shfo.pTo = "b.txt\0c.txt\0d.txt\0";
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_SUCCESS)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n");
RemoveDirectory("b.txt");
ok(DeleteFile("c.txt\\test2.txt"), "Expected c.txt\\test2.txt to exist\n");
RemoveDirectory("c.txt");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n"); ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
}
/* copy one file and one directory to three others */ /* copy one file and one directory to three others */
shfo.pFrom = "test1.txt\0test4.txt\0"; shfo.pFrom = "test1.txt\0test4.txt\0";
shfo.pTo = "b.txt\0c.txt\0d.txt\0"; shfo.pTo = "b.txt\0c.txt\0d.txt\0";
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_SUCCESS)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n");
RemoveDirectory("b.txt");
ok(RemoveDirectory("c.txt\\test4.txt"), "Expected c.txt\\test4.txt to exist\n");
RemoveDirectory("c.txt");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n"); ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n"); ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n");
}
/* copy a directory with a file beneath it, plus some files */ /* copy a directory with a file beneath it, plus some files */
createTestFile("test4.txt\\a.txt"); createTestFile("test4.txt\\a.txt");
@ -954,9 +1058,20 @@ static void test_copy(void)
shfo.pFrom = "test4.txt\\a.txt\0test4.txt\0"; shfo.pFrom = "test4.txt\\a.txt\0test4.txt\0";
shfo.pTo = "nonexistent\0"; shfo.pTo = "nonexistent\0";
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_SUCCESS)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("nonexistent\\test4.txt\\a.txt"), "Expected nonexistent\\test4.txt\\a.txt to exist\n");
RemoveDirectory("nonexistent\\test4.txt");
ok(DeleteFile("nonexistent\\a.txt"), "Expected nonexistent\\a.txt to exist\n");
RemoveDirectory("nonexistent");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n"); ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n"); ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n");
}
DeleteFile("test4.txt\\a.txt"); DeleteFile("test4.txt\\a.txt");
/* destination is same as source file */ /* destination is same as source file */
@ -976,7 +1091,9 @@ static void test_copy(void)
shfo.pTo = "b.txt\0test4.txt\0c.txt\0"; shfo.pTo = "b.txt\0test4.txt\0c.txt\0";
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(retval == ERROR_SUCCESS ||
retval == ERROR_NO_VOLUME_LABEL, /* Vista */
"Expected ERROR_SUCCESS or ERROR_NO_VOLUME_LABEL, got %d\n", retval);
ok(DeleteFile("b.txt"), "Expected b.txt to exist\n"); ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
ok(!file_exists("c.txt"), "Expected c.txt to not exist\n"); ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
@ -986,7 +1103,9 @@ static void test_copy(void)
shfo.fFlags &= ~FOF_MULTIDESTFILES; shfo.fFlags &= ~FOF_MULTIDESTFILES;
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(retval == ERROR_SUCCESS ||
retval == ERROR_INVALID_VERIFY_SWITCH, /* Vista */
"Expected ERROR_SUCCESS or ERROR_INVALID_VERIFY_SWITCH, got %d\n", retval);
ok(!RemoveDirectory("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n"); ok(!RemoveDirectory("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n");
/* copy a directory to itself, error displayed in UI */ /* copy a directory to itself, error displayed in UI */
@ -994,7 +1113,9 @@ static void test_copy(void)
shfo.pTo = "test4.txt\0"; shfo.pTo = "test4.txt\0";
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(retval == ERROR_SUCCESS ||
retval == ERROR_INVALID_VERIFY_SWITCH, /* Vista */
"Expected ERROR_SUCCESS or ERROR_INVALID_VERIFY_SWITCH, got %d\n", retval);
/* copy a file into a directory, and the directory into itself */ /* copy a file into a directory, and the directory into itself */
shfo.pFrom = "test1.txt\0test4.txt\0"; shfo.pFrom = "test1.txt\0test4.txt\0";
@ -1002,7 +1123,9 @@ static void test_copy(void)
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
shfo.fFlags |= FOF_NOCONFIRMATION; shfo.fFlags |= FOF_NOCONFIRMATION;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); ok(retval == ERROR_SUCCESS ||
retval == ERROR_INVALID_VERIFY_SWITCH, /* Vista */
"Expected ERROR_SUCCESS or ERROR_INVALID_VERIFY_SWITCH, got %d\n", retval);
ok(DeleteFile("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n"); ok(DeleteFile("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n");
/* copy a file to a file, and the directory into itself */ /* copy a file to a file, and the directory into itself */
@ -1010,15 +1133,26 @@ static void test_copy(void)
shfo.pTo = "test4.txt\\a.txt\0"; shfo.pTo = "test4.txt\\a.txt\0";
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
if (retval == ERROR_INVALID_VERIFY_SWITCH)
{
/* Vista and W2K8 (broken or new behavior ?) */
ok(DeleteFile("test4.txt\\a.txt\\test1.txt"), "Expected test4.txt\\a.txt\\test1.txt to exist\n");
RemoveDirectory("test4.txt\\a.txt");
}
else
{
expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */); expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
ok(!file_exists("test4.txt\\a.txt"), "Expected test4.txt\\a.txt to not exist\n"); ok(!file_exists("test4.txt\\a.txt"), "Expected test4.txt\\a.txt to not exist\n");
}
/* copy a nonexistent file to a nonexistent directory */ /* copy a nonexistent file to a nonexistent directory */
shfo.pFrom = "e.txt\0"; shfo.pFrom = "e.txt\0";
shfo.pTo = "nonexistent\0"; shfo.pTo = "nonexistent\0";
shfo.fAnyOperationsAborted = FALSE; shfo.fAnyOperationsAborted = FALSE;
retval = SHFileOperation(&shfo); retval = SHFileOperation(&shfo);
ok(retval == 1026, "Expected 1026, got %d\n", retval); ok(retval == 1026 ||
retval == ERROR_FILE_NOT_FOUND, /* Vista */
"Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", retval);
ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n"); ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n");
ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n"); ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n");