Chromium Code Reviews| 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 void ActivateBrowserWindow(Browser* browser) { | |
| 27 ASSERT_TRUE(BringBrowserWindowToFront(browser)); | |
|
sky
2016/11/15 03:47:00
You should make ActivateBrowserWindow return a sta
Qiang(Joe) Xu
2016/11/15 16:25:30
Yes, I agree. Done.
| |
| 28 BrowserActivationWaiter waiter(browser); | |
| 29 waiter.WaitForActivation(); | |
| 30 } | |
| 31 | |
| 26 bool BringBrowserWindowToFront(const Browser* browser) { | 32 bool BringBrowserWindowToFront(const Browser* browser) { |
| 27 gfx::NativeWindow window = NULL; | 33 gfx::NativeWindow window = NULL; |
| 28 if (!GetNativeWindow(browser, &window)) | 34 if (!GetNativeWindow(browser, &window)) |
| 29 return false; | 35 return false; |
| 30 | 36 |
| 31 return ui_test_utils::ShowAndFocusNativeWindow(window); | 37 return ui_test_utils::ShowAndFocusNativeWindow(window); |
| 32 } | 38 } |
| 33 | 39 |
| 34 bool SendKeyPressSync(const Browser* browser, | 40 bool SendKeyPressSync(const Browser* browser, |
| 35 ui::KeyboardCode key, | 41 ui::KeyboardCode key, |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 118 const base::Closure& followup) { | 124 const base::Closure& followup) { |
| 119 if (!followup.is_null()) | 125 if (!followup.is_null()) |
| 120 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); | 126 ui_controls::SendMouseEventsNotifyWhenDone(button, state, followup); |
| 121 else | 127 else |
| 122 ui_controls::SendMouseEvents(button, state); | 128 ui_controls::SendMouseEvents(button, state); |
| 123 } | 129 } |
| 124 | 130 |
| 125 } // namespace internal | 131 } // namespace internal |
| 126 | 132 |
| 127 } // namespace ui_test_utils | 133 } // namespace ui_test_utils |
| OLD | NEW |