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