Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1127)

Side by Side Diff: chrome/test/base/interactive_test_utils_win.cc

Issue 549713004: Add more logging to ShowAndFocusNativeWindow. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698