From 0a7d5d840862d40a988a27f03744cdf731685695 Mon Sep 17 00:00:00 2001 From: Kimmo Kinnunen Date: Fri, 30 Aug 2019 15:33:02 +0300 Subject: [PATCH] Set console window NOTOPMOST flag after WindowFinderTest.FindDrawerWindow on Windows Otherwise it's inconvenient to run the test interactively, since it leaves the interactive console window topmost preventing any other window visibility even when the console window is deactivated. Bug: webrtc:7950 Change-Id: I80a19509f1518550fe93b26feea9e8964b0e405d Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150943 Reviewed-by: Jamie Walch Commit-Queue: Kimmo Kinnunen FI Cr-Commit-Position: refs/heads/master@{#29181} --- modules/desktop_capture/window_finder_unittest.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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