Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
|
tapted
2016/02/05 05:11:11
nit: (c) 2012 -> 2016
kirr
2016/02/05 13:26:24
Done.
| |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
|
tapted
2016/02/05 05:11:11
perhaps a comment in here about this file's purpos
kirr
2016/02/05 13:26:24
Done.
| |
| 5 #include "chrome/test/base/interactive_test_utils.h" | |
| 6 | |
| 7 #include "ui/base/test/ui_controls.h" | |
|
tapted
2016/02/05 05:11:11
nit: I think this can be removed since interactive
kirr
2016/02/05 13:26:23
Done.
| |
| 8 #include "ui/compositor/layer.h" | |
| 9 #include "ui/compositor/layer_animator.h" | |
| 10 #include "ui/views/view.h" | |
| 11 #include "ui/views/widget/widget.h" | |
| 12 | |
| 13 namespace ui_test_utils { | |
| 14 | |
| 15 void MoveMouseToCenterAndPress(views::View* view, | |
| 16 ui_controls::MouseButton button, | |
| 17 int state, | |
| 18 const base::Closure& closure) { | |
| 19 DCHECK(view); | |
| 20 DCHECK(view->GetWidget()); | |
| 21 // Complete any in-progress animation before sending the events so that the | |
| 22 // mouse-event targetting happens reliably, and does not flake because of | |
| 23 // unreliable animation state. | |
| 24 ui::Layer* layer = view->GetWidget()->GetLayer(); | |
| 25 if (layer) { | |
| 26 ui::LayerAnimator* animator = layer->GetAnimator(); | |
| 27 if (animator && animator->is_animating()) | |
| 28 animator->StopAnimating(); | |
| 29 } | |
| 30 | |
| 31 gfx::Point view_center(view->width() / 2, view->height() / 2); | |
| 32 views::View::ConvertPointToScreen(view, &view_center); | |
| 33 ui_controls::SendMouseMoveNotifyWhenDone( | |
| 34 view_center.x(), | |
| 35 view_center.y(), | |
| 36 base::Bind(&internal::ClickTask, button, state, closure)); | |
| 37 } | |
| 38 | |
| 39 } // namespace ui_test_utils | |
| OLD | NEW |