Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(721)

Unified Diff: content/browser/renderer_host/input/touch_input_browsertest.cc

Issue 888793002: Make content_browsertests for Chrome on Android running with valid Views (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Set valid physical backing size before viewport size is set Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..5d01e7886743da9c1a12b0e19994ec9c0575e905 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 {
@@ -164,6 +168,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 +194,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 +219,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 +241,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 +268,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());

Powered by Google App Engine
This is Rietveld 408576698