From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=56073 --- dlls/user32/tests/input.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
diff --git a/dlls/user32/tests/input.c b/dlls/user32/tests/input.c index f92b839f1cb..f8890d0d6d0 100644 --- a/dlls/user32/tests/input.c +++ b/dlls/user32/tests/input.c @@ -5386,6 +5386,42 @@ static void test_ClipCursor( char **argv ) if (!EqualRect( &rect, &virtual_rect )) ok_ret( 1, ClipCursor( NULL ) ); }
+static void test_SetFocus_activate(void) +{ + HWND hwnd, tmp_hwnd, focus, foreground; + BOOL ret; + + hwnd = CreateWindowW( L"static", L"static", WS_OVERLAPPEDWINDOW, + 100, 100, 200, 200, 0, 0, 0, NULL ); + ok( !!hwnd, "CreateWindowW failed, error %lu\n", GetLastError() ); + foreground = GetForegroundWindow(); + focus = GetFocus(); + + ret = ShowWindow( hwnd, SW_SHOWNA ); + ok( !ret, "ShowWindow succeeded\n" ); + tmp_hwnd = GetForegroundWindow(); + ok( tmp_hwnd == foreground, "GetForegroundWindow returned %p\n", tmp_hwnd ); + tmp_hwnd = GetFocus(); + ok( tmp_hwnd == focus, "GetFocus returned %p\n", tmp_hwnd ); + + tmp_hwnd = SetFocus( hwnd ); + ok( tmp_hwnd == hwnd, "SetFocus returned %p\n", tmp_hwnd ); + tmp_hwnd = GetForegroundWindow(); + todo_wine + ok( tmp_hwnd == hwnd, "GetForegroundWindow returned %p\n", tmp_hwnd ); + tmp_hwnd = GetFocus(); + ok( tmp_hwnd == hwnd, "GetFocus returned %p\n", tmp_hwnd ); + + DestroyWindow( hwnd ); +} + +static void test_SetFocus( char **argv ) +{ + /* run the test_SetFocus_activate in a new desktop, as it depends on the process + * not being foreground yet, and to avoid spurious foreground window failures */ + run_in_desktop( argv, "test_SetFocus_activate", 1 ); +} + START_TEST(input) { char **argv; @@ -5408,6 +5444,8 @@ START_TEST(input) return test_ClipCursor_process(); if (argc >= 3 && !strcmp( argv[2], "test_ClipCursor_desktop" )) return test_ClipCursor_desktop( argv ); + if (argc >= 3 && !strcmp( argv[2], "test_SetFocus_activate" )) + return test_SetFocus_activate();
test_SendInput(); test_Input_blackbox(); @@ -5431,6 +5469,7 @@ START_TEST(input) test_RegisterRawInputDevices(); test_rawinput(argv[0]); test_DefRawInputProc(); + test_SetFocus( argv );
if(pGetMouseMovePointsEx) test_GetMouseMovePointsEx( argv );