Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 14 matching lines...) Expand all Loading... | |
| 25 #include "content/common/input_messages.h" | 25 #include "content/common/input_messages.h" |
| 26 #include "content/common/resize_params.h" | 26 #include "content/common/resize_params.h" |
| 27 #include "content/common/view_messages.h" | 27 #include "content/common/view_messages.h" |
| 28 #include "content/public/common/content_switches.h" | 28 #include "content/public/common/content_switches.h" |
| 29 #include "content/public/test/mock_render_process_host.h" | 29 #include "content/public/test/mock_render_process_host.h" |
| 30 #include "content/public/test/test_browser_context.h" | 30 #include "content/public/test/test_browser_context.h" |
| 31 #include "content/public/test/test_browser_thread_bundle.h" | 31 #include "content/public/test/test_browser_thread_bundle.h" |
| 32 #include "content/test/test_render_view_host.h" | 32 #include "content/test/test_render_view_host.h" |
| 33 #include "testing/gtest/include/gtest/gtest.h" | 33 #include "testing/gtest/include/gtest/gtest.h" |
| 34 #include "ui/display/screen.h" | 34 #include "ui/display/screen.h" |
| 35 #include "ui/events/base_event_utils.h" | |
| 35 #include "ui/events/blink/web_input_event_traits.h" | 36 #include "ui/events/blink/web_input_event_traits.h" |
| 36 #include "ui/events/keycodes/keyboard_codes.h" | 37 #include "ui/events/keycodes/keyboard_codes.h" |
| 37 #include "ui/gfx/canvas.h" | 38 #include "ui/gfx/canvas.h" |
| 38 | 39 |
| 39 #if defined(OS_ANDROID) | 40 #if defined(OS_ANDROID) |
| 40 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" | 41 #include "content/browser/renderer_host/context_provider_factory_impl_android.h" |
| 41 #include "content/browser/renderer_host/render_widget_host_view_android.h" | 42 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
| 42 #include "content/test/mock_gpu_channel_establish_factory.h" | 43 #include "content/test/mock_gpu_channel_establish_factory.h" |
| 43 #include "ui/android/screen_android.h" | 44 #include "ui/android/screen_android.h" |
| 44 #endif | 45 #endif |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 } | 253 } |
| 253 | 254 |
| 254 // Sets the bounds returned by GetViewBounds. | 255 // Sets the bounds returned by GetViewBounds. |
| 255 void set_bounds(const gfx::Rect& bounds) { | 256 void set_bounds(const gfx::Rect& bounds) { |
| 256 bounds_ = bounds; | 257 bounds_ = bounds; |
| 257 } | 258 } |
| 258 | 259 |
| 259 const WebTouchEvent& acked_event() const { return acked_event_; } | 260 const WebTouchEvent& acked_event() const { return acked_event_; } |
| 260 int acked_event_count() const { return acked_event_count_; } | 261 int acked_event_count() const { return acked_event_count_; } |
| 261 void ClearAckedEvent() { | 262 void ClearAckedEvent() { |
| 262 acked_event_.type = blink::WebInputEvent::Undefined; | 263 acked_event_.setType(blink::WebInputEvent::Undefined); |
| 263 acked_event_count_ = 0; | 264 acked_event_count_ = 0; |
| 264 } | 265 } |
| 265 | 266 |
| 266 const WebMouseWheelEvent& unhandled_wheel_event() const { | 267 const WebMouseWheelEvent& unhandled_wheel_event() const { |
| 267 return unhandled_wheel_event_; | 268 return unhandled_wheel_event_; |
| 268 } | 269 } |
| 269 int unhandled_wheel_event_count() const { | 270 int unhandled_wheel_event_count() const { |
| 270 return unhandled_wheel_event_count_; | 271 return unhandled_wheel_event_count_; |
| 271 } | 272 } |
| 272 int gesture_event_type() const { return gesture_event_type_; } | 273 int gesture_event_type() const { return gesture_event_type_; } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 304 return mock_physical_backing_size_; | 305 return mock_physical_backing_size_; |
| 305 return TestRenderWidgetHostView::GetPhysicalBackingSize(); | 306 return TestRenderWidgetHostView::GetPhysicalBackingSize(); |
| 306 } | 307 } |
| 307 #if defined(USE_AURA) | 308 #if defined(USE_AURA) |
| 308 ~TestView() override { | 309 ~TestView() override { |
| 309 // Simulate the mouse exit event dispatched when an aura window is | 310 // Simulate the mouse exit event dispatched when an aura window is |
| 310 // destroyed. (MakeWebMouseEventFromAuraEvent translates ET_MOUSE_EXITED | 311 // destroyed. (MakeWebMouseEventFromAuraEvent translates ET_MOUSE_EXITED |
| 311 // into WebInputEvent::MouseMove.) | 312 // into WebInputEvent::MouseMove.) |
| 312 WebMouseEvent event = | 313 WebMouseEvent event = |
| 313 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove); | 314 SyntheticWebMouseEventBuilder::Build(WebInputEvent::MouseMove); |
| 314 event.timeStampSeconds = | 315 event.setTimeStampSeconds( |
| 315 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 316 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
| 316 rwh_->input_router()->SendMouseEvent( | 317 rwh_->input_router()->SendMouseEvent( |
| 317 MouseEventWithLatencyInfo(event, ui::LatencyInfo())); | 318 MouseEventWithLatencyInfo(event, ui::LatencyInfo())); |
| 318 } | 319 } |
| 319 #endif | 320 #endif |
| 320 | 321 |
| 321 protected: | 322 protected: |
| 322 WebMouseWheelEvent unhandled_wheel_event_; | 323 WebMouseWheelEvent unhandled_wheel_event_; |
| 323 int unhandled_wheel_event_count_; | 324 int unhandled_wheel_event_count_; |
| 324 WebTouchEvent acked_event_; | 325 WebTouchEvent acked_event_; |
| 325 int acked_event_count_; | 326 int acked_event_count_; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 441 // RenderWidgetHostTest -------------------------------------------------------- | 442 // RenderWidgetHostTest -------------------------------------------------------- |
| 442 | 443 |
| 443 class RenderWidgetHostTest : public testing::Test { | 444 class RenderWidgetHostTest : public testing::Test { |
| 444 public: | 445 public: |
| 445 RenderWidgetHostTest() | 446 RenderWidgetHostTest() |
| 446 : process_(NULL), | 447 : process_(NULL), |
| 447 handle_key_press_event_(false), | 448 handle_key_press_event_(false), |
| 448 handle_mouse_event_(false), | 449 handle_mouse_event_(false), |
| 449 simulated_event_time_delta_seconds_(0) { | 450 simulated_event_time_delta_seconds_(0) { |
| 450 last_simulated_event_time_seconds_ = | 451 last_simulated_event_time_seconds_ = |
| 451 (base::TimeTicks::Now() - base::TimeTicks()).InSecondsF(); | 452 ui::EventTimeStampToSeconds(ui::EventTimeForNow()); |
| 452 } | 453 } |
| 453 ~RenderWidgetHostTest() override {} | 454 ~RenderWidgetHostTest() override {} |
| 454 | 455 |
| 455 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) { | 456 bool KeyPressEventCallback(const NativeWebKeyboardEvent& /* event */) { |
| 456 return handle_key_press_event_; | 457 return handle_key_press_event_; |
| 457 } | 458 } |
| 458 bool MouseEventCallback(const blink::WebMouseEvent& /* event */) { | 459 bool MouseEventCallback(const blink::WebMouseEvent& /* event */) { |
| 459 return handle_mouse_event_; | 460 return handle_mouse_event_; |
| 460 } | 461 } |
| 461 | 462 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 double GetNextSimulatedEventTimeSeconds() { | 539 double GetNextSimulatedEventTimeSeconds() { |
| 539 last_simulated_event_time_seconds_ += simulated_event_time_delta_seconds_; | 540 last_simulated_event_time_seconds_ += simulated_event_time_delta_seconds_; |
| 540 return last_simulated_event_time_seconds_; | 541 return last_simulated_event_time_seconds_; |
| 541 } | 542 } |
| 542 | 543 |
| 543 void SimulateKeyboardEvent(WebInputEvent::Type type) { | 544 void SimulateKeyboardEvent(WebInputEvent::Type type) { |
| 544 SimulateKeyboardEvent(type, 0); | 545 SimulateKeyboardEvent(type, 0); |
| 545 } | 546 } |
| 546 | 547 |
| 547 void SimulateKeyboardEvent(WebInputEvent::Type type, int modifiers) { | 548 void SimulateKeyboardEvent(WebInputEvent::Type type, int modifiers) { |
| 548 WebKeyboardEvent event = SyntheticWebKeyboardEventBuilder::Build(type); | 549 NativeWebKeyboardEvent native_event(type, modifiers, ui::EventTimeForNow()); |
|
majidvp
2016/12/19 20:09:52
Shouldn't this be the simulate time i.e., GetNextS
dtapuska
2016/12/20 19:49:21
Done.
| |
| 549 event.modifiers = modifiers; | |
| 550 NativeWebKeyboardEvent native_event; | |
| 551 memcpy(&native_event, &event, sizeof(event)); | |
| 552 host_->ForwardKeyboardEvent(native_event); | 550 host_->ForwardKeyboardEvent(native_event); |
| 553 } | 551 } |
| 554 | 552 |
| 555 void SimulateMouseEvent(WebInputEvent::Type type) { | 553 void SimulateMouseEvent(WebInputEvent::Type type) { |
| 556 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); | 554 host_->ForwardMouseEvent(SyntheticWebMouseEventBuilder::Build(type)); |
| 557 } | 555 } |
| 558 | 556 |
| 559 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type, | 557 void SimulateMouseEventWithLatencyInfo(WebInputEvent::Type type, |
| 560 const ui::LatencyInfo& ui_latency) { | 558 const ui::LatencyInfo& ui_latency) { |
| 561 host_->ForwardMouseEventWithLatencyInfo( | 559 host_->ForwardMouseEventWithLatencyInfo( |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 582 void SimulateMouseMove(int x, int y, int modifiers) { | 580 void SimulateMouseMove(int x, int y, int modifiers) { |
| 583 SimulateMouseEvent(WebInputEvent::MouseMove, x, y, modifiers, false); | 581 SimulateMouseEvent(WebInputEvent::MouseMove, x, y, modifiers, false); |
| 584 } | 582 } |
| 585 | 583 |
| 586 void SimulateMouseEvent( | 584 void SimulateMouseEvent( |
| 587 WebInputEvent::Type type, int x, int y, int modifiers, bool pressed) { | 585 WebInputEvent::Type type, int x, int y, int modifiers, bool pressed) { |
| 588 WebMouseEvent event = | 586 WebMouseEvent event = |
| 589 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers); | 587 SyntheticWebMouseEventBuilder::Build(type, x, y, modifiers); |
| 590 if (pressed) | 588 if (pressed) |
| 591 event.button = WebMouseEvent::Button::Left; | 589 event.button = WebMouseEvent::Button::Left; |
| 592 event.timeStampSeconds = GetNextSimulatedEventTimeSeconds(); | 590 event.setTimeStampSeconds(GetNextSimulatedEventTimeSeconds()); |
| 593 host_->ForwardMouseEvent(event); | 591 host_->ForwardMouseEvent(event); |
| 594 } | 592 } |
| 595 | 593 |
| 596 // Inject simple synthetic WebGestureEvent instances. | 594 // Inject simple synthetic WebGestureEvent instances. |
| 597 void SimulateGestureEvent(WebInputEvent::Type type, | 595 void SimulateGestureEvent(WebInputEvent::Type type, |
| 598 WebGestureDevice sourceDevice) { | 596 WebGestureDevice sourceDevice) { |
| 599 host_->ForwardGestureEvent( | 597 host_->ForwardGestureEvent( |
| 600 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); | 598 SyntheticWebGestureEventBuilder::Build(type, sourceDevice)); |
| 601 } | 599 } |
| 602 | 600 |
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1715 ui::LatencyInfo()); | 1713 ui::LatencyInfo()); |
| 1716 | 1714 |
| 1717 | 1715 |
| 1718 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). | 1716 // Tests RWHI::ForwardWheelEventWithLatencyInfo(). |
| 1719 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); | 1717 SimulateWheelEventWithLatencyInfo(-5, 0, 0, true, ui::LatencyInfo()); |
| 1720 | 1718 |
| 1721 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); | 1719 ASSERT_FALSE(host_->input_router()->HasPendingEvents()); |
| 1722 } | 1720 } |
| 1723 | 1721 |
| 1724 } // namespace content | 1722 } // namespace content |
| OLD | NEW |