user32/tests: Add tests for radio button WM_SETFOCUS.

This commit is contained in:
Fabian Maurer 2024-05-31 00:55:45 +02:00
parent 7f59af2684
commit 8bcc754e11

View file

@ -20526,6 +20526,103 @@ static void test_hook_changing_window_proc(void)
DestroyWindow( hwnd ); DestroyWindow( hwnd );
} }
static void test_radiobutton_focus(void)
{
HWND hwnd, button;
DWORD style;
MSG msg;
int i;
DWORD types[] = { BS_RADIOBUTTON, BS_AUTORADIOBUTTON };
static const struct message set_focus_default_seq[] =
{
{ WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
{ WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_BUTTON, BN_CLICKED) },
{ 0 }
};
static const struct message set_focus_checked_seq[] =
{
{ WM_COMMAND, sent|parent|wparam, MAKEWPARAM(ID_BUTTON, BN_SETFOCUS) },
{ 0 }
};
static const struct message WM_LBUTTONDOWN_seq[] =
{
{ WM_KILLFOCUS, sent|parent },
{ WM_IME_SETCONTEXT, sent|optional|parent },
{ WM_IME_SETCONTEXT, sent|optional|defwinproc },
{ WM_COMMAND, sent|parent },
{ 0 }
};
static const struct message set_focus_without_notify_seq[] =
{
{ WM_COMMAND, sent|parent|wparam, ID_BUTTON },
{ 0 }
};
hwnd = CreateWindowExA(0, "TestParentClass", "Test parent", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
100, 100, 200, 200, 0, 0, 0, NULL);
ok(hwnd != 0, "Failed to create parent window\n");
for (i = 0; i < ARRAY_SIZE(types); i++)
{
/* Test default button */
style = types[i] | WS_CHILD | WS_VISIBLE | BS_NOTIFY;
button = CreateWindowExA(0, WC_BUTTONA, "test", style, 0, 0, 50, 14, hwnd, (HMENU)ID_BUTTON, 0, NULL);
ok(button != NULL, "failed to create a button, 0x%08lx, %p\n", style, hwnd);
flush_events();
flush_sequence();
SendMessageA(button, WM_SETFOCUS, 0, 0);
flush_events();
ok_sequence(set_focus_default_seq, "WM_SETFOCUS on default radiobutton", TRUE);
DestroyWindow(button);
/* Test already checked button */
button = CreateWindowExA(0, WC_BUTTONA, "test", style, 0, 0, 50, 14, hwnd, (HMENU)ID_BUTTON, 0, NULL);
SendMessageA(button, BM_SETCHECK, BST_CHECKED, 0);
flush_events();
flush_sequence();
SendMessageA(button, WM_SETFOCUS, 0, 0);
flush_events();
ok_sequence(set_focus_checked_seq, "WM_SETFOCUS on checked radiobutton", FALSE);
DestroyWindow(button);
/* Test already focused button */
button = CreateWindowExA(0, WC_BUTTONA, "test", style, 0, 0, 50, 14, hwnd, (HMENU)ID_BUTTON, 0, NULL);
SendMessageA(button, WM_SETFOCUS, 0, 0);
SendMessageA(button, BM_SETCHECK, BST_UNCHECKED, 0);
flush_events();
flush_sequence();
SendMessageA(button, WM_SETFOCUS, 0, 0);
flush_events();
ok_sequence(set_focus_default_seq, "WM_SETFOCUS on focused radiobutton", TRUE);
DestroyWindow(button);
/* Test WM_LBUTTONDOWN */
button = CreateWindowExA(0, WC_BUTTONA, "test", style, 0, 0, 50, 14, hwnd, (HMENU)ID_BUTTON, 0, NULL);
flush_events();
flush_sequence();
SendMessageA(button, WM_LBUTTONDOWN, 0, 0);
while (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessageA(&msg);
ok_sequence(WM_LBUTTONDOWN_seq, "WM_LBUTTONDOWN on radiobutton", FALSE);
DestroyWindow(button);
/* Test without BS_NOTIFY */
style = types[i] | WS_CHILD | WS_VISIBLE;
button = CreateWindowExA(0, WC_BUTTONA, "test", style, 0, 0, 50, 14, hwnd, (HMENU)ID_BUTTON, 0, NULL);
flush_events();
flush_sequence();
SendMessageA(button, WM_SETFOCUS, 0, 0);
flush_events();
ok_sequence(set_focus_without_notify_seq, "WM_SETFOCUS on radiobutton withouth BS_NOTIFY", TRUE);
DestroyWindow(button);
}
DestroyWindow(hwnd);
}
START_TEST(msg) START_TEST(msg)
{ {
char **test_argv; char **test_argv;
@ -20573,6 +20670,7 @@ START_TEST(msg)
test_setparent_status(); test_setparent_status();
test_InSendMessage(); test_InSendMessage();
test_SetFocus(); test_SetFocus();
test_radiobutton_focus();
test_SetParent(); test_SetParent();
test_PostMessage(); test_PostMessage();
test_broadcast(); test_broadcast();