summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 02:10:42 +0000
committersadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-15 02:10:42 +0000
commit7140ec2585f4369e40c33115e0387372a415c889 (patch)
treeef04c97bf1119e16082e2a92ad5dbbc9110a90f5
parent06f4f202c8c1334667545a7801b4e76ec3a11ab2 (diff)
downloadchromium_src-7140ec2585f4369e40c33115e0387372a415c889.zip
chromium_src-7140ec2585f4369e40c33115e0387372a415c889.tar.gz
chromium_src-7140ec2585f4369e40c33115e0387372a415c889.tar.bz2
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
-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(