James Hawkins : shell32: Add tests for SHFileOperation's FO_DELETE
command.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Dec 22 07:07:33 CST 2005
Module: wine
Branch: refs/heads/master
Commit: d3c3bc1d3a29d7e8aacfcf04c07331fc83b7dff7
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=d3c3bc1d3a29d7e8aacfcf04c07331fc83b7dff7
Author: James Hawkins <truiken at gmail.com>
Date: Thu Dec 22 11:15:42 2005 +0100
shell32: Add tests for SHFileOperation's FO_DELETE command.
---
dlls/shell32/tests/shlfileop.c | 83 ++++++++++++++++++++++++++++++++++++++++
1 files changed, 83 insertions(+), 0 deletions(-)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index a850c3b..1a6edd5 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -171,6 +171,89 @@ static void test_delete(void)
ok(!file_exists("test4.txt"), "Directory should be removed\n");
}
ok(file_exists("test2.txt"), "This file should not be removed\n");
+
+ /* FOF_FILESONLY does not delete a dir matching a wildcard */
+ init_shfo_tests();
+ shfo.fFlags |= FOF_FILESONLY;
+ shfo.pFrom = "*.txt\0";
+ todo_wine
+ {
+ ok(!SHFileOperation(&shfo), "Failed to delete files\n");
+ ok(!file_exists("test1.txt"), "test1.txt should be removed\n");
+ }
+ ok(!file_exists("test_5.txt"), "test_5.txt should be removed\n");
+ ok(file_exists("test4.txt"), "test4.txt should not be removed\n");
+
+ /* FOF_FILESONLY only deletes a dir if explicitly specified */
+ init_shfo_tests();
+ shfo.pFrom = "test_?.txt\0test4.txt\0";
+ todo_wine
+ {
+ ok(!SHFileOperation(&shfo), "Failed to delete files\n");
+ ok(!file_exists("test4.txt"), "test4.txt should be removed\n");
+ }
+ ok(!file_exists("test_5.txt"), "test_5.txt should be removed\n");
+ ok(file_exists("test1.txt"), "test1.txt should not be removed\n");
+
+ /* try to delete an invalid filename */
+ init_shfo_tests();
+ shfo.pFrom = "\0";
+ shfo.fFlags &= ~FOF_FILESONLY;
+ shfo.fAnyOperationsAborted = FALSE;
+ ret = SHFileOperation(&shfo);
+ todo_wine
+ {
+ 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");
+
+ /* try an invalid function */
+ init_shfo_tests();
+ shfo.pFrom = "test1.txt\0";
+ shfo.wFunc = 0;
+ ret = SHFileOperation(&shfo);
+ todo_wine
+ {
+ ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %ld\n", ret);
+ }
+ ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
+
+ /* try an invalid list, only one null terminator */
+ init_shfo_tests();
+ shfo.pFrom = "";
+ shfo.wFunc = FO_DELETE;
+ ret = SHFileOperation(&shfo);
+ todo_wine
+ {
+ ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %ld\n", ret);
+ }
+ ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
+
+ /* delete a dir, and then a file inside the dir, same as
+ * deleting a nonexistent file
+ */
+ init_shfo_tests();
+ shfo.pFrom = "testdir2\0testdir2\\one.txt\0";
+ ret = SHFileOperation(&shfo);
+ todo_wine
+ {
+ ok(ret == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %ld\n", ret);
+ ok(!file_exists("testdir2"), "Expected testdir2 to not exist\n");
+ }
+ ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
+
+ /* try the FOF_NORECURSION flag, continues deleting subdirs */
+ init_shfo_tests();
+ shfo.pFrom = "testdir2\0";
+ shfo.fFlags |= FOF_NORECURSION;
+ ret = SHFileOperation(&shfo);
+ todo_wine
+ {
+ ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", ret);
+ }
+ ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
+ ok(!file_exists("testdir2\\nested"), "Expected testdir2\\nested to exist\n");
}
/* tests the FO_RENAME action */
More information about the wine-cvs
mailing list