[WINESYNC]

- Sync comdlg32, crypt32, gdiplus, inetcomm, jscript, msctf, mshtml, msxml3, rsaenh, schannel, shlwapi, urlmon, usp10, wininet winetests.

svn path=/trunk/; revision=46982
This commit is contained in:
Aleksey Bragin
2010-04-21 20:35:09 +00:00
parent e20b4df9ef
commit 577625f6f8
41 changed files with 7905 additions and 1238 deletions
+192 -53
View File
@@ -23,21 +23,16 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "windef.h"
#include "winbase.h"
#include "winnls.h"
#include "wininet.h"
#include "wine/test.h"
#define TEST_URL "http://www.winehq.org/site/about"
#define TEST_URL_HOST "www.winehq.org"
#define TEST_URL_PATH "/site/about"
#define TEST_URL2 "http://www.myserver.com/myscript.php?arg=1"
#define TEST_URL2_SERVER "www.myserver.com"
#define TEST_URL2_PATH "/myscript.php"
#define TEST_URL2_PATHEXTRA "/myscript.php?arg=1"
#define TEST_URL2_EXTRA "?arg=1"
#define TEST_URL "http://www.winehq.org/site/about#hi"
#define TEST_URL3 "file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml"
#define CREATE_URL1 "http://username:[email protected]/site/about"
@@ -94,6 +89,190 @@ static void zero_compsA(
SetLastError(0xfaceabad);
}
typedef struct {
const char *url;
int scheme_off;
int scheme_len;
INTERNET_SCHEME scheme;
int host_off;
int host_len;
int host_skip_broken;
INTERNET_PORT port;
int user_off;
int user_len;
int pass_off;
int pass_len;
int path_off;
int path_len;
int extra_off;
int extra_len;
} crack_url_test_t;
static const crack_url_test_t crack_url_tests[] = {
{"http://www.winehq.org/site/about#hi",
0, 4, INTERNET_SCHEME_HTTP, 7, 14, -1, 80, -1, 0, -1, 0, 21, 11, 32, 3},
{"http://www.myserver.com/myscript.php?arg=1",
0, 4, INTERNET_SCHEME_HTTP, 7, 16, -1, 80, -1, 0, -1, 0, 23, 13, 36, 6},
{"http://www.winehq.org?test=123",
0, 4, INTERNET_SCHEME_HTTP, 7, 14, 23, 80, -1, 0, -1, 0, 21, 0, 21, 9},
{"file:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0},
{"fide:///C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_UNKNOWN, 7, 0, -1, 0, -1, 0, -1, 0, 7, 55, -1, 0},
{"file://C:/Program%20Files/Atmel/AVR%20Tools/STK500/STK500.xml",
0, 4, INTERNET_SCHEME_FILE, -1, 0, -1, 0, -1, 0, -1, 0, 7, 54, -1, 0},
};
static void test_crack_url(const crack_url_test_t *test)
{
WCHAR buf[INTERNET_MAX_URL_LENGTH];
URL_COMPONENTSW urlw;
URL_COMPONENTSA url;
BOOL b;
zero_compsA(&url, 1, 1, 1, 1, 1, 1);
b = InternetCrackUrlA(test->url, strlen(test->url), 0, &url);
ok(b, "InternetCrackUrl failed with error %d\n", GetLastError());
if(test->scheme_off == -1)
ok(!url.lpszScheme, "[%s] url.lpszScheme = %p, expected NULL\n", test->url, url.lpszScheme);
else
ok(url.lpszScheme == test->url+test->scheme_off, "[%s] url.lpszScheme = %p, expected %p\n",
test->url, url.lpszScheme, test->url+test->scheme_off);
ok(url.dwSchemeLength == test->scheme_len, "[%s] url.lpszSchemeLength = %d, expected %d\n",
test->url, url.dwSchemeLength, test->scheme_len);
ok(url.nScheme == test->scheme, "[%s] url.nScheme = %d, expected %d\n", test->url, url.nScheme, test->scheme);
if(test->host_off == -1)
ok(!url.lpszHostName, "[%s] url.lpszHostName = %p, expected NULL\n", test->url, url.lpszHostName);
else
ok(url.lpszHostName == test->url+test->host_off, "[%s] url.lpszHostName = %p, expected %p\n",
test->url, url.lpszHostName, test->url+test->host_off);
if(test->host_skip_broken != -1 && url.dwHostNameLength == test->host_skip_broken) {
win_skip("skipping broken dwHostNameLength result\n");
return;
}
ok(url.dwHostNameLength == test->host_len, "[%s] url.lpszHostNameLength = %d, expected %d\n",
test->url, url.dwHostNameLength, test->host_len);
ok(url.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, url.nPort, test->port);
if(test->user_off == -1)
ok(!url.lpszUserName, "[%s] url.lpszUserName = %p\n", test->url, url.lpszUserName);
else
ok(url.lpszUserName == test->url+test->user_off, "[%s] url.lpszUserName = %p, expected %p\n",
test->url, url.lpszUserName, test->url+test->user_off);
ok(url.dwUserNameLength == test->user_len, "[%s] url.lpszUserNameLength = %d, expected %d\n",
test->url, url.dwUserNameLength, test->user_len);
if(test->pass_off == -1)
ok(!url.lpszPassword, "[%s] url.lpszPassword = %p\n", test->url, url.lpszPassword);
else
ok(url.lpszPassword == test->url+test->pass_off, "[%s] url.lpszPassword = %p, expected %p\n",
test->url, url.lpszPassword, test->url+test->pass_off);
ok(url.dwPasswordLength == test->pass_len, "[%s] url.lpszPasswordLength = %d, expected %d\n",
test->url, url.dwPasswordLength, test->pass_len);
if(test->path_off == -1)
ok(!url.lpszUrlPath, "[%s] url.lpszPath = %p, expected NULL\n", test->url, url.lpszUrlPath);
else
ok(url.lpszUrlPath == test->url+test->path_off, "[%s] url.lpszPath = %p, expected %p\n",
test->url, url.lpszUrlPath, test->url+test->path_off);
ok(url.dwUrlPathLength == test->path_len, "[%s] url.lpszUrlPathLength = %d, expected %d\n",
test->url, url.dwUrlPathLength, test->path_len);
if(test->extra_off == -1)
ok(!url.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, url.lpszExtraInfo);
else
ok(url.lpszExtraInfo == test->url+test->extra_off, "[%s] url.lpszExtraInfo = %p, expected %p\n",
test->url, url.lpszExtraInfo, test->url+test->extra_off);
ok(url.dwExtraInfoLength == test->extra_len, "[%s] url.lpszExtraInfoLength = %d, expected %d\n",
test->url, url.dwExtraInfoLength, test->extra_len);
memset(&urlw, 0, sizeof(URL_COMPONENTSW));
urlw.dwStructSize = sizeof(URL_COMPONENTSW);
urlw.dwSchemeLength = 1;
urlw.dwHostNameLength = 1;
urlw.dwUserNameLength = 1;
urlw.dwPasswordLength = 1;
urlw.dwUrlPathLength = 1;
urlw.dwExtraInfoLength = 1;
MultiByteToWideChar(CP_ACP, 0, test->url, -1, buf, sizeof(buf));
b = InternetCrackUrlW(buf, lstrlenW(buf), 0, &urlw);
if(!b && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) {
win_skip("InternetCrackUrlW is not implemented\n");
return;
}
ok(b, "InternetCrackUrl failed with error %d\n", GetLastError());
if(test->scheme_off == -1)
ok(!urlw.lpszScheme, "[%s] urlw.lpszScheme = %p, expected NULL\n", test->url, urlw.lpszScheme);
else
ok(urlw.lpszScheme == buf+test->scheme_off, "[%s] urlw.lpszScheme = %p, expected %p\n",
test->url, urlw.lpszScheme, buf+test->scheme_off);
ok(urlw.dwSchemeLength == test->scheme_len, "[%s] urlw.lpszSchemeLength = %d, expected %d\n",
test->url, urlw.dwSchemeLength, test->scheme_len);
ok(urlw.nScheme == test->scheme, "[%s] urlw.nScheme = %d, expected %d\n", test->url, urlw.nScheme, test->scheme);
if(test->host_off == -1) {
ok(!urlw.lpszHostName, "[%s] urlw.lpszHostName = %p, expected NULL\n", test->url, urlw.lpszHostName);
ok(urlw.dwHostNameLength == 0 || broken(urlw.dwHostNameLength == 1), "[%s] urlw.lpszHostNameLength = %d, expected %d\n",
test->url, urlw.dwHostNameLength, test->host_len);
}else {
ok(urlw.lpszHostName == buf+test->host_off, "[%s] urlw.lpszHostName = %p, expected %p\n",
test->url, urlw.lpszHostName, test->url+test->host_off);
ok(urlw.dwHostNameLength == test->host_len, "[%s] urlw.lpszHostNameLength = %d, expected %d\n",
test->url, urlw.dwHostNameLength, test->host_len);
}
ok(urlw.nPort == test->port, "[%s] nPort = %d, expected %d\n", test->url, urlw.nPort, test->port);
if(test->user_off == -1) {
ok(!urlw.lpszUserName, "[%s] urlw.lpszUserName = %p\n", test->url, urlw.lpszUserName);
ok(urlw.dwUserNameLength == 0 || broken(urlw.dwUserNameLength == 1), "[%s] urlw.lpszUserNameLength = %d, expected %d\n",
test->url, urlw.dwUserNameLength, test->user_len);
}else {
ok(urlw.lpszUserName == buf+test->user_off, "[%s] urlw.lpszUserName = %p, expected %p\n",
test->url, urlw.lpszUserName, buf+test->user_off);
ok(urlw.dwUserNameLength == test->user_len, "[%s] urlw.lpszUserNameLength = %d, expected %d\n",
test->url, urlw.dwUserNameLength, test->user_len);
}
if(test->pass_off == -1) {
ok(!urlw.lpszPassword, "[%s] urlw.lpszPassword = %p\n", test->url, urlw.lpszPassword);
ok(urlw.dwPasswordLength == 0 || broken(urlw.dwPasswordLength), "[%s] urlw.lpszPasswordLength = %d, expected %d\n",
test->url, urlw.dwPasswordLength, test->pass_len);
}else {
ok(urlw.lpszPassword == buf+test->pass_off, "[%s] urlw.lpszPassword = %p, expected %p\n",
test->url, urlw.lpszPassword, buf+test->pass_off);
ok(urlw.dwPasswordLength == test->pass_len, "[%s] urlw.lpszPasswordLength = %d, expected %d\n",
test->url, urlw.dwPasswordLength, test->pass_len);
}
if(test->path_off == -1)
ok(!urlw.lpszUrlPath, "[%s] urlw.lpszPath = %p, expected NULL\n", test->url, urlw.lpszUrlPath);
else
ok(urlw.lpszUrlPath == buf+test->path_off, "[%s] urlw.lpszPath = %p, expected %p\n",
test->url, urlw.lpszUrlPath, buf+test->path_off);
ok(urlw.dwUrlPathLength == test->path_len, "[%s] urlw.lpszUrlPathLength = %d, expected %d\n",
test->url, urlw.dwUrlPathLength, test->path_len);
if(test->extra_off == -1) {
ok(!urlw.lpszExtraInfo, "[%s] url.lpszExtraInfo = %p, expected NULL\n", test->url, urlw.lpszExtraInfo);
ok(urlw.dwExtraInfoLength == 0 || broken(urlw.dwExtraInfoLength == 1), "[%s] urlw.lpszExtraInfoLength = %d, expected %d\n",
test->url, urlw.dwExtraInfoLength, test->extra_len);
}else {
ok(urlw.lpszExtraInfo == buf+test->extra_off, "[%s] urlw.lpszExtraInfo = %p, expected %p\n",
test->url, urlw.lpszExtraInfo, buf+test->extra_off);
ok(urlw.dwExtraInfoLength == test->extra_len, "[%s] urlw.lpszExtraInfoLength = %d, expected %d\n",
test->url, urlw.dwExtraInfoLength, test->extra_len);
}
}
static void InternetCrackUrl_test(void)
{
URL_COMPONENTSA urlSrc, urlComponents;
@@ -111,51 +290,6 @@ static void InternetCrackUrl_test(void)
urlSrc.lpszUrlPath = path;
urlSrc.lpszExtraInfo = extra;
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
ret = InternetCrackUrl(TEST_URL, 0,0,&urlComponents);
ok( ret, "InternetCrackUrl failed, error %d\n",GetLastError());
ok((strcmp(TEST_URL_PATH,path) == 0),"path cracked wrong\n");
/* Bug 1805: Confirm the returned lengths are correct: */
/* 1. When extra info split out explicitly */
zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 1);
ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed, error %d\n", GetLastError());
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATH),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATH), urlComponents.dwUrlPathLength);
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATH,strlen(TEST_URL2_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATH, urlComponents.lpszUrlPath);
ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
ok(urlComponents.dwExtraInfoLength == strlen(TEST_URL2_EXTRA),".dwExtraInfoLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_EXTRA), urlComponents.dwExtraInfoLength);
ok(!strncmp(urlComponents.lpszExtraInfo,TEST_URL2_EXTRA,strlen(TEST_URL2_EXTRA)),"lpszExtraInfo should be %s but is %s\n", TEST_URL2_EXTRA, urlComponents.lpszHostName);
/* 2. When extra info is not split out explicitly and is in url path */
zero_compsA(&urlComponents, 0, 1, 0, 0, 1, 0);
ok(InternetCrackUrlA(TEST_URL2, 0, 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL2_PATHEXTRA),".dwUrlPathLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_PATHEXTRA), urlComponents.dwUrlPathLength);
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL2_PATHEXTRA,strlen(TEST_URL2_PATHEXTRA)),"lpszUrlPath should be %s but is %s\n", TEST_URL2_PATHEXTRA, urlComponents.lpszUrlPath);
ok(urlComponents.dwHostNameLength == strlen(TEST_URL2_SERVER),".dwHostNameLength should be %d, but is %d\n", (DWORD)strlen(TEST_URL2_SERVER), urlComponents.dwHostNameLength);
ok(!strncmp(urlComponents.lpszHostName,TEST_URL2_SERVER,strlen(TEST_URL2_SERVER)),"lpszHostName should be %s but is %s\n", TEST_URL2_SERVER, urlComponents.lpszHostName);
ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort);
ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme);
zero_compsA(&urlComponents, 1, 1, 1, 1, 1, 1);
ok(InternetCrackUrlA(TEST_URL, strlen(TEST_URL), 0, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
ok(urlComponents.dwUrlPathLength == strlen(TEST_URL_PATH),".dwUrlPathLength should be %d, but is %d\n", lstrlenA(TEST_URL_PATH), urlComponents.dwUrlPathLength);
ok(!strncmp(urlComponents.lpszUrlPath,TEST_URL_PATH,strlen(TEST_URL_PATH)),"lpszUrlPath should be %s but is %s\n", TEST_URL_PATH, urlComponents.lpszUrlPath);
ok(urlComponents.dwHostNameLength == strlen(TEST_URL_HOST),".dwHostNameLength should be %d, but is %d\n", lstrlenA(TEST_URL_HOST), urlComponents.dwHostNameLength);
ok(!strncmp(urlComponents.lpszHostName,TEST_URL_HOST,strlen(TEST_URL_HOST)),"lpszHostName should be %s but is %s\n", TEST_URL_HOST, urlComponents.lpszHostName);
ok(urlComponents.nPort == INTERNET_DEFAULT_HTTP_PORT,"urlComponents->nPort should have been 80 instead of %d\n", urlComponents.nPort);
ok(urlComponents.nScheme == INTERNET_SCHEME_HTTP,"urlComponents->nScheme should have been INTERNET_SCHEME_HTTP instead of %d\n", urlComponents.nScheme);
ok(!urlComponents.lpszUserName, ".lpszUserName should have been set to NULL\n");
ok(!urlComponents.lpszPassword, ".lpszPassword should have been set to NULL\n");
ok(!urlComponents.lpszExtraInfo, ".lpszExtraInfo should have been set to NULL\n");
ok(!urlComponents.dwUserNameLength,".dwUserNameLength should be 0, but is %d\n", urlComponents.dwUserNameLength);
ok(!urlComponents.dwPasswordLength,".dwPasswordLength should be 0, but is %d\n", urlComponents.dwPasswordLength);
ok(!urlComponents.dwExtraInfoLength,".dwExtraInfoLength should be 0, but is %d\n", urlComponents.dwExtraInfoLength);
/*3. Check for %20 */
copy_compsA(&urlSrc, &urlComponents, 32, 1024, 1024, 1024, 2048, 1024);
ok(InternetCrackUrlA(TEST_URL3, 0, ICU_DECODE, &urlComponents),"InternetCrackUrl failed with GLE %d\n",GetLastError());
/* Tests for lpsz* members pointing to real strings while
* some corresponding length members are set to zero.
* As of IE7 (wininet 7.0*?) all members are checked. So we
@@ -810,6 +944,11 @@ static void InternetCreateUrlA_test(void)
START_TEST(url)
{
int i;
for(i=0; i < sizeof(crack_url_tests)/sizeof(*crack_url_tests); i++)
test_crack_url(crack_url_tests+i);
InternetCrackUrl_test();
InternetCrackUrlW_test();
InternetCreateUrlA_test();