[RICHED20_WINETEST] Sync with Wine Staging 1.7.47. CORE-9924

svn path=/trunk/; revision=68496
This commit is contained in:
Amine Khaldi 2015-07-20 22:53:56 +00:00
parent e917285fba
commit b6bf232f18
4 changed files with 2875 additions and 221 deletions

View file

@ -7,6 +7,10 @@ list(APPEND SOURCE
testlist.c testlist.c
txtsrv.c) txtsrv.c)
if(MSVC)
set_property(SOURCE editor.c APPEND_STRING PROPERTY COMPILE_FLAGS " /w14189")
endif()
add_executable(riched20_winetest ${SOURCE}) add_executable(riched20_winetest ${SOURCE})
set_module_type(riched20_winetest win32cui) set_module_type(riched20_winetest win32cui)
add_importlibs(riched20_winetest ole32 oleaut32 user32 gdi32 msvcrt kernel32) add_importlibs(riched20_winetest ole32 oleaut32 user32 gdi32 msvcrt kernel32)

View file

@ -30,6 +30,7 @@
#include <winnls.h> #include <winnls.h>
#include <ole2.h> #include <ole2.h>
#include <richedit.h> #include <richedit.h>
#include <commdlg.h>
#include <time.h> #include <time.h>
#include <wine/test.h> #include <wine/test.h>
@ -3403,6 +3404,37 @@ static void test_WM_SETTEXT(void)
#undef TEST_SETTEXTW #undef TEST_SETTEXTW
} }
/* Set *pcb to one to show that the remaining cb-1 bytes are not
resent to the callkack. */
static DWORD CALLBACK test_esCallback_written_1(DWORD_PTR dwCookie,
LPBYTE pbBuff,
LONG cb,
LONG *pcb)
{
char** str = (char**)dwCookie;
ok(*pcb == cb || *pcb == 0, "cb %d, *pcb %d\n", cb, *pcb);
*pcb = 0;
if (cb > 0) {
memcpy(*str, pbBuff, cb);
*str += cb;
*pcb = 1;
}
return 0;
}
static int count_pars(const char *buf)
{
const char *p = buf;
int count = 0;
while ((p = strstr( p, "\\par" )) != NULL)
{
if (!isalpha( p[4] ))
count++;
p++;
}
return count;
}
static void test_EM_STREAMOUT(void) static void test_EM_STREAMOUT(void)
{ {
HWND hwndRichEdit = new_richedit(NULL); HWND hwndRichEdit = new_richedit(NULL);
@ -3427,6 +3459,19 @@ static void test_EM_STREAMOUT(void)
ok(strcmp(buf, TestItem1) == 0, ok(strcmp(buf, TestItem1) == 0,
"streamed text different, got %s\n", buf); "streamed text different, got %s\n", buf);
/* RTF mode writes the final end of para \r if it's part of the selection */
p = buf;
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es);
ok (count_pars(buf) == 1, "got %s\n", buf);
p = buf;
SendMessageA(hwndRichEdit, EM_SETSEL, 0, 12);
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
ok (count_pars(buf) == 0, "got %s\n", buf);
p = buf;
SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1);
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
ok (count_pars(buf) == 1, "got %s\n", buf);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem2); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem2);
p = buf; p = buf;
es.dwCookie = (DWORD_PTR)&p; es.dwCookie = (DWORD_PTR)&p;
@ -3439,6 +3484,20 @@ static void test_EM_STREAMOUT(void)
ok(r == 14, "streamed text length is %d, expecting 14\n", r); ok(r == 14, "streamed text length is %d, expecting 14\n", r);
ok(strcmp(buf, TestItem3) == 0, ok(strcmp(buf, TestItem3) == 0,
"streamed text different from, got %s\n", buf); "streamed text different from, got %s\n", buf);
/* And again RTF mode writes the final end of para \r if it's part of the selection */
p = buf;
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es);
ok (count_pars(buf) == 2, "got %s\n", buf);
p = buf;
SendMessageA(hwndRichEdit, EM_SETSEL, 0, 13);
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
ok (count_pars(buf) == 1, "got %s\n", buf);
p = buf;
SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1);
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
ok (count_pars(buf) == 2, "got %s\n", buf);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem3); SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem3);
p = buf; p = buf;
es.dwCookie = (DWORD_PTR)&p; es.dwCookie = (DWORD_PTR)&p;
@ -3451,6 +3510,19 @@ static void test_EM_STREAMOUT(void)
ok(strcmp(buf, TestItem3) == 0, ok(strcmp(buf, TestItem3) == 0,
"streamed text different, got %s\n", buf); "streamed text different, got %s\n", buf);
/* Use a callback that sets *pcb to one */
p = buf;
es.dwCookie = (DWORD_PTR)&p;
es.dwError = 0;
es.pfnCallback = test_esCallback_written_1;
memset(buf, 0, sizeof(buf));
SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
r = strlen(buf);
ok(r == 14, "streamed text length is %d, expecting 14\n", r);
ok(strcmp(buf, TestItem3) == 0,
"streamed text different, got %s\n", buf);
DestroyWindow(hwndRichEdit); DestroyWindow(hwndRichEdit);
} }
@ -4353,33 +4425,36 @@ struct exsetsel_s {
LRESULT expected_retval; LRESULT expected_retval;
int expected_getsel_start; int expected_getsel_start;
int expected_getsel_end; int expected_getsel_end;
int _getsel_todo_wine; BOOL todo;
}; };
const struct exsetsel_s exsetsel_tests[] = { static const struct exsetsel_s exsetsel_tests[] = {
/* sanity tests */ /* sanity tests */
{5, 10, 10, 5, 10, 0}, {5, 10, 10, 5, 10 },
{15, 17, 17, 15, 17, 0}, {15, 17, 17, 15, 17 },
/* test cpMax > strlen() */ /* test cpMax > strlen() */
{0, 100, 18, 0, 18, 0}, {0, 100, 18, 0, 18 },
/* test cpMin < 0 && cpMax >= 0 after cpMax > strlen() */ /* test cpMin < 0 && cpMax >= 0 after cpMax > strlen() */
{-1, 1, 17, 17, 17, 0}, {-1, 1, 17, 17, 17 },
/* test cpMin == cpMax */ /* test cpMin == cpMax */
{5, 5, 5, 5, 5, 0}, {5, 5, 5, 5, 5 },
/* test cpMin < 0 && cpMax >= 0 (bug 4462) */ /* test cpMin < 0 && cpMax >= 0 (bug 4462) */
{-1, 0, 5, 5, 5, 0}, {-1, 0, 5, 5, 5 },
{-1, 17, 5, 5, 5, 0}, {-1, 17, 5, 5, 5 },
{-1, 18, 5, 5, 5, 0}, {-1, 18, 5, 5, 5 },
/* test cpMin < 0 && cpMax < 0 */ /* test cpMin < 0 && cpMax < 0 */
{-1, -1, 17, 17, 17, 0}, {-1, -1, 17, 17, 17 },
{-4, -5, 17, 17, 17, 0}, {-4, -5, 17, 17, 17 },
/* test cpMin >=0 && cpMax < 0 (bug 6814) */ /* test cpMin >=0 && cpMax < 0 (bug 6814) */
{0, -1, 18, 0, 18, 0}, {0, -1, 18, 0, 18 },
{17, -5, 18, 17, 18, 0}, {17, -5, 18, 17, 18 },
{18, -3, 17, 17, 17, 0}, {18, -3, 17, 17, 17 },
/* test if cpMin > cpMax */ /* test if cpMin > cpMax */
{15, 19, 18, 15, 18, 0}, {15, 19, 18, 15, 18 },
{19, 15, 18, 15, 18, 0}, {19, 15, 18, 15, 18 },
/* cpMin == strlen() && cpMax > cpMin */
{17, 18, 18, 17, 18 },
{17, 50, 18, 17, 18 },
}; };
static void check_EM_EXSETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id) { static void check_EM_EXSETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id) {
@ -4395,7 +4470,7 @@ static void check_EM_EXSETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id
SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end); SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
if (setsel->_getsel_todo_wine) { if (setsel->todo) {
todo_wine { todo_wine {
ok(start == setsel->expected_getsel_start && end == setsel->expected_getsel_end, "EM_EXSETSEL(%d): expected (%d,%d) actual:(%d,%d)\n", id, setsel->expected_getsel_start, setsel->expected_getsel_end, start, end); ok(start == setsel->expected_getsel_start && end == setsel->expected_getsel_end, "EM_EXSETSEL(%d): expected (%d,%d) actual:(%d,%d)\n", id, setsel->expected_getsel_start, setsel->expected_getsel_end, start, end);
} }
@ -4432,7 +4507,7 @@ static void check_EM_SETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id)
SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end); SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
if (setsel->_getsel_todo_wine) { if (setsel->todo) {
todo_wine { todo_wine {
ok(start == setsel->expected_getsel_start && end == setsel->expected_getsel_end, "EM_SETSEL(%d): expected (%d,%d) actual:(%d,%d)\n", id, setsel->expected_getsel_start, setsel->expected_getsel_end, start, end); ok(start == setsel->expected_getsel_start && end == setsel->expected_getsel_end, "EM_SETSEL(%d): expected (%d,%d) actual:(%d,%d)\n", id, setsel->expected_getsel_start, setsel->expected_getsel_end, start, end);
} }
@ -4443,6 +4518,7 @@ static void check_EM_SETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id)
static void test_EM_SETSEL(void) static void test_EM_SETSEL(void)
{ {
char buffA[32];
HWND hwndRichEdit = new_richedit(NULL); HWND hwndRichEdit = new_richedit(NULL);
int i; int i;
const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s); const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
@ -4456,6 +4532,11 @@ static void test_EM_SETSEL(void)
check_EM_SETSEL(hwndRichEdit, &exsetsel_tests[i], i); check_EM_SETSEL(hwndRichEdit, &exsetsel_tests[i], i);
} }
SendMessageA(hwndRichEdit, EM_SETSEL, 17, 18);
buffA[0] = 123;
SendMessageA(hwndRichEdit, EM_GETSELTEXT, 0, (LPARAM)buffA);
ok(buffA[0] == 0, "selection text %s\n", buffA);
DestroyWindow(hwndRichEdit); DestroyWindow(hwndRichEdit);
} }
@ -4872,7 +4953,7 @@ static void test_WM_PASTE(void)
SendMessageA(hwndRichEdit, WM_PASTE, 0, 0); SendMessageA(hwndRichEdit, WM_PASTE, 0, 0);
SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
result = strcmp(buffer,"cut\r\n"); result = strcmp(buffer,"cut\r\n");
todo_wine ok(result == 0, ok(result == 0,
"test paste: strcmp = %i, actual = '%s'\n", result, buffer); "test paste: strcmp = %i, actual = '%s'\n", result, buffer);
/* Simulates undo (Ctrl-Z) */ /* Simulates undo (Ctrl-Z) */
hold_key(VK_CONTROL); hold_key(VK_CONTROL);
@ -4887,7 +4968,7 @@ static void test_WM_PASTE(void)
(MapVirtualKeyA('Y', MAPVK_VK_TO_VSC) << 16) | 1); (MapVirtualKeyA('Y', MAPVK_VK_TO_VSC) << 16) | 1);
SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer); SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
result = strcmp(buffer,"cut\r\n"); result = strcmp(buffer,"cut\r\n");
todo_wine ok(result == 0, ok(result == 0,
"test paste: strcmp = %i, actual = '%s'\n", result, buffer); "test paste: strcmp = %i, actual = '%s'\n", result, buffer);
release_key(VK_CONTROL); release_key(VK_CONTROL);
@ -5424,7 +5505,6 @@ static void test_unicode_conversions(void)
do { \ do { \
SETTEXTEX stex = { ST_DEFAULT, CP_ACP }; \ SETTEXTEX stex = { ST_DEFAULT, CP_ACP }; \
WPARAM wparam = (wm_set_text == WM_SETTEXT) ? 0 : (WPARAM)&stex; \ WPARAM wparam = (wm_set_text == WM_SETTEXT) ? 0 : (WPARAM)&stex; \
UNREFERENCED_LOCAL_VARIABLE(stex); \
assert(wm_set_text == WM_SETTEXT || wm_set_text == EM_SETTEXTEX); \ assert(wm_set_text == WM_SETTEXT || wm_set_text == EM_SETTEXTEX); \
ret = SendMessageA(hwnd, wm_set_text, wparam, (LPARAM)txt); \ ret = SendMessageA(hwnd, wm_set_text, wparam, (LPARAM)txt); \
ok(ret, "SendMessageA(%02x) error %u\n", wm_set_text, GetLastError()); \ ok(ret, "SendMessageA(%02x) error %u\n", wm_set_text, GetLastError()); \
@ -5433,7 +5513,6 @@ static void test_unicode_conversions(void)
do { \ do { \
GETTEXTEX gtex = { 64, GT_DEFAULT, CP_ACP, NULL, NULL }; \ GETTEXTEX gtex = { 64, GT_DEFAULT, CP_ACP, NULL, NULL }; \
WPARAM wparam = (wm_get_text == WM_GETTEXT) ? 64 : (WPARAM)&gtex; \ WPARAM wparam = (wm_get_text == WM_GETTEXT) ? 64 : (WPARAM)&gtex; \
UNREFERENCED_LOCAL_VARIABLE(gtex); \
assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \ assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \
memset(bufA, 0xAA, sizeof(bufA)); \ memset(bufA, 0xAA, sizeof(bufA)); \
ret = SendMessageA(hwnd, wm_get_text, wparam, (LPARAM)bufA); \ ret = SendMessageA(hwnd, wm_get_text, wparam, (LPARAM)bufA); \
@ -5446,7 +5525,6 @@ static void test_unicode_conversions(void)
do { \ do { \
SETTEXTEX stex = { ST_DEFAULT, 1200 }; \ SETTEXTEX stex = { ST_DEFAULT, 1200 }; \
WPARAM wparam = (wm_set_text == WM_SETTEXT) ? 0 : (WPARAM)&stex; \ WPARAM wparam = (wm_set_text == WM_SETTEXT) ? 0 : (WPARAM)&stex; \
UNREFERENCED_LOCAL_VARIABLE(stex); \
assert(wm_set_text == WM_SETTEXT || wm_set_text == EM_SETTEXTEX); \ assert(wm_set_text == WM_SETTEXT || wm_set_text == EM_SETTEXTEX); \
ret = SendMessageW(hwnd, wm_set_text, wparam, (LPARAM)txt); \ ret = SendMessageW(hwnd, wm_set_text, wparam, (LPARAM)txt); \
ok(ret, "SendMessageW(%02x) error %u\n", wm_set_text, GetLastError()); \ ok(ret, "SendMessageW(%02x) error %u\n", wm_set_text, GetLastError()); \
@ -5455,7 +5533,6 @@ static void test_unicode_conversions(void)
do { \ do { \
GETTEXTEX gtex = { 64, GT_DEFAULT, 1200, NULL, NULL }; \ GETTEXTEX gtex = { 64, GT_DEFAULT, 1200, NULL, NULL }; \
WPARAM wparam = (wm_get_text == WM_GETTEXT) ? 64 : (WPARAM)&gtex; \ WPARAM wparam = (wm_get_text == WM_GETTEXT) ? 64 : (WPARAM)&gtex; \
UNREFERENCED_LOCAL_VARIABLE(gtex); \
assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \ assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \
memset(bufW, 0xAA, sizeof(bufW)); \ memset(bufW, 0xAA, sizeof(bufW)); \
ret = SendMessageW(hwnd, wm_get_text, wparam, (LPARAM)bufW); \ ret = SendMessageW(hwnd, wm_get_text, wparam, (LPARAM)bufW); \
@ -5467,7 +5544,6 @@ static void test_unicode_conversions(void)
do { \ do { \
GETTEXTEX gtex = { 64, GT_DEFAULT, CP_ACP, NULL, NULL }; \ GETTEXTEX gtex = { 64, GT_DEFAULT, CP_ACP, NULL, NULL }; \
WPARAM wparam = (wm_get_text == WM_GETTEXT) ? 64 : (WPARAM)&gtex; \ WPARAM wparam = (wm_get_text == WM_GETTEXT) ? 64 : (WPARAM)&gtex; \
UNREFERENCED_LOCAL_VARIABLE(gtex); \
assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \ assert(wm_get_text == WM_GETTEXT || wm_get_text == EM_GETTEXTEX); \
memset(bufA, 0xAA, sizeof(bufA)); \ memset(bufA, 0xAA, sizeof(bufA)); \
ret = SendMessageA(hwnd, wm_get_text, wparam, (LPARAM)bufA); \ ret = SendMessageA(hwnd, wm_get_text, wparam, (LPARAM)bufA); \
@ -5977,26 +6053,153 @@ static void test_WM_NOTIFY(void)
DestroyWindow(parent); DestroyWindow(parent);
} }
static int cpMin_EN_LINK = -1; static ENLINK enlink;
static int cpMax_EN_LINK = -1; #define CURSOR_CLIENT_X 5
#define CURSOR_CLIENT_Y 5
#define WP_PARENT 1
#define WP_CHILD 2
static LRESULT WINAPI EN_LINK_ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI EN_LINK_ParentMsgCheckProcA(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ {
ENLINK* enlink = (ENLINK*)lParam; if(message == WM_NOTIFY && ((NMHDR*)lParam)->code == EN_LINK)
if(message == WM_NOTIFY && enlink->nmhdr.code == EN_LINK)
{ {
cpMin_EN_LINK = enlink->chrg.cpMin; enlink = *(ENLINK*)lParam;
cpMax_EN_LINK = enlink->chrg.cpMax;
} }
return DefWindowProcA(hwnd, message, wParam, lParam); return DefWindowProcA(hwnd, message, wParam, lParam);
} }
static void link_notify_test(const char *desc, int i, HWND hwnd, HWND parent,
UINT msg, WPARAM wParam, LPARAM lParam, BOOL notifies)
{
ENLINK junk_enlink;
switch (msg)
{
case WM_LBUTTONDBLCLK:
case WM_LBUTTONDOWN:
case WM_LBUTTONUP:
case WM_MOUSEHOVER:
case WM_MOUSEMOVE:
case WM_MOUSEWHEEL:
case WM_RBUTTONDBLCLK:
case WM_RBUTTONDOWN:
case WM_RBUTTONUP:
lParam = MAKELPARAM(CURSOR_CLIENT_X, CURSOR_CLIENT_Y);
break;
case WM_SETCURSOR:
if (wParam == WP_PARENT)
wParam = (WPARAM)parent;
else if (wParam == WP_CHILD)
wParam = (WPARAM)hwnd;
break;
}
memset(&junk_enlink, 0x23, sizeof(junk_enlink));
enlink = junk_enlink;
SendMessageA(hwnd, msg, wParam, lParam);
if (notifies)
{
ok(enlink.nmhdr.hwndFrom == hwnd,
"%s test %i: Expected hwnd %p got %p\n", desc, i, hwnd, enlink.nmhdr.hwndFrom);
ok(enlink.nmhdr.idFrom == 0,
"%s test %i: Expected idFrom 0 got 0x%lx\n", desc, i, enlink.nmhdr.idFrom);
ok(enlink.msg == msg,
"%s test %i: Expected msg 0x%x got 0x%x\n", desc, i, msg, enlink.msg);
if (msg == WM_SETCURSOR)
{
ok(enlink.wParam == 0,
"%s test %i: Expected wParam 0 got 0x%lx\n", desc, i, enlink.wParam);
}
else
{
ok(enlink.wParam == wParam,
"%s test %i: Expected wParam 0x%lx got 0x%lx\n", desc, i, wParam, enlink.wParam);
}
ok(enlink.lParam == MAKELPARAM(CURSOR_CLIENT_X, CURSOR_CLIENT_Y),
"%s test %i: Expected lParam 0x%lx got 0x%lx\n",
desc, i, MAKELPARAM(CURSOR_CLIENT_X, CURSOR_CLIENT_Y), enlink.lParam);
ok(enlink.chrg.cpMin == 0 && enlink.chrg.cpMax == 31,
"%s test %i: Expected link range [0,31) got [%i,%i)\n", desc, i, enlink.chrg.cpMin, enlink.chrg.cpMax);
}
else
{
ok(memcmp(&enlink, &junk_enlink, sizeof(enlink)) == 0,
"%s test %i: Expected enlink to remain unmodified\n", desc, i);
}
}
static void test_EN_LINK(void) static void test_EN_LINK(void)
{ {
HWND parent; HWND hwnd, parent;
WNDCLASSA cls; WNDCLASSA cls;
HWND hwndRichedit_EN_LINK;
CHARFORMAT2A cf2; CHARFORMAT2A cf2;
POINT orig_cursor_pos;
POINT cursor_screen_pos = {CURSOR_CLIENT_X, CURSOR_CLIENT_Y};
int i;
static const struct
{
UINT msg;
WPARAM wParam;
LPARAM lParam;
BOOL notifies;
}
link_notify_tests[] =
{
/* hold down the left button and try some messages */
{ WM_LBUTTONDOWN, 0, 0, TRUE }, /* 0 */
{ EM_LINESCROLL, 0, 1, FALSE },
{ EM_SCROLL, SB_BOTTOM, 0, FALSE },
{ WM_LBUTTONDBLCLK, 0, 0, TRUE },
{ WM_MOUSEHOVER, 0, 0, FALSE },
{ WM_MOUSEMOVE, 0, 0, FALSE },
{ WM_MOUSEWHEEL, 0, 0, FALSE },
{ WM_RBUTTONDBLCLK, 0, 0, TRUE },
{ WM_RBUTTONDOWN, 0, 0, TRUE },
{ WM_RBUTTONUP, 0, 0, TRUE },
{ WM_SETCURSOR, 0, 0, FALSE },
{ WM_SETCURSOR, WP_PARENT, 0, FALSE },
{ WM_SETCURSOR, WP_CHILD, 0, TRUE },
{ WM_SETCURSOR, WP_CHILD, 1, TRUE },
{ WM_VSCROLL, SB_BOTTOM, 0, FALSE },
{ WM_LBUTTONUP, 0, 0, TRUE },
/* hold down the right button and try some messages */
{ WM_RBUTTONDOWN, 0, 0, TRUE }, /* 16 */
{ EM_LINESCROLL, 0, 1, FALSE },
{ EM_SCROLL, SB_BOTTOM, 0, FALSE },
{ WM_LBUTTONDBLCLK, 0, 0, TRUE },
{ WM_LBUTTONDOWN, 0, 0, TRUE },
{ WM_LBUTTONUP, 0, 0, TRUE },
{ WM_MOUSEHOVER, 0, 0, FALSE },
{ WM_MOUSEMOVE, 0, 0, TRUE },
{ WM_MOUSEWHEEL, 0, 0, FALSE },
{ WM_RBUTTONDBLCLK, 0, 0, TRUE },
{ WM_SETCURSOR, 0, 0, FALSE },
{ WM_SETCURSOR, WP_PARENT, 0, FALSE },
{ WM_SETCURSOR, WP_CHILD, 0, TRUE },
{ WM_SETCURSOR, WP_CHILD, 1, TRUE },
{ WM_VSCROLL, SB_BOTTOM, 0, FALSE },
{ WM_RBUTTONUP, 0, 0, TRUE },
/* try the messages with both buttons released */
{ EM_LINESCROLL, 0, 1, FALSE }, /* 32 */
{ EM_SCROLL, SB_BOTTOM, 0, FALSE },
{ WM_LBUTTONDBLCLK, 0, 0, TRUE },
{ WM_LBUTTONDOWN, 0, 0, TRUE },
{ WM_LBUTTONUP, 0, 0, TRUE },
{ WM_MOUSEHOVER, 0, 0, FALSE },
{ WM_MOUSEMOVE, 0, 0, TRUE },
{ WM_MOUSEWHEEL, 0, 0, FALSE },
{ WM_RBUTTONDBLCLK, 0, 0, TRUE },
{ WM_RBUTTONDOWN, 0, 0, TRUE },
{ WM_RBUTTONUP, 0, 0, TRUE },
{ WM_SETCURSOR, 0, 0, FALSE },
{ WM_SETCURSOR, WP_CHILD, 0, TRUE },
{ WM_SETCURSOR, WP_CHILD, 1, TRUE },
{ WM_SETCURSOR, WP_PARENT, 0, FALSE },
{ WM_VSCROLL, SB_BOTTOM, 0, FALSE }
};
/* register class to capture WM_NOTIFY */ /* register class to capture WM_NOTIFY */
cls.style = 0; cls.style = 0;
@ -6015,21 +6218,40 @@ static void test_EN_LINK(void)
0, 0, 200, 60, NULL, NULL, NULL, NULL); 0, 0, 200, 60, NULL, NULL, NULL, NULL);
ok(parent != 0, "Failed to create parent window\n"); ok(parent != 0, "Failed to create parent window\n");
hwndRichedit_EN_LINK = new_richedit(parent); hwnd = new_richedit(parent);
ok(hwndRichedit_EN_LINK != 0, "Failed to create edit window\n"); ok(hwnd != 0, "Failed to create edit window\n");
SendMessageA(hwndRichedit_EN_LINK, EM_SETEVENTMASK, 0, ENM_LINK); SendMessageA(hwnd, EM_SETEVENTMASK, 0, ENM_LINK);
cf2.cbSize = sizeof(CHARFORMAT2A); cf2.cbSize = sizeof(CHARFORMAT2A);
cf2.dwMask = CFM_LINK; cf2.dwMask = CFM_LINK;
cf2.dwEffects = CFE_LINK; cf2.dwEffects = CFE_LINK;
SendMessageA(hwndRichedit_EN_LINK, EM_SETCHARFORMAT, 0, (LPARAM)&cf2); SendMessageA(hwnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf2);
/* mixing letters and numbers causes runs to be split */ /* mixing letters and numbers causes runs to be split */
SendMessageA(hwndRichedit_EN_LINK, WM_SETTEXT, 0, (LPARAM)"link text with at least 2 runs"); SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"link text with at least 2 runs");
SendMessageA(hwndRichedit_EN_LINK, WM_LBUTTONDOWN, 0, MAKELPARAM(5, 5));
ok(cpMin_EN_LINK == 0 && cpMax_EN_LINK == 31, "Expected link range [0,31) got [%i,%i)\n", cpMin_EN_LINK, cpMax_EN_LINK);
DestroyWindow(hwndRichedit_EN_LINK); GetCursorPos(&orig_cursor_pos);
SetCursorPos(0, 0);
for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++)
{
link_notify_test("cursor position simulated", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
link_notify_tests[i].msg == WM_SETCURSOR ? FALSE : link_notify_tests[i].notifies);
}
ClientToScreen(hwnd, &cursor_screen_pos);
SetCursorPos(cursor_screen_pos.x, cursor_screen_pos.y);
for (i = 0; i < sizeof(link_notify_tests)/sizeof(link_notify_tests[0]); i++)
{
link_notify_test("cursor position set", i, hwnd, parent,
link_notify_tests[i].msg, link_notify_tests[i].wParam, link_notify_tests[i].lParam,
link_notify_tests[i].notifies);
}
SetCursorPos(orig_cursor_pos.x, orig_cursor_pos.y);
DestroyWindow(hwnd);
DestroyWindow(parent); DestroyWindow(parent);
} }
@ -7625,12 +7847,12 @@ static void test_EM_SETREADONLY(void)
res = SendMessageA(richedit, EM_SETREADONLY, TRUE, 0); res = SendMessageA(richedit, EM_SETREADONLY, TRUE, 0);
ok(res == 1, "EM_SETREADONLY\n"); ok(res == 1, "EM_SETREADONLY\n");
dwStyle = GetWindowLongA(richedit, GWL_STYLE); dwStyle = GetWindowLongA(richedit, GWL_STYLE);
ok(dwStyle & ES_READONLY, "got wrong value: 0x%x\n", dwStyle & ES_READONLY); ok(dwStyle & ES_READONLY, "got wrong value: 0x%x\n", dwStyle);
res = SendMessageA(richedit, EM_SETREADONLY, FALSE, 0); res = SendMessageA(richedit, EM_SETREADONLY, FALSE, 0);
ok(res == 1, "EM_SETREADONLY\n"); ok(res == 1, "EM_SETREADONLY\n");
dwStyle = GetWindowLongA(richedit, GWL_STYLE); dwStyle = GetWindowLongA(richedit, GWL_STYLE);
ok(!(dwStyle & ES_READONLY), "got wrong value: 0x%x\n", dwStyle & ES_READONLY); ok(!(dwStyle & ES_READONLY), "got wrong value: 0x%x\n", dwStyle);
DestroyWindow(richedit); DestroyWindow(richedit);
} }

File diff suppressed because it is too large Load diff

View file

@ -32,6 +32,7 @@
#include <tom.h> #include <tom.h>
#include <richole.h> #include <richole.h>
#include <initguid.h> #include <initguid.h>
#include <imm.h>
#include <textserv.h> #include <textserv.h>
#include <wine/test.h> #include <wine/test.h>
#include <oleauto.h> #include <oleauto.h>
@ -505,8 +506,6 @@ static ITextHostVtbl itextHostVtbl = {
ITextHostImpl_TxGetSelectionBarWidth ITextHostImpl_TxGetSelectionBarWidth
}; };
static ITextServices *txtserv = NULL;
static ITextHostTestImpl *dummyTextHost;
static void *wrapperCodeMem = NULL; static void *wrapperCodeMem = NULL;
#include "pshpack1.h" #include "pshpack1.h"
@ -605,14 +604,15 @@ static void setup_thiscall_wrappers(void)
/* Conformance test functions. */ /* Conformance test functions. */
/* Initialize the test texthost structure */ /* Initialize the test texthost structure */
static BOOL init_texthost(void) static BOOL init_texthost(ITextServices **txtserv, ITextHost **ret)
{ {
ITextHostTestImpl *dummyTextHost;
IUnknown *init; IUnknown *init;
HRESULT result; HRESULT result;
dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost)); dummyTextHost = CoTaskMemAlloc(sizeof(*dummyTextHost));
if (dummyTextHost == NULL) { if (dummyTextHost == NULL) {
skip("Insufficient memory to create ITextHost interface\n"); win_skip("Insufficient memory to create ITextHost interface\n");
return FALSE; return FALSE;
} }
dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl; dummyTextHost->ITextHost_iface.lpVtbl = &itextHostVtbl;
@ -621,54 +621,53 @@ static BOOL init_texthost(void)
/* MSDN states that an IUnknown object is returned by /* MSDN states that an IUnknown object is returned by
CreateTextServices which is then queried to obtain a CreateTextServices which is then queried to obtain a
ITextServices object. */ ITextServices object. */
result = (*pCreateTextServices)(NULL, &dummyTextHost->ITextHost_iface, &init); result = pCreateTextServices(NULL, &dummyTextHost->ITextHost_iface, &init);
ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result); ok(result == S_OK, "Did not return S_OK when created (result = %x)\n", result);
if (result != S_OK) { if (result != S_OK) {
CoTaskMemFree(dummyTextHost); CoTaskMemFree(dummyTextHost);
skip("CreateTextServices failed.\n"); win_skip("CreateTextServices failed.\n");
return FALSE; return FALSE;
} }
result = IUnknown_QueryInterface(init, pIID_ITextServices, result = IUnknown_QueryInterface(init, pIID_ITextServices, (void**)txtserv);
(void **)&txtserv); ok((result == S_OK) && (*txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, *txtserv);
ok((result == S_OK) && (txtserv != NULL), "Querying interface failed (result = %x, txtserv = %p)\n", result, txtserv);
IUnknown_Release(init); IUnknown_Release(init);
if (!((result == S_OK) && (txtserv != NULL))) { if (!((result == S_OK) && (*txtserv != NULL))) {
CoTaskMemFree(dummyTextHost); CoTaskMemFree(dummyTextHost);
skip("Could not retrieve ITextServices interface\n"); win_skip("Could not retrieve ITextServices interface\n");
return FALSE; return FALSE;
} }
*ret = &dummyTextHost->ITextHost_iface;
return TRUE; return TRUE;
} }
static void free_texthost(void)
{
ITextServices_Release(txtserv);
CoTaskMemFree(dummyTextHost);
}
static void test_TxGetText(void) static void test_TxGetText(void)
{ {
ITextServices *txtserv;
ITextHost *host;
HRESULT hres; HRESULT hres;
BSTR rettext; BSTR rettext;
if (!init_texthost()) if (!init_texthost(&txtserv, &host))
return; return;
hres = ITextServices_TxGetText(txtserv, &rettext); hres = ITextServices_TxGetText(txtserv, &rettext);
ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres); ok(hres == S_OK, "ITextServices_TxGetText failed (result = %x)\n", hres);
free_texthost(); ITextServices_Release(txtserv);
ITextHost_Release(host);
} }
static void test_TxSetText(void) static void test_TxSetText(void)
{ {
ITextServices *txtserv;
ITextHost *host;
HRESULT hres; HRESULT hres;
BSTR rettext; BSTR rettext;
WCHAR settext[] = {'T','e','s','t',0}; WCHAR settext[] = {'T','e','s','t',0};
if (!init_texthost()) if (!init_texthost(&txtserv, &host))
return; return;
hres = ITextServices_TxSetText(txtserv, settext); hres = ITextServices_TxSetText(txtserv, settext);
@ -683,10 +682,14 @@ static void test_TxSetText(void)
"String returned differs\n"); "String returned differs\n");
SysFreeString(rettext); SysFreeString(rettext);
free_texthost(); ITextServices_Release(txtserv);
ITextHost_Release(host);
} }
static void test_TxGetNaturalSize(void) { static void test_TxGetNaturalSize(void)
{
ITextServices *txtserv;
ITextHost *host;
HRESULT result; HRESULT result;
BOOL ret; BOOL ret;
@ -709,7 +712,7 @@ static void test_TxGetNaturalSize(void) {
INT charwidth_caps_text[26]; INT charwidth_caps_text[26];
TEXTMETRICA tmInfo_text; TEXTMETRICA tmInfo_text;
if (!init_texthost()) if (!init_texthost(&txtserv, &host))
return; return;
hdcDraw = GetDC(NULL); hdcDraw = GetDC(NULL);
@ -758,11 +761,14 @@ static void test_TxGetNaturalSize(void) {
cleanup: cleanup:
RestoreDC(hdcDraw,1); RestoreDC(hdcDraw,1);
ReleaseDC(NULL,hdcDraw); ReleaseDC(NULL,hdcDraw);
free_texthost(); ITextServices_Release(txtserv);
ITextHost_Release(host);
} }
static void test_TxDraw(void) static void test_TxDraw(void)
{ {
ITextServices *txtserv;
ITextHost *host;
HDC tmphdc = GetDC(NULL); HDC tmphdc = GetDC(NULL);
DWORD dwAspect = DVASPECT_CONTENT; DWORD dwAspect = DVASPECT_CONTENT;
HDC hicTargetDev = NULL; /* Means "default" device */ HDC hicTargetDev = NULL; /* Means "default" device */
@ -771,7 +777,8 @@ static void test_TxDraw(void)
HRESULT result; HRESULT result;
RECTL client = {0,0,100,100}; RECTL client = {0,0,100,100};
if (!init_texthost())
if (!init_texthost(&txtserv, &host))
return; return;
todo_wine { todo_wine {
@ -781,8 +788,8 @@ static void test_TxDraw(void)
ok(result == S_OK, "TxDraw failed (result = %x)\n", result); ok(result == S_OK, "TxDraw failed (result = %x)\n", result);
} }
free_texthost(); ITextServices_Release(txtserv);
ITextHost_Release(host);
} }
DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5); DEFINE_GUID(expected_iid_itextservices, 0x8d33f740, 0xcf58, 0x11ce, 0xa8, 0x9d, 0x00, 0xaa, 0x00, 0x6c, 0xad, 0xc5);
@ -871,12 +878,14 @@ static ULONG get_refcount(IUnknown *iface)
static void test_QueryInterface(void) static void test_QueryInterface(void)
{ {
ITextServices *txtserv;
ITextHost *host;
HRESULT hres; HRESULT hres;
IRichEditOle *reole, *txtsrv_reole; IRichEditOle *reole, *txtsrv_reole;
ITextDocument *txtdoc, *txtsrv_txtdoc; ITextDocument *txtdoc, *txtsrv_txtdoc;
ULONG refcount; ULONG refcount;
if(!init_texthost()) if(!init_texthost(&txtserv, &host))
return; return;
refcount = get_refcount((IUnknown *)txtserv); refcount = get_refcount((IUnknown *)txtserv);
@ -926,11 +935,15 @@ static void test_QueryInterface(void)
refcount = get_refcount((IUnknown *)txtserv); refcount = get_refcount((IUnknown *)txtserv);
ok(refcount == 1, "got wrong ref count: %d\n", refcount); ok(refcount == 1, "got wrong ref count: %d\n", refcount);
free_texthost(); ITextServices_Release(txtserv);
ITextHost_Release(host);
} }
START_TEST( txtsrv ) START_TEST( txtsrv )
{ {
ITextServices *txtserv;
ITextHost *host;
setup_thiscall_wrappers(); setup_thiscall_wrappers();
/* Must explicitly LoadLibrary(). The test has no references to functions in /* Must explicitly LoadLibrary(). The test has no references to functions in
@ -946,9 +959,10 @@ START_TEST( txtsrv )
test_IIDs(); test_IIDs();
test_COM(); test_COM();
if (init_texthost()) if (init_texthost(&txtserv, &host))
{ {
free_texthost(); ITextServices_Release(txtserv);
ITextHost_Release(host);
test_TxGetText(); test_TxGetText();
test_TxSetText(); test_TxSetText();