Bruno Jesus : user32/tests: Add SetCaretPos/GetCaretPos tests.

Alexandre Julliard julliard at winehq.org
Thu Sep 8 14:52:11 CDT 2011


Module: wine
Branch: master
Commit: 2b6f0b9af73a64f98fa66f9c2749c4b078c7765a
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=2b6f0b9af73a64f98fa66f9c2749c4b078c7765a

Author: Bruno Jesus <00cpxxx at gmail.com>
Date:   Wed Sep  7 23:59:10 2011 -0300

user32/tests: Add SetCaretPos/GetCaretPos tests.

---

 dlls/user32/tests/edit.c |   38 +++++++++++++++++++++++++++++++++++---
 1 files changed, 35 insertions(+), 3 deletions(-)

diff --git a/dlls/user32/tests/edit.c b/dlls/user32/tests/edit.c
index c6c815a..934fc52 100644
--- a/dlls/user32/tests/edit.c
+++ b/dlls/user32/tests/edit.c
@@ -736,9 +736,10 @@ static void test_edit_control_1(void)
  */
 static void test_edit_control_2(void)
 {
-    HWND hwndMain;
+    HWND hwndMain, phwnd;
     char szLocalString[MAXLEN];
-    LONG r;
+    LONG r, w = 150, h = 50;
+    POINT cpos;
 
     /* Create main and edit windows. */
     hwndMain = CreateWindow(szEditTest2Class, "ET2", WS_OVERLAPPEDWINDOW,
@@ -749,7 +750,7 @@ static void test_edit_control_2(void)
 
     hwndET2 = CreateWindow("EDIT", NULL,
                            WS_CHILD|WS_BORDER|ES_LEFT|ES_AUTOHSCROLL,
-                           0, 0, 150, 50, /* important this not be 0 size. */
+                           0, 0, w, h, /* important this not be 0 size. */
                            hwndMain, (HMENU) ID_EDITTEST2, hinst, NULL);
     assert(hwndET2);
     if (winetest_interactive)
@@ -768,6 +769,37 @@ static void test_edit_control_2(void)
     ok(lstrcmp(szLocalString, "bar")==0,
        "Wrong contents of edit: %s\n", szLocalString);
 
+    /* try setting the caret before it's visible */
+    r = SetCaretPos(0, 0);
+    todo_wine ok(0 == r, "SetCaretPos succeeded unexpectedly, expected: 0, got: %d\n", r);
+    phwnd = SetFocus(hwndET2);
+    ok(phwnd != NULL, "SetFocus failed unexpectedly, expected non-zero, got NULL");
+    r = SetCaretPos(0, 0);
+    ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    r = GetCaretPos(&cpos);
+    ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    ok(cpos.x == 0 && cpos.y == 0, "Wrong caret position, expected: (0,0), got: (%d,%d)\n", cpos.x, cpos.y);
+    r = SetCaretPos(-1, -1);
+    ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    r = GetCaretPos(&cpos);
+    ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    ok(cpos.x == -1 && cpos.y == -1, "Wrong caret position, expected: (-1,-1), got: (%d,%d)\n", cpos.x, cpos.y);
+    r = SetCaretPos(w << 1, h << 1);
+    ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    r = GetCaretPos(&cpos);
+    ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    ok(cpos.x == (w << 1) && cpos.y == (h << 1), "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w << 1, h << 1, cpos.x, cpos.y);
+    r = SetCaretPos(w, h);
+    ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    r = GetCaretPos(&cpos);
+    ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    ok(cpos.x == w && cpos.y == h, "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w, h, cpos.x, cpos.y);
+    r = SetCaretPos(w - 1, h - 1);
+    ok(1 == r, "SetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    r = GetCaretPos(&cpos);
+    ok(1 == r, "GetCaretPos failed unexpectedly, expected: 1, got: %d\n", r);
+    ok(cpos.x == (w - 1) && cpos.y == (h - 1), "Wrong caret position, expected: (%d,%d), got: (%d,%d)\n", w - 1, h - 1, cpos.x, cpos.y);
+
     /* OK, done! */
     DestroyWindow (hwndET2);
     DestroyWindow (hwndMain);




More information about the wine-cvs mailing list