diff --git a/modules/desktop_capture/window_finder_unittest.cc b/modules/desktop_capture/window_finder_unittest.cc index 4fa30e18a3..6fda6b7561 100644 --- a/modules/desktop_capture/window_finder_unittest.cc +++ b/modules/desktop_capture/window_finder_unittest.cc @@ -64,21 +64,30 @@ TEST(WindowFinderTest, FindConsoleWindow) { // Moves the window to the top-left of the display. MoveWindow(console_window, 0, 0, kMaxSize, kMaxSize, true); + bool should_restore_notopmost = + (GetWindowLong(console_window, GWL_EXSTYLE) & WS_EX_TOPMOST) == 0; + // Brings console window to top. SetWindowPos(console_window, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); BringWindowToTop(console_window); + bool success = false; WindowFinderWin finder; for (int i = 0; i < kMaxSize; i++) { const DesktopVector spot(i, i); const HWND id = reinterpret_cast(finder.GetWindowUnderPoint(spot)); if (id == console_window) { - return; + success = true; + break; } } + if (should_restore_notopmost) + SetWindowPos(console_window, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); - FAIL(); + if (!success) + FAIL(); } #else