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

Side by Side Diff: content/browser/renderer_host/render_widget_host_unittest.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Fix nits Created 3 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <memory> 8 #include <memory>
9 #include <tuple> 9 #include <tuple>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::string GetInputMessageTypes(MockRenderProcessHost* process) { 70 std::string GetInputMessageTypes(MockRenderProcessHost* process) {
71 std::string result; 71 std::string result;
72 for (size_t i = 0; i < process->sink().message_count(); ++i) { 72 for (size_t i = 0; i < process->sink().message_count(); ++i) {
73 const IPC::Message* message = process->sink().GetMessageAt(i); 73 const IPC::Message* message = process->sink().GetMessageAt(i);
74 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); 74 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type());
75 InputMsg_HandleInputEvent::Param params; 75 InputMsg_HandleInputEvent::Param params;
76 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, &params)); 76 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, &params));
77 const WebInputEvent* event = std::get<0>(params); 77 const WebInputEvent* event = std::get<0>(params);
78 if (i != 0) 78 if (i != 0)
79 result += " "; 79 result += " ";
80 result += WebInputEvent::GetName(event->type); 80 result += WebInputEvent::GetName(event->type());
81 } 81 }
82 process->sink().ClearMessages(); 82 process->sink().ClearMessages();
83 return result; 83 return result;
84 } 84 }
85 85
86 // MockInputRouter ------------------------------------------------------------- 86 // MockInputRouter -------------------------------------------------------------
87 87
88 class MockInputRouter : public InputRouter { 88 class MockInputRouter : public InputRouter {
89 public: 89 public:
90 explicit MockInputRouter(InputRouterClient* client) 90 explicit MockInputRouter(InputRouterClient* client)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 using RenderWidgetHostImpl::RendererExited; 176 using RenderWidgetHostImpl::RendererExited;
177 using RenderWidgetHostImpl::SetInitialRenderSizeParams; 177 using RenderWidgetHostImpl::SetInitialRenderSizeParams;
178 using RenderWidgetHostImpl::old_resize_params_; 178 using RenderWidgetHostImpl::old_resize_params_;
179 using RenderWidgetHostImpl::is_hidden_; 179 using RenderWidgetHostImpl::is_hidden_;
180 using RenderWidgetHostImpl::resize_ack_pending_; 180 using RenderWidgetHostImpl::resize_ack_pending_;
181 using RenderWidgetHostImpl::input_router_; 181 using RenderWidgetHostImpl::input_router_;
182 182
183 void OnTouchEventAck(const TouchEventWithLatencyInfo& event, 183 void OnTouchEventAck(const TouchEventWithLatencyInfo& event,
184 InputEventAckState ack_result) override { 184 InputEventAckState ack_result) override {
185 // Sniff touch acks. 185 // Sniff touch acks.
186 acked_touch_event_type_ = event.event.type; 186 acked_touch_event_type_ = event.event.type();
187 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result); 187 RenderWidgetHostImpl::OnTouchEventAck(event, ack_result);
188 } 188 }
189 189
190 bool new_content_rendering_timeout_fired() const { 190 bool new_content_rendering_timeout_fired() const {
191 return new_content_rendering_timeout_fired_; 191 return new_content_rendering_timeout_fired_;
192 } 192 }
193 193
194 void DisableGestureDebounce() { 194 void DisableGestureDebounce() {
195 input_router_.reset(new InputRouterImpl( 195 input_router_.reset(new InputRouterImpl(
196 process_, this, this, routing_id_, InputRouterImpl::Config())); 196 process_, this, this, routing_id_, InputRouterImpl::Config()));
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 } 290 }
291 void WheelEventAck(const WebMouseWheelEvent& event, 291 void WheelEventAck(const WebMouseWheelEvent& event,
292 InputEventAckState ack_result) override { 292 InputEventAckState ack_result) override {
293 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) 293 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED)
294 return; 294 return;
295 unhandled_wheel_event_count_++; 295 unhandled_wheel_event_count_++;
296 unhandled_wheel_event_ = event; 296 unhandled_wheel_event_ = event;
297 } 297 }
298 void GestureEventAck(const WebGestureEvent& event, 298 void GestureEventAck(const WebGestureEvent& event,
299 InputEventAckState ack_result) override { 299 InputEventAckState ack_result) override {
300 gesture_event_type_ = event.type; 300 gesture_event_type_ = event.type();
301 ack_result_ = ack_result; 301 ack_result_ = ack_result;
302 } 302 }
303 gfx::Size GetPhysicalBackingSize() const override { 303 gfx::Size GetPhysicalBackingSize() const override {
304 if (use_fake_physical_backing_size_) 304 if (use_fake_physical_backing_size_)
305 return mock_physical_backing_size_; 305 return mock_physical_backing_size_;
306 return TestRenderWidgetHostView::GetPhysicalBackingSize(); 306 return TestRenderWidgetHostView::GetPhysicalBackingSize();
307 } 307 }
308 #if defined(USE_AURA) 308 #if defined(USE_AURA)
309 ~TestView() override { 309 ~TestView() override {
310 // Simulate the mouse exit event dispatched when an aura window is 310 // Simulate the mouse exit event dispatched when an aura window is
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
389 } 389 }
390 390
391 // RenderWidgetHostDelegate overrides. 391 // RenderWidgetHostDelegate overrides.
392 void GetScreenInfo(ScreenInfo* screen_info) override { 392 void GetScreenInfo(ScreenInfo* screen_info) override {
393 *screen_info = screen_info_; 393 *screen_info = screen_info_;
394 } 394 }
395 395
396 protected: 396 protected:
397 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 397 bool PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
398 bool* is_keyboard_shortcut) override { 398 bool* is_keyboard_shortcut) override {
399 prehandle_keyboard_event_type_ = event.type; 399 prehandle_keyboard_event_type_ = event.type();
400 prehandle_keyboard_event_called_ = true; 400 prehandle_keyboard_event_called_ = true;
401 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_; 401 *is_keyboard_shortcut = prehandle_keyboard_event_is_shortcut_;
402 return prehandle_keyboard_event_; 402 return prehandle_keyboard_event_;
403 } 403 }
404 404
405 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override { 405 void HandleKeyboardEvent(const NativeWebKeyboardEvent& event) override {
406 unhandled_keyboard_event_type_ = event.type; 406 unhandled_keyboard_event_type_ = event.type();
407 unhandled_keyboard_event_called_ = true; 407 unhandled_keyboard_event_called_ = true;
408 } 408 }
409 409
410 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override { 410 bool HandleWheelEvent(const blink::WebMouseWheelEvent& event) override {
411 handle_wheel_event_called_ = true; 411 handle_wheel_event_called_ = true;
412 return handle_wheel_event_; 412 return handle_wheel_event_;
413 } 413 }
414 414
415 void RendererUnresponsive(RenderWidgetHostImpl* render_widget_host, 415 void RendererUnresponsive(RenderWidgetHostImpl* render_widget_host,
416 RendererUnresponsiveType type) override { 416 RendererUnresponsiveType type) override {
(...skipping 1152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1569 EXPECT_EQ(process->sink().message_count(), 1U); 1569 EXPECT_EQ(process->sink().message_count(), 1U);
1570 1570
1571 const IPC::Message* message = process->sink().GetMessageAt(0); 1571 const IPC::Message* message = process->sink().GetMessageAt(0);
1572 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type()); 1572 EXPECT_EQ(InputMsg_HandleInputEvent::ID, message->type());
1573 InputMsg_HandleInputEvent::Param params; 1573 InputMsg_HandleInputEvent::Param params;
1574 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, &params)); 1574 EXPECT_TRUE(InputMsg_HandleInputEvent::Read(message, &params));
1575 1575
1576 const WebInputEvent* event = std::get<0>(params); 1576 const WebInputEvent* event = std::get<0>(params);
1577 ui::LatencyInfo latency_info = std::get<1>(params); 1577 ui::LatencyInfo latency_info = std::get<1>(params);
1578 1578
1579 EXPECT_TRUE(event->type == expected_type); 1579 EXPECT_TRUE(event->type() == expected_type);
1580 EXPECT_TRUE(latency_info.FindLatency( 1580 EXPECT_TRUE(latency_info.FindLatency(
1581 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL)); 1581 ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT, component_id, NULL));
1582 1582
1583 process->sink().ClearMessages(); 1583 process->sink().ClearMessages();
1584 } 1584 }
1585 1585
1586 // Tests that after input event passes through RWHI through ForwardXXXEvent() 1586 // Tests that after input event passes through RWHI through ForwardXXXEvent()
1587 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component 1587 // or ForwardXXXEventWithLatencyInfo(), LatencyInfo component
1588 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the 1588 // ui::INPUT_EVENT_LATENCY_BEGIN_RWH_COMPONENT will always present in the
1589 // event's LatencyInfo. 1589 // event's LatencyInfo.
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
1714 ui::LatencyInfo()); 1714 ui::LatencyInfo());
1715 1715
1716 1716
1717 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). 1717 // Tests RWHI::ForwardWheelEventWithLatencyInfo().
1718 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); 1718 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo());
1719 1719
1720 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); 1720 ASSERT_FALSE(host_->input_router()->HasPendingEvents());
1721 } 1721 }
1722 1722
1723 } // namespace content 1723 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698