jsproxy/tests: Add tests.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
ea8b261abe
commit
1f144fae1a
|
@ -17749,6 +17749,7 @@ wine_fn_config_dll joy.cpl enable_joy_cpl clean
|
|||
wine_fn_config_dll jscript enable_jscript clean
|
||||
wine_fn_config_test dlls/jscript/tests jscript_test
|
||||
wine_fn_config_dll jsproxy enable_jsproxy implib
|
||||
wine_fn_config_test dlls/jsproxy/tests jsproxy_test
|
||||
wine_fn_config_dll kernel32 enable_kernel32 clean,implib
|
||||
wine_fn_config_test dlls/kernel32/tests kernel32_test
|
||||
wine_fn_config_dll kernelbase enable_kernelbase
|
||||
|
|
|
@ -2997,6 +2997,7 @@ WINE_CONFIG_DLL(joy.cpl,,[clean])
|
|||
WINE_CONFIG_DLL(jscript,,[clean])
|
||||
WINE_CONFIG_TEST(dlls/jscript/tests)
|
||||
WINE_CONFIG_DLL(jsproxy,,[implib])
|
||||
WINE_CONFIG_TEST(dlls/jsproxy/tests)
|
||||
WINE_CONFIG_DLL(kernel32,,[clean,implib])
|
||||
WINE_CONFIG_TEST(dlls/kernel32/tests)
|
||||
WINE_CONFIG_DLL(kernelbase)
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
TESTDLL = jsproxy.dll
|
||||
IMPORTS = jsproxy
|
||||
|
||||
C_SRCS = \
|
||||
jsproxy.c
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright 2016 Hans Leidekker 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 <stdlib.h>
|
||||
#include <windef.h>
|
||||
#include <winbase.h>
|
||||
#include <wininet.h>
|
||||
|
||||
#include "wine/test.h"
|
||||
|
||||
static BOOL (WINAPI *pInternetInitializeAutoProxyDll)
|
||||
(DWORD, LPSTR, LPSTR, AutoProxyHelperFunctions *, AUTO_PROXY_SCRIPT_BUFFER *);
|
||||
static BOOL (WINAPI *pInternetDeInitializeAutoProxyDll)(LPSTR, DWORD);
|
||||
static BOOL (WINAPI *pInternetGetProxyInfo)(LPCSTR, DWORD, LPSTR, DWORD, LPSTR *, LPDWORD);
|
||||
|
||||
static void test_InternetInitializeAutoProxyDll(void)
|
||||
{
|
||||
const char url[] = "http://localhost";
|
||||
char script[] = "function FindProxyForURL(url, host) {return \"DIRECT\";}\0test";
|
||||
char script2[] = "function FindProxyForURL(url, host) {return \"PROXY 10.0.0.1:8080\";}\0test";
|
||||
char *proxy, host[] = "localhost";
|
||||
AUTO_PROXY_SCRIPT_BUFFER buf;
|
||||
DWORD err, len;
|
||||
BOOL ret;
|
||||
|
||||
buf.dwStructSize = sizeof(buf);
|
||||
buf.lpszScriptBuffer = script;
|
||||
buf.dwScriptBufferSize = 0;
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pInternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buf );
|
||||
err = GetLastError();
|
||||
ok( !ret, "unexpected success\n" );
|
||||
ok( err == ERROR_INVALID_PARAMETER, "got %u\n", err );
|
||||
|
||||
buf.dwScriptBufferSize = strlen(script) + 1;
|
||||
ret = pInternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buf );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
|
||||
ret = pInternetGetProxyInfo( url, strlen(url), host, strlen(host), &proxy, &len );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( !strcmp( proxy, "DIRECT" ), "got \"%s\"\n", proxy );
|
||||
GlobalFree( proxy );
|
||||
|
||||
buf.dwScriptBufferSize = strlen(script2) + 1;
|
||||
buf.lpszScriptBuffer = script2;
|
||||
ret = pInternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buf );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
|
||||
ret = pInternetGetProxyInfo( url, strlen(url), host, strlen(host), &proxy, &len );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( !strcmp( proxy, "PROXY 10.0.0.1:8080" ), "got \"%s\"\n", proxy );
|
||||
GlobalFree( proxy );
|
||||
|
||||
buf.dwScriptBufferSize = strlen(script2) + 2;
|
||||
ret = pInternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buf );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
|
||||
ret = pInternetGetProxyInfo( url, strlen(url), host, strlen(host), &proxy, &len );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( !strcmp( proxy, "PROXY 10.0.0.1:8080" ), "got \"%s\"\n", proxy );
|
||||
GlobalFree( proxy );
|
||||
|
||||
ret = pInternetDeInitializeAutoProxyDll( NULL, 0 );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
}
|
||||
|
||||
static void test_InternetGetProxyInfo(void)
|
||||
{
|
||||
const char url[] = "http://localhost";
|
||||
char script[] = "function FindProxyForURL(url, host) { return \"DIRECT\"; }";
|
||||
char *proxy, host[] = "localhost";
|
||||
AUTO_PROXY_SCRIPT_BUFFER buf;
|
||||
DWORD len, err;
|
||||
BOOL ret;
|
||||
|
||||
SetLastError( 0xdeadbeef );
|
||||
ret = pInternetGetProxyInfo( url, strlen(url), host, strlen(host), &proxy, &len );
|
||||
err = GetLastError();
|
||||
ok( !ret, "unexpected succes\n" );
|
||||
ok( err == ERROR_CAN_NOT_COMPLETE, "got %u\n", err );
|
||||
|
||||
buf.dwStructSize = sizeof(buf);
|
||||
buf.lpszScriptBuffer = script;
|
||||
buf.dwScriptBufferSize = strlen(script) + 1;
|
||||
ret = pInternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buf );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
|
||||
len = 0;
|
||||
proxy = NULL;
|
||||
ret = pInternetGetProxyInfo( url, strlen(url), host, strlen(host), &proxy, &len );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( !strcmp( proxy, "DIRECT" ), "got \"%s\"\n", proxy );
|
||||
ok( len == strlen("DIRECT") + 1, "got %u\n", len );
|
||||
GlobalFree( proxy );
|
||||
|
||||
len = 0;
|
||||
proxy = NULL;
|
||||
ret = pInternetGetProxyInfo( url, strlen(url) + 1, host, strlen(host), &proxy, &len );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( !strcmp( proxy, "DIRECT" ), "got \"%s\"\n", proxy );
|
||||
ok( len == strlen("DIRECT") + 1, "got %u\n", len );
|
||||
GlobalFree( proxy );
|
||||
|
||||
len = 0;
|
||||
proxy = NULL;
|
||||
ret = pInternetGetProxyInfo( url, strlen(url) - 1, host, strlen(host), &proxy, &len );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( !strcmp( proxy, "DIRECT" ), "got \"%s\"\n", proxy );
|
||||
ok( len == strlen("DIRECT") + 1, "got %u\n", len );
|
||||
GlobalFree( proxy );
|
||||
|
||||
len = 0;
|
||||
proxy = NULL;
|
||||
ret = pInternetGetProxyInfo( url, strlen(url), host, strlen(host) + 1, &proxy, &len );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
ok( !strcmp( proxy, "DIRECT" ), "got \"%s\"\n", proxy );
|
||||
ok( len == strlen("DIRECT") + 1, "got %u\n", len );
|
||||
GlobalFree( proxy );
|
||||
|
||||
ret = pInternetDeInitializeAutoProxyDll( NULL, 0 );
|
||||
ok( ret, "got %u\n", GetLastError() );
|
||||
}
|
||||
|
||||
START_TEST(jsproxy)
|
||||
{
|
||||
HMODULE module = LoadLibraryA( "jsproxy.dll" );
|
||||
pInternetInitializeAutoProxyDll = (void *)GetProcAddress( module, "InternetInitializeAutoProxyDll" );
|
||||
pInternetDeInitializeAutoProxyDll = (void *)GetProcAddress( module, "InternetDeInitializeAutoProxyDll" );
|
||||
pInternetGetProxyInfo = (void *)GetProcAddress( module, "InternetGetProxyInfo" );
|
||||
|
||||
if (!pInternetInitializeAutoProxyDll)
|
||||
{
|
||||
win_skip( "InternetInitializeAutoProxyDll not available\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
test_InternetInitializeAutoProxyDll();
|
||||
test_InternetGetProxyInfo();
|
||||
}
|
Loading…
Reference in New Issue