From 0c3a1f70d651cd4bf7eaaa6957d08ec7efb20c9b Mon Sep 17 00:00:00 2001 From: Anatoly Lyutin Date: Thu, 19 Jun 2008 12:58:48 +0400 Subject: [PATCH] Add test for SetFocus() --- dlls/user32/tests/msg.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 222 insertions(+), 0 deletions(-) diff --git a/dlls/user32/tests/msg.c b/dlls/user32/tests/msg.c index 962aa5c..8f7e319 100644 --- a/dlls/user32/tests/msg.c +++ b/dlls/user32/tests/msg.c @@ -9935,6 +9935,227 @@ 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 }, + { 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[] = +{ + { 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 }, + { WM_NCACTIVATE, sent }, + { WM_ACTIVATE, sent }, + { 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 }, + { 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 }, + { 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 }, + { 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 }, + { 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; + 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_sequence(SetFocusSeq_1, "SetFocus( 0 ) Visible parent, visible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Visible parent, visible child\n"); + SetFocus( child ); + ok_sequence(SetFocusSeq_2, "SetFocus( child ) Visible parent, visible child", FALSE); + flush_sequence(); + + trace("SetFocus( child ) Visible parent, visible child\n"); + SetFocus( child ); + 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_sequence(SetFocusSeq_4, "SetFocus( 0 ) Invisible parent, visible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Invisible parent, visible child\n"); + SetFocus( hwnd ); + ok_sequence(SetFocusSeq_5, "SetFocus( hwnd ) Invisible parent, visible child", TRUE); + flush_sequence(); + + trace("SetFocus( child ) Invisible parent, visible child\n"); + SetFocus( child ); + 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_sequence(SetFocusSeq_7, "SetFocus( 0 ) Invisible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Invisible parent, invisible child\n"); + SetFocus( hwnd ); + ok_sequence(SetFocusSeq_8, "SetFocus( hwnd ) Invisible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( child ) Invisible parent, invisible child\n"); + SetFocus( child ); + 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_sequence(SetFocusSeq_10, "SetFocus( 0 ) Visible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( hwnd ) Visible parent, invisible child\n"); + SetFocus( hwnd ); + ok_sequence(SetFocusSeq_11, "SetFocus( hwnd ) Visible parent, invisible child", FALSE); + flush_sequence(); + + trace("SetFocus( child ) Visible parent, invisible child\n"); + SetFocus( child ); + 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 }, @@ -10789,6 +11010,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