| 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/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/views/frame/browser_view.h" | 10 #include "chrome/browser/ui/views/frame/browser_view.h" |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 views::View* view = | 36 views::View* view = |
| 37 BrowserView::GetBrowserViewForBrowser(browser)->GetViewByID(vid); | 37 BrowserView::GetBrowserViewForBrowser(browser)->GetViewByID(vid); |
| 38 DCHECK(view); | 38 DCHECK(view); |
| 39 MoveMouseToCenterAndPress(view, | 39 MoveMouseToCenterAndPress(view, |
| 40 ui_controls::LEFT, | 40 ui_controls::LEFT, |
| 41 ui_controls::DOWN | ui_controls::UP, | 41 ui_controls::DOWN | ui_controls::UP, |
| 42 base::MessageLoop::QuitClosure()); | 42 base::MessageLoop::QuitClosure()); |
| 43 content::RunMessageLoop(); | 43 content::RunMessageLoop(); |
| 44 } | 44 } |
| 45 | 45 |
| 46 void FocusView(const Browser* browser, ViewID vid) { |
| 47 views::View* view = |
| 48 BrowserView::GetBrowserViewForBrowser(browser)->GetViewByID(vid); |
| 49 DCHECK(view); |
| 50 view->RequestFocus(); |
| 51 } |
| 52 |
| 46 #endif // defined(OS_MACOSX) | 53 #endif // defined(OS_MACOSX) |
| 47 | 54 |
| 48 void MoveMouseToCenterAndPress(views::View* view, | 55 void MoveMouseToCenterAndPress(views::View* view, |
| 49 ui_controls::MouseButton button, | 56 ui_controls::MouseButton button, |
| 50 int state, | 57 int state, |
| 51 const base::Closure& closure) { | 58 const base::Closure& closure) { |
| 52 DCHECK(view); | 59 DCHECK(view); |
| 53 DCHECK(view->GetWidget()); | 60 DCHECK(view->GetWidget()); |
| 54 // Complete any in-progress animation before sending the events so that the | 61 // Complete any in-progress animation before sending the events so that the |
| 55 // mouse-event targetting happens reliably, and does not flake because of | 62 // mouse-event targetting happens reliably, and does not flake because of |
| 56 // unreliable animation state. | 63 // unreliable animation state. |
| 57 ui::Layer* layer = view->GetWidget()->GetLayer(); | 64 ui::Layer* layer = view->GetWidget()->GetLayer(); |
| 58 if (layer) { | 65 if (layer) { |
| 59 ui::LayerAnimator* animator = layer->GetAnimator(); | 66 ui::LayerAnimator* animator = layer->GetAnimator(); |
| 60 if (animator && animator->is_animating()) | 67 if (animator && animator->is_animating()) |
| 61 animator->StopAnimating(); | 68 animator->StopAnimating(); |
| 62 } | 69 } |
| 63 | 70 |
| 64 gfx::Point view_center(view->width() / 2, view->height() / 2); | 71 gfx::Point view_center(view->width() / 2, view->height() / 2); |
| 65 views::View::ConvertPointToScreen(view, &view_center); | 72 views::View::ConvertPointToScreen(view, &view_center); |
| 66 ui_controls::SendMouseMoveNotifyWhenDone( | 73 ui_controls::SendMouseMoveNotifyWhenDone( |
| 67 view_center.x(), | 74 view_center.x(), |
| 68 view_center.y(), | 75 view_center.y(), |
| 69 base::Bind(&internal::ClickTask, button, state, closure)); | 76 base::Bind(&internal::ClickTask, button, state, closure)); |
| 70 } | 77 } |
| 71 | 78 |
| 72 } // namespace ui_test_utils | 79 } // namespace ui_test_utils |
| OLD | NEW |