[1/3] wininet: Add test case for FtpSetCurrentDirectoryA

Zac Brown zac at zacbrown.org
Tue Dec 4 09:01:24 CST 2007


Hi,

Changelog:
* Add test case for FtpSetCurrentDirectoryA

Notes:
* Test passes entirely on Windows XP installation



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

diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index 1f63752..7344554 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -774,6 +774,75 @@ todo_wine
     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];
+
+    ZeroMemory(testDirectory, MAX_PATH * sizeof(CHAR));
+    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;
@@ -817,6 +886,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