From 17fdd394feb8cf4ac16a698b99f5938c15316331 Mon Sep 17 00:00:00 2001 From: Anatoly Lyutin Date: Fri, 20 Jun 2008 16:17:03 +0400 Subject: [PATCH] Additional tests for SetFocus() --- dlls/user32/tests/msg.c | 238 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 238 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 0aaa7d7..57e8c93 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -9977,6 +9977,243 @@ static void test_nullCallback(void) DestroyWindow(hwnd); } +/* SetFocus( 0 ) Visible parent, visible child */ +static const struct message SetFocusSeq_1[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent|wparam, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 }, + { 0 } +}; + +/* SetFocus( hwnd ) Visible parent, visible child */ +static const struct message SetFocusSeq_2[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 2 }, + { WM_SETFOCUS, sent }, + { 0 } +}; + +/* SetFocus( child ) Visible parent, visible child */ +static const struct message SetFocusSeq_3[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_SETFOCUS, sent }, + { 0 } +}; + +/* SetFocus( 0 ) Invisible parent, visible child */ +static const struct message SetFocusSeq_4[] = +{ + { 0 } +}; + +/* SetFocus( hwnd ) Invisible parent, visible child */ +static const struct message SetFocusSeq_5[] = +{ + { HCBT_SETFOCUS, hook }, + { HCBT_ACTIVATE, hook }, + { WM_WINDOWPOSCHANGING, sent|wparam, SWP_NOSIZE|SWP_NOMOVE }, + { WM_WINDOWPOSCHANGED, sent|wparam, SWP_NOCLIENTMOVE|SWP_NOCLIENTSIZE|SWP_NOREDRAW|SWP_NOMOVE|SWP_NOSIZE }, + { WM_ACTIVATEAPP, sent|wparam, 1 }, + { WM_NCACTIVATE, sent|wparam, 1 }, + { WM_ACTIVATE, sent|wparam, 1 }, + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|optional|defwinproc, 1 }, + { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 2 }, + { WM_SETFOCUS, sent|defwinproc }, + { WM_KILLFOCUS, sent }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_SETFOCUS, sent }, + { 0 } +}; + +/* SetFocus( child ) Invisible parent, visible child */ +static const struct message SetFocusSeq_6[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_SETFOCUS, sent }, + { 0 } +}; + +/* SetFocus( 0 ) Invisible parent, invisible child */ +static const struct message SetFocusSeq_7[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent|wparam, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 }, + { 0 } +}; + +/* SetFocus( hwnd ) Invisible parent, invisible child */ +static const struct message SetFocusSeq_8[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 2 }, + { WM_SETFOCUS, sent|wparam, 0 }, + { 0 } +}; + +/* SetFocus( child ) Invisible parent, invisible child */ +static const struct message SetFocusSeq_9[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_SETFOCUS, sent }, + { 0 } +}; + +/* SetFocus( 0 ) Visible parent, invisible child */ +static const struct message SetFocusSeq_10[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent|wparam, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 1 }, + { 0 } +}; + +/* SetFocus( hwnd ) Visible parent, invisible child */ +static const struct message SetFocusSeq_11[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_IME_NOTIFY, sent|wparam|optional|defwinproc, 2 }, + { WM_SETFOCUS, sent|wparam, 0 }, + { 0 } +}; + +/* SetFocus( child ) Visible parent, invisible child */ +static const struct message SetFocusSeq_12[] = +{ + { HCBT_SETFOCUS, hook }, + { WM_KILLFOCUS, sent }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 0 }, + { WM_IME_SETCONTEXT, sent|wparam|optional, 1 }, + { WM_SETFOCUS, sent }, + { 0 } +}; + +static void test_SetFocus(void) +{ + HWND hwnd, child; + + hwnd = CreateWindowExA(0, "TestWindowClass", "Test SetForegroundWindow", + WS_OVERLAPPEDWINDOW | WS_VISIBLE, + 100, 100, 200, 200, 0, 0, 0, NULL); + ok (hwnd != 0, "Failed to create overlapped window\n"); + flush_sequence(); + + child = CreateWindowEx(0, "TestWindowClass", NULL, + WS_CHILD | WS_BORDER | WS_VISIBLE, + 50, 50, 200, 200, hwnd, + NULL, NULL, 0); + assert(child); + + flush_events(); + flush_sequence(); + + trace("SetFocus( 0 ) Visible parent, visible child\n"); + SetFocus( 0 ); + ok(!GetFocus(), "Failed to set focus to 0\n"); + ok_sequence(SetFocusSeq_1, "SetFocus( 0 ) Visible parent, visible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Visible parent, visible child\n"); + SetFocus( hwnd ); + ok(hwnd == GetFocus(), "Failed to set focus to visible parent\n"); + ok_sequence(SetFocusSeq_2, "SetFocus( hwnd ) Visible parent, visible child", FALSE); + flush_sequence(); + + trace("SetFocus( child ) Visible parent, visible child\n"); + SetFocus( child ); + ok(child == GetFocus(), "Failed to set focus to visible child\n"); + ok_sequence(SetFocusSeq_3, "SetFocus( child ) Visible parent, visible child", FALSE); + flush_sequence(); + + ShowWindow( hwnd, SW_HIDE ); + flush_sequence(); + + trace("SetFocus( 0 ) Invisible parent, visible child\n"); + SetFocus( 0 ); + ok(!GetFocus(), "Failed to set focus to 0\n"); + ok_sequence(SetFocusSeq_4, "SetFocus( 0 ) Invisible parent, visible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Invisible parent, visible child\n"); + SetFocus( hwnd ); + ok(hwnd == GetFocus(), "Failed to set focus to invisible parent\n"); + ok_sequence(SetFocusSeq_5, "SetFocus( hwnd ) Invisible parent, visible child", TRUE); + flush_sequence(); + + trace("SetFocus( child ) Invisible parent, visible child\n"); + SetFocus( child ); + ok(child == GetFocus(), "Failed to set focus to visible child\n"); + ok_sequence(SetFocusSeq_6, "SetFocus( child ) Invisible parent, visible child", FALSE); + flush_sequence(); + + ShowWindow( child, SW_HIDE ); + flush_sequence(); + + trace("SetFocus( 0 ) Invisible parent, invisible child\n"); + SetFocus( 0 ); + ok(!GetFocus(), "Failed to set focus to 0\n"); + ok_sequence(SetFocusSeq_7, "SetFocus( 0 ) Invisible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Invisible parent, invisible child\n"); + SetFocus( hwnd ); + ok(hwnd == GetFocus(), "Failed to set focus to invisible parent\n"); + ok_sequence(SetFocusSeq_8, "SetFocus( hwnd ) Invisible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( child ) Invisible parent, invisible child\n"); + SetFocus( child ); + ok(child == GetFocus(), "Failed to set focus to visible child\n"); + ok_sequence(SetFocusSeq_9, "SetFocus( child ) Invisible parent, invisible child", FALSE); + flush_sequence(); + + ShowWindow( hwnd, SW_SHOW ); + flush_sequence(); + + trace("SetFocus( 0 ) Visible parent, invisible child\n"); + SetFocus( 0 ); + ok(!GetFocus(), "Failed to set focus to 0\n"); + ok_sequence(SetFocusSeq_10, "SetFocus( 0 ) Visible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Visible parent, invisible child\n"); + SetFocus( hwnd ); + ok(hwnd == GetFocus(), "Failed to set focus to visible parent\n"); + ok_sequence(SetFocusSeq_11, "SetFocus( hwnd ) Visible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( child ) Visible parent, invisible child\n"); + SetFocus( child ); + ok(child == GetFocus(), "Failed to set focus to invisible child\n"); + ok_sequence(SetFocusSeq_12, "SetFocus( child ) Visible parent, invisible child", FALSE); + flush_sequence(); + + trace("done\n"); + + DestroyWindow(child); + DestroyWindow(hwnd); +} + static const struct message SetForegroundWindowSeq[] = { { WM_NCACTIVATE, sent|wparam, 0 }, @@ -10831,6 +11068,7 @@ START_TEST(msg) test_sys_menu(); test_dialog_messages(); test_nullCallback(); + test_SetFocus(); test_SetForegroundWindow(); test_dbcs_wm_char(); test_menu_messages(); -- 1.5.4.5.GIT