From 3a934e7323e82d35018b7f0dcf55abe7b39e8128 Mon Sep 17 00:00:00 2001 From: Dmitry Timoshkov Date: Fri, 27 Jun 2008 19:05:16 +0900 Subject: [PATCH] user32: Add a test for focus behaviour on minimize/restore. --- dlls/user32/tests/win.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index cac34f73fef..6cb784feda7 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -2164,9 +2164,23 @@ static void test_vis_rgn( HWND hwnd ) ReleaseDC( hwnd, hdc ); } +static LRESULT WINAPI set_focus_on_activate_proc(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) +{ + if (msg == WM_ACTIVATE && LOWORD(wp) == WA_ACTIVE) + { + HWND child = GetWindow(hwnd, GW_CHILD); + ok(child != 0, "couldn't find child window\n"); + SetFocus(child); + ok(GetFocus() == child, "Focus should be on child %p\n", child); + return 0; + } + return DefWindowProc(hwnd, msg, wp, lp); +} + static void test_SetFocus(HWND hwnd) { HWND child; + WNDPROC old_wnd_proc; /* check if we can set focus to non-visible windows */ @@ -2213,6 +2227,28 @@ static void test_SetFocus(HWND hwnd) ok( GetFocus() == child, "Focus should still be on child %p\n", child ); EnableWindow(hwnd, TRUE); + ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd); + ShowWindow(hwnd, SW_SHOWMINIMIZED); + ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd); +todo_wine + ok( GetFocus() != child, "Focus should not be on child %p\n", child ); + ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd ); + ShowWindow(hwnd, SW_RESTORE); + ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd); + ok( GetFocus() == hwnd, "Focus should be on parent %p\n", hwnd ); + ShowWindow(hwnd, SW_SHOWMINIMIZED); + ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd); + ok( GetFocus() != child, "Focus should not be on child %p\n", child ); +todo_wine + ok( GetFocus() != hwnd, "Focus should not be on parent %p\n", hwnd ); + old_wnd_proc = (WNDPROC)SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)set_focus_on_activate_proc); + ShowWindow(hwnd, SW_RESTORE); + ok( GetActiveWindow() == hwnd, "parent window %p should be active\n", hwnd); +todo_wine + ok( GetFocus() == child, "Focus should be on child %p, not %p\n", child, GetFocus() ); + + SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR)old_wnd_proc); + DestroyWindow( child ); } -- 2.11.4.GIT