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 11 matching lines...) Expand all Loading... |
22 | 22 |
23 namespace ui_test_utils { | 23 namespace ui_test_utils { |
24 | 24 |
25 void HideNativeWindow(gfx::NativeWindow window) { | 25 void HideNativeWindow(gfx::NativeWindow window) { |
26 #if defined(USE_AURA) | 26 #if defined(USE_AURA) |
27 if (chrome::GetHostDesktopTypeForNativeWindow(window) == | 27 if (chrome::GetHostDesktopTypeForNativeWindow(window) == |
28 chrome::HOST_DESKTOP_TYPE_ASH) { | 28 chrome::HOST_DESKTOP_TYPE_ASH) { |
29 HideNativeWindowAura(window); | 29 HideNativeWindowAura(window); |
30 return; | 30 return; |
31 } | 31 } |
32 HWND hwnd = window->GetDispatcher()->GetAcceleratedWidget(); | 32 HWND hwnd = window->GetDispatcher()->host()->GetAcceleratedWidget(); |
33 #else | 33 #else |
34 HWND hwnd = window; | 34 HWND hwnd = window; |
35 #endif | 35 #endif |
36 ::ShowWindow(hwnd, SW_HIDE); | 36 ::ShowWindow(hwnd, SW_HIDE); |
37 } | 37 } |
38 | 38 |
39 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { | 39 bool ShowAndFocusNativeWindow(gfx::NativeWindow window) { |
40 #if defined(USE_AURA) | 40 #if defined(USE_AURA) |
41 if (chrome::GetHostDesktopTypeForNativeWindow(window) == | 41 if (chrome::GetHostDesktopTypeForNativeWindow(window) == |
42 chrome::HOST_DESKTOP_TYPE_ASH) | 42 chrome::HOST_DESKTOP_TYPE_ASH) |
43 ShowAndFocusNativeWindowAura(window); | 43 ShowAndFocusNativeWindowAura(window); |
44 window->Show(); | 44 window->Show(); |
45 // Always make sure the window hosting ash is visible and focused. | 45 // Always make sure the window hosting ash is visible and focused. |
46 HWND hwnd = window->GetDispatcher()->GetAcceleratedWidget(); | 46 HWND hwnd = window->GetDispatcher()->host()->GetAcceleratedWidget(); |
47 #else | 47 #else |
48 HWND hwnd = window; | 48 HWND hwnd = window; |
49 #endif | 49 #endif |
50 | 50 |
51 ::ShowWindow(hwnd, SW_SHOW); | 51 ::ShowWindow(hwnd, SW_SHOW); |
52 | 52 |
53 if (GetForegroundWindow() != hwnd) { | 53 if (GetForegroundWindow() != hwnd) { |
54 VLOG(1) << "Forcefully refocusing front window"; | 54 VLOG(1) << "Forcefully refocusing front window"; |
55 ui::ForegroundHelper::SetForeground(hwnd); | 55 ui::ForegroundHelper::SetForeground(hwnd); |
56 } | 56 } |
57 | 57 |
58 // ShowWindow does not necessarily activate the window. In particular if a | 58 // ShowWindow does not necessarily activate the window. In particular if a |
59 // window from another app is the foreground window then the request to | 59 // window from another app is the foreground window then the request to |
60 // activate the window fails. See SetForegroundWindow for details. | 60 // activate the window fails. See SetForegroundWindow for details. |
61 return GetForegroundWindow() == hwnd; | 61 return GetForegroundWindow() == hwnd; |
62 } | 62 } |
63 | 63 |
64 } // namespace ui_test_utils | 64 } // namespace ui_test_utils |
OLD | NEW |