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>
This commit is contained in:
Sebastian Lackner 2016-08-21 21:20:08 +02:00 committed by Alexandre Julliard
parent 6b44c4f5cc
commit 58f944bb4b
1 changed files with 23 additions and 0 deletions

View File

@ -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);
}