Dylan Smith : richedit: Added riched32 tests for word wrap.
Alexandre Julliard
julliard at winehq.org
Mon Oct 27 08:03:29 CDT 2008
Module: wine
Branch: master
Commit: 9b4c821185af5ecf62c5becc6e790a7003be0988
URL: http://source.winehq.org/git/wine.git/?a=commit;h=9b4c821185af5ecf62c5becc6e790a7003be0988
Author: Dylan Smith <dylan.ah.smith at gmail.com>
Date: Sun Oct 26 23:38:07 2008 -0400
richedit: Added riched32 tests for word wrap.
---
dlls/riched32/tests/editor.c | 106 ++++++++++++++++++++++++++++++++++++++++++
1 files changed, 106 insertions(+), 0 deletions(-)
diff --git a/dlls/riched32/tests/editor.c b/dlls/riched32/tests/editor.c
index 2bf44f9..15876f4 100644
--- a/dlls/riched32/tests/editor.c
+++ b/dlls/riched32/tests/editor.c
@@ -817,6 +817,111 @@ static void test_EM_POSFROMCHAR(void)
DestroyWindow(hwndRichEdit);
}
+static void test_word_wrap(void)
+{
+ HWND hwnd;
+ POINTL point = {0, 60}; /* This point must be below the first line */
+ const char *text = "Must be long enough to test line wrapping";
+ DWORD dwCommonStyle = WS_VISIBLE|WS_POPUP|WS_VSCROLL|ES_MULTILINE;
+ int res, pos, lines;
+
+ /* Test the effect of WS_HSCROLL and ES_AUTOHSCROLL styles on wrapping
+ * when specified on window creation and set later. */
+ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle,
+ 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL);
+ ok(hwnd != NULL, "error: %d\n", (int) GetLastError());
+ res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text);
+ ok(res, "WM_SETTEXT failed.\n");
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos);
+ lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0);
+ ok(lines > 1, "Line was expected to wrap (lines=%d).\n", lines);
+
+ SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle|WS_HSCROLL|ES_AUTOHSCROLL);
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos);
+ DestroyWindow(hwnd);
+
+ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle|WS_HSCROLL,
+ 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL);
+ ok(hwnd != NULL, "error: %d\n", (int) GetLastError());
+
+ res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text);
+ ok(res, "WM_SETTEXT failed.\n");
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ todo_wine ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos);
+ lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0);
+ todo_wine ok(lines > 1, "Line was expected to wrap (lines=%d).\n", lines);
+
+ SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle|WS_HSCROLL|ES_AUTOHSCROLL);
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ todo_wine ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos);
+ DestroyWindow(hwnd);
+
+ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle|ES_AUTOHSCROLL,
+ 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL);
+ ok(hwnd != NULL, "error: %d\n", (int) GetLastError());
+ res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text);
+ ok(res, "WM_SETTEXT failed.\n");
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos);
+
+ SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle);
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos);
+ DestroyWindow(hwnd);
+
+ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL,
+ dwCommonStyle|WS_HSCROLL|ES_AUTOHSCROLL,
+ 0, 0, 200, 80, NULL, NULL, hmoduleRichEdit, NULL);
+ ok(hwnd != NULL, "error: %d\n", (int) GetLastError());
+ res = SendMessage(hwnd, WM_SETTEXT, 0, (LPARAM) text);
+ ok(res, "WM_SETTEXT failed.\n");
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos);
+
+ SetWindowLong(hwnd, GWL_STYLE, dwCommonStyle);
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos);
+
+ /* Test the effect of EM_SETTARGETDEVICE on word wrap. */
+ res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 1);
+ todo_wine ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(!pos, "pos=%d indicating word wrap when none is expected.\n", pos);
+
+ res = SendMessage(hwnd, EM_SETTARGETDEVICE, 0, 0);
+ todo_wine ok(res, "EM_SETTARGETDEVICE failed (returned %d).\n", res);
+ pos = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM) &point);
+ ok(pos, "pos=%d indicating no word wrap when it is expected.\n", pos);
+ DestroyWindow(hwnd);
+
+ /* Test to see if wrapping happens with redraw disabled. */
+ hwnd = CreateWindow(RICHEDIT_CLASS10A, NULL, dwCommonStyle,
+ 0, 0, 400, 80, NULL, NULL, hmoduleRichEdit, NULL);
+ ok(hwnd != NULL, "error: %d\n", (int) GetLastError());
+ ok(IsWindowVisible(hwnd), "Window should be visible.\n");
+ SendMessage(hwnd, WM_SETREDRAW, FALSE, 0);
+ /* redraw is disabled by making the window invisible. */
+ ok(!IsWindowVisible(hwnd), "Window shouldn't be visible.\n");
+ res = SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) text);
+ ok(res, "EM_REPLACESEL failed.\n");
+ MoveWindow(hwnd, 0, 0, 100, 80, TRUE);
+ SendMessage(hwnd, WM_SETREDRAW, TRUE, 0);
+ /* Wrapping didn't happen while redraw was disabled. */
+ lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0);
+ todo_wine ok(lines == 1, "Line wasn't expected to wrap (lines=%d).\n", lines);
+ /* There isn't even a rewrap from resizing the window. */
+ lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0);
+ todo_wine ok(lines == 1, "Line wasn't expected to wrap (lines=%d).\n", lines);
+ res = SendMessage(hwnd, EM_REPLACESEL, FALSE, (LPARAM) text);
+ ok(res, "EM_REPLACESEL failed.\n");
+ lines = SendMessage(hwnd, EM_GETLINECOUNT, 0, 0);
+ ok(lines > 1, "Line was expected to wrap (lines=%d).\n", lines);
+
+ DestroyWindow(hwnd);
+}
+
START_TEST( editor )
{
@@ -838,6 +943,7 @@ START_TEST( editor )
test_EM_LINELENGTH();
test_EM_FINDTEXT();
test_EM_POSFROMCHAR();
+ test_word_wrap();
/* Set the environment variable WINETEST_RICHED32 to keep windows
* responsive and open for 30 seconds. This is useful for debugging.
More information about the wine-cvs
mailing list