From 7140ec2585f4369e40c33115e0387372a415c889 Mon Sep 17 00:00:00 2001 From: "sadrul@chromium.org" Date: Wed, 15 Jan 2014 02:10:42 +0000 Subject: interactive tests: Complete in-progress animations before sending mouse events. Sending mouse events while it animates can be flaky, so stop any in-progress animation of the window before sending mouse events to it. BUG=none R=sky@chromium.org Review URL: https://codereview.chromium.org/138633002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@244821 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/test/base/interactive_test_utils_views.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/chrome/test/base/interactive_test_utils_views.cc b/chrome/test/base/interactive_test_utils_views.cc index 63bb560..2a39ba4 100644 --- a/chrome/test/base/interactive_test_utils_views.cc +++ b/chrome/test/base/interactive_test_utils_views.cc @@ -8,7 +8,9 @@ #include "base/message_loop/message_loop.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/views/frame/browser_view.h" +#include "ui/aura/window.h" #include "ui/base/test/ui_controls.h" +#include "ui/compositor/layer.h" #include "ui/views/focus/focus_manager.h" namespace ui_test_utils { @@ -44,6 +46,16 @@ void MoveMouseToCenterAndPress(views::View* view, const base::Closure& closure) { DCHECK(view); DCHECK(view->GetWidget()); + // Complete any in-progress animation before sending the events so that the + // mouse-event targetting happens reliably, and does not flake because of + // unreliable animation state. + aura::Window* window = view->GetWidget()->GetNativeView(); + if (window && window->layer()) { + ui::LayerAnimator* animator = window->layer()->GetAnimator(); + if (animator && animator->is_animating()) + animator->StopAnimating(); + } + gfx::Point view_center(view->width() / 2, view->height() / 2); views::View::ConvertPointToScreen(view, &view_center); ui_controls::SendMouseMoveNotifyWhenDone( -- cgit v1.1