winhttp/tests: Use wide character string literals.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2020-02-14 16:41:38 +01:00 committed by Alexandre Julliard
parent 6745afd81d
commit ef908c59c1
3 changed files with 325 additions and 488 deletions

View file

@ -28,12 +28,6 @@
#include "wine/test.h"
static const WCHAR user_agent[] = {'w','i','n','e','t','e','s','t',0};
static const WCHAR test_winehq[] = {'t','e','s','t','.','w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR tests_hello_html[] = {'/','t','e','s','t','s','/','h','e','l','l','o','.','h','t','m','l',0};
static const WCHAR tests_redirect[] = {'/','t','e','s','t','s','/','r','e','d','i','r','e','c','t',0};
static const WCHAR localhostW[] = {'l','o','c','a','l','h','o','s','t',0};
enum api
{
winhttp_connect = 1,
@ -191,7 +185,7 @@ static void test_connection_cache( void )
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
ses = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
ok(ses != NULL, "failed to open session %u\n", GetLastError());
event = CreateEventW( NULL, FALSE, FALSE, NULL );
@ -208,11 +202,11 @@ static void test_connection_cache( void )
ok(ret, "failed to set context value %u\n", GetLastError());
setup_test( &info, winhttp_connect, __LINE__ );
con = WinHttpConnect( ses, test_winehq, 0, 0 );
con = WinHttpConnect( ses, L"test.winehq.org", 0, 0 );
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
setup_test( &info, winhttp_open_request, __LINE__ );
req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 );
req = WinHttpOpenRequest( con, NULL, L"/tests/hello.html", NULL, NULL, NULL, 0 );
ok(req != NULL, "failed to open a request %u\n", GetLastError());
setup_test( &info, winhttp_send_request, __LINE__ );
@ -240,7 +234,7 @@ static void test_connection_cache( void )
WaitForSingleObject( info.wait, INFINITE );
setup_test( &info, winhttp_open_request, __LINE__ );
req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 );
req = WinHttpOpenRequest( con, NULL, L"/tests/hello.html", NULL, NULL, NULL, 0 );
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
@ -289,7 +283,7 @@ static void test_connection_cache( void )
}
ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
ses = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
ok(ses != NULL, "failed to open session %u\n", GetLastError());
if (unload)
@ -304,11 +298,11 @@ static void test_connection_cache( void )
ok(ret, "failed to set context value %u\n", GetLastError());
setup_test( &info, winhttp_connect, __LINE__ );
con = WinHttpConnect( ses, test_winehq, 0, 0 );
con = WinHttpConnect( ses, L"test.winehq.org", 0, 0 );
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
setup_test( &info, winhttp_open_request, __LINE__ );
req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 );
req = WinHttpOpenRequest( con, NULL, L"/tests/hello.html", NULL, NULL, NULL, 0 );
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
@ -339,7 +333,7 @@ static void test_connection_cache( void )
WaitForSingleObject( info.wait, INFINITE );
setup_test( &info, winhttp_open_request, __LINE__ );
req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 );
req = WinHttpOpenRequest( con, NULL, L"/tests/hello.html", NULL, NULL, NULL, 0 );
ok(req != NULL, "failed to open a request %u\n", GetLastError());
ret = WinHttpSetOption( req, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
@ -431,7 +425,7 @@ static void test_redirect( void )
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
ses = WinHttpOpen( L"winetest", 0, NULL, NULL, 0 );
ok(ses != NULL, "failed to open session %u\n", GetLastError());
WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
@ -440,11 +434,11 @@ static void test_redirect( void )
ok(ret, "failed to set context value %u\n", GetLastError());
setup_test( &info, winhttp_connect, __LINE__ );
con = WinHttpConnect( ses, test_winehq, 0, 0 );
con = WinHttpConnect( ses, L"test.winehq.org", 0, 0 );
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
setup_test( &info, winhttp_open_request, __LINE__ );
req = WinHttpOpenRequest( con, NULL, tests_redirect, NULL, NULL, NULL, 0 );
req = WinHttpOpenRequest( con, NULL, L"/tests/redirect", NULL, NULL, NULL, 0 );
ok(req != NULL, "failed to open a request %u\n", GetLastError());
setup_test( &info, winhttp_send_request, __LINE__ );
@ -512,7 +506,7 @@ static void test_async( void )
info.index = 0;
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
ses = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
ses = WinHttpOpen( L"winetest", 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
ok(ses != NULL, "failed to open session %u\n", GetLastError());
event = CreateEventW( NULL, FALSE, FALSE, NULL );
@ -536,14 +530,14 @@ static void test_async( void )
setup_test( &info, winhttp_connect, __LINE__ );
SetLastError( 0xdeadbeef );
con = WinHttpConnect( ses, test_winehq, 0, 0 );
con = WinHttpConnect( ses, L"test.winehq.org", 0, 0 );
err = GetLastError();
ok(con != NULL, "failed to open a connection %u\n", err);
ok(err == ERROR_SUCCESS || broken(err == WSAEINVAL) /* < win7 */, "got %u\n", err);
setup_test( &info, winhttp_open_request, __LINE__ );
SetLastError( 0xdeadbeef );
req = WinHttpOpenRequest( con, NULL, tests_hello_html, NULL, NULL, NULL, 0 );
req = WinHttpOpenRequest( con, NULL, L"/tests/hello.html", NULL, NULL, NULL, 0 );
err = GetLastError();
ok(req != NULL, "failed to open a request %u\n", err);
ok(err == ERROR_SUCCESS, "got %u\n", err);
@ -718,7 +712,7 @@ static void test_basic_request(int port, const WCHAR *verb, const WCHAR *path)
ses = WinHttpOpen(NULL, WINHTTP_ACCESS_TYPE_NO_PROXY, NULL, NULL, 0);
ok(ses != NULL, "failed to open session %u\n", GetLastError());
con = WinHttpConnect(ses, localhostW, port, 0);
con = WinHttpConnect(ses, L"localhost", port, 0);
ok(con != NULL, "failed to open a connection %u\n", GetLastError());
req = WinHttpOpenRequest(con, verb, path, NULL, NULL, NULL, 0);
@ -787,14 +781,14 @@ static void open_async_request(int port, struct test_request *req, struct info *
info->count = ARRAY_SIZE( open_socket_request_test );
}
req->session = WinHttpOpen( user_agent, 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
req->session = WinHttpOpen( L"winetest", 0, NULL, NULL, WINHTTP_FLAG_ASYNC );
ok(req->session != NULL, "failed to open session %u\n", GetLastError());
WinHttpSetOption( req->session, WINHTTP_OPTION_CONTEXT_VALUE, &info, sizeof(struct info *) );
WinHttpSetStatusCallback( req->session, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );
setup_test( info, winhttp_connect, __LINE__ );
req->connection = WinHttpConnect( req->session, localhostW, port, 0 );
req->connection = WinHttpConnect( req->session, L"localhost", port, 0 );
ok(req->connection != NULL, "failed to open a connection %u\n", GetLastError());
setup_test( info, winhttp_open_request, __LINE__ );
@ -808,10 +802,8 @@ static void open_async_request(int port, struct test_request *req, struct info *
static void open_socket_request(int port, struct test_request *req, struct info *info)
{
static const WCHAR socketW[] = {'/','s','o','c','k','e','t',0};
ResetEvent( server_socket_done );
open_async_request( port, req, info, socketW, FALSE );
open_async_request( port, req, info, L"/socket", FALSE );
WaitForSingleObject( server_socket_available, INFINITE );
}
@ -951,8 +943,6 @@ static void test_persistent_connection(int port)
struct test_request req;
struct info info;
static const WCHAR testW[] = {'/','t','e','s','t',0};
trace("Testing persistent connection...\n");
info.wait = CreateEventW( NULL, FALSE, FALSE, NULL );
@ -969,7 +959,7 @@ static void test_persistent_connection(int port)
close_request( &req, &info, FALSE );
/* chunked connection test */
open_async_request( port, &req, &info, testW, TRUE );
open_async_request( port, &req, &info, L"/test", TRUE );
server_read_data( "GET /test HTTP/1.1\r\n" );
server_send_reply( &req, &info,
"HTTP/1.1 200 OK\r\n"
@ -983,7 +973,7 @@ static void test_persistent_connection(int port)
close_request( &req, &info, FALSE );
/* HTTP/1.1 connections are persistent by default, no additional header is needed */
open_async_request( port, &req, &info, testW, TRUE );
open_async_request( port, &req, &info, L"/test", TRUE );
server_read_data( "GET /test HTTP/1.1\r\n" );
server_send_reply( &req, &info,
"HTTP/1.1 200 OK\r\n"
@ -994,7 +984,7 @@ static void test_persistent_connection(int port)
read_request_data( &req, &info, "xx", FALSE );
close_request( &req, &info, FALSE );
open_async_request( port, &req, &info, testW, TRUE );
open_async_request( port, &req, &info, L"/test", TRUE );
server_read_data( "GET /test HTTP/1.1\r\n" );
server_send_reply( &req, &info,
"HTTP/1.1 200 OK\r\n"
@ -1011,7 +1001,6 @@ static void test_persistent_connection(int port)
START_TEST (notification)
{
static const WCHAR quitW[] = {'/','q','u','i','t',0};
struct server_info si;
HANDLE thread;
DWORD ret;
@ -1040,7 +1029,7 @@ START_TEST (notification)
test_persistent_connection( si.port );
/* send the basic request again to shutdown the server thread */
test_basic_request( si.port, NULL, quitW );
test_basic_request( si.port, NULL, L"/quit" );
WaitForSingleObject( thread, 3000 );
CloseHandle( thread );

View file

@ -33,80 +33,45 @@ static WCHAR username[] = {'u','s','e','r','n','a','m','e',0};
static WCHAR password[] = {'p','a','s','s','w','o','r','d',0};
static WCHAR about[] = {'/','s','i','t','e','/','a','b','o','u','t',0};
static WCHAR query[] = {'?','q','u','e','r','y',0};
static WCHAR escape[] = {' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>','?','@','[','\\',']','^','_','`','{','|','}','~',0};
static WCHAR escape[] = {' ','!','"','#','$','%','&','\'','(',')','*','+',',','-','.','/',':',';','<','=','>',
'?','@','[','\\',']','^','_','`','{','|','}','~',0};
static WCHAR escape2[] = {'\r',0x1f,' ','\n',0x7f,'\r','\n',0};
static WCHAR escape3[] = {'?','t','e','x','t','=',0xfb00,0};
static WCHAR escape4[] = {'/','t','e','x','t','=',0xfb00,0};
static const WCHAR url1[] =
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
static const WCHAR url2[] = {'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':',0};
static const WCHAR url3[] =
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
static const WCHAR url4[] = {'h','t','t','p',':','/','/',0};
static const WCHAR url5[] =
{'f','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','8','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
static const WCHAR url6[] =
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','2','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
static const WCHAR url7[] =
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t',
'%','2','0','!','%','2','2','%','2','3','$','%','2','5','&','\'','(',')','*','+',',','-','.','/',':',';','%','3','C','=','%','3','E','?','@','%',
'5','B','%','5','C','%','5','D','%','5','E','_','%','6','0','%','7','B','%','7','C','%','7','D','%','7','E',0};
static const WCHAR url8[] =
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
static const WCHAR url9[] =
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','8','0','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
static const WCHAR url10[] =
{'h','t','t','p','s',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g',':','4','4','3','/','s','i','t','e','/','a','b','o','u','t','?','q','u','e','r','y',0};
static const WCHAR url11[] =
{'h','t','t','p',':','/','/','e','x','a','m','p','l','e','.','n','e','t','/','p','a','t','h','?','v','a','r','1','=','e','x','a','m','p','l','e','@','e','x','a','m','p','l','e','.','c','o','m','&','v','a','r','2','=','x','&','v','a','r','3','=','y', 0};
static const WCHAR url12[] =
{'h','t','t','p','s',':','/','/','t','o','o','l','s','.','g','o','o','g','l','e','.','c','o','m','/','s','e','r','v','i','c','e','/','u','p','d','a','t','e','2','?','w','=','3',':','B','x','D','H','o','W','y','8','e','z','M',0};
static const WCHAR url13[] =
{'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o',' ','g','/','p','a','t','h',' ','w','i','t','h',' ','s','p','a','c','e','s',0};
static const WCHAR url14[] = {'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','t','e','s','t',0};
static const WCHAR url15[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','6','5','5','3','6',0};
static const WCHAR url16[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':','0',0};
static const WCHAR url17[] = {'h','t','t','p',':','/','/','w','i','n','e','h','q','.','o','r','g',':',0};
static const WCHAR url18[] =
{'h','t','t','p',':','/','/','%','0','D','%','1','F','%','2','0','%','0','A','%','7','F','%','0','D','%','0','A',0};
static const WCHAR url19[] =
{'h','t','t','p',':','/','/','?','t','e','x','t','=',0xfb00,0};
static const WCHAR url20[] =
{'h','t','t','p',':','/','/','/','t','e','x','t','=',0xfb00,0};
static const WCHAR url21[] =
{'h','t','t','p','s',':','/','/','n','b','a','2','k','1','9','-','w','s','.','2','k','s','p','o','r','t','s','.','c','o','m',':','1','9','1','3','3',
'/','n','b','a','/','v','4','/','A','c','c','o','u','n','t','s','/','g','e','t','_','a','c','c','o','u','n','t','?','x','=','3','7','8','9','5','2',
'6','7','7','5','2','6','5','6','6','3','8','7','6',0};
static const WCHAR url1[] = L"http://username:password@www.winehq.org/site/about?query";
static const WCHAR url2[] = L"http://username:";
static const WCHAR url3[] = L"http://www.winehq.org/site/about?query";
static const WCHAR url4[] = L"http://";
static const WCHAR url5[] = L"ftp://username:password@www.winehq.org:80/site/about?query";
static const WCHAR url6[] = L"http://username:password@www.winehq.org:42/site/about?query";
static const WCHAR url7[] = L"http://username:password@www.winehq.org/site/about%20!%22%23$%25&'()"
"*+,-./:;%3C=%3E?@%5B%5C%5D%5E_%60%7B%7C%7D%7E";
static const WCHAR url8[] = L"http://username:password@www.winehq.org:0/site/about?query";
static const WCHAR url9[] = L"http://username:password@www.winehq.org:80/site/about?query";
static const WCHAR url10[] = L"https://username:password@www.winehq.org:443/site/about?query";
static const WCHAR url11[] = L"http://example.net/path?var1=example@example.com&var2=x&var3=y";
static const WCHAR url12[] = L"https://tools.google.com/service/update2?w=3:BxDHoWy8ezM";
static const WCHAR url13[] = L"http://winehq.o g/path with spaces";
static const WCHAR url14[] = L"http://www.winehq.org/test";
static const WCHAR url15[] = L"http://winehq.org:65536";
static const WCHAR url16[] = L"http://winehq.org:0";
static const WCHAR url17[] = L"http://winehq.org:";
static const WCHAR url18[] = L"http://%0D%1F%20%0A%7F%0D%0A";
static const WCHAR url19[] = L"http://?text=\xfb00";
static const WCHAR url20[] = L"http:///text=\xfb00";
static const WCHAR url21[] = L"https://nba2k19-ws.2ksports.com:19133/nba/v4/Accounts/get_account?x=3789526775265663876";
static const WCHAR url_k1[] =
{'h','t','t','p',':','/','/','u','s','e','r','n','a','m','e',':','p','a','s','s','w','o','r','d',
'@','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','s','i','t','e','/','a','b','o','u','t',0};
static const WCHAR url_k2[] =
{'h','t','t','p',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR url_k3[] =
{'h','t','t','p','s',':','/','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g','/','p','o','s','t','?',0};
static const WCHAR url_k4[] =
{'H','T','T','P',':','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR url_k5[] =
{'h','t','t','p',':','/','w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR url_k6[] =
{'w','w','w','.','w','i','n','e','h','q','.','o','r','g',0};
static const WCHAR url_k7[] =
{'w','w','w',0};
static const WCHAR url_k8[] =
{'h','t','t','p',0};
static const WCHAR url_k9[] =
{'h','t','t','p',':','/','/','w','i','n','e','h','q','?',0};
static const WCHAR url_k10[] =
{'h','t','t','p',':','/','/','w','i','n','e','h','q','/','p','o','s','t',';','a',0};
static const WCHAR url_k1[] = L"http://username:password@www.winehq.org/site/about";
static const WCHAR url_k2[] = L"http://www.winehq.org";
static const WCHAR url_k3[] = L"https://www.winehq.org/post?";
static const WCHAR url_k4[] = L"HTTP:www.winehq.org";
static const WCHAR url_k5[] = L"http:/www.winehq.org";
static const WCHAR url_k6[] = L"www.winehq.org";
static const WCHAR url_k7[] = L"www";
static const WCHAR url_k8[] = L"http";
static const WCHAR url_k9[] = L"http://winehq?";
static const WCHAR url_k10[] = L"http://winehq/post;a";
static void fill_url_components( URL_COMPONENTS *uc )
{
@ -427,10 +392,6 @@ static void reset_url_components( URL_COMPONENTS *uc )
static void WinHttpCrackUrl_test( void )
{
static const WCHAR hostnameW[] =
{'w','i','n','e','h','q','.','o',' ','g',0};
static const WCHAR pathW[] =
{'/','p','a','t','h','%','2','0','w','i','t','h','%','2','0','s','p','a','c','e','s',0};
URL_COMPONENTSW uc;
WCHAR scheme[20], user[20], pass[20], host[40], path[80], extra[40];
DWORD error;
@ -758,9 +719,9 @@ static void WinHttpCrackUrl_test( void )
uc.nPort = 0;
ret = WinHttpCrackUrl( url13, 0, ICU_ESCAPE|ICU_DECODE, &uc );
ok( ret, "WinHttpCrackUrl failed le=%u\n", GetLastError() );
ok( !lstrcmpW( uc.lpszHostName, hostnameW ), "unexpected host name\n" );
ok( !lstrcmpW( uc.lpszUrlPath, pathW ), "unexpected path\n" );
ok( uc.dwUrlPathLength == lstrlenW(pathW), "got %u\n", uc.dwUrlPathLength );
ok( !lstrcmpW( uc.lpszHostName, L"winehq.o g" ), "unexpected host name\n" );
ok( !lstrcmpW( uc.lpszUrlPath, L"/path%20with%20spaces" ), "unexpected path\n" );
ok( uc.dwUrlPathLength == lstrlenW(L"/path%20with%20spaces"), "got %u\n", uc.dwUrlPathLength );
uc.dwStructSize = sizeof(uc);
uc.lpszScheme = NULL;

File diff suppressed because it is too large Load diff