richedit: Tested EM_CHARFROMPOS with position outside of control.

Dylan Smith dylan.ah.smith at gmail.com
Sun Jan 11 01:59:01 CST 2009


MSDN documents the return value as being -1 in this case, but this is
not how it was implemented in native richedit control.
---
 dlls/riched20/tests/editor.c |   40 +++++++++++++++++++++++++++++++++++++---
 1 files changed, 37 insertions(+), 3 deletions(-)
-------------- next part --------------
diff --git a/dlls/riched20/tests/editor.c b/dlls/riched20/tests/editor.c
index 11930ad..70ae327 100644
--- a/dlls/riched20/tests/editor.c
+++ b/dlls/riched20/tests/editor.c
@@ -5692,17 +5692,51 @@ static void test_EM_CHARFROMPOS(void)
 {
     HWND hwnd;
     int result;
+    RECT rcClient;
     POINTL point;
     point.x = 0;
-    point.y = 50;
+    point.y = 40;
 
     /* multi-line control inserts CR normally */
     hwnd = new_richedit(NULL);
     result = SendMessageA(hwnd, WM_SETTEXT, 0,
-                          (LPARAM)"one two three four five six seven");
+                          (LPARAM)"one two three four five six seven\reight");
 
+    GetClientRect(hwnd, &rcClient);
+
+    result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point);
+    ok(result == 34, "expected character index of 34 but got %d\n", result);
+
+    /* Test with points outside the bounds of the richedit control. */
+    point.x = -1;
+    point.y = 40;
+    result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point);
+    todo_wine ok(result == 34, "expected character index of 34 but got %d\n", result);
+
+    point.x = 1000;
+    point.y = 0;
+    result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point);
+    todo_wine ok(result == 33, "expected character index of 33 but got %d\n", result);
+
+    point.x = 1000;
+    point.y = 40;
+    result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point);
+    todo_wine ok(result == 39, "expected character index of 39 but got %d\n", result);
+
+    point.x = 1000;
+    point.y = -1;
+    result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point);
+    todo_wine ok(result == 0, "expected character index of 0 but got %d\n", result);
+
+    point.x = 1000;
+    point.y = rcClient.bottom + 1;
+    result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point);
+    todo_wine ok(result == 34, "expected character index of 34 but got %d\n", result);
+
+    point.x = 1000;
+    point.y = rcClient.bottom;
     result = SendMessage(hwnd, EM_CHARFROMPOS, 0, (LPARAM)&point);
-    ok(result == 0, "expected character index of 0 but got %d\n", result);
+    todo_wine ok(result == 39, "expected character index of 39 but got %d\n", result);
 
     DestroyWindow(hwnd);
 }


More information about the wine-patches mailing list