httpapi/tests: Added some basic tests for session and group creation.

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
oldstable
Nikolay Sivov 2017-12-04 12:09:16 +03:00 committed by Alexandre Julliard
parent c0f96a406f
commit 727a8fba26
6 changed files with 204 additions and 2 deletions

3
configure vendored
View File

@ -18560,7 +18560,8 @@ wine_fn_config_dll hlink enable_hlink clean,implib
wine_fn_config_test dlls/hlink/tests hlink_test
wine_fn_config_dll hnetcfg enable_hnetcfg clean
wine_fn_config_test dlls/hnetcfg/tests hnetcfg_test
wine_fn_config_dll httpapi enable_httpapi
wine_fn_config_dll httpapi enable_httpapi implib
wine_fn_config_test dlls/httpapi/tests httpapi_test
wine_fn_config_dll iccvid enable_iccvid clean
wine_fn_config_dll icmp enable_icmp
wine_fn_config_dll ieframe enable_ieframe clean,implib

View File

@ -3206,7 +3206,8 @@ WINE_CONFIG_DLL(hlink,,[clean,implib])
WINE_CONFIG_TEST(dlls/hlink/tests)
WINE_CONFIG_DLL(hnetcfg,,[clean])
WINE_CONFIG_TEST(dlls/hnetcfg/tests)
WINE_CONFIG_DLL(httpapi)
WINE_CONFIG_DLL(httpapi,,[implib])
WINE_CONFIG_TEST(dlls/httpapi/tests)
WINE_CONFIG_DLL(iccvid,,[clean])
WINE_CONFIG_DLL(icmp)
WINE_CONFIG_DLL(ieframe,,[clean,implib])

View File

@ -1,4 +1,5 @@
MODULE = httpapi.dll
IMPORTLIB = httpapi
C_SRCS = \
httpapi_main.c

View File

@ -0,0 +1,5 @@
TESTDLL = httpapi.dll
IMPORTS = httpapi
C_SRCS = \
httpapi.c

View File

