message_received_(false),
client_(client) {
}
- virtual ~MockInputRouter() {}
+ ~MockInputRouter() override {}
// InputRouter
- virtual void Flush() OVERRIDE {
- flush_called_ = true;
- }
- virtual bool SendInput(scoped_ptr<IPC::Message> message) OVERRIDE {
+ void Flush() override { flush_called_ = true; }
+ bool SendInput(scoped_ptr<IPC::Message> message) override {
send_event_called_ = true;
return true;
}
- virtual void SendMouseEvent(
- const MouseEventWithLatencyInfo& mouse_event) OVERRIDE {
+ void SendMouseEvent(const MouseEventWithLatencyInfo& mouse_event) override {
sent_mouse_event_ = true;
}
- virtual void SendWheelEvent(
- const MouseWheelEventWithLatencyInfo& wheel_event) OVERRIDE {
+ void SendWheelEvent(
+ const MouseWheelEventWithLatencyInfo& wheel_event) override {
sent_wheel_event_ = true;
}
- virtual void SendKeyboardEvent(
- const NativeWebKeyboardEvent& key_event,
- const ui::LatencyInfo& latency_info,
- bool is_shortcut) OVERRIDE {
+ void SendKeyboardEvent(const NativeWebKeyboardEvent& key_event,
+ const ui::LatencyInfo& latency_info,
+ bool is_shortcut) override {
sent_keyboard_event_ = true;
}
- virtual void SendGestureEvent(
- const GestureEventWithLatencyInfo& gesture_event) OVERRIDE {
+ void SendGestureEvent(
+ const GestureEventWithLatencyInfo& gesture_event) override {
sent_gesture_event_ = true;
}
- virtual void SendTouchEvent(
- const TouchEventWithLatencyInfo& touch_event) OVERRIDE {
+ void SendTouchEvent(const TouchEventWithLatencyInfo& touch_event) override {
send_touch_event_not_cancelled_ =
client_->FilterInputEvent(touch_event.event, touch_event.latency) ==
INPUT_EVENT_ACK_STATE_NOT_CONSUMED;
}
- virtual const NativeWebKeyboardEvent* GetLastKeyboardEvent() const OVERRIDE {
+ const NativeWebKeyboardEvent* GetLastKeyboardEvent() const override {
NOTREACHED();
return NULL;
}
- virtual bool ShouldForwardTouchEvent() const OVERRIDE { return true; }
- virtual void OnViewUpdated(int view_flags) OVERRIDE {}
- virtual bool HasPendingEvents() const OVERRIDE { return false; }
+ bool ShouldForwardTouchEvent() const override { return true; }
+ void OnViewUpdated(int view_flags) override {}
+ bool HasPendingEvents() const override { return false; }
// IPC::Listener
- virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE {
+ bool OnMessageReceived(const IPC::Message& message) override {
message_received_ = true;
return false;
}
using RenderWidgetHostImpl::resize_ack_pending_;
using RenderWidgetHostImpl::input_router_;
- virtual void OnTouchEventAck(
- const TouchEventWithLatencyInfo& event,
- InputEventAckState ack_result) OVERRIDE {
+ void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
+ InputEventAckState ack_result) override {
// Sniff touch acks.
acked_touch_event_type_ = event.event.type;
RenderWidgetHostImpl::OnTouchEventAck(event, ack_result);
return unresponsive_timer_fired_;
}
- void set_hung_renderer_delay_ms(int delay_ms) {
+ void set_hung_renderer_delay_ms(int64 delay_ms) {
hung_renderer_delay_ms_ = delay_ms;
}
}
protected:
- virtual void NotifyRendererUnresponsive() OVERRIDE {
+ void NotifyRendererUnresponsive() override {
unresponsive_timer_fired_ = true;
}
: MockRenderProcessHost(browser_context),
update_msg_reply_flags_(0) {
}
- virtual ~RenderWidgetHostProcess() {
- }
+ ~RenderWidgetHostProcess() override {}
void set_update_msg_reply_flags(int flags) {
update_msg_reply_flags_ = flags;
// Fills the given update parameters with resonable default values.
void InitUpdateRectParams(ViewHostMsg_UpdateRect_Params* params);
- virtual bool HasConnection() const OVERRIDE { return true; }
+ bool HasConnection() const override { return true; }
protected:
// Indicates the flags that should be sent with a repaint request. This
}
// RenderWidgetHostView override.
- virtual gfx::Rect GetViewBounds() const OVERRIDE {
- return bounds_;
- }
- virtual void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch,
- InputEventAckState ack_result) OVERRIDE {
+ gfx::Rect GetViewBounds() const override { return bounds_; }
+ void ProcessAckedTouchEvent(const TouchEventWithLatencyInfo& touch,
+ InputEventAckState ack_result) override {
acked_event_ = touch.event;
++acked_event_count_;
}
- virtual void WheelEventAck(const WebMouseWheelEvent& event,
- InputEventAckState ack_result) OVERRIDE {
+ void WheelEventAck(const WebMouseWheelEvent& event,
+ InputEventAckState ack_result) override {
if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
return;
unhandled_wheel_event_count_++;
unhandled_wheel_event_ = event;
}
- virtual void GestureEventAck(const WebGestureEvent& event,
- InputEventAckState ack_result) OVERRIDE {
+ void GestureEventAck(const WebGestureEvent& event,
+ InputEventAckState ack_result) override {
gesture_event_type_ = event.type;
ack_result_ = ack_result;
}
- virtual gfx::Size GetPhysicalBackingSize() const OVERRIDE {
+ gfx::Size GetPhysicalBackingSize() const override {
if (use_fake_physical_backing_size_)
return mock_physical_backing_size_;
return TestRenderWidgetHostView::GetPhysicalBackingSize();
}
#if defined(USE_AURA)
- virtual ~TestView() {
+ ~TestView() override {
// Simulate the mouse exit event dispatched when an aura window is
// destroyed. (MakeWebMouseEventFromAuraEvent translates ET_MOUSE_EXITED
// into WebInputEvent::MouseMove.)
handle_wheel_event_(false),
handle_wheel_event_called_(false) {
}
- virtual ~MockRenderWidgetHostDelegate() {}
+ ~MockRenderWidgetHostDelegate() override {}
// Tests that make sure we ignore keyboard event acknowledgments to events we
// didn't send work by making sure we didn't call UnhandledKeyboardEvent().
}
protected:
- virtual bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
- bool* is_keyboard_shortcut) OVERRIDE {
+ bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
+ bool* is_keyboard_shortcut) override {
prehandle_keyboard_event_type_ = event.type;
prehandle_keyboard_event_called_ = true;
return prehandle_keyboard_event_;
}
- virtual void HandleKeyboardEvent(
- const NativeWebKeyboardEvent& event) OVERRIDE {
+ void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override {
unhandled_keyboard_event_type_ = event.type;
unhandled_keyboard_event_called_ = true;
}
- virtual bool HandleWheelEvent(
- const blink::WebMouseWheelEvent& event) OVERRIDE {
+ bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override {
handle_wheel_event_called_ = true;
return handle_wheel_event_;
}
last_simulated_event_time_seconds_ =
(base::TimeTicks::Now() - base::TimeTicks()).InSecondsF();
}
- virtual ~RenderWidgetHostTest() {
- }
+ ~RenderWidgetHostTest() override {}
bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) {
return handle_key_press_event_;
protected:
// testing::Test
- virtual void SetUp() {
+ void SetUp() override {
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
command_line->AppendSwitch(switches::kValidateInputEventStream);
host_->Init();
host_->DisableGestureDebounce();
}
- virtual void TearDown() {
+ void TearDown() override {
view_.reset();
host_.reset();
delegate_.reset();
TEST_F(RenderWidgetHostTest, Background) {
scoped_ptr<RenderWidgetHostViewBase> view;
#if defined(USE_AURA)
- view.reset(new RenderWidgetHostViewAura(host_.get()));
+ view.reset(new RenderWidgetHostViewAura(host_.get(), false));
// TODO(derat): Call this on all platforms: http://crbug.com/102450.
view->InitAsChild(NULL);
#elif defined(OS_ANDROID)
host_->SetView(view.get());
EXPECT_TRUE(view->GetBackgroundOpaque());
- view->SetBackgroundOpaque(false);
+ view->SetBackgroundColor(SK_ColorTRANSPARENT);
EXPECT_FALSE(view->GetBackgroundOpaque());
const IPC::Message* set_background =
simulated_event_time_delta_seconds_ = 0.1;
// Immediately ack all touches instead of sending them to the renderer.
host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
- host_->OnMessageReceived(
- ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true));
+ host_->SetTouchEventEmulationEnabled(true);
process_->sink().ClearMessages();
view_->set_bounds(gfx::Rect(0, 0, 400, 200));
view_->Show();
EXPECT_EQ(0U, process_->sink().message_count());
// Turn off emulation during a pinch.
- host_->OnMessageReceived(
- ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false));
+ host_->SetTouchEventEmulationEnabled(false);
EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type());
EXPECT_EQ("GesturePinchEnd GestureScrollEnd",
GetInputMessageTypes(process_));
EXPECT_EQ(0U, process_->sink().message_count());
// Turn on emulation.
- host_->OnMessageReceived(
- ViewHostMsg_SetTouchEventEmulationEnabled(0, true, true));
+ host_->SetTouchEventEmulationEnabled(true);
EXPECT_EQ(0U, process_->sink().message_count());
// Another touch.
INPUT_EVENT_ACK_STATE_CONSUMED);
// Turn off emulation during a scroll.
- host_->OnMessageReceived(
- ViewHostMsg_SetTouchEventEmulationEnabled(0, false, false));
+ host_->SetTouchEventEmulationEnabled(false);
EXPECT_EQ(WebInputEvent::TouchCancel, host_->acked_touch_event_type());
EXPECT_EQ("GestureScrollEnd", GetInputMessageTypes(process_));
TEST_F(RenderWidgetHostTest, InputRouterReceivesMoveCaret_ACK) {
host_->SetupForInputRouterTest();
- host_->OnMessageReceived(ViewHostMsg_MoveCaret_ACK(0));
+ host_->OnMessageReceived(InputHostMsg_MoveCaret_ACK(0));
EXPECT_TRUE(host_->mock_input_router()->message_received_);
}
TEST_F(RenderWidgetHostTest, InputRouterReceivesSelectRange_ACK) {
host_->SetupForInputRouterTest();
- host_->OnMessageReceived(ViewHostMsg_SelectRange_ACK(0));
+ host_->OnMessageReceived(InputHostMsg_SelectRange_ACK(0));
EXPECT_TRUE(host_->mock_input_router()->message_received_);
}
EXPECT_TRUE(host_->mock_input_router()->message_received_);
}
-
-void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process,
- int64 component_id,
- WebInputEvent::Type input_type) {
+ui::LatencyInfo GetLatencyInfoFromInputEvent(RenderWidgetHostProcess* process) {
const IPC::Message* message = process->sink().GetUniqueMessageMatching(
InputMsg_HandleInputEvent::ID);
- ASSERT_TRUE(message);
+ EXPECT_TRUE(message);
InputMsg_HandleInputEvent::Param params;
EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, ¶ms));
- ui::LatencyInfo latency_info = params.b;
+ process->sink().ClearMessages();
+ return params.b;
+}
+
+void CheckLatencyInfoComponentInMessage(RenderWidgetHostProcess* process,
+ int64 component_id,
+ WebInputEvent::Type input_type) {
+ ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process);
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()
SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
}
+// Tests that after input event passes through RWHI through
+// ForwardXXXEventWithLatencyInfo(), input event coordinates will be present in
+// the latency info.
+TEST_F(RenderWidgetHostTest, InputEventRWHLatencyInfoCoordinates) {
+ host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, true));
+ process_->sink().ClearMessages();
+
+ {
+ WebMouseWheelEvent event =
+ SyntheticWebMouseWheelEventBuilder::Build(-5, 0, 0, true);
+ event.x = 100;
+ event.y = 200;
+ host_->ForwardWheelEvent(event);
+ ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process_);
+ EXPECT_EQ(1u, latency_info.input_coordinates_size);
+ EXPECT_EQ(100, latency_info.input_coordinates[0].x);
+ EXPECT_EQ(200, latency_info.input_coordinates[0].y);
+ SendInputEventACK(WebInputEvent::MouseWheel,
+ INPUT_EVENT_ACK_STATE_CONSUMED);
+ }
+
+ {
+ WebMouseEvent event =
+ SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove);
+ event.x = 300;
+ event.y = 400;
+ host_->ForwardMouseEvent(event);
+ ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process_);
+ EXPECT_EQ(1u, latency_info.input_coordinates_size);
+ EXPECT_EQ(300, latency_info.input_coordinates[0].x);
+ EXPECT_EQ(400, latency_info.input_coordinates[0].y);
+ SendInputEventACK(WebInputEvent::MouseMove, INPUT_EVENT_ACK_STATE_CONSUMED);
+ }
+
+ {
+ WebGestureEvent event = SyntheticWebGestureEventBuilder::Build(
+ WebInputEvent::GestureScrollBegin, blink::WebGestureDeviceTouchscreen);
+ event.x = 500;
+ event.y = 600;
+ host_->ForwardGestureEvent(event);
+ ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process_);
+ EXPECT_EQ(1u, latency_info.input_coordinates_size);
+ EXPECT_EQ(500, latency_info.input_coordinates[0].x);
+ EXPECT_EQ(600, latency_info.input_coordinates[0].y);
+ SendInputEventACK(WebInputEvent::GestureScrollBegin,
+ INPUT_EVENT_ACK_STATE_CONSUMED);
+ }
+
+ {
+ PressTouchPoint(700, 800);
+ PressTouchPoint(900, 1000);
+ PressTouchPoint(1100, 1200); // LatencyInfo only holds two coordinates.
+ SendTouchEvent();
+ ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process_);
+ EXPECT_EQ(2u, latency_info.input_coordinates_size);
+ EXPECT_EQ(700, latency_info.input_coordinates[0].x);
+ EXPECT_EQ(800, latency_info.input_coordinates[0].y);
+ EXPECT_EQ(900, latency_info.input_coordinates[1].x);
+ EXPECT_EQ(1000, latency_info.input_coordinates[1].y);
+ SendInputEventACK(WebInputEvent::TouchStart,
+ INPUT_EVENT_ACK_STATE_CONSUMED);
+ }
+
+ {
+ NativeWebKeyboardEvent event;
+ event.type = WebKeyboardEvent::KeyDown;
+ host_->ForwardKeyboardEvent(event);
+ ui::LatencyInfo latency_info = GetLatencyInfoFromInputEvent(process_);
+ EXPECT_EQ(0u, latency_info.input_coordinates_size);
+ SendInputEventACK(WebInputEvent::KeyDown, INPUT_EVENT_ACK_STATE_CONSUMED);
+ }
+}
+
TEST_F(RenderWidgetHostTest, RendererExitedResetsInputRouter) {
// RendererExited will delete the view.
host_->SetView(new TestView(host_.get()));