#include <winnls.h>
#include <ole2.h>
#include <richedit.h>
+#include <commdlg.h>
#include <time.h>
#include <wine/test.h>
DestroyWindow(hwndRichEdit);
}
+LONG streamout_written = 0;
+
static DWORD CALLBACK test_WM_SETTEXT_esCallback(DWORD_PTR dwCookie,
LPBYTE pbBuff,
LONG cb,
memcpy(*str, pbBuff, *pcb);
*str += *pcb;
}
+ streamout_written = *pcb;
return 0;
}
#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)
{
HWND hwndRichEdit = new_richedit(NULL);
EDITSTREAM es;
char buf[1024] = {0};
char * p;
+ LRESULT result;
const char * TestItem1 = "TestSomeText";
const char * TestItem2 = "TestSomeText\r";
es.dwError = 0;
es.pfnCallback = test_WM_SETTEXT_esCallback;
memset(buf, 0, sizeof(buf));
- SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
r = strlen(buf);
ok(r == 12, "streamed text length is %d, expecting 12\n", r);
ok(strcmp(buf, TestItem1) == 0,
"streamed text different, got %s\n", buf);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
+
+ /* RTF mode writes the final end of para \r if it's part of the selection */
+ p = buf;
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es);
+ ok (count_pars(buf) == 1, "got %s\n", buf);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, 12);
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 0, "got %s\n", buf);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1);
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 1, "got %s\n", buf);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem2);
p = buf;
es.dwError = 0;
es.pfnCallback = test_WM_SETTEXT_esCallback;
memset(buf, 0, sizeof(buf));
- SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
r = strlen(buf);
/* Here again, \r gets converted to \r\n, like WM_GETTEXT */
ok(r == 14, "streamed text length is %d, expecting 14\n", r);
ok(strcmp(buf, TestItem3) == 0,
"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;
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF, (LPARAM)&es);
+ ok (count_pars(buf) == 2, "got %s\n", buf);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, 13);
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 1, "got %s\n", buf);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
+ p = buf;
+ SendMessageA(hwndRichEdit, EM_SETSEL, 0, -1);
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_RTF|SFF_SELECTION, (LPARAM)&es);
+ ok (count_pars(buf) == 2, "got %s\n", buf);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
+
SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)TestItem3);
p = buf;
es.dwCookie = (DWORD_PTR)&p;
es.dwError = 0;
es.pfnCallback = test_WM_SETTEXT_esCallback;
memset(buf, 0, sizeof(buf));
- SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
+ result = SendMessageA(hwndRichEdit, EM_STREAMOUT, SF_TEXT, (LPARAM)&es);
+ ok(result == streamout_written, "got %ld expected %d\n", result, streamout_written);
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);
+ /* 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));
+ result = 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);
+ ok(result == 0, "got %ld expected 0\n", result);
+
+
DestroyWindow(hwndRichEdit);
}
ok (result == 1,
"EM_SETTEXTEX returned %d, instead of 1\n",result);
- ok(lstrlenW(buf) == 0,
- "EM_SETTEXTEX with NULL lParam should clear rich edit.\n");
-
+ ok(!buf[0], "EM_SETTEXTEX with NULL lParam should clear rich edit.\n");
+
/* put some text back: !ST_SELECTION && Unicode && !\rtf */
setText.flags = 0;
SendMessageA(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, (LPARAM)TestItem1);
LRESULT expected_retval;
int expected_getsel_start;
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 */
- {5, 10, 10, 5, 10, 0},
- {15, 17, 17, 15, 17, 0},
+ {5, 10, 10, 5, 10 },
+ {15, 17, 17, 15, 17 },
/* test cpMax > strlen() */
- {0, 100, 18, 0, 18, 1},
+ {0, 100, 18, 0, 18 },
+ /* test cpMin < 0 && cpMax >= 0 after cpMax > strlen() */
+ {-1, 1, 17, 17, 17 },
/* test cpMin == cpMax */
- {5, 5, 5, 5, 5, 0},
+ {5, 5, 5, 5, 5 },
/* test cpMin < 0 && cpMax >= 0 (bug 4462) */
- {-1, 0, 5, 5, 5, 0},
- {-1, 17, 5, 5, 5, 0},
- {-1, 18, 5, 5, 5, 0},
+ {-1, 0, 5, 5, 5 },
+ {-1, 17, 5, 5, 5 },
+ {-1, 18, 5, 5, 5 },
/* test cpMin < 0 && cpMax < 0 */
- {-1, -1, 17, 17, 17, 0},
- {-4, -5, 17, 17, 17, 0},
- /* test cMin >=0 && cpMax < 0 (bug 6814) */
- {0, -1, 18, 0, 18, 1},
- {17, -5, 18, 17, 18, 1},
- {18, -3, 17, 17, 17, 0},
+ {-1, -1, 17, 17, 17 },
+ {-4, -5, 17, 17, 17 },
+ /* test cpMin >=0 && cpMax < 0 (bug 6814) */
+ {0, -1, 18, 0, 18 },
+ {17, -5, 18, 17, 18 },
+ {18, -3, 17, 17, 17 },
/* test if cpMin > cpMax */
- {15, 19, 18, 15, 18, 1},
- {19, 15, 18, 15, 18, 1}
+ {15, 19, 18, 15, 18 },
+ {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) {
SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
- if (setsel->_getsel_todo_wine) {
+ if (setsel->todo) {
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);
}
DestroyWindow(hwndRichEdit);
}
+static void check_EM_SETSEL(HWND hwnd, const struct exsetsel_s *setsel, int id) {
+ LRESULT result;
+ int start, end;
+
+ result = SendMessageA(hwnd, EM_SETSEL, setsel->min, setsel->max);
+
+ ok(result == setsel->expected_retval, "EM_SETSEL(%d): expected: %ld actual: %ld\n", id, setsel->expected_retval, result);
+
+ SendMessageA(hwnd, EM_GETSEL, (WPARAM)&start, (LPARAM)&end);
+
+ if (setsel->todo) {
+ 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);
+ }
+ } else {
+ 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);
+ }
+}
+
+static void test_EM_SETSEL(void)
+{
+ char buffA[32];
+ HWND hwndRichEdit = new_richedit(NULL);
+ int i;
+ const int num_tests = sizeof(exsetsel_tests)/sizeof(struct exsetsel_s);
+
+ /* sending some text to the window */
+ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)"testing selection");
+ /* 01234567890123456*/
+ /* 10 */
+
+ for (i = 0; i < num_tests; 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);
+}
+
static void test_EM_REPLACESEL(int redraw)
{
HWND hwndRichEdit = new_richedit(NULL);
SendMessageA(hwndRichEdit, WM_PASTE, 0, 0);
SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
result = strcmp(buffer,"cut\r\n");
- todo_wine ok(result == 0,
+ ok(result == 0,
"test paste: strcmp = %i, actual = '%s'\n", result, buffer);
/* Simulates undo (Ctrl-Z) */
hold_key(VK_CONTROL);
(MapVirtualKeyA('Y', MAPVK_VK_TO_VSC) << 16) | 1);
SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
result = strcmp(buffer,"cut\r\n");
- todo_wine ok(result == 0,
+ ok(result == 0,
"test paste: strcmp = %i, actual = '%s'\n", result, buffer);
release_key(VK_CONTROL);
DWORD phase;
LRESULT result;
EDITSTREAM es;
- char buffer[1024] = {0};
+ char buffer[1024] = {0}, tmp[16];
+ CHARRANGE range;
const char * streamText0 = "{\\rtf1 TestSomeText}";
const char * streamText0a = "{\\rtf1 TestSomeText\\par}";
const char * streamText0b = "{\\rtf1 TestSomeText\\par\\par}";
+ const char * ptr;
const char * streamText1 =
"{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang12298{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 System;}}\r\n"
"This text just needs to be long enough to cause run to be split onto "
"two separate lines and make sure the null terminating character is "
"handled properly.\0";
+
+ const WCHAR UTF8Split_exp[4] = {0xd6, 0xcf, 0xcb, 0};
+
int length4 = strlen(streamText4) + 1;
struct StringWithLength cookieForStream4 = {
length4,
ok(es.dwError == 0, "EM_STREAMIN: Test 0 set error %d, expected %d\n", es.dwError, 0);
/* Native richedit 2.0 ignores last \par */
- es.dwCookie = (DWORD_PTR)&streamText0a;
+ ptr = streamText0a;
+ es.dwCookie = (DWORD_PTR)&ptr;
es.dwError = 0;
es.pfnCallback = test_EM_STREAMIN_esCallback;
result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es);
"EM_STREAMIN: Test 0-b set wrong text: Result: %s\n",buffer);
ok(es.dwError == 0, "EM_STREAMIN: Test 0-b set error %d, expected %d\n", es.dwError, 0);
+ /* Show that when using SFF_SELECTION the last \par is not ignored. */
+ ptr = streamText0a;
+ es.dwCookie = (DWORD_PTR)&ptr;
+ es.dwError = 0;
+ es.pfnCallback = test_EM_STREAMIN_esCallback;
+ result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_RTF, (LPARAM)&es);
+ ok(result == 12, "got %ld, expected %d\n", result, 12);
+
+ result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
+ ok (result == 12,
+ "EM_STREAMIN: Test 0-a returned %ld, expected 12\n", result);
+ result = strcmp (buffer,"TestSomeText");
+ ok (result == 0,
+ "EM_STREAMIN: Test 0-a set wrong text: Result: %s\n",buffer);
+ ok(es.dwError == 0, "EM_STREAMIN: Test 0-a set error %d, expected %d\n", es.dwError, 0);
+
+ range.cpMin = 0;
+ range.cpMax = -1;
+ result = SendMessageA(hwndRichEdit, EM_EXSETSEL, 0, (LPARAM)&range);
+ ok (result == 13, "got %ld\n", result);
+
+ ptr = streamText0a;
+ es.dwCookie = (DWORD_PTR)&ptr;
+ es.dwError = 0;
+ es.pfnCallback = test_EM_STREAMIN_esCallback;
+
+ result = SendMessageA(hwndRichEdit, EM_STREAMIN, SFF_SELECTION | SF_RTF, (LPARAM)&es);
+ ok(result == 13, "got %ld, expected 13\n", result);
+
+ result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
+ ok (result == 14,
+ "EM_STREAMIN: Test SFF_SELECTION 0-a returned %ld, expected 14\n", result);
+ result = strcmp (buffer,"TestSomeText\r\n");
+ ok (result == 0,
+ "EM_STREAMIN: Test SFF_SELECTION 0-a set wrong text: Result: %s\n",buffer);
+ ok(es.dwError == 0, "EM_STREAMIN: Test SFF_SELECTION 0-a set error %d, expected %d\n", es.dwError, 0);
+
es.dwCookie = (DWORD_PTR)&streamText1;
es.dwError = 0;
es.pfnCallback = test_EM_STREAMIN_esCallback;
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
ok (result == 0,
"EM_STREAMIN: Test 2 returned %ld, expected 0\n", result);
- ok (strlen(buffer) == 0,
- "EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer);
+ ok(!buffer[0], "EM_STREAMIN: Test 2 set wrong text: Result: %s\n",buffer);
ok(es.dwError == -16, "EM_STREAMIN: Test 2 set error %d, expected %d\n", es.dwError, -16);
es.dwCookie = (DWORD_PTR)&streamText3;
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
ok (result == 0,
"EM_STREAMIN: Test 3 returned %ld, expected 0\n", result);
- ok (strlen(buffer) == 0,
- "EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer);
+ ok(!buffer[0], "EM_STREAMIN: Test 3 set wrong text: Result: %s\n",buffer);
ok(es.dwError == -16, "EM_STREAMIN: Test 3 set error %d, expected %d\n", es.dwError, -16);
es.dwCookie = (DWORD_PTR)&streamTextUTF8BOM;
result = SendMessageA(hwndRichEdit, EM_STREAMIN, SF_TEXT, (LPARAM)&es);
ok(result == 8, "got %ld\n", result);
+ WideCharToMultiByte(CP_ACP, 0, UTF8Split_exp, -1, tmp, sizeof(tmp), NULL, NULL);
+
result = SendMessageA(hwndRichEdit, WM_GETTEXT, 1024, (LPARAM)buffer);
ok(result == 3,
"EM_STREAMIN: Test UTF8Split returned %ld\n", result);
- result = memcmp (buffer,"\xd6\xcf\xcb", 3);
+ result = memcmp (buffer, tmp, 3);
ok(result == 0,
"EM_STREAMIN: Test UTF8Split set wrong text: Result: %s\n",buffer);
ok(es.dwError == 0, "EM_STREAMIN: Test UTF8Split set error %d, expected %d\n", es.dwError, 0);
DestroyWindow(parent);
}
+static ENLINK enlink;
+#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)
+{
+ if(message == WM_NOTIFY && ((NMHDR*)lParam)->code == EN_LINK)
+ {
+ enlink = *(ENLINK*)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)
+{
+ HWND hwnd, parent;
+ WNDCLASSA cls;
+ 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 */
+ cls.style = 0;
+ cls.lpfnWndProc = EN_LINK_ParentMsgCheckProcA;
+ cls.cbClsExtra = 0;
+ cls.cbWndExtra = 0;
+ cls.hInstance = GetModuleHandleA(0);
+ cls.hIcon = 0;
+ cls.hCursor = LoadCursorA(0, (LPCSTR)IDC_ARROW);
+ cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+ cls.lpszMenuName = NULL;
+ cls.lpszClassName = "EN_LINK_ParentClass";
+ if(!RegisterClassA(&cls)) assert(0);
+
+ parent = CreateWindowA(cls.lpszClassName, NULL, WS_POPUP|WS_VISIBLE,
+ 0, 0, 200, 60, NULL, NULL, NULL, NULL);
+ ok(parent != 0, "Failed to create parent window\n");
+
+ hwnd = new_richedit(parent);
+ ok(hwnd != 0, "Failed to create edit window\n");
+
+ SendMessageA(hwnd, EM_SETEVENTMASK, 0, ENM_LINK);
+
+ cf2.cbSize = sizeof(CHARFORMAT2A);
+ cf2.dwMask = CFM_LINK;
+ cf2.dwEffects = CFE_LINK;
+ SendMessageA(hwnd, EM_SETCHARFORMAT, 0, (LPARAM)&cf2);
+ /* mixing letters and numbers causes runs to be split */
+ SendMessageA(hwnd, WM_SETTEXT, 0, (LPARAM)"link text with at least 2 runs");
+
+ 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);
+}
+
static void test_undo_coalescing(void)
{
HWND hwnd;
char buf[2];
buf[0] = delimiter_tests[i].c;
buf[1] = 0;
- SendMessageW(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)buf);
+ SendMessageA(hwndRichEdit, WM_SETTEXT, 0, (LPARAM)buf);
result = SendMessageA(hwndRichEdit, EM_FINDWORDBREAK, WB_ISDELIMITER, 0);
if (buf[0] == 0x20)
todo_wine
DestroyWindow( richedit );
}
+static void test_EM_SETREADONLY(void)
+{
+ HWND richedit = new_richeditW(NULL);
+ DWORD dwStyle;
+ LRESULT res;
+
+ res = SendMessageA(richedit, EM_SETREADONLY, TRUE, 0);
+ ok(res == 1, "EM_SETREADONLY\n");
+ dwStyle = GetWindowLongA(richedit, GWL_STYLE);
+ ok(dwStyle & ES_READONLY, "got wrong value: 0x%x\n", dwStyle);
+
+ res = SendMessageA(richedit, EM_SETREADONLY, FALSE, 0);
+ ok(res == 1, "EM_SETREADONLY\n");
+ dwStyle = GetWindowLongA(richedit, GWL_STYLE);
+ ok(!(dwStyle & ES_READONLY), "got wrong value: 0x%x\n", dwStyle);
+
+ DestroyWindow(richedit);
+}
+
+static inline LONG twips2points(LONG value)
+{
+ return value / 20;
+}
+
+#define TEST_EM_SETFONTSIZE(hwnd,size,expected_size,expected_res,expected_undo) \
+ _test_font_size(__LINE__,hwnd,size,expected_size,expected_res,expected_undo)
+static void _test_font_size(unsigned line, HWND hwnd, LONG size, LONG expected_size,
+ LRESULT expected_res, BOOL expected_undo)
+{
+ CHARFORMAT2A cf;
+ LRESULT res;
+ BOOL isundo;
+
+ cf.cbSize = sizeof(cf);
+ cf.dwMask = CFM_SIZE;
+
+ res = SendMessageA(hwnd, EM_SETFONTSIZE, size, 0);
+ SendMessageA(hwnd, EM_GETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
+ isundo = SendMessageA(hwnd, EM_CANUNDO, 0, 0);
+ ok_(__FILE__,line)(res == expected_res, "EM_SETFONTSIZE unexpected return value: %lx.\n", res);
+ ok_(__FILE__,line)(twips2points(cf.yHeight) == expected_size, "got wrong font size: %d, expected: %d\n",
+ twips2points(cf.yHeight), expected_size);
+ ok_(__FILE__,line)(isundo == expected_undo, "get wrong undo mark: %d, expected: %d.\n",
+ isundo, expected_undo);
+}
+
+static void test_EM_SETFONTSIZE(void)
+{
+ HWND richedit = new_richedit(NULL);
+ CHAR text[] = "wine";
+ CHARFORMAT2A tmp_cf;
+ LONG default_size;
+
+ tmp_cf.cbSize = sizeof(tmp_cf);
+ tmp_cf.dwMask = CFM_SIZE;
+ tmp_cf.yHeight = 9 * 20.0;
+ SendMessageA(richedit, EM_SETCHARFORMAT, SCF_DEFAULT, (LPARAM)&tmp_cf);
+
+ SendMessageA(richedit, WM_SETTEXT, 0, (LPARAM)text);
+
+ SendMessageA(richedit, EM_SETMODIFY, FALSE, 0);
+ /* without selection */
+ TEST_EM_SETFONTSIZE(richedit, 1, 10, TRUE, FALSE); /* 9 + 1 -> 10 */
+ SendMessageA(richedit, EM_GETCHARFORMAT, SCF_DEFAULT, (LPARAM)&tmp_cf);
+ default_size = twips2points(tmp_cf.yHeight);
+ ok(default_size == 9, "Default font size should not be changed.\n");
+ ok(SendMessageA(richedit, EM_SETMODIFY, 0, 0) == FALSE, "Modify flag should not be changed.\n");
+
+ SendMessageA(richedit, EM_SETSEL, 0, 2);
+
+ TEST_EM_SETFONTSIZE(richedit, 0, 9, TRUE, TRUE); /* 9 + 0 -> 9 */
+
+ SendMessageA(richedit, EM_SETMODIFY, FALSE, 0);
+ TEST_EM_SETFONTSIZE(richedit, 3, 12, TRUE, TRUE); /* 9 + 3 -> 12 */
+ ok(SendMessageA(richedit, EM_SETMODIFY, 0, 0) == FALSE, "Modify flag should not be changed.\n");
+
+ TEST_EM_SETFONTSIZE(richedit, 1, 14, TRUE, TRUE); /* 12 + 1 + 1 -> 14 */
+ TEST_EM_SETFONTSIZE(richedit, -1, 12, TRUE, TRUE); /* 14 - 1 - 1 -> 12 */
+ TEST_EM_SETFONTSIZE(richedit, 4, 16, TRUE, TRUE); /* 12 + 4 -> 16 */
+ TEST_EM_SETFONTSIZE(richedit, 3, 20, TRUE, TRUE); /* 16 + 3 + 1 -> 20 */
+ TEST_EM_SETFONTSIZE(richedit, 0, 20, TRUE, TRUE); /* 20 + 0 -> 20 */
+ TEST_EM_SETFONTSIZE(richedit, 8, 28, TRUE, TRUE); /* 20 + 8 -> 28 */
+ TEST_EM_SETFONTSIZE(richedit, 0, 28, TRUE, TRUE); /* 28 + 0 -> 28 */
+ TEST_EM_SETFONTSIZE(richedit, 1, 36, TRUE, TRUE); /* 28 + 1 -> 36 */
+ TEST_EM_SETFONTSIZE(richedit, 0, 36, TRUE, TRUE); /* 36 + 0 -> 36 */
+ TEST_EM_SETFONTSIZE(richedit, 1, 48, TRUE, TRUE); /* 36 + 1 -> 48 */
+ TEST_EM_SETFONTSIZE(richedit, 0, 48, TRUE, TRUE); /* 48 + 0 -> 48 */
+ TEST_EM_SETFONTSIZE(richedit, 1, 72, TRUE, TRUE); /* 48 + 1 -> 72 */
+ TEST_EM_SETFONTSIZE(richedit, 0, 72, TRUE, TRUE); /* 72 + 0 -> 72 */
+ TEST_EM_SETFONTSIZE(richedit, 1, 80, TRUE, TRUE); /* 72 + 1 -> 80 */
+ TEST_EM_SETFONTSIZE(richedit, 0, 80, TRUE, TRUE); /* 80 + 0 -> 80 */
+ TEST_EM_SETFONTSIZE(richedit, 1, 90, TRUE, TRUE); /* 80 + 1 -> 90 */
+ TEST_EM_SETFONTSIZE(richedit, 0, 90, TRUE, TRUE); /* 90 + 0 -> 90 */
+ TEST_EM_SETFONTSIZE(richedit, 1, 100, TRUE, TRUE); /* 90 + 1 -> 100 */
+ TEST_EM_SETFONTSIZE(richedit, 25, 130, TRUE, TRUE); /* 100 + 25 -> 130 */
+ TEST_EM_SETFONTSIZE(richedit, -1, 120, TRUE, TRUE); /* 130 - 1 -> 120 */
+ TEST_EM_SETFONTSIZE(richedit, -35, 80, TRUE, TRUE); /* 120 - 35 -> 80 */
+ TEST_EM_SETFONTSIZE(richedit, -7, 72, TRUE, TRUE); /* 80 - 7 -> 72 */
+ TEST_EM_SETFONTSIZE(richedit, -42, 28, TRUE, TRUE); /* 72 - 42 -> 28 */
+ TEST_EM_SETFONTSIZE(richedit, -16, 12, TRUE, TRUE); /* 28 - 16 -> 12 */
+ TEST_EM_SETFONTSIZE(richedit, -3, 9, TRUE, TRUE); /* 12 - 3 -> 9 */
+ TEST_EM_SETFONTSIZE(richedit, -8, 1, TRUE, TRUE); /* 9 - 8 -> 1 */
+ TEST_EM_SETFONTSIZE(richedit, -111, 1, TRUE, TRUE); /* 1 - 111 -> 1 */
+ TEST_EM_SETFONTSIZE(richedit, 10086, 1638, TRUE, TRUE); /* 1 + 10086 -> 1638 */
+
+ /* return FALSE when richedit is TM_PLAINTEXT mode */
+ SendMessageA(richedit, WM_SETTEXT, 0, (LPARAM)"");
+ SendMessageA(richedit, EM_SETTEXTMODE, (WPARAM)TM_PLAINTEXT, 0);
+ TEST_EM_SETFONTSIZE(richedit, 0, 9, FALSE, FALSE);
+
+ DestroyWindow(richedit);
+}
+
+static void test_alignment_style(void)
+{
+ HWND richedit = NULL;
+ PARAFORMAT2 pf;
+ DWORD align_style[] = {ES_LEFT, ES_CENTER, ES_RIGHT, ES_RIGHT | ES_CENTER,
+ ES_LEFT | ES_CENTER, ES_LEFT | ES_RIGHT,
+ ES_LEFT | ES_RIGHT | ES_CENTER};
+ DWORD align_mask[] = {PFA_LEFT, PFA_CENTER, PFA_RIGHT, PFA_CENTER, PFA_CENTER,
+ PFA_RIGHT, PFA_CENTER};
+ const char * streamtext =
+ "{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang12298{\\fonttbl{\\f0\\fswiss\\fprq2\\fcharset0 System;}}\r\n"
+ "\\viewkind4\\uc1\\pard\\f0\\fs17 TestSomeText\\par\r\n"
+ "}\r\n";
+ EDITSTREAM es;
+ int i;
+
+ for (i = 0; i < sizeof(align_style) / sizeof(align_style[0]); i++)
+ {
+ DWORD dwStyle, new_align;
+
+ richedit = new_windowW(RICHEDIT_CLASS20W, align_style[i], NULL);
+ memset(&pf, 0, sizeof(pf));
+ pf.cbSize = sizeof(PARAFORMAT2);
+ pf.dwMask = -1;
+
+ SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
+ ok(pf.wAlignment == align_mask[i], "(i = %d) got %d expected %d\n",
+ i, pf.wAlignment, align_mask[i]);
+ dwStyle = GetWindowLongW(richedit, GWL_STYLE);
+ ok((i ? (dwStyle & align_style[i]) : (!(dwStyle & 0x0000000f))) ,
+ "(i = %d) didn't set right align style: 0x%x\n", i, dwStyle);
+
+
+ /* Based on test_reset_default_para_fmt() */
+ new_align = (align_mask[i] == PFA_LEFT) ? PFA_RIGHT : PFA_LEFT;
+ simulate_typing_characters(richedit, "123");
+
+ SendMessageW(richedit, EM_SETSEL, 0, -1);
+ pf.dwMask = PFM_ALIGNMENT;
+ pf.wAlignment = new_align;
+ SendMessageW(richedit, EM_SETPARAFORMAT, 0, (LPARAM)&pf);
+
+ SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
+ ok(pf.wAlignment == new_align, "got %d expect %d\n", pf.wAlignment, new_align);
+
+ SendMessageW(richedit, EM_SETSEL, 0, -1);
+ SendMessageW(richedit, WM_CUT, 0, 0);
+
+ SendMessageW(richedit, EM_GETPARAFORMAT, 0, (LPARAM)&pf);
+ ok(pf.wAlignment == align_mask[i], "got %d exppect %d\n", pf.wAlignment, align_mask[i]);
+
+ DestroyWindow(richedit);
+ }
+
+ /* test with EM_STREAMIN */
+ richedit = new_windowW(RICHEDIT_CLASS20W, ES_CENTER, NULL);
+ simulate_typing_characters(richedit, "abc");
+ es.dwCookie = (DWORD_PTR)&streamtext;
+ es.dwError = 0;
+ es.pfnCallback = test_EM_STREAMIN_esCallback;
+ SendMessageW(richedit, EM_STREAMIN, SF_RTF, (LPARAM)&es);
+ SendMessageW(richedit, EM_SETSEL, 0, -1);
+ memset(&pf, 0, sizeof(pf));
+ pf.cbSize = sizeof(PARAFORMAT2);
+ pf.dwMask = -1;
+ SendMessageW(richedit, EM_GETPARAFORMAT, SCF_SELECTION, (LPARAM)&pf);
+ ok(pf.wAlignment == ES_CENTER, "got %d expected ES_CENTER\n", pf.wAlignment);
+ DestroyWindow(richedit);
+}
+
START_TEST( editor )
{
BOOL ret;
test_EM_GETLIMITTEXT();
test_WM_SETFONT();
test_EM_GETMODIFY();
+ test_EM_SETSEL();
test_EM_EXSETSEL();
test_WM_PASTE();
test_EM_STREAMIN();
test_EM_REPLACESEL(1);
test_EM_REPLACESEL(0);
test_WM_NOTIFY();
+ test_EN_LINK();
test_EM_AUTOURLDETECT();
test_eventMask();
test_undo_coalescing();
test_enter();
test_WM_CREATE();
test_reset_default_para_fmt();
+ test_EM_SETREADONLY();
+ test_EM_SETFONTSIZE();
+ test_alignment_style();
/* Set the environment variable WINETEST_RICHED20 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.