Hans Leidekker : wininet: Add a test for status callbacks on ftp connections.
Alexandre Julliard
julliard at winehq.org
Fri Dec 4 09:11:30 CST 2009
Module: wine
Branch: master
Commit: e018a5e25b653e49b6b9c8703a8b5a117c9058bf
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e018a5e25b653e49b6b9c8703a8b5a117c9058bf
Author: Hans Leidekker <hans at codeweavers.com>
Date: Fri Dec 4 13:26:00 2009 +0100
wininet: Add a test for status callbacks on ftp connections.
---
dlls/wininet/tests/ftp.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 48 insertions(+), 0 deletions(-)
diff --git a/dlls/wininet/tests/ftp.c b/dlls/wininet/tests/ftp.c
index d19b9a8..37c71da 100644
--- a/dlls/wininet/tests/ftp.c
+++ b/dlls/wininet/tests/ftp.c
@@ -42,6 +42,7 @@
static BOOL (WINAPI *pFtpCommandA)(HINTERNET,BOOL,DWORD,LPCSTR,DWORD_PTR,HINTERNET*);
+static INTERNET_STATUS_CALLBACK (WINAPI *pInternetSetStatusCallbackA)(HINTERNET,INTERNET_STATUS_CALLBACK);
static void test_getfile_no_open(void)
@@ -908,6 +909,51 @@ static void test_get_current_dir(HINTERNET hFtp, HINTERNET hConnect)
ok ( GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got: %d\n", GetLastError());
}
+static void WINAPI status_callback(HINTERNET handle, DWORD_PTR ctx, DWORD status, LPVOID info, DWORD info_len)
+{
+ switch (status)
+ {
+ case INTERNET_STATUS_RESOLVING_NAME:
+ case INTERNET_STATUS_NAME_RESOLVED:
+ case INTERNET_STATUS_CONNECTING_TO_SERVER:
+ case INTERNET_STATUS_CONNECTED_TO_SERVER:
+ trace("%p %lx %u %s %u\n", handle, ctx, status, (char *)info, info_len);
+ break;
+ default:
+ break;
+ }
+}
+
+static void test_status_callbacks(HINTERNET hInternet)
+{
+ INTERNET_STATUS_CALLBACK cb;
+ HINTERNET hFtp;
+ BOOL ret;
+
+ if (!pInternetSetStatusCallbackA)
+ {
+ win_skip("InternetSetStatusCallbackA() is not available, skipping test\n");
+ return;
+ }
+
+ cb = pInternetSetStatusCallbackA(hInternet, status_callback);
+ ok(cb == NULL, "expected NULL got %p\n", cb);
+
+ hFtp = InternetConnect(hInternet, "ftp.winehq.org", INTERNET_DEFAULT_FTP_PORT, "anonymous", NULL,
+ INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 1);
+ if (!hFtp)
+ {
+ skip("No ftp connection could be made to ftp.winehq.org %u\n", GetLastError());
+ return;
+ }
+
+ ret = InternetCloseHandle(hFtp);
+ ok(ret, "InternetCloseHandle failed %u\n", GetLastError());
+
+ cb = pInternetSetStatusCallbackA(hInternet, NULL);
+ ok(cb == status_callback, "expected check_status got %p\n", cb);
+}
+
START_TEST(ftp)
{
HMODULE hWininet;
@@ -915,6 +961,7 @@ START_TEST(ftp)
hWininet = GetModuleHandleA("wininet.dll");
pFtpCommandA = (void*)GetProcAddress(hWininet, "FtpCommandA");
+ pInternetSetStatusCallbackA = (void*)GetProcAddress(hWininet, "InternetSetStatusCallbackA");
SetLastError(0xdeadbeef);
hInternet = InternetOpen("winetest", 0, NULL, NULL, 0);
@@ -956,6 +1003,7 @@ START_TEST(ftp)
test_command(hFtp, hHttp);
test_find_first_file(hFtp, hHttp);
test_get_current_dir(hFtp, hHttp);
+ test_status_callbacks(hInternet);
InternetCloseHandle(hHttp);
InternetCloseHandle(hFtp);
More information about the wine-cvs
mailing list