[1/2] wininet: Add test for FtpSetCurrentDirectoryA [try 2]

Zac Brown zac at zacbrown.org
Mon Dec 10 14:15:22 CST 2007


Hi,

Changelog:
* Add test for FtpSetCurrentDirectoryA



---
 dlls/wininet/tests/ftp.c |   69 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 69 insertions(+), 0 deletions(-)

diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index 985b23b..6542e67 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -769,6 +769,74 @@ static void test_get_current_dir(HINTERNET hFtp, HINTERNET hConnect)
     ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
 }

+test_set_current_dir(HINTERNET hFtp, HINTERNET hConnect)
+{
+    BOOL    bRet;
+    LPSTR  testDirectory[MAX_PATH];
+
+    lstrcpy(testDirectory, "/tub");
+
+    /* test with null input */
+    SetLastError(0xdeadbeef);
+    bRet = FtpSetCurrentDirectoryA(NULL, NULL);
+    ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
+todo_wine
+    ok ( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got: %d\n", GetLastError());
+
+    /* test with NULL handle */
+    SetLastError(0xdeadbeef);
+    bRet = FtpSetCurrentDirectory(NULL, testDirectory);
+    ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
+todo_wine
+    ok ( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got: %d\n", GetLastError());
+
+    /* test with bad handle */
+    SetLastError(0xdeadbeef);
+    bRet = FtpSetCurrentDirectoryA(hConnect, testDirectory);
+    ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
+    ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE, "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got: %d\n", GetLastError());
+
+    /* test with bad directory pointer */
+    SetLastError(0xdeadbeef);
+    bRet = FtpSetCurrentDirectoryA(hFtp, NULL);
+    ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
+    ok ( GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got: %d\n", GetLastError());
+
+    /* test with bad directory name */
+    SetLastError(0xdeadbeef);
+    bRet = FtpSetCurrentDirectoryA(hFtp, testDirectory);
+    ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
+    ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR, "Expected ERROR_INTERNET_EXTENDED_ERROR, got: %d\n", GetLastError());
+
+    /* test with legit directory name */
+    SetLastError(0xdeadbeef);
+    lstrcpy(testDirectory, "/pub");
+    bRet = FtpSetCurrentDirectoryA(hFtp, testDirectory);
+    ok ( bRet == TRUE, "Expected FtpSetCurrentDirectoryA to pass\n");
+    ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
+
+    /* test with legit directory name without the '/' */
+    SetLastError(0xdeadbeef);
+    lstrcpy(testDirectory, "pub");
+    bRet = FtpSetCurrentDirectoryA(hFtp, testDirectory);
+    ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
+    ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR, "Expected ERROR_INTERNET_EXTENDED_ERROR, got: %d\n", GetLastError());
+
+    /* test with legit directory name with a trailing '/' */
+    SetLastError(0xdeadbeef);
+    lstrcpy(testDirectory, "pub/");
+    bRet = FtpSetCurrentDirectoryA(hFtp, testDirectory);
+    ok ( bRet == FALSE, "Expected FtpSetCurrentDirectoryA to fail\n");
+    ok ( GetLastError() == ERROR_INTERNET_EXTENDED_ERROR, "Expected ERROR_INTERNET_EXTENDED_ERROR, got: %d\n", GetLastError());
+
+    /* test with legit directory name with a starting and ending '/' */
+    SetLastError(0xdeadbeef);
+    lstrcpy(testDirectory, "/pub/");
+    bRet = FtpSetCurrentDirectoryA(hFtp, testDirectory);
+    ok ( bRet == TRUE, "Expected FtpSetCurrentDirectoryA to pass\n");
+    ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
+}
+
 START_TEST(ftp)
 {
     HANDLE hInternet, hFtp, hHttp;
@@ -812,6 +880,7 @@ START_TEST(ftp)
     test_renamefile(hFtp, hHttp);
     test_command(hFtp, hHttp);
     test_get_current_dir(hFtp, hHttp);
+    test_set_current_dir(hFtp, hHttp);

     InternetCloseHandle(hHttp);
     InternetCloseHandle(hFtp);
-- 
1.5.2.5




More information about the wine-patches mailing list