summaryrefslogtreecommitdiffstats
path: root/chrome/test/base/interactive_test_utils_views.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/base/interactive_test_utils_views.cc')
-rw-r--r--chrome/test/base/interactive_test_utils_views.cc12
1 files changed, 12 insertions, 0 deletions
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(