OLD | NEW |
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" |
11 #include "base/test/histogram_tester.h" | 11 #include "base/test/histogram_tester.h" |
12 #include "content/common/input/synthetic_web_input_event_builders.h" | 12 #include "content/common/input/synthetic_web_input_event_builders.h" |
13 #include "content/common/input_messages.h" | 13 #include "content/common/input_messages.h" |
14 #include "content/common/resize_params.h" | 14 #include "content/common/resize_params.h" |
15 #include "content/public/test/mock_render_thread.h" | 15 #include "content/public/test/mock_render_thread.h" |
16 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" | 16 #include "content/renderer/devtools/render_widget_screen_metrics_emulator.h" |
17 #include "content/test/fake_compositor_dependencies.h" | 17 #include "content/test/fake_compositor_dependencies.h" |
18 #include "content/test/mock_render_process.h" | 18 #include "content/test/mock_render_process.h" |
19 #include "ipc/ipc_test_sink.h" | 19 #include "ipc/ipc_test_sink.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 22 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
23 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 23 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 24 #include "ui/events/base_event_utils.h" |
24 #include "ui/events/blink/web_input_event_traits.h" | 25 #include "ui/events/blink/web_input_event_traits.h" |
25 #include "ui/gfx/geometry/rect.h" | 26 #include "ui/gfx/geometry/rect.h" |
26 | 27 |
27 using testing::_; | 28 using testing::_; |
28 | 29 |
29 namespace content { | 30 namespace content { |
30 | 31 |
31 namespace { | 32 namespace { |
32 | 33 |
33 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners"; | 34 const char* EVENT_LISTENER_RESULT_HISTOGRAM = "Event.PassiveListeners"; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
240 widget()->sink()->ClearMessages(); | 241 widget()->sink()->ClearMessages(); |
241 } | 242 } |
242 | 243 |
243 TEST_F(RenderWidgetUnittest, EventOverscroll) { | 244 TEST_F(RenderWidgetUnittest, EventOverscroll) { |
244 widget()->set_always_overscroll(true); | 245 widget()->set_always_overscroll(true); |
245 | 246 |
246 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 247 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
247 .WillRepeatedly( | 248 .WillRepeatedly( |
248 ::testing::Return(blink::WebInputEventResult::NotHandled)); | 249 ::testing::Return(blink::WebInputEventResult::NotHandled)); |
249 | 250 |
250 blink::WebGestureEvent scroll; | 251 blink::WebGestureEvent scroll( |
251 scroll.type = blink::WebInputEvent::GestureScrollUpdate; | 252 blink::WebInputEvent::GestureScrollUpdate, |
| 253 blink::WebInputEvent::NoModifiers, |
| 254 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
252 scroll.x = -10; | 255 scroll.x = -10; |
253 scroll.data.scrollUpdate.deltaY = 10; | 256 scroll.data.scrollUpdate.deltaY = 10; |
254 widget()->SendInputEvent(scroll); | 257 widget()->SendInputEvent(scroll); |
255 | 258 |
256 // Overscroll notifications received while handling an input event should | 259 // Overscroll notifications received while handling an input event should |
257 // be bundled with the event ack IPC. | 260 // be bundled with the event ack IPC. |
258 ASSERT_EQ(1u, widget()->sink()->message_count()); | 261 ASSERT_EQ(1u, widget()->sink()->message_count()); |
259 const IPC::Message* message = widget()->sink()->GetMessageAt(0); | 262 const IPC::Message* message = widget()->sink()->GetMessageAt(0); |
260 ASSERT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); | 263 ASSERT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); |
261 InputHostMsg_HandleInputEvent_ACK::Param params; | 264 InputHostMsg_HandleInputEvent_ACK::Param params; |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 blink::WebRect popup_emulated_rect(130, 170, 100, 400); | 522 blink::WebRect popup_emulated_rect(130, 170, 100, 400); |
520 widget()->setWindowRect(popup_emulated_rect); | 523 widget()->setWindowRect(popup_emulated_rect); |
521 | 524 |
522 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); | 525 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); |
523 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); | 526 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); |
524 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); | 527 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); |
525 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); | 528 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); |
526 } | 529 } |
527 | 530 |
528 } // namespace content | 531 } // namespace content |
OLD | NEW |