wininet/ftp.c: Add tests to show the order of parameter checking.

This commit is contained in:
Paul Vriens 2007-02-12 10:55:13 +01:00 committed by Alexandre Julliard
parent b6d8b27be5
commit 00b7b29c3a
1 changed files with 26 additions and 10 deletions

View File

@ -237,22 +237,30 @@ static void test_getfile(void)
BOOL bRet; BOOL bRet;
HINTERNET hInternet, hFtp, hConnect; HINTERNET hInternet, hFtp, hConnect;
/* Invalid internet handle, the other is a valid parameter */ /* The order of checking is:
SetLastError(0xdeadbeef); *
bRet = FtpGetFileA(NULL, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0); * All parameters except 'session handle' and 'condition flags'
ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n"); * Session handle
todo_wine * Session handle type
ok ( GetLastError() == ERROR_INVALID_HANDLE, * Condition flags
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError()); */
/* Test to show that FtpGetFileA checks the parameters before the handle */ /* Test to show existence of local file is tested first (together with 'remote file') */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
bRet = FtpGetFileA(NULL, NULL, NULL, FALSE, 0, 5, 0); bRet = FtpGetFileA(NULL, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n"); ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
todo_wine todo_wine
ok ( GetLastError() == ERROR_INVALID_PARAMETER, ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError()); "Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
/* Test to show session handle is checked before 'condition flags' */
SetLastError(0xdeadbeef);
bRet = FtpGetFileA(NULL, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0);
ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
todo_wine
ok ( GetLastError() == ERROR_INVALID_HANDLE,
"Expected ERROR_INVALID_HANDLE, got %d\n", GetLastError());
hInternet = InternetOpen(NULL, 0, NULL, NULL, 0); hInternet = InternetOpen(NULL, 0, NULL, NULL, 0);
hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0); hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", "IEUser@", INTERNET_SERVICE_FTP, 0, 0);
if(!hFtp) if(!hFtp)
@ -378,7 +386,15 @@ static void test_getfile(void)
hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0); hConnect = InternetConnect(hInternet, "www.winehq.org", INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
/* One small test to show that handle type is checked before parameters */ /* Test to show existence of local file is tested before 'session handle type' */
SetLastError(0xdeadbeef);
bRet = FtpGetFileA(hConnect, NULL, "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_UNKNOWN, 0);
ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");
todo_wine
ok ( GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
/* Test to show that 'session handle type' is checked before 'condition flags' */
SetLastError(0xdeadbeef); SetLastError(0xdeadbeef);
bRet = FtpGetFileA(hConnect, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0); bRet = FtpGetFileA(hConnect, "welcome.msg", "should_be_non_existing_deadbeef", FALSE, FILE_ATTRIBUTE_NORMAL, 5, 0);
ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n"); ok ( bRet == FALSE, "Expected FtpGetFileA to fail\n");