| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/test/base/interactive_test_utils.h" | 5 #include "chrome/test/base/interactive_test_utils.h" |
| 6 | 6 |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 ::ShowWindow(hwnd, SW_SHOW); | 39 ::ShowWindow(hwnd, SW_SHOW); |
| 40 | 40 |
| 41 if (GetForegroundWindow() != hwnd) { | 41 if (GetForegroundWindow() != hwnd) { |
| 42 VLOG(1) << "Forcefully refocusing front window"; | 42 VLOG(1) << "Forcefully refocusing front window"; |
| 43 ui::ForegroundHelper::SetForeground(hwnd); | 43 ui::ForegroundHelper::SetForeground(hwnd); |
| 44 } | 44 } |
| 45 | 45 |
| 46 // ShowWindow does not necessarily activate the window. In particular if a | 46 // ShowWindow does not necessarily activate the window. In particular if a |
| 47 // window from another app is the foreground window then the request to | 47 // window from another app is the foreground window then the request to |
| 48 // activate the window fails. See SetForegroundWindow for details. | 48 // activate the window fails. See SetForegroundWindow for details. |
| 49 return GetForegroundWindow() == hwnd; | 49 HWND foreground_window = GetForegroundWindow(); |
| 50 if (foreground_window == hwnd) |
| 51 return true; |
| 52 |
| 53 wchar_t window_title[256]; |
| 54 GetWindowText(foreground_window, window_title, arraysize(window_title)); |
| 55 LOG(ERROR) << "ShowAndFocusNativeWindow failed. foreground window text: " << |
| 56 window_title; |
| 57 return false; |
| 50 } | 58 } |
| 51 | 59 |
| 52 } // namespace ui_test_utils | 60 } // namespace ui_test_utils |
| OLD | NEW |