@ -0,0 +1,193 @@
/*
* HttpApi tests
*
* Copyright 2017 Nikolay Sivov for CodeWeavers
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "windef.h"
#include "winbase.h"
#include "winnt.h"
#include "winternl.h"
#include "http.h"
#include "wine/test.h"
static ULONG (WINAPI *pHttpCreateServerSession)(HTTPAPI_VERSION version, HTTP_SERVER_SESSION_ID *session_id,
ULONG reserved);
static ULONG (WINAPI *pHttpCloseServerSession)(HTTP_SERVER_SESSION_ID session_id);
static ULONG (WINAPI *pHttpCreateUrlGroup)(HTTP_SERVER_SESSION_ID session_id, HTTP_URL_GROUP_ID *group_id,
ULONG reserved);
static ULONG (WINAPI *pHttpCloseUrlGroup)(HTTP_URL_GROUP_ID group_id);
static void init(void)
{
HMODULE mod = GetModuleHandleA("httpapi.dll");
#define X(f) p##f = (void *)GetProcAddress(mod, #f)
X(HttpCreateServerSession);
X(HttpCloseServerSession);
X(HttpCreateUrlGroup);
X(HttpCloseUrlGroup);
#undef X
}
static void test_HttpCreateHttpHandle(void)
{
HANDLE handle, handle2;
ULONG ret;
BOOL b;
ret = HttpCreateHttpHandle(NULL, 0);
todo_wine
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected ret value %u.\n", ret);
/* Non-zero reserved parameter is accepted on XP/2k3. */
handle = NULL;
ret = HttpCreateHttpHandle(&handle, 0);
todo_wine {
ok(!ret, "Unexpected ret value %u.\n", ret);
ok(handle != NULL, "Unexpected handle value %p.\n", handle);
}
handle2 = NULL;
ret = HttpCreateHttpHandle(&handle2, 0);
todo_wine {
ok(!ret, "Unexpected ret value %u.\n", ret);
ok(handle2 != NULL && handle != handle2, "Unexpected handle %p.\n", handle2);
}
b = CloseHandle(handle);
todo_wine
ok(b, "Failed to close queue handle.\n");
}
static void test_HttpCreateServerSession(void)
{
HTTP_SERVER_SESSION_ID session;
HTTPAPI_VERSION version;
ULONG ret;
if (!pHttpCreateServerSession || !pHttpCloseServerSession)
{
skip("HttpCreateServerSession() is not supported.\n");
return;
}
version.HttpApiMajorVersion = 1;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, NULL, 0);
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 1;
version.HttpApiMinorVersion = 1;
ret = pHttpCreateServerSession(version, &session, 0);
ok(ret == ERROR_REVISION_MISMATCH, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 3;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, &session, 0);
ok(ret == ERROR_REVISION_MISMATCH, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 2;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, &session, 0);
ok(!ret, "Unexpected return value %u.\n", ret);
ret = pHttpCloseServerSession(session);
ok(!ret, "Unexpected return value %u.\n", ret);
version.HttpApiMajorVersion = 1;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, &session, 0);
ok(!ret, "Unexpected return value %u.\n", ret);
ret = pHttpCloseServerSession(session);
ok(!ret, "Unexpected return value %u.\n", ret);
ret = pHttpCloseServerSession(0xdead);
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
}
static void test_HttpCreateUrlGroup(void)
{
HTTP_SERVER_SESSION_ID session;
HTTP_URL_GROUP_ID group_id;
HTTPAPI_VERSION version;
ULONG ret;
if (!pHttpCreateUrlGroup)
{
skip("HttpCreateUrlGroup is not supported.\n");
return;
}
group_id = 1;
ret = pHttpCreateUrlGroup(0, &group_id, 0);
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
ok(group_id == 1, "Unexpected group id %s.\n", wine_dbgstr_longlong(group_id));
/* Create session, url group, close session. */
version.HttpApiMajorVersion = 1;
version.HttpApiMinorVersion = 0;
ret = pHttpCreateServerSession(version, &session, 0);
ok(!ret, "Unexpected return value %u.\n", ret);
group_id = 0;
ret = pHttpCreateUrlGroup(session, &group_id, 0);
ok(!ret, "Unexpected return value %u.\n", ret);
ok(group_id != 0, "Unexpected group id %s.\n", wine_dbgstr_longlong(group_id));
ret = pHttpCloseServerSession(session);
ok(!ret, "Unexpected return value %u.\n", ret);
/* Groups are closed together with their session. */
ret = pHttpCloseUrlGroup(group_id);
ok(ret == ERROR_INVALID_PARAMETER, "Unexpected return value %u.\n", ret);
/* Create session, url group, close group. */
ret = pHttpCreateServerSession(version, &session, 0);
ok(!ret, "Unexpected return value %u.\n", ret);
group_id = 0;
ret = pHttpCreateUrlGroup(session, &group_id, 0);
ok(!ret, "Unexpected return value %u.\n", ret);
ok(group_id != 0, "Unexpected group id %s.\n", wine_dbgstr_longlong(group_id));
ret = pHttpCloseUrlGroup(group_id);
ok(!ret, "Unexpected return value %u.\n", ret);
ret = pHttpCloseServerSession(session);
ok(!ret, "Unexpected return value %u.\n", ret);
}
START_TEST(httpapi)
{
HTTPAPI_VERSION version = { 1, 0 };
ULONG ret;
init();
ret = HttpInitialize(version, HTTP_INITIALIZE_SERVER, NULL);
ok(!ret, "Failed to initialize library, ret %u.\n", ret);
test_HttpCreateHttpHandle();
test_HttpCreateServerSession();
test_HttpCreateUrlGroup();
ret = HttpTerminate(HTTP_INITIALIZE_SERVER, NULL);
ok(!ret, "Failed to terminate, ret %u.\n", ret);
}

View File

@ -52,6 +52,7 @@ typedef enum _HTTP_SERVICE_CONFIG_ID
typedef ULONGLONG HTTP_OPAQUE_ID, *PHTTP_OPAQUE_ID;
typedef HTTP_OPAQUE_ID HTTP_SERVER_SESSION_ID, *PHTTP_SERVER_SESSION_ID;
typedef HTTP_OPAQUE_ID HTTP_URL_GROUP_ID, *PHTTP_URL_GROUP_ID;
ULONG WINAPI HttpInitialize(HTTPAPI_VERSION,ULONG,PVOID);
ULONG WINAPI HttpTerminate(ULONG,PVOID);