Module: wine Branch: master Commit: 9b7825f6f66fd8264d8c0600fab95c540ae0dec0 URL: http://source.winehq.org/git/wine.git/?a=commit;h=9b7825f6f66fd8264d8c0600fa...
Author: Dylan Smith dylan.ah.smith@gmail.com Date: Wed Jan 21 10:09:58 2009 -0500
richedit: Added test for scroll position after EM_SETTEXTEX.
---
dlls/riched20/tests/editor.c | 74 +++++++++++++++++++++++++++++++++++++++++- 1 files changed, 73 insertions(+), 1 deletions(-)
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c index aa78e2a..244ab09 100644 --- a/dlls/riched20/tests/editor.c +++ b/dlls/riched20/tests/editor.c @@ -3345,7 +3345,9 @@ static void test_EM_STREAMOUT(void)
static void test_EM_SETTEXTEX(void) { - HWND hwndRichEdit = new_richedit(NULL); + HWND hwndRichEdit, parent; + SCROLLINFO si; + int sel_start, sel_end; SETTEXTEX setText; GETTEXTEX getText; WCHAR TestItem1[] = {'T', 'e', 's', 't', @@ -3392,6 +3394,76 @@ static void test_EM_SETTEXTEX(void) int result; CHARRANGE cr; EDITSTREAM es; + WNDCLASSA cls; + + /* Test the scroll position with and without a parent window. + * + * For some reason the scroll position is 0 after EM_SETTEXTEX + * with the ST_SELECTION flag only when the control has a parent + * window, even though the selection is at the end. */ + cls.style = 0; + cls.lpfnWndProc = DefWindowProcA; + cls.cbClsExtra = 0; + cls.cbWndExtra = 0; + cls.hInstance = GetModuleHandleA(0); + cls.hIcon = 0; + cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + cls.hbrBackground = GetStockObject(WHITE_BRUSH); + cls.lpszMenuName = NULL; + cls.lpszClassName = "ParentTestClass"; + if(!RegisterClassA(&cls)) assert(0); + + parent = CreateWindow(cls.lpszClassName, NULL, WS_POPUP|WS_VISIBLE, + 0, 0, 200, 60, NULL, NULL, NULL, NULL); + ok (parent != 0, "Failed to create parent window\n"); + + hwndRichEdit = CreateWindowEx(0, + RICHEDIT_CLASS, NULL, + ES_MULTILINE|WS_VSCROLL|WS_VISIBLE|WS_CHILD, + 0, 0, 200, 60, parent, NULL, + hmoduleRichEdit, NULL); + + setText.codepage = CP_ACP; + setText.flags = ST_SELECTION; + SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, + (LPARAM)"{\rtf 1\par 2\par 3\par 4\par 5\par 6\par 7\par 8\par 9\par}"); + si.cbSize = sizeof(si); + si.fMask = SIF_ALL; + GetScrollInfo(hwndRichEdit, SB_VERT, &si); + todo_wine ok(si.nPos == 0, "Position is incorrectly at %d\n", si.nPos); + SendMessage(hwndRichEdit, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == 18, "Selection start incorrectly at %d\n", sel_start); + ok(sel_end == 18, "Selection end incorrectly at %d\n", sel_end); + + DestroyWindow(parent); + + /* Test without a parent window */ + hwndRichEdit = new_richedit(NULL); + setText.codepage = CP_ACP; + setText.flags = ST_SELECTION; + SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, + (LPARAM)"{\rtf 1\par 2\par 3\par 4\par 5\par 6\par 7\par 8\par 9\par}"); + si.cbSize = sizeof(si); + si.fMask = SIF_ALL; + GetScrollInfo(hwndRichEdit, SB_VERT, &si); + ok(si.nPos != 0, "Position is incorrectly at %d\n", si.nPos); + SendMessage(hwndRichEdit, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == 18, "Selection start incorrectly at %d\n", sel_start); + ok(sel_end == 18, "Selection end incorrectly at %d\n", sel_end); + + /* The scroll position should also be 0 after EM_SETTEXTEX with ST_DEFAULT, + * but this time it is because the selection is at the beginning. */ + setText.codepage = CP_ACP; + setText.flags = ST_DEFAULT; + SendMessage(hwndRichEdit, EM_SETTEXTEX, (WPARAM)&setText, + (LPARAM)"{\rtf 1\par 2\par 3\par 4\par 5\par 6\par 7\par 8\par 9\par}"); + si.cbSize = sizeof(si); + si.fMask = SIF_ALL; + GetScrollInfo(hwndRichEdit, SB_VERT, &si); + ok(si.nPos == 0, "Position is incorrectly at %d\n", si.nPos); + SendMessage(hwndRichEdit, EM_GETSEL, (WPARAM)&sel_start, (LPARAM)&sel_end); + ok(sel_start == 0, "Selection start incorrectly at %d\n", sel_start); + ok(sel_end == 0, "Selection end incorrectly at %d\n", sel_end);
setText.codepage = 1200; /* no constant for unicode */ getText.codepage = 1200; /* no constant for unicode */