Synced riched32_winetest.exe, shlwapi_winetest.exe, urlmon_winetest.exe with Wine HEAD

svn path=/trunk/; revision=34373
This commit is contained in:
Pierre Schweitzer 2008-07-08 19:30:15 +00:00
parent e492be818a
commit a1e82ff2da
7 changed files with 206 additions and 29 deletions

View file

@ -696,6 +696,130 @@ static void test_EM_FINDTEXT(void)
DestroyWindow(hwndRichEdit);
}
static void test_EM_POSFROMCHAR(void)
{
HWND hwndRichEdit = new_richedit(NULL);
int i;
POINTL pl;
LRESULT result;
unsigned int height = 0;
int xpos = 0;
static const char text[] = "aa\n"
"this is a long line of text that should be longer than the "
"control's width\n"
"cc\n"
"dd\n"
"ee\n"
"ff\n"
"gg\n"
"hh\n";
/* Fill the control to lines to ensure that most of them are offscreen */
for (i = 0; i < 50; i++)
{
/* Do not modify the string; it is exactly 16 characters long. */
SendMessage(hwndRichEdit, EM_SETSEL, 0, 0);
SendMessage(hwndRichEdit, EM_REPLACESEL, 0, (LPARAM)"0123456789ABCD\r\n");
}
/*
Richedit 1.0 receives a POINTL* on wParam and character offset on lParam, returns void.
Richedit 2.0 receives character offset on wParam, ignores lParam, returns MAKELONG(x,y)
Richedit 3.0 accepts either of the above API conventions.
*/
/* Testing Richedit 1.0 API format */
/* Testing start of lines. X-offset should be constant on all cases (native is 1).
Since all lines are identical and drawn with the same font,
they should have the same height... right?
*/
for (i = 0; i < 50; i++)
{
/* All the lines are 16 characters long */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, i * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
if (i == 0)
{
ok(pl.y == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl.y);
todo_wine {
ok(pl.x == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
}
xpos = pl.x;
}
else if (i == 1)
{
ok(pl.y > 0, "EM_POSFROMCHAR reports y=%d, expected > 0\n", pl.y);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
height = pl.y;
}
else
{
ok(pl.y == i * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, i * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
}
}
/* Testing position at end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 50 * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == 50 * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, 50 * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
/* Testing position way past end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 55 * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == 50 * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, 50 * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
/* Testing that vertical scrolling does, in fact, have an effect on EM_POSFROMCHAR */
SendMessage(hwndRichEdit, EM_SCROLL, SB_LINEDOWN, 0); /* line down */
for (i = 0; i < 50; i++)
{
/* All the lines are 16 characters long */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, i * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == (i - 1) * height,
"EM_POSFROMCHAR reports y=%d, expected %d\n",
pl.y, (i - 1) * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
}
/* Testing position at end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 50 * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == (50 - 1) * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, (50 - 1) * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
/* Testing position way past end of text */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 55 * 16);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == (50 - 1) * height, "EM_POSFROMCHAR reports y=%d, expected %d\n", pl.y, (50 - 1) * height);
ok(pl.x == xpos, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
/* Testing that horizontal scrolling does, in fact, have an effect on EM_POSFROMCHAR */
SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text);
SendMessage(hwndRichEdit, EM_SCROLL, SB_LINEUP, 0); /* line up */
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 0);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl.y);
todo_wine {
ok(pl.x == 1, "EM_POSFROMCHAR reports x=%d, expected 1\n", pl.x);
}
xpos = pl.x;
SendMessage(hwndRichEdit, WM_HSCROLL, SB_LINERIGHT, 0);
result = SendMessage(hwndRichEdit, EM_POSFROMCHAR, (WPARAM)&pl, 0);
ok(result == 0, "EM_POSFROMCHAR returned %ld, expected 0\n", result);
ok(pl.y == 0, "EM_POSFROMCHAR reports y=%d, expected 0\n", pl.y);
todo_wine {
/* Fails on builtin because horizontal scrollbar is not being shown */
ok(pl.x < xpos, "EM_POSFROMCHAR reports x=%hd, expected value less than %d\n", pl.x, xpos);
}
DestroyWindow(hwndRichEdit);
}
START_TEST( editor )
@ -717,6 +841,7 @@ START_TEST( editor )
test_EM_GETLINE();
test_EM_LINELENGTH();
test_EM_FINDTEXT();
test_EM_POSFROMCHAR();
/* Set the environment variable WINETEST_RICHED32 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.

View file

@ -384,10 +384,15 @@ static void test_SHCreateStreamOnFileEx(DWORD mode, DWORD stgm)
IStream * template = NULL;
HRESULT ret;
ULONG refcount;
static const WCHAR test_file[] = { 'c', ':', '\\', 't', 'e', 's', 't', '.', 't', 'x', 't', '\0' };
WCHAR test_file[MAX_PATH];
static const WCHAR testEx_txt[] = { '\\', 't', 'e', 's', 't', 'E','x', '.', 't', 'x', 't', '\0' };
trace("SHCreateStreamOnFileEx: testing mode %d, STGM flags %08x\n", mode, stgm);
/* Don't used a fixed path for the testEx.txt file */
GetTempPathW(MAX_PATH, test_file);
lstrcatW(test_file, testEx_txt);
/* invalid arguments */
stream = NULL;

