2006-01-31 Thomas Kho * dlls/riched20/tests/editor.c: riched20: added test for EM_SCROLLCARET messages Signed-off-by: Thomas Kho diff -Naur 20060131-testpatch/dlls/riched20/tests/editor.c sc_conftest/dlls/riched20/tests/editor.c --- 20060131-testpatch/dlls/riched20/tests/editor.c 2006-01-31 16:53:24.074021000 -0800 +++ sc_conftest/dlls/riched20/tests/editor.c 2006-01-31 16:50:16.106175000 -0800 @@ -163,6 +163,86 @@ DestroyWindow(hwndRichEdit); } +static int get_scroll_pos_y(HWND hwnd) +{ + POINT p; + p.x = -1; + p.y = -1; + SendMessage(hwnd, EM_GETSCROLLPOS, 0, (LPARAM) &p); + todo_wine { + ok(p.x != -1 && p.y != -1, "p.x:%d p.y:%d\n", p.x, p.y); + } + return p.y; +} + +static void move_cursor(HWND hwnd, long charindex) +{ + CHARRANGE cr; + cr.cpMax = charindex; + cr.cpMin = charindex; + SendMessage(hwnd, EM_EXSETSEL, 0, (LPARAM) &cr); +} + +static void line_scroll(HWND hwnd, int amount) +{ + SendMessage(hwnd, EM_LINESCROLL, 0, amount); +} + +static void test_EM_SCROLLCARET(void) +{ + int prevY, curY; + HWND hwndRichEdit = new_richedit(NULL); + const char text[] = "aa\n" + "this is a long line of text that should be longer than one " + "screen-width\n" + "cc\n" + "dd\n" + "ee\n" + "ff\n" + "gg\n" + "hh\n"; + + /* can't verify this */ + SendMessage(hwndRichEdit, EM_SCROLLCARET, 0, 0); + + SendMessage(hwndRichEdit, WM_SETTEXT, 0, (LPARAM) text); + + /* caret above visible window */ + line_scroll(hwndRichEdit, 3); + prevY = get_scroll_pos_y(hwndRichEdit); + SendMessage(hwndRichEdit, EM_SCROLLCARET, 0, 0); + curY = get_scroll_pos_y(hwndRichEdit); + todo_wine { + ok(prevY != curY, "%d == %d\n", prevY, curY); + } + + /* caret below visible window */ + move_cursor(hwndRichEdit, sizeof(text) - 1); + line_scroll(hwndRichEdit, -3); + prevY = get_scroll_pos_y(hwndRichEdit); + SendMessage(hwndRichEdit, EM_SCROLLCARET, 0, 0); + curY = get_scroll_pos_y(hwndRichEdit); + todo_wine { + ok(prevY != curY, "%d == %d\n", prevY, curY); + } + + /* caret in visible window */ + move_cursor(hwndRichEdit, sizeof(text) - 2); + prevY = get_scroll_pos_y(hwndRichEdit); + SendMessage(hwndRichEdit, EM_SCROLLCARET, 0, 0); + curY = get_scroll_pos_y(hwndRichEdit); + ok(prevY == curY, "%d != %d\n", prevY, curY); + + /* caret still in visible window */ + line_scroll(hwndRichEdit, -1); + prevY = get_scroll_pos_y(hwndRichEdit); + SendMessage(hwndRichEdit, EM_SCROLLCARET, 0, 0); + curY = get_scroll_pos_y(hwndRichEdit); + ok(prevY == curY, "%d != %d\n", prevY, curY); + + DestroyWindow(hwndRichEdit); +} + START_TEST( editor ) { MSG msg; @@ -175,6 +255,7 @@ test_EM_FINDTEXT(); test_EM_FINDTEXTEX(); + test_EM_SCROLLCARET(); /* Set the environment variable WINETEST_RICHED20 to keep windows * responsive and open for 30 seconds. This is useful for debugging.