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> | 7 #include <Psapi.h> |
8 | 8 |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/strings/stringprintf.h" | 12 #include "base/strings/stringprintf.h" |
13 #include "base/time/time.h" | 13 #include "base/time/time.h" |
14 #include "chrome/browser/ui/host_desktop.h" | |
15 #include "chrome/test/base/interactive_test_utils_aura.h" | 14 #include "chrome/test/base/interactive_test_utils_aura.h" |
16 #include "ui/aura/window_tree_host.h" | 15 #include "ui/aura/window_tree_host.h" |
17 #include "ui/base/test/ui_controls.h" | 16 #include "ui/base/test/ui_controls.h" |
18 #include "ui/base/win/foreground_helper.h" | 17 #include "ui/base/win/foreground_helper.h" |
19 #include "ui/views/focus/focus_manager.h" | 18 #include "ui/views/focus/focus_manager.h" |
20 | 19 |
21 namespace ui_test_utils { | 20 namespace ui_test_utils { |
22 | 21 |
23 void HideNativeWindow(gfx::NativeWindow window) { | 22 void HideNativeWindow(gfx::NativeWindow window) { |
24 if (chrome::GetHostDesktopTypeForNativeWindow(window) == | 23 #if defined(USE_ASH) |
25 chrome::HOST_DESKTOP_TYPE_ASH) { | 24 HideNativeWindowAura(window); |
26 HideNativeWindowAura(window); | 25 #else |
27 return; | |
28 } | |
29 HWND hwnd = window->GetHost()->GetAcceleratedWidget(); | 26 HWND hwnd = window->GetHost()->GetAcceleratedWidget(); |
30 ::ShowWindow(hwnd, SW_HIDE); | 27 ::ShowWindow(hwnd, SW_HIDE); |
| 28 #endif // USE_ASH |
31 } | 29 } |
32 | 30 |
33 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { | 31 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { |
34 if (chrome::GetHostDesktopTypeForNativeWindow(window) == | 32 #if defined(USE_ASH) |
35 chrome::HOST_DESKTOP_TYPE_ASH) | 33 ShowAndFocusNativeWindowAura(window); |
36 ShowAndFocusNativeWindowAura(window); | 34 #endif // USE_ASH |
37 window->Show(); | 35 window->Show(); |
38 // Always make sure the window hosting ash is visible and focused. | 36 // Always make sure the window hosting ash is visible and focused. |
39 HWND hwnd = window->GetHost()->GetAcceleratedWidget(); | 37 HWND hwnd = window->GetHost()->GetAcceleratedWidget(); |
40 | 38 |
41 ::ShowWindow(hwnd, SW_SHOW); | 39 ::ShowWindow(hwnd, SW_SHOW); |
42 | 40 |
43 if (GetForegroundWindow() != hwnd) { | 41 if (GetForegroundWindow() != hwnd) { |
44 VLOG(1) << "Forcefully refocusing front window"; | 42 VLOG(1) << "Forcefully refocusing front window"; |
45 ui::ForegroundHelper::SetForeground(hwnd); | 43 ui::ForegroundHelper::SetForeground(hwnd); |
46 } | 44 } |
(...skipping 20 matching lines...) Expand all Loading... |
67 } | 65 } |
68 } | 66 } |
69 GetWindowText(foreground_window, window_title, arraysize(window_title)); | 67 GetWindowText(foreground_window, window_title, arraysize(window_title)); |
70 LOG(ERROR) << "ShowAndFocusNativeWindow failed. foreground window: " | 68 LOG(ERROR) << "ShowAndFocusNativeWindow failed. foreground window: " |
71 << foreground_window << ", title: " << window_title << ", path: " | 69 << foreground_window << ", title: " << window_title << ", path: " |
72 << path_str; | 70 << path_str; |
73 return false; | 71 return false; |
74 } | 72 } |
75 | 73 |
76 } // namespace ui_test_utils | 74 } // namespace ui_test_utils |
OLD | NEW |