Module: wine Branch: master Commit: 58f944bb4b68cef5c95da4829214e59c9705bd6b URL: http://source.winehq.org/git/wine.git/?a=commit;h=58f944bb4b68cef5c95da48292...
Author: Sebastian Lackner sebastian@fds-team.de Date: Sun Aug 21 21:20:08 2016 +0200
ws2_32/tests: Add basic tests for async messages.
Signed-off-by: Sebastian Lackner sebastian@fds-team.de Signed-off-by: Bruno Jesus 00cpxxx@gmail.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/ws2_32/tests/sock.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/dlls/ws2_32/tests/sock.c b/dlls/ws2_32/tests/sock.c index d6412fd..2640dd4 100644 --- a/dlls/ws2_32/tests/sock.c +++ b/dlls/ws2_32/tests/sock.c @@ -8464,6 +8464,22 @@ static HWND create_async_message_window(void) return hWnd; }
+static void wait_for_async_message(HWND hwnd, HANDLE handle) +{ + BOOL ret; + MSG msg; + + while ((ret = GetMessageA(&msg, 0, 0, 0)) && + !(msg.hwnd == hwnd && msg.message == WM_ASYNCCOMPLETE)) + { + TranslateMessage(&msg); + DispatchMessageA(&msg); + } + + ok(ret, "did not expect WM_QUIT message\n"); + ok(msg.wParam == (WPARAM)handle, "expected wParam = %p, got %lx\n", handle, msg.wParam); +} + static void test_WSAAsyncGetServByPort(void) { HWND hwnd = create_async_message_window(); @@ -8481,12 +8497,15 @@ static void test_WSAAsyncGetServByPort(void)
ret = WSAAsyncGetServByPort(hwnd, WM_ASYNCCOMPLETE, 0, NULL, NULL, 0); ok(ret != NULL, "WSAAsyncGetServByPort returned NULL\n"); + wait_for_async_message(hwnd, ret);
ret = WSAAsyncGetServByPort(hwnd, WM_ASYNCCOMPLETE, htons(80), NULL, NULL, 0); ok(ret != NULL, "WSAAsyncGetServByPort returned NULL\n"); + wait_for_async_message(hwnd, ret);
ret = WSAAsyncGetServByPort(hwnd, WM_ASYNCCOMPLETE, htons(80), NULL, buffer, MAXGETHOSTSTRUCT); ok(ret != NULL, "WSAAsyncGetServByPort returned NULL\n"); + wait_for_async_message(hwnd, ret);
DestroyWindow(hwnd); } @@ -8505,15 +8524,19 @@ static void test_WSAAsyncGetServByName(void) /* Parameters are not checked when initiating the asynchronous operation. */ ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "", NULL, NULL, 0); ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + wait_for_async_message(hwnd, ret);
ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "", "", buffer, MAXGETHOSTSTRUCT); ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + wait_for_async_message(hwnd, ret);
ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "http", NULL, NULL, 0); ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + wait_for_async_message(hwnd, ret);
ret = WSAAsyncGetServByName(hwnd, WM_ASYNCCOMPLETE, "http", "tcp", buffer, MAXGETHOSTSTRUCT); ok(ret != NULL, "WSAAsyncGetServByName returned NULL\n"); + wait_for_async_message(hwnd, ret);
DestroyWindow(hwnd); }