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

Side by Side Diff: content/renderer/render_widget_unittest.cc

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Created 4 years 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/renderer/render_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <tuple> 7 #include <tuple>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/macros.h" 10 #include "base/macros.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 for (std::vector<gfx::Rect>::const_iterator iter = rects_.begin(); 93 for (std::vector<gfx::Rect>::const_iterator iter = rects_.begin();
94 iter != rects_.end(); ++iter) { 94 iter != rects_.end(); ++iter) {
95 if ((*iter).Contains(point)) 95 if ((*iter).Contains(point))
96 return true; 96 return true;
97 } 97 }
98 return false; 98 return false;
99 } 99 }
100 100
101 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override { 101 bool WillHandleGestureEvent(const blink::WebGestureEvent& event) override {
102 if (always_overscroll_ && 102 if (always_overscroll_ &&
103 event.type == blink::WebInputEvent::GestureScrollUpdate) { 103 event.type() == blink::WebInputEvent::GestureScrollUpdate) {
104 didOverscroll(blink::WebFloatSize(event.data.scrollUpdate.deltaX, 104 didOverscroll(blink::WebFloatSize(event.data.scrollUpdate.deltaX,
105 event.data.scrollUpdate.deltaY), 105 event.data.scrollUpdate.deltaY),
106 blink::WebFloatSize(event.data.scrollUpdate.deltaX, 106 blink::WebFloatSize(event.data.scrollUpdate.deltaX,
107 event.data.scrollUpdate.deltaY), 107 event.data.scrollUpdate.deltaY),
108 blink::WebFloatPoint(event.x, event.y), 108 blink::WebFloatPoint(event.x, event.y),
109 blink::WebFloatSize(event.data.scrollUpdate.velocityX, 109 blink::WebFloatSize(event.data.scrollUpdate.velocityX,
110 event.data.scrollUpdate.velocityY)); 110 event.data.scrollUpdate.velocityY));
111 return true; 111 return true;
112 } 112 }
113 113
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 widget()->SendInputEvent(scroll); 254 widget()->SendInputEvent(scroll);
255 255
256 // Overscroll notifications received while handling an input event should 256 // Overscroll notifications received while handling an input event should
257 // be bundled with the event ack IPC. 257 // be bundled with the event ack IPC.
258 ASSERT_EQ(1u, widget()->sink()->message_count()); 258 ASSERT_EQ(1u, widget()->sink()->message_count());
259 const IPC::Message* message = widget()->sink()->GetMessageAt(0); 259 const IPC::Message* message = widget()->sink()->GetMessageAt(0);
260 ASSERT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); 260 ASSERT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type());
261 InputHostMsg_HandleInputEvent_ACK::Param params; 261 InputHostMsg_HandleInputEvent_ACK::Param params;
262 InputHostMsg_HandleInputEvent_ACK::Read(message, &params); 262 InputHostMsg_HandleInputEvent_ACK::Read(message, &params);
263 const InputEventAck& ack = std::get<0>(params); 263 const InputEventAck& ack = std::get<0>(params);
264 ASSERT_EQ(ack.type, scroll.type); 264 ASSERT_EQ(ack.type, scroll.type());
265 ASSERT_TRUE(ack.overscroll); 265 ASSERT_TRUE(ack.overscroll);
266 EXPECT_EQ(gfx::Vector2dF(0, 10), ack.overscroll->accumulated_overscroll); 266 EXPECT_EQ(gfx::Vector2dF(0, 10), ack.overscroll->accumulated_overscroll);
267 EXPECT_EQ(gfx::Vector2dF(0, 10), ack.overscroll->latest_overscroll_delta); 267 EXPECT_EQ(gfx::Vector2dF(0, 10), ack.overscroll->latest_overscroll_delta);
268 EXPECT_EQ(gfx::Vector2dF(), ack.overscroll->current_fling_velocity); 268 EXPECT_EQ(gfx::Vector2dF(), ack.overscroll->current_fling_velocity);
269 EXPECT_EQ(gfx::PointF(-10, 0), ack.overscroll->causal_event_viewport_point); 269 EXPECT_EQ(gfx::PointF(-10, 0), ack.overscroll->causal_event_viewport_point);
270 widget()->sink()->ClearMessages(); 270 widget()->sink()->ClearMessages();
271 } 271 }
272 272
273 TEST_F(RenderWidgetUnittest, FlingOverscroll) { 273 TEST_F(RenderWidgetUnittest, FlingOverscroll) {
274 // Overscroll notifications received outside of handling an input event should 274 // Overscroll notifications received outside of handling an input event should
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 blink::WebRect popup_emulated_rect(130, 170, 100, 400); 501 blink::WebRect popup_emulated_rect(130, 170, 100, 400);
502 widget()->setWindowRect(popup_emulated_rect); 502 widget()->setWindowRect(popup_emulated_rect);
503 503
504 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); 504 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x);
505 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); 505 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y);
506 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); 506 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x);
507 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); 507 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y);
508 } 508 }
509 509
510 } // namespace content 510 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698