View file

@ -537,9 +537,13 @@ static void test_PathCombineA(void)
SetLastError(0xdeadbeef);
lstrcpyA(dest, "control");
str = PathCombineA(dest, "relative\\dir", "\\one\\two\\three\\");
ok(str == dest, "Expected str == dest, got %p\n", str);
ok(!lstrcmp(str, "one\\two\\three\\"), "Expected one\\two\\three\\, got %s\n", str);
ok(GetLastError() == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", GetLastError());
/* Vista fails which probably makes sense as PathCombineA expects an absolute dir */
if (str)
{
ok(str == dest, "Expected str == dest, got %p\n", str);
ok(!lstrcmp(str, "one\\two\\three\\"), "Expected one\\two\\three\\, got %s\n", str);
}
/* try forward slashes */
SetLastError(0xdeadbeef);
@ -806,10 +810,8 @@ static void test_PathCanonicalizeA(void)
ok(!res, "Expected failure\n");
ok(GetLastError() == ERROR_INVALID_PARAMETER,
"Expected ERROR_INVALID_PARAMETER, got %d\n", GetLastError());
todo_wine
{
ok(!lstrcmp(dest, "test"), "Expected test, got %s\n", dest);
}
ok(dest[0] == 0 || !lstrcmp(dest, "test"),
"Expected either an empty string (Vista) or test, got %s\n", dest);
/* try an empty source */
lstrcpy(dest, "test");

View file

@ -74,6 +74,10 @@ static const TEST_URL_CANONICALIZE TEST_CANONICALIZE[] = {
{"file:///c:/tests\\foo%20bar", URL_UNESCAPE , S_OK, "file:///c:/tests/foo bar", FALSE},
{"file:///c:/tests/foo%20bar", 0, S_OK, "file:///c:/tests/foo%20bar", FALSE},
{"file:///c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
{"file://localhost/c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
{"file://localhost\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
{"file://localhost\\\\c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
{"file://localhost\\c:\\tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
{"file://c:/tests/../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
{"file://c:/tests\\../tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
{"file://c:/tests/foo%20bar", URL_FILE_USE_PATHURL, S_OK, "file://c:\\tests\\foo bar", FALSE},
@ -575,6 +579,7 @@ static void test_UrlCanonicalizeW(void)
DWORD dwSize;
DWORD urllen;
HRESULT hr;
int i;
if (!pUrlCanonicalizeW) {
@ -624,6 +629,21 @@ static void test_UrlCanonicalizeW(void)
"got 0x%x with %u and size %u for %u (expected 'S_OK' and size %u)\n",
hr, GetLastError(), dwSize, lstrlenW(szReturnUrl), urllen);
/* check that the characters 1..32 are chopped from the end of the string */
for (i = 1; i < 65536; i++)
{
WCHAR szUrl[128];
BOOL choped;
int pos;
MultiByteToWideChar(CP_UTF8, 0, "http://www.winehq.org/X", -1, szUrl, 128);
pos = lstrlenW(szUrl) - 1;
szUrl[pos] = i;
urllen = INTERNET_MAX_URL_LENGTH;
pUrlCanonicalizeW(szUrl, szReturnUrl, &urllen, 0);
choped = lstrlenW(szReturnUrl) < lstrlenW(szUrl);
ok(choped == (i <= 32), "Incorrect char chopping for char %d\n", i);
}
}
/* ########################### */
@ -781,8 +801,8 @@ static void test_UrlUnescape(void)
DWORD dwEscaped;
size_t i;
static char inplace[] = "file:///C:/Program%20Files";
static WCHAR inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/',
'P','r','o','g','r','a','m','%','2','0','F','i','l','e','s',0};
static const char expected[] = "file:///C:/Program Files";
static WCHAR inplaceW[] = {'f','i','l','e',':','/','/','/','C',':','/','P','r','o','g','r','a','m',' ','F','i','l','e','s',0};
for(i=0; i<sizeof(TEST_URL_UNESCAPE)/sizeof(TEST_URL_UNESCAPE[0]); i++) {
dwEscaped=INTERNET_MAX_URL_LENGTH;
@ -801,9 +821,12 @@ static void test_UrlUnescape(void)
dwEscaped = sizeof(inplace);
ok(UrlUnescapeA(inplace, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeA failed unexpectedly\n");
ok(!strcmp(inplace, expected), "got %s expected %s\n", inplace, expected);
ok(dwEscaped == 27, "got %d expected 27\n", dwEscaped);
dwEscaped = sizeof(inplaceW);
ok(UrlUnescapeW(inplaceW, NULL, &dwEscaped, URL_UNESCAPE_INPLACE) == S_OK, "UrlUnescapeW failed unexpectedly\n");
ok(dwEscaped == 50, "got %d expected 50\n", dwEscaped);
}
/* ########################### */

View file

@ -426,7 +426,7 @@ static HRESULT WINAPI ProtocolSink_ReportProgress(IInternetProtocolSink *iface,
ok(szStatusText != NULL, "szStatusText == NULL\n");
if(szStatusText) {
if(binding_test)
ok(szStatusText == expect_wsz, "unexpected szStatusText\n");
ok(!lstrcmpW(szStatusText, expect_wsz), "unexpected szStatusText\n");
else if(tested_protocol == FILE_TEST)
ok(!lstrcmpW(szStatusText, file_name), "szStatusText = \"%s\"\n", debugstr_w(szStatusText));
else
@ -1342,8 +1342,10 @@ static void test_file_protocol_fail(void)
SET_EXPECT(GetBindInfo);
expect_hrResult = MK_E_SYNTAX;
hres = IInternetProtocol_Start(protocol, wszIndexHtml, &protocol_sink, &bind_info, 0, 0);
ok(hres == MK_E_SYNTAX, "Start failed: %08x, expected MK_E_SYNTAX\n", hres);
CHECK_CALLED(GetBindInfo);
ok(hres == MK_E_SYNTAX ||
hres == E_INVALIDARG,
"Start failed: %08x, expected MK_E_SYNTAX or E_INVALIDARG\n", hres);
CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
SET_EXPECT(GetBindInfo);
if(!(bindf & BINDF_FROMURLMON))
@ -1387,12 +1389,12 @@ static void test_file_protocol_fail(void)
SET_EXPECT(GetBindInfo);
hres = IInternetProtocol_Start(protocol, NULL, &protocol_sink, &bind_info, 0, 0);
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
CHECK_CALLED(GetBindInfo);
CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
SET_EXPECT(GetBindInfo);
hres = IInternetProtocol_Start(protocol, emptyW, &protocol_sink, &bind_info, 0, 0);
ok(hres == E_INVALIDARG, "Start failed: %08x, expected E_INVALIDARG\n", hres);
CHECK_CALLED(GetBindInfo);
CLEAR_CALLED(GetBindInfo); /* GetBindInfo not called in IE7 */
IInternetProtocol_Release(protocol);
}
@ -1721,13 +1723,23 @@ static void test_mk_protocol(void)
expect_hrResult = INET_E_RESOURCE_NOT_FOUND;
hres = IInternetProtocol_Start(protocol, wrong_url2, &protocol_sink, &bind_info, 0, 0);
ok(hres == INET_E_RESOURCE_NOT_FOUND, "Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND\n", hres);
ok(hres == INET_E_RESOURCE_NOT_FOUND ||
hres == INET_E_INVALID_URL, /* win2k3 */
"Start failed: %08x, expected INET_E_RESOURCE_NOT_FOUND or INET_E_INVALID_URL\n", hres);
CHECK_CALLED(GetBindInfo);
CLEAR_CALLED(ReportProgress_DIRECTBIND);
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
CHECK_CALLED(ReportResult);
if (hres == INET_E_RESOURCE_NOT_FOUND) {
CHECK_CALLED(GetBindInfo);
CLEAR_CALLED(ReportProgress_DIRECTBIND);
CHECK_CALLED(ReportProgress_SENDINGREQUEST);
CHECK_CALLED(ReportProgress_MIMETYPEAVAILABLE);
CHECK_CALLED(ReportResult);
}else {
CLEAR_CALLED(GetBindInfo);
CLEAR_CALLED(ReportProgress_DIRECTBIND);
CLEAR_CALLED(ReportProgress_SENDINGREQUEST);
CLEAR_CALLED(ReportProgress_MIMETYPEAVAILABLE);
CLEAR_CALLED(ReportResult);
}
IInternetProtocol_Release(protocol);
}

View file

@ -294,7 +294,7 @@ static void create_file(void)
static void test_URLOpenBlockingStreamW(void)
{
HRESULT hr;
IStream *pStream;
IStream *pStream = NULL;
char buffer[256];
hr = URLOpenBlockingStreamW(NULL, NULL, &pStream, 0, &BindStatusCallback);
@ -324,12 +324,14 @@ static void test_URLOpenBlockingStreamW(void)
CHECK_CALLED(OnStopBinding);
ok(pStream != NULL, "pStream is NULL\n");
if(pStream)
{
hr = IStream_Read(pStream, buffer, sizeof(buffer), NULL);
ok(hr == S_OK, "IStream_Read failed with error 0x%08x\n", hr);
ok(!memcmp(buffer, szHtmlDoc, sizeof(szHtmlDoc)-1), "read data differs from file\n");
hr = IStream_Read(pStream, buffer, sizeof(buffer), NULL);
ok(hr == S_OK, "IStream_Read failed with error 0x%08x\n", hr);
ok(!memcmp(buffer, szHtmlDoc, sizeof(szHtmlDoc)-1), "read data differs from file\n");
IStream_Release(pStream);
IStream_Release(pStream);
}
}
static void test_URLOpenStreamW(void)

View file

@ -2194,6 +2194,8 @@ static void test_BindToObject(int protocol, BOOL emul)
SET_EXPECT(Start);
if(test_protocol == HTTP_TEST)
SET_EXPECT(Terminate);
if(test_protocol == FILE_TEST)
SET_EXPECT(OnProgress_MIMETYPEAVAILABLE);
SET_EXPECT(UnlockRequest);
}else {
if(test_protocol == HTTP_TEST) {
@ -2260,6 +2262,8 @@ static void test_BindToObject(int protocol, BOOL emul)
CHECK_CALLED(Start);
if(test_protocol == HTTP_TEST)
CHECK_CALLED(Terminate);
if(test_protocol == FILE_TEST)
CLEAR_CALLED(OnProgress_MIMETYPEAVAILABLE); /* not called in IE7 */
CHECK_CALLED(UnlockRequest);
}else {
if(test_protocol == HTTP_TEST) {
@ -2302,9 +2306,13 @@ static void test_BindToObject(int protocol, BOOL emul)
if(test_protocol != HTTP_TEST || emul || urls[test_protocol] == SHORT_RESPONSE_URL) {
ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
}else todo_wine {
ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
}else {
todo_wine ok(IMoniker_Release(mon) == 0, "mon should be destroyed here\n");
if(bindf & BINDF_ASYNCHRONOUS)
ok(IBindCtx_Release(bctx) != 0, "bctx should not be destroyed here\n");
else
todo_wine ok(IBindCtx_Release(bctx) == 0, "bctx should be destroyed here\n");
}
if(emul)