OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/test/ui_test_utils.h" |
| 6 |
| 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" |
| 9 #include "chrome/browser/browser.h" |
| 10 #include "chrome/browser/browser_window.h" |
| 11 #include "chrome/browser/automation/ui_controls.h" |
| 12 #include "chrome/browser/views/frame/browser_view.h" |
| 13 #include "views/focus/focus_manager.h" |
| 14 |
| 15 namespace ui_test_utils { |
| 16 |
| 17 bool IsViewFocused(const Browser* browser, ViewID vid) { |
| 18 BrowserWindow* browser_window = browser->window(); |
| 19 DCHECK(browser_window); |
| 20 gfx::NativeWindow window = browser_window->GetNativeHandle(); |
| 21 DCHECK(window); |
| 22 views::FocusManager* focus_manager = |
| 23 views::FocusManager::GetFocusManagerForNativeView(window); |
| 24 DCHECK(focus_manager); |
| 25 return focus_manager->GetFocusedView()->GetID() == vid; |
| 26 } |
| 27 |
| 28 void ClickOnView(const Browser* browser, ViewID vid) { |
| 29 BrowserWindow* browser_window = browser->window(); |
| 30 DCHECK(browser_window); |
| 31 views::View* view = |
| 32 reinterpret_cast<BrowserView*>(browser_window)->GetViewByID(vid); |
| 33 DCHECK(view); |
| 34 ui_controls::MoveMouseToCenterAndPress( |
| 35 view, |
| 36 ui_controls::LEFT, |
| 37 ui_controls::DOWN | ui_controls::UP, |
| 38 new MessageLoop::QuitTask()); |
| 39 RunMessageLoop(); |
| 40 } |
| 41 |
| 42 } // namespace ui_test_utils |
OLD | NEW |