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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 widget()->sink()->ClearMessages(); | 238 widget()->sink()->ClearMessages(); |
238 } | 239 } |
239 | 240 |
240 TEST_F(RenderWidgetUnittest, EventOverscroll) { | 241 TEST_F(RenderWidgetUnittest, EventOverscroll) { |
241 widget()->set_always_overscroll(true); | 242 widget()->set_always_overscroll(true); |
242 | 243 |
243 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) | 244 EXPECT_CALL(*widget()->mock_webwidget(), handleInputEvent(_)) |
244 .WillRepeatedly( | 245 .WillRepeatedly( |
245 ::testing::Return(blink::WebInputEventResult::NotHandled)); | 246 ::testing::Return(blink::WebInputEventResult::NotHandled)); |
246 | 247 |
247 blink::WebGestureEvent scroll; | 248 blink::WebGestureEvent scroll( |
248 scroll.type = blink::WebInputEvent::GestureScrollUpdate; | 249 blink::WebInputEvent::GestureScrollUpdate, |
| 250 blink::WebInputEvent::NoModifiers, |
| 251 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
249 scroll.x = -10; | 252 scroll.x = -10; |
250 scroll.data.scrollUpdate.deltaY = 10; | 253 scroll.data.scrollUpdate.deltaY = 10; |
251 widget()->SendInputEvent(scroll); | 254 widget()->SendInputEvent(scroll); |
252 | 255 |
253 // Overscroll notifications received while handling an input event should | 256 // Overscroll notifications received while handling an input event should |
254 // be bundled with the event ack IPC. | 257 // be bundled with the event ack IPC. |
255 ASSERT_EQ(1u, widget()->sink()->message_count()); | 258 ASSERT_EQ(1u, widget()->sink()->message_count()); |
256 const IPC::Message* message = widget()->sink()->GetMessageAt(0); | 259 const IPC::Message* message = widget()->sink()->GetMessageAt(0); |
257 ASSERT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); | 260 ASSERT_EQ(InputHostMsg_HandleInputEvent_ACK::ID, message->type()); |
258 InputHostMsg_HandleInputEvent_ACK::Param params; | 261 InputHostMsg_HandleInputEvent_ACK::Param params; |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
498 blink::WebRect popup_emulated_rect(130, 170, 100, 400); | 501 blink::WebRect popup_emulated_rect(130, 170, 100, 400); |
499 widget()->setWindowRect(popup_emulated_rect); | 502 widget()->setWindowRect(popup_emulated_rect); |
500 | 503 |
501 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); | 504 EXPECT_EQ(popup_emulated_rect.x, widget()->windowRect().x); |
502 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); | 505 EXPECT_EQ(popup_emulated_rect.y, widget()->windowRect().y); |
503 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); | 506 EXPECT_EQ(popup_emulated_rect.x, widget()->viewRect().x); |
504 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); | 507 EXPECT_EQ(popup_emulated_rect.y, widget()->viewRect().y); |
505 } | 508 } |
506 | 509 |
507 } // namespace content | 510 } // namespace content |
OLD | NEW |