wininet: Add test for FtpGetCurrentDirectoryA

James Hawkins truiken at gmail.com
Fri Nov 30 15:53:06 CST 2007


On Nov 30, 2007 3:47 PM, Zac Brown <zac at zacbrown.org> wrote:
> Hi,
>
> Changelog:
> * Add a test in dlls/wininet/tests/ftp.c for FtpGetCurrentDirectoryA
>
> Notes:
> * This test passes fully without error on Windows XP, with the test compiled by Visual Studio Express C++ 2008.
> * The functions this test call are currently broken in wine and I am in the process of fixing them myself.
>
> Patch is pasted below:
>
>
> ---
>  dlls/wininet/tests/ftp.c |   84 +++++++++++++++++++++++++++++++++++++++++++++-
>  1 files changed, 83 insertions(+), 1 deletions(-)
>
> diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
> index 6d03fb8..f6517b0 100644
> --- a/dlls/wininet/tests/ftp.c
> +++ b/dlls/wininet/tests/ftp.c
> @@ -691,6 +691,85 @@ static void test_command(HINTERNET hFtp, HINTERNET hConnect)
>      }
>  }
>
> +static void test_get_current_dir(HINTERNET hFtp, HINTERNET hConnect)
> +{
> +    BOOL    bRet;
> +    DWORD   dwCurrentDirectory = MAX_PATH;
> +    CHAR    lpszCurrentDirectory[MAX_PATH];
> +
> +    /* change directories to get a more interesting pwd */
> +    bRet = FtpCommandA(hFtp, FALSE, FTP_TRANSFER_TYPE_ASCII, "CWD pub/", 0, NULL);
> +    if(bRet == FALSE)
> +    {
> +        trace("Failed to change directories in test_get_current_dir(HINTERNET hFtp).\n");
> +        return;
> +    }
> +
> +    /* test with all NULL arguments */
> +    SetLastError(0xdeadbeef);
> +    bRet = FtpGetCurrentDirectoryA( NULL, NULL, 0 );
> +    ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n" );
> +    ok ( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got: %d\n", GetLastError());
> +
> +    /* test with NULL parameters instead of expected LPSTR/LPDWORD */
> +    SetLastError(0xdeadbeef);
> +    bRet = FtpGetCurrentDirectoryA( hFtp, NULL, 0 );
> +    ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n" );
> +    ok ( GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got: %d\n", GetLastError());
> +
> +    /* test with no valid handle and valid parameters */
> +    SetLastError(0xdeadbeef);
> +    bRet = FtpGetCurrentDirectoryA( NULL, lpszCurrentDirectory, &dwCurrentDirectory );
> +    ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n" );
> +    ok ( GetLastError() == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got: %d\n", GetLastError());
> +
> +    /* test with invalid dwCurrentDirectory and all other parameters correct */
> +    SetLastError(0xdeadbeef);
> +    bRet = FtpGetCurrentDirectoryA( hFtp, lpszCurrentDirectory, 0 );
> +    ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n" );
> +    ok ( GetLastError() == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got: %d\n", GetLastError());
> +
> +    /* test with invalid lpszCurrentDirectory and all other parameters correct */
> +    SetLastError(0xdeadbeef);
> +    bRet = FtpGetCurrentDirectoryA( hFtp, NULL, &dwCurrentDirectory );
> +    ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n" );
> +    ok ( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got: %d\n", GetLastError());
> +
> +    /* test to show it checks the handle type */
> +    SetLastError(0xdeadbeef);
> +    bRet = FtpGetCurrentDirectoryA( hConnect, lpszCurrentDirectory, &dwCurrentDirectory );
> +    ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n" );
> +    ok ( GetLastError() == ERROR_INTERNET_INCORRECT_HANDLE_TYPE,
> +    "Expected ERROR_INTERNET_INCORRECT_HANDLE_TYPE, got: %d\n", GetLastError());
> +
> +    /* test for the current directory with legitimate values */
> +    SetLastError(0xdeadbeef);
> +    bRet = FtpGetCurrentDirectoryA( hFtp, lpszCurrentDirectory, &dwCurrentDirectory );
> +    ok ( bRet == TRUE, "Expected FtpGetCurrentDirectoryA to pass\n" );
> +    ok ( lstrcmp(lpszCurrentDirectory, "/pub") == 0, "Expected returned value \"%s\" to match \"%s\" \n", (char*)lpszCurrentDirectory, "/pub");
> +    ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
> +
> +
> +    /* test for the current directory with a size only large enough to
> +     * fit the string and not the null terminating character */
> +    SetLastError(0xdeadbeef);
> +    dwCurrentDirectory = 4;
> +    lpszCurrentDirectory[4] = 'a'; /* set position 4 of the array to something else to make sure a leftover \0 isn't fooling the test */
> +    bRet = FtpGetCurrentDirectoryA( hFtp, lpszCurrentDirectory, &dwCurrentDirectory );
> +    ok ( bRet == FALSE, "Expected FtpGetCurrentDirectoryA to fail\n");
> +    ok ( lstrcmp(lpszCurrentDirectory, "/pub") != 0, "Expected returned value \"%s\" to not match \"%s\" \n", (char*)lpszCurrentDirectory, "/pub");
> +    ok ( GetLastError() == ERROR_INSUFFICIENT_BUFFER, "Expected ERROR_INSUFFICIENT_BUFFER, got: %d\n", GetLastError());
> +
> +    /* test for the current directory with a size large enough to store
> +     * the expected string as well as the null terminating character */
> +    SetLastError(0xdeadbeef);
> +    dwCurrentDirectory = 5;
> +    bRet = FtpGetCurrentDirectoryA( hFtp, lpszCurrentDirectory, &dwCurrentDirectory );
> +    ok ( bRet == TRUE, "Expected FtpGetCurrentDirectoryA to pass\n");
> +    ok ( lstrcmp(lpszCurrentDirectory, "/pub") == 0, "Expected returned value \"%s\" to match \"%s\" \n", (char*)lpszCurrentDirectory, "/pub");
> +    ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
> +}
> +
>  START_TEST(ftp)
>  {
>      HANDLE hInternet, hFtp, hHttp;
> @@ -733,7 +812,10 @@ START_TEST(ftp)
>      test_removedir(hFtp, hHttp);
>      test_renamefile(hFtp, hHttp);
>      test_command(hFtp, hHttp);
> -
> +todo_wine
> +{
> +    test_get_current_dir(hFtp, hHttp);
> +}
>      InternetCloseHandle(hHttp);
>      InternetCloseHandle(hFtp);
>      InternetCloseHandle(hInternet);
>

You put the todo_wine around each block of ok's that fail, not around
the whole test function.

-- 
James Hawkins



More information about the wine-devel mailing list