user32/tests: Add single-threaded tests for WM_[GET|SET]TEXT and [Get|Set]WindowText.
This commit is contained in:
parent
0a6e56bdc6
commit
d6bdae11df
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue