Commit 25df0ee3 authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

Deflake TouchActionAckTimeout

Currently this test is flaky because we do not wait for the ack of the
touch start from the main thread.

This CL fixes this issue by using a ack waiter, to ensure that the ack
from the main thread has arrived.

TBR=alexmos@chromium.org

Bug: 871062
Change-Id: Ia883bcbb1b483d8fb481ce88dd5c947ea623d506
Reviewed-on: https://chromium-review.googlesource.com/1221476
Commit-Queue: Xida Chen <xidachen@chromium.org>
Reviewed-by: default avatarJames MacLean <wjmaclean@chromium.org>
Cr-Commit-Position: refs/heads/master@{#591271}
parent 988ba92e
...@@ -1506,33 +1506,12 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessEmulatedTouchBrowserTest, ...@@ -1506,33 +1506,12 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessEmulatedTouchBrowserTest,
RunTest(TouchActionBubbling); RunTest(TouchActionBubbling);
} }
#if defined(OS_ANDROID)
namespace {
// This function is used in TouchActionAckTimeout and
// SubframeGestureEventRouting, which is defined either under Android or Aura.
void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner,
SyntheticGesture::Result result) {
EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
runner->Quit();
}
void GiveItSomeTime(int t) {
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(), base::TimeDelta::FromMilliseconds(t));
run_loop.Run();
}
} // namespace
#endif // defined(OS_ANDROID)
// Regression test for https://crbug.com/851644. The test passes as long as it // Regression test for https://crbug.com/851644. The test passes as long as it
// doesn't crash. // doesn't crash.
// Touch action ack timeout is enabled on Android only. // Touch action ack timeout is enabled on Android only.
// Flaky, see https://crbug.com/871062.
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
DISABLED_TouchActionAckTimeout) { TouchActionAckTimeout) {
GURL main_url( GURL main_url(
embedded_test_server()->GetURL("/frame_tree/page_with_janky_frame.html")); embedded_test_server()->GetURL("/frame_tree/page_with_janky_frame.html"));
ASSERT_TRUE(NavigateToURL(shell(), main_url)); ASSERT_TRUE(NavigateToURL(shell(), main_url));
...@@ -1566,41 +1545,29 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest, ...@@ -1566,41 +1545,29 @@ IN_PROC_BROWSER_TEST_P(SitePerProcessHitTestBrowserTest,
params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT; params.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
params.anchor = gfx::PointF(point_in_child.x(), point_in_child.y()); params.anchor = gfx::PointF(point_in_child.x(), point_in_child.y());
params.distances.push_back(gfx::Vector2dF(0, -10)); params.distances.push_back(gfx::Vector2dF(0, -10));
// Make this scroll slow so that the second scroll will be queued even before // The JS jank from the "page_with_touch_start_janking_main_thread.html"
// this one ends. // causes the touch ack timeout. Set the speed high so that the gesture can be
params.speed_in_pixels_s = 1000; // completed quickly and so does this test.
params.speed_in_pixels_s = 100000;
std::unique_ptr<SyntheticSmoothScrollGesture> gesture( std::unique_ptr<SyntheticSmoothScrollGesture> gesture(
new SyntheticSmoothScrollGesture(params)); new SyntheticSmoothScrollGesture(params));
scoped_refptr<MessageLoopRunner> runner = new MessageLoopRunner(); InputEventAckWaiter ack_observer(
child_frame_host->GetRenderWidgetHost(),
base::BindRepeating([](content::InputEventAckSource source,
content::InputEventAckState state,
const blink::WebInputEvent& event) {
return event.GetType() == blink::WebGestureEvent::kGestureScrollEnd;
}));
ack_observer.Reset();
RenderWidgetHostImpl* render_widget_host = RenderWidgetHostImpl* render_widget_host =
root->current_frame_host()->GetRenderWidgetHost(); root->current_frame_host()->GetRenderWidgetHost();
render_widget_host->QueueSyntheticGesture( render_widget_host->QueueSyntheticGesture(
std::move(gesture), base::BindOnce(OnSyntheticGestureCompleted, runner)); std::move(gesture), base::BindOnce([](SyntheticGesture::Result result) {
// The first gesture takes 100ms, so wait for 120ms to ensure that it has EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result);
// finished. }));
runner->Run(); ack_observer.Wait();
GiveItSomeTime(120);
SyntheticSmoothScrollGestureParams params2;
params2.gesture_source_type = SyntheticGestureParams::TOUCH_INPUT;
params2.anchor = gfx::PointF(point_in_child.x(), point_in_child.y());
params2.distances.push_back(gfx::Vector2dF(0, -10));
params2.speed_in_pixels_s = 100000;
std::unique_ptr<SyntheticSmoothScrollGesture> gesture2(
new SyntheticSmoothScrollGesture(params2));
render_widget_host->QueueSyntheticGesture(
std::move(gesture2), base::BindOnce(OnSyntheticGestureCompleted, runner));
runner->Run();
runner = nullptr;
// Give enough time to make sure all gesture are flushed and handled.
base::RunLoop run_loop;
base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
FROM_HERE, run_loop.QuitClosure(),
base::TimeDelta::FromMilliseconds(2500));
run_loop.Run();
} }
#endif // defined(OS_ANDROID) #endif // defined(OS_ANDROID)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment