Sebastian Lackner : user32/tests: Add single-threaded tests for WM_[ GET|SET]TEXT and [Get|Set]WindowText.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Nov 18 10:25:19 CST 2014


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

Author: Sebastian Lackner <sebastian at fds-team.de>
Date:   Tue Nov 18 05:11:10 2014 +0100

user32/tests: Add single-threaded tests for WM_[GET|SET]TEXT and [Get|Set]WindowText.

---

 dlls/user32/tests/win.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 24cbd78..6922cd0 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -64,6 +64,7 @@ static BOOL (WINAPI *pMirrorRgn)(HWND hwnd, HRGN hrgn);
 
 static BOOL test_lbuttondown_flag;
 static DWORD num_gettext_msgs;
+static DWORD num_settext_msgs;
 static HWND hwndMessage;
 static HWND hwndMain, hwndMain2;
 static HHOOK hhook;
@@ -798,6 +799,9 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
         case WM_GETTEXT:
             num_gettext_msgs++;
             break;
+        case WM_SETTEXT:
+            num_settext_msgs++;
+            break;
     }
 
     return DefWindowProcA(hwnd, msg, wparam, lparam);
@@ -5691,12 +5695,57 @@ static void test_ShowWindow(void)
 
 static void test_gettext(void)
 {
+    BOOL success;
+    char buf[32];
+    INT buf_len;
     HWND hwnd;
     LRESULT r;
 
     hwnd = CreateWindowExA( 0, "MainWindowClass", "caption", WS_POPUP, 0, 0, 0, 0, 0, 0, 0, NULL );
     ok( hwnd != 0, "CreateWindowExA error %d\n", GetLastError() );
 
+    /* test GetWindowTextA */
+    num_gettext_msgs = 0;
+    memset( buf, 0, sizeof(buf) );
+    buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
+    ok( buf_len != 0, "expected a nonempty window text\n" );
+    ok( !strcmp(buf, "caption"), "got wrong window text '%s'\n", buf );
+    ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
+
+    /* test WM_GETTEXT */
+    num_gettext_msgs = 0;
+    memset( buf, 0, sizeof(buf) );
+    r = SendMessageA( hwnd, WM_GETTEXT, sizeof(buf), (LONG_PTR)buf );
+    ok( r != 0, "expected a nonempty window text\n" );
+    ok( !strcmp(buf, "caption"), "got wrong window text '%s'\n", buf );
+    ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
+
+    /* test SetWindowTextA */
+    num_settext_msgs = 0;
+    success = SetWindowTextA( hwnd, "new_caption" );
+    ok( success, "SetWindowTextA failed\n" );
+    ok( num_settext_msgs == 1, "got %u WM_SETTEXT messages\n", num_settext_msgs );
+
+    num_gettext_msgs = 0;
+    memset( buf, 0, sizeof(buf) );
+    buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
+    ok( buf_len != 0, "expected a nonempty window text\n" );
+    ok( !strcmp(buf, "new_caption"), "got wrong window text '%s'\n", buf );
+    ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
+
+    /* test WM_SETTEXT */
+    num_settext_msgs = 0;
+    r = SendMessageA( hwnd, WM_SETTEXT, 0, (ULONG_PTR)"another_caption" );
+    ok( r != 0, "WM_SETTEXT failed\n" );
+    ok( num_settext_msgs == 1, "got %u WM_SETTEXT messages\n", num_settext_msgs );
+
+    num_gettext_msgs = 0;
+    memset( buf, 0, sizeof(buf) );
+    buf_len = GetWindowTextA( hwnd, buf, sizeof(buf) );
+    ok( buf_len != 0, "expected a nonempty window text\n" );
+    ok( !strcmp(buf, "another_caption"), "got wrong window text '%s'\n", buf );
+    ok( num_gettext_msgs == 1, "got %u WM_GETTEXT messages\n", num_gettext_msgs );
+
     /* seems to crash on every modern Windows version */
     if (0)
     {




More information about the wine-cvs mailing list