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

Unified Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 2727683002: Fix unit tests to enable them testing with the rAF aligned touch input. (Closed)
Patch Set: Rebase Created 3 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/render_widget_host_unittest.cc
diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
index 972f34021b3a5ddaaa670a1a445ef43646e6fb07..abdec429d1d6161410632ae5c537690f7a7e03af 100644
--- a/content/browser/renderer_host/render_widget_host_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_unittest.cc
@@ -14,6 +14,7 @@
#include "base/macros.h"
#include "base/run_loop.h"
#include "base/single_thread_task_runner.h"
+#include "base/test/scoped_feature_list.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/timer/timer.h"
#include "build/build_config.h"
@@ -26,6 +27,7 @@
#include "content/common/input_messages.h"
#include "content/common/resize_params.h"
#include "content/common/view_messages.h"
+#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/mock_render_process_host.h"
#include "content/public/test/test_browser_context.h"
@@ -466,6 +468,8 @@ class RenderWidgetHostTest : public testing::Test {
void SetUp() override {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitch(switches::kValidateInputEventStream);
+ feature_list_.InitFromCommandLine(
+ features::kRafAlignedTouchInputEvents.name, "");
browser_context_.reset(new TestBrowserContext());
delegate_.reset(new MockRenderWidgetHostDelegate());
@@ -671,6 +675,7 @@ class RenderWidgetHostTest : public testing::Test {
SyntheticWebTouchEvent touch_event_;
TestBrowserThreadBundle thread_bundle_;
+ base::test::ScopedFeatureList feature_list_;
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHostTest);
};
@@ -1304,7 +1309,8 @@ TEST_F(RenderWidgetHostTest, TouchEmulator) {
SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true);
EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
EXPECT_EQ(
- "GestureTapCancel GestureScrollBegin GestureScrollUpdate",
+ "GestureTapCancel GestureScrollBegin TouchScrollStarted "
+ "GestureScrollUpdate",
GetInputMessageTypes(process_));
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_CONSUMED);
@@ -1362,7 +1368,8 @@ TEST_F(RenderWidgetHostTest, TouchEmulator) {
SimulateMouseEvent(WebInputEvent::MouseMove, 10, 100, 0, true);
EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
EXPECT_EQ(
- "GestureTapCancel GestureScrollBegin GestureScrollUpdate",
+ "GestureTapCancel GestureScrollBegin TouchScrollStarted "
+ "GestureScrollUpdate",
GetInputMessageTypes(process_));
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_CONSUMED);
@@ -1416,7 +1423,8 @@ TEST_F(RenderWidgetHostTest, TouchEmulator) {
SimulateMouseEvent(WebInputEvent::MouseMove, 10, 30, 0, true);
EXPECT_EQ(WebInputEvent::TouchMove, host_->acked_touch_event_type());
EXPECT_EQ(
- "GestureTapCancel GestureScrollBegin GestureScrollUpdate",
+ "GestureTapCancel GestureScrollBegin TouchScrollStarted "
+ "GestureScrollUpdate",
GetInputMessageTypes(process_));
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_CONSUMED);
@@ -1612,6 +1620,34 @@ void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process,
process->sink().ClearMessages();
}
+void CheckLatencyInfoComponentInGestureScrollUpdate(
+ RenderWidgetHostProcess* process,
+ int64_t component_id) {
+ EXPECT_EQ(process->sink().message_count(), 2U);
+ const IPC::Message* message = process->sink().GetMessageAt(0);
+ EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type());
+ InputMsg_HandleInputEvent::Param params;
+ EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, &params));
+
+ const WebInputEvent* event = std::get<0>(params);
+ ui::LatencyInfo latency_info = std::get<2>(params);
+
+ EXPECT_TRUE(event->type() == WebInputEvent::TouchScrollStarted);
+
+ message = process->sink().GetMessageAt(1);
+ EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type());
+ EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, &params));
+
+ event = std::get<0>(params);
+ latency_info = std::get<2>(params);
+
+ EXPECT_TRUE(event->type() == WebInputEvent::GestureScrollUpdate);
+ EXPECT_TRUE(latency_info.FindLatency(
+ ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL));
+
+ process->sink().ClearMessages();
+}
+
// Tests that after input event passes through RWHI through ForwardXXXEvent()
// or ForwardXXXEventWithLatencyInfo(), LatencyInfo component
// ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the
@@ -1655,8 +1691,8 @@ TEST_F(RenderWidgetHostTest, InputEventRWHLatencyComponent) {
SimulateGestureEventWithLatencyInfo(WebInputEvent::GestureScrollUpdate,
blink::WebGestureDeviceTouchscreen,
ui::LatencyInfo());
- CheckLatencyInfoComponentInMessage(
- process_, GetLatencyComponentId(), WebInputEvent::GestureScrollUpdate);
+ CheckLatencyInfoComponentInGestureScrollUpdate(process_,
+ GetLatencyComponentId());
SendInputEventACK(WebInputEvent::GestureScrollUpdate,
INPUT_EVENT_ACK_STATE_CONSUMED);

Powered by Google App Engine
This is Rietveld 408576698