Commit 9b7825f6 authored by Dylan Smith's avatar Dylan Smith Committed by Alexandre Julliard

richedit: Added test for scroll position after EM_SETTEXTEX.

parent 9b5f3ed8
......@@ -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 */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment