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 <jamiewalch@chromium.org>
Commit-Queue: Kimmo Kinnunen FI <kkinnunen@nvidia.com>
Cr-Commit-Position: refs/heads/master@{#29181}
This commit is contained in:
Kimmo Kinnunen
2019-08-30 15:33:02 +03:00
committed by Commit Bot
parent 01be33b35e
commit 0a7d5d8408

View File

@ -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<HWND>(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