Chromium Code Reviews| Index: content/browser/renderer_host/input/touch_input_browsertest.cc |
| diff --git a/content/browser/renderer_host/input/touch_input_browsertest.cc b/content/browser/renderer_host/input/touch_input_browsertest.cc |
| index ce20fc2fde40c906b56af87aa2df4b07bba8074a..eb754e993f1f50b189e81a44df8039fea6e576d6 100644 |
| --- a/content/browser/renderer_host/input/touch_input_browsertest.cc |
| +++ b/content/browser/renderer_host/input/touch_input_browsertest.cc |
| @@ -21,6 +21,10 @@ |
| #include "ui/events/event_switches.h" |
| #include "ui/events/latency_info.h" |
| +#if defined(OS_ANDROID) |
| +#include "content/browser/renderer_host/render_widget_host_view_android.h" |
| +#endif |
| + |
| using blink::WebInputEvent; |
| namespace { |
| @@ -149,7 +153,12 @@ class TouchInputBrowserTest : public ContentBrowserTest { |
| static_cast<WebContentsImpl*>(shell()->web_contents()); |
| RenderWidgetHostImpl* host = |
| RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
| +#if defined(OS_ANDROID) |
| + static_cast<RenderWidgetHostViewAndroid*>(host->GetView()) |
| + ->GenerateNewFrameForTesting(); |
|
no sievers
2015/02/09 23:11:20
Why do we need to do this, i.e. fake onSizeChanged
Jaekyun Seok (inactive)
2015/02/09 23:23:14
RenderWidgetHostImpl::OnUpdateRect() wasn't called
|
| +#else |
| host->GetView()->SetSize(gfx::Size(400, 400)); |
| +#endif |
| // The page is loaded in the renderer, wait for a new frame to arrive. |
| while (!host->ScheduleComposite()) |
| @@ -164,6 +173,17 @@ class TouchInputBrowserTest : public ContentBrowserTest { |
| switches::kTouchEventsEnabled); |
| } |
| +#if defined(OS_ANDROID) |
| + float GetPageScaleFactor() { |
| + WebContentsImpl* web_contents = |
| + static_cast<WebContentsImpl*>(shell()->web_contents()); |
| + RenderWidgetHostImpl* host = |
| + RenderWidgetHostImpl::From(web_contents->GetRenderViewHost()); |
| + return static_cast<RenderWidgetHostViewAndroid*>(host->GetView()) |
| + ->last_page_scale_factor(); |
| + } |
| +#endif |
| + |
| scoped_refptr<InputEventMessageFilter> filter_; |
| }; |
| @@ -179,7 +199,12 @@ IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_TouchNoHandler) { |
| // A press on |first| should be acked with NO_CONSUMER_EXISTS since there is |
| // no touch-handler on it. |
| +#if defined(OS_ANDROID) |
| + float scale = GetPageScaleFactor(); |
| + touch.PressPoint(25 * scale, 25 * scale); |
| +#else |
| touch.PressPoint(25, 25); |
| +#endif |
| GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); |
| filter()->WaitForAck(WebInputEvent::TouchStart); |
| @@ -199,7 +224,12 @@ IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, TouchHandlerNoConsume) { |
| // Press on |second| should be acked with NOT_CONSUMED since there is a |
| // touch-handler on |second|, but it doesn't consume the event. |
| +#if defined(OS_ANDROID) |
| + float scale = GetPageScaleFactor(); |
| + touch.PressPoint(125 * scale, 25 * scale); |
| +#else |
| touch.PressPoint(125, 25); |
| +#endif |
| GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); |
| filter()->WaitForAck(WebInputEvent::TouchStart); |
| EXPECT_EQ(INPUT_EVENT_ACK_STATE_NOT_CONSUMED, filter()->last_ack_state()); |
| @@ -216,7 +246,12 @@ IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, TouchHandlerConsume) { |
| // Press on |third| should be acked with CONSUMED since the touch-handler on |
| // |third| consimes the event. |
| +#if defined(OS_ANDROID) |
| + float scale = GetPageScaleFactor(); |
| + touch.PressPoint(25 * scale, 125 * scale); |
| +#else |
| touch.PressPoint(25, 125); |
| +#endif |
| GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); |
| filter()->WaitForAck(WebInputEvent::TouchStart); |
| EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, filter()->last_ack_state()); |
| @@ -238,13 +273,22 @@ IN_PROC_BROWSER_TEST_F(TouchInputBrowserTest, MAYBE_MultiPointTouchPress) { |
| // Press on |first|, which sould be acked with NO_CONSUMER_EXISTS. Then press |
| // on |third|. That point should be acked with CONSUMED. |
| +#if defined(OS_ANDROID) |
| + float scale = GetPageScaleFactor(); |
| + touch.PressPoint(25 * scale, 25 * scale); |
| +#else |
| touch.PressPoint(25, 25); |
| +#endif |
| GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); |
| filter()->WaitForAck(WebInputEvent::TouchStart); |
| EXPECT_EQ(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, |
| filter()->last_ack_state()); |
| +#if defined(OS_ANDROID) |
| + touch.PressPoint(25 * scale, 125 * scale); |
| +#else |
| touch.PressPoint(25, 125); |
| +#endif |
| GetWidgetHost()->ForwardTouchEventWithLatencyInfo(touch, ui::LatencyInfo()); |
| filter()->WaitForAck(WebInputEvent::TouchStart); |
| EXPECT_EQ(INPUT_EVENT_ACK_STATE_CONSUMED, filter()->last_ack_state()); |