| 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 "build/build_config.h" | 7 #include "build/build_config.h" |
| 8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
| 9 #include "chrome/browser/ui/browser_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
| 10 | 10 |
| 11 namespace ui_test_utils { | 11 namespace ui_test_utils { |
| 12 | 12 |
| 13 namespace { | 13 namespace { |
| 14 | 14 |
| 15 bool GetNativeWindow(const Browser* browser, gfx::NativeWindow* native_window) { | 15 bool GetNativeWindow(const Browser* browser, gfx::NativeWindow* native_window) { |
| 16 BrowserWindow* window = browser->window(); | 16 BrowserWindow* window = browser->window(); |
| 17 if (!window) | 17 if (!window) |
| 18 return false; | 18 return false; |
| 19 | 19 |
| 20 *native_window = window->GetNativeWindow(); | 20 *native_window = window->GetNativeWindow(); |
| 21 return *native_window; | 21 return *native_window; |
| 22 } | 22 } |
| 23 | 23 |
| 24 } // namespace | 24 } // namespace |
| 25 | 25 |
| 26 bool ActivateBrowserWindow(Browser* browser) { |
| 27 if (!BringBrowserWindowToFront(browser)) |
| 28 return false; |
| 29 |
| 30 BrowserActivationWaiter waiter(browser); |
| 31 waiter.WaitForActivation(); |
| 32 return true; |
| 33 } |
| 34 |
| 26 bool BringBrowserWindowToFront(const Browser* browser) { | 35 bool BringBrowserWindowToFront(const Browser* browser) { |
| 27 gfx::NativeWindow window = NULL; | 36 gfx::NativeWindow window = NULL; |
| 28 if (!GetNativeWindow(browser, &window)) | 37 if (!GetNativeWindow(browser, &window)) |
| 29 return false; | 38 return false; |
| 30 | 39 |
| 31 return ui_test_utils::ShowAndFocusNativeWindow(window); | 40 return ui_test_utils::ShowAndFocusNativeWindow(window); |
| 32 } | 41 } |
| 33 | 42 |
| 34 bool SendKeyPressSync(const Browser* browser, | 43 bool SendKeyPressSync(const Browser* browser, |
| 35 ui::KeyboardCode key, | 44 ui::KeyboardCode key, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 const base::Closure& followup) { | 127 const base::Closure& followup) { |
| 119 if (!followup.is_null()) | 128 if (!followup.is_null()) |
| 120 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 129 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
| 121 else | 130 else |
| 122 ui_controls::SendMouseEvents(button, state); | 131 ui_controls::SendMouseEvents(button, state); |
| 123 } | 132 } |
| 124 | 133 |
| 125 } // namespace internal | 134 } // namespace internal |
| 126 | 135 |
| 127 } // namespace ui_test_utils | 136 } // namespace ui_test_utils |
| OLD | NEW |