Chromium Code Reviews| Index: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
| diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
| index 6d840d7043a0b55a91c0ebb661165e13ae43e41a..0fab892c73c6d6fdd55b8db2e1b722699935bbc3 100644 |
| --- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
| +++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc |
| @@ -308,6 +308,15 @@ class MockWindowObserver : public aura::WindowObserver { |
| MOCK_METHOD2(OnDelegatedFrameDamage, void(aura::Window*, const gfx::Rect&)); |
| }; |
| +const WebInputEvent* GetInputEventFromMessage(const IPC::Message& message) { |
| + PickleIterator iter(message); |
| + const char* data; |
| + int data_length; |
| + if (!message.ReadData(&iter, &data, &data_length)) |
| + return NULL; |
| + return reinterpret_cast<const WebInputEvent*>(data); |
| +} |
| + |
| } // namespace |
| class RenderWidgetHostViewAuraTest : public testing::Test { |
| @@ -388,6 +397,15 @@ class RenderWidgetHostViewAuraTest : public testing::Test { |
| RendererFrameManager::GetInstance()->OnMemoryPressure(level); |
| } |
| + void SendInputEventACK(WebInputEvent::Type type, |
| + InputEventAckState ack_result) { |
| + InputHostMsg_HandleInputEvent_ACK_Params ack; |
| + ack.type = type; |
| + ack.state = ack_result; |
| + InputHostMsg_HandleInputEvent_ACK response(0, ack); |
| + widget_host_->OnMessageReceived(response); |
| + } |
| + |
| protected: |
| // If true, then calls RWH::Shutdown() instead of deleting RWH. |
| bool widget_host_uses_shutdown_to_destroy_; |
| @@ -580,15 +598,6 @@ class RenderWidgetHostViewAuraOverscrollTest |
| velocityX, velocityY, sourceDevice)); |
| } |
| - void SendInputEventACK(WebInputEvent::Type type, |
| - InputEventAckState ack_result) { |
| - InputHostMsg_HandleInputEvent_ACK_Params ack; |
| - ack.type = type; |
| - ack.state = ack_result; |
| - InputHostMsg_HandleInputEvent_ACK response(0, ack); |
| - widget_host_->OnMessageReceived(response); |
| - } |
| - |
| bool ScrollStateIsContentScrolling() const { |
| return scroll_state() == OverscrollController::STATE_CONTENT_SCROLLING; |
| } |
| @@ -3070,4 +3079,57 @@ TEST_F(RenderWidgetHostViewAuraTest, KeyEvent) { |
| } |
| } |
| +TEST_F(RenderWidgetHostViewAuraTest, SetCanScrollForWebMouseWheelEvent) { |
| + view_->InitAsChild(NULL); |
| + view_->Show(); |
| + |
| + sink_->ClearMessages(); |
| + |
| + // Simulates the mouse wheel event with ctrl modifier applied. |
| + ui::MouseWheelEvent event(gfx::Vector2d(1, 1), |
| + gfx::Point(), gfx::Point(), |
| + ui::EF_CONTROL_DOWN, 0); |
| + view_->OnMouseEvent(&event); |
| + |
| + const WebInputEvent* input_event = |
| + GetInputEventFromMessage(*sink_->GetMessageAt(0)); |
| + const WebMouseWheelEvent* wheel_event = |
| + static_cast<const WebMouseWheelEvent*>(input_event); |
| + // Check if the canScroll set to false when ctrl-scroll is generated from |
| + // mouse wheel event. |
| + EXPECT_FALSE(wheel_event->canScroll); |
| + sink_->ClearMessages(); |
| + |
| + // Ack'ing the outstanding event should flush the pending event queue. |
| + SendInputEventACK(blink::WebInputEvent::MouseWheel, |
| + INPUT_EVENT_ACK_STATE_CONSUMED); |
| + |
| + // Simulates the mouse wheel event with no modifier applied. |
| + event = ui::MouseWheelEvent(gfx::Vector2d(1, 1), gfx::Point(), gfx::Point(), |
| + ui::EF_NONE, 0); |
| + |
| + view_->OnMouseEvent(&event); |
| + |
| + input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); |
| + wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); |
| + // Check if the canScroll set to true when no modifier is applied to the |
| + // mouse wheel event. |
| + EXPECT_TRUE(wheel_event->canScroll); |
| + sink_->ClearMessages(); |
| + |
| + SendInputEventACK(blink::WebInputEvent::MouseWheel, |
| + INPUT_EVENT_ACK_STATE_CONSUMED); |
| + |
| + // Simulates the scroll event with ctrl modifier applied. |
| + ui::ScrollEvent scroll(ui::ET_SCROLL, gfx::Point(2, 2), ui::EventTimeForNow(), |
| + ui::EF_CONTROL_DOWN, 0, 5, 0, 5, 2); |
| + view_->OnScrollEvent(&scroll); |
| + |
| + input_event = GetInputEventFromMessage(*sink_->GetMessageAt(0)); |
| + wheel_event = static_cast<const WebMouseWheelEvent*>(input_event); |
| + // Check if the canScroll set to true when ctrl-tpuchpad-scroll is generated |
|
Rick Byers
2014/12/20 21:44:54
nit: typo, "tpuchpad"
|
| + // from scroll event. |
| + EXPECT_TRUE(wheel_event->canScroll); |
| +} |
| + |
| } // namespace content |