James Hawkins : shell32: Add tests for SHFileOperation's FO_MOVE command.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Dec 22 07:07:35 CST 2005


Module: wine
Branch: refs/heads/master
Commit: 036d5eff7bf6d2146d036066336aff842d15c988
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=036d5eff7bf6d2146d036066336aff842d15c988

Author: James Hawkins <truiken at gmail.com>
Date:   Thu Dec 22 11:19:13 2005 +0100

shell32: Add tests for SHFileOperation's FO_MOVE command.

---

 dlls/shell32/tests/shlfileop.c |   81 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 80 insertions(+), 1 deletions(-)

diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index e73a513..60418ed 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -738,6 +738,7 @@ static void test_move(void)
     SHFILEOPSTRUCTA shfo, shfo2;
     CHAR from[MAX_PATH];
     CHAR to[MAX_PATH];
+    DWORD retval;
 
     shfo.hwnd = NULL;
     shfo.wFunc = FO_MOVE;
@@ -750,7 +751,8 @@ static void test_move(void)
     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");
-    ok(file_exists("test4.txt\\test1.txt"), "The file is moved\n");
+    ok(!file_exists("test1.txt"), "test1.txt should not exist\n");
+    ok(file_exists("test4.txt\\test1.txt"), "The file is not moved\n");
 
     set_curr_dir_path(from, "test?.txt\0");
     set_curr_dir_path(to, "testdir2\0");
@@ -815,6 +817,83 @@ static void test_move(void)
     set_curr_dir_path(from, "test6.txt\0");
     set_curr_dir_path(to, "test4.txt\0");
     ok(!SHFileOperationA(&shfo), "Move dir back\n");
+
+    /* move one file to two others */
+    init_shfo_tests();
+    shfo.pFrom = "test1.txt\0";
+    shfo.pTo = "a.txt\0b.txt\0";
+    retval = SHFileOperationA(&shfo);
+    todo_wine
+    {
+        ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval);
+        ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
+        ok(DeleteFile("a.txt"), "Expected a.txt to 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 == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval);
+        ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
+    }
+    ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
+    ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
+
+    /* move a directory into itself */
+    shfo.pFrom = "test4.txt\0";
+    shfo.pTo = "test4.txt\\b.txt\0";
+    retval = SHFileOperationA(&shfo);
+    todo_wine
+    {
+        ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval);
+    }
+    ok(!RemoveDirectory("test4.txt\\b.txt"), "Expected test4.txt\\b.txt to not exist\n");
+    ok(file_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 == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval);
+    }
+    ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
+    ok(!DeleteFile("e.txt"), "Expected e.txt to not exist\n");
+
+    /* number of sources != number of targets */
+    shfo.pTo = "d.txt\0";
+    shfo.fFlags |= FOF_MULTIDESTFILES;
+    retval = SHFileOperationA(&shfo);
+    todo_wine
+    {
+        ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval);
+    }
+    ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
+
+    /* FO_MOVE does not create dest directories */
+    shfo.pFrom = "test2.txt\0";
+    shfo.pTo = "dir1\\dir2\\test2.txt\0";
+    retval = SHFileOperationA(&shfo);
+    todo_wine
+    {
+        ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %ld\n", retval);
+    }
+    ok(!file_exists("dir1"), "Expected dir1 to exist\n");
+
+    /* try to overwrite an existing file */
+    shfo.pTo = "test3.txt\0";
+    retval = SHFileOperationA(&shfo);
+    todo_wine
+    {
+        ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %ld\n", retval);
+        ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n");
+    }
+    ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
 }
 
 static void test_sh_create_dir(void)




More information about the wine-cvs mailing list