| 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 <Psapi.h> |
| 8 |
| 7 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 8 #include "base/logging.h" | 10 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 10 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
| 11 #include "base/time/time.h" | 13 #include "base/time/time.h" |
| 12 #include "chrome/browser/ui/host_desktop.h" | 14 #include "chrome/browser/ui/host_desktop.h" |
| 13 #include "chrome/test/base/interactive_test_utils_aura.h" | 15 #include "chrome/test/base/interactive_test_utils_aura.h" |
| 14 #include "ui/aura/window_tree_host.h" | 16 #include "ui/aura/window_tree_host.h" |
| 15 #include "ui/base/test/ui_controls.h" | 17 #include "ui/base/test/ui_controls.h" |
| 16 #include "ui/base/win/foreground_helper.h" | 18 #include "ui/base/win/foreground_helper.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 44 } | 46 } |
| 45 | 47 |
| 46 // ShowWindow does not necessarily activate the window. In particular if a | 48 // ShowWindow does not necessarily activate the window. In particular if a |
| 47 // window from another app is the foreground window then the request to | 49 // window from another app is the foreground window then the request to |
| 48 // activate the window fails. See SetForegroundWindow for details. | 50 // activate the window fails. See SetForegroundWindow for details. |
| 49 HWND foreground_window = GetForegroundWindow(); | 51 HWND foreground_window = GetForegroundWindow(); |
| 50 if (foreground_window == hwnd) | 52 if (foreground_window == hwnd) |
| 51 return true; | 53 return true; |
| 52 | 54 |
| 53 wchar_t window_title[256]; | 55 wchar_t window_title[256]; |
| 56 std::wstring path_str; |
| 57 if (foreground_window) { |
| 58 DWORD process_id = 0; |
| 59 GetWindowThreadProcessId(foreground_window, &process_id); |
| 60 HANDLE process_handle = OpenProcess( |
| 61 PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, process_id); |
| 62 if (process_handle) { |
| 63 wchar_t path[MAX_PATH]; |
| 64 if (GetModuleFileNameEx(process_handle, NULL, path, MAX_PATH)) |
| 65 path_str = path; |
| 66 CloseHandle(process_handle); |
| 67 } |
| 68 } |
| 54 GetWindowText(foreground_window, window_title, arraysize(window_title)); | 69 GetWindowText(foreground_window, window_title, arraysize(window_title)); |
| 55 LOG(ERROR) << "ShowAndFocusNativeWindow failed. foreground window text: " << | 70 LOG(ERROR) << "ShowAndFocusNativeWindow failed. foreground window: " |
| 56 window_title; | 71 << foreground_window << ", title: " << window_title << ", path: " |
| 72 << path_str; |
| 57 return false; | 73 return false; |
| 58 } | 74 } |
| 59 | 75 |
| 60 } // namespace ui_test_utils | 76 } // namespace ui_test_utils |
| OLD | NEW |