Chromium Code Reviews| 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 <math.h> | 5 #include <math.h> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 input_router_->SendInput(scoped_ptr<IPC::Message>( | 347 input_router_->SendInput(scoped_ptr<IPC::Message>( |
| 348 new InputMsg_SelectRange(0, gfx::Point(5, 6), gfx::Point(7, 8)))); | 348 new InputMsg_SelectRange(0, gfx::Point(5, 6), gfx::Point(7, 8)))); |
| 349 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); | 349 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); |
| 350 | 350 |
| 351 input_router_->SendInput(scoped_ptr<IPC::Message>( | 351 input_router_->SendInput(scoped_ptr<IPC::Message>( |
| 352 new InputMsg_SelectRange(0, gfx::Point(9, 10), gfx::Point(11, 12)))); | 352 new InputMsg_SelectRange(0, gfx::Point(9, 10), gfx::Point(11, 12)))); |
| 353 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); | 353 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); |
| 354 | 354 |
| 355 // Now ack the first message. | 355 // Now ack the first message. |
| 356 { | 356 { |
| 357 scoped_ptr<IPC::Message> response(new ViewHostMsg_SelectRange_ACK(0)); | 357 scoped_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); |
|
jdduke (slow)
2014/10/27 15:22:13
Maybe a short test that interleaves RangeSelection
| |
| 358 input_router_->OnMessageReceived(*response); | 358 input_router_->OnMessageReceived(*response); |
| 359 } | 359 } |
| 360 | 360 |
| 361 // Verify that the two messages are coalesced into one message. | 361 // Verify that the two messages are coalesced into one message. |
| 362 ExpectIPCMessageWithArg2<InputMsg_SelectRange>( | 362 ExpectIPCMessageWithArg2<InputMsg_SelectRange>( |
| 363 process_->sink().GetMessageAt(0), | 363 process_->sink().GetMessageAt(0), |
| 364 gfx::Point(9, 10), | 364 gfx::Point(9, 10), |
| 365 gfx::Point(11, 12)); | 365 gfx::Point(11, 12)); |
| 366 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); | 366 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); |
| 367 | 367 |
| 368 // Acking the coalesced msg should not send any more msg. | 368 // Acking the coalesced msg should not send any more msg. |
| 369 { | 369 { |
| 370 scoped_ptr<IPC::Message> response(new ViewHostMsg_SelectRange_ACK(0)); | 370 scoped_ptr<IPC::Message> response(new InputHostMsg_SelectRange_ACK(0)); |
| 371 input_router_->OnMessageReceived(*response); | 371 input_router_->OnMessageReceived(*response); |
| 372 } | 372 } |
| 373 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); | 373 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); |
| 374 } | 374 } |
| 375 | 375 |
| 376 TEST_F(InputRouterImplTest, CoalescesCaretMove) { | 376 TEST_F(InputRouterImplTest, CoalescesCaretMove) { |
| 377 input_router_->SendInput( | 377 input_router_->SendInput( |
| 378 scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(1, 2)))); | 378 scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(1, 2)))); |
| 379 ExpectIPCMessageWithArg1<InputMsg_MoveCaret>( | 379 ExpectIPCMessageWithArg1<InputMsg_MoveCaret>( |
| 380 process_->sink().GetMessageAt(0), gfx::Point(1, 2)); | 380 process_->sink().GetMessageAt(0), gfx::Point(1, 2)); |
| 381 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); | 381 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); |
| 382 | 382 |
| 383 // Send two more messages without acking. | 383 // Send two more messages without acking. |
| 384 input_router_->SendInput( | 384 input_router_->SendInput( |
| 385 scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(5, 6)))); | 385 scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(5, 6)))); |
| 386 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); | 386 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); |
| 387 | 387 |
| 388 input_router_->SendInput( | 388 input_router_->SendInput( |
| 389 scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(9, 10)))); | 389 scoped_ptr<IPC::Message>(new InputMsg_MoveCaret(0, gfx::Point(9, 10)))); |
| 390 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); | 390 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); |
| 391 | 391 |
| 392 // Now ack the first message. | 392 // Now ack the first message. |
| 393 { | 393 { |
| 394 scoped_ptr<IPC::Message> response(new ViewHostMsg_MoveCaret_ACK(0)); | 394 scoped_ptr<IPC::Message> response(new InputHostMsg_MoveCaret_ACK(0)); |
| 395 input_router_->OnMessageReceived(*response); | 395 input_router_->OnMessageReceived(*response); |
| 396 } | 396 } |
| 397 | 397 |
| 398 // Verify that the two messages are coalesced into one message. | 398 // Verify that the two messages are coalesced into one message. |
| 399 ExpectIPCMessageWithArg1<InputMsg_MoveCaret>( | 399 ExpectIPCMessageWithArg1<InputMsg_MoveCaret>( |
| 400 process_->sink().GetMessageAt(0), gfx::Point(9, 10)); | 400 process_->sink().GetMessageAt(0), gfx::Point(9, 10)); |
| 401 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); | 401 EXPECT_EQ(1u, GetSentMessageCountAndResetSink()); |
| 402 | 402 |
| 403 // Acking the coalesced msg should not send any more msg. | 403 // Acking the coalesced msg should not send any more msg. |
| 404 { | 404 { |
| 405 scoped_ptr<IPC::Message> response(new ViewHostMsg_MoveCaret_ACK(0)); | 405 scoped_ptr<IPC::Message> response(new InputHostMsg_MoveCaret_ACK(0)); |
| 406 input_router_->OnMessageReceived(*response); | 406 input_router_->OnMessageReceived(*response); |
| 407 } | 407 } |
| 408 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); | 408 EXPECT_EQ(0u, GetSentMessageCountAndResetSink()); |
| 409 } | 409 } |
| 410 | 410 |
| 411 TEST_F(InputRouterImplTest, HandledInputEvent) { | 411 TEST_F(InputRouterImplTest, HandledInputEvent) { |
| 412 client_->set_filter_state(INPUT_EVENT_ACK_STATE_CONSUMED); | 412 client_->set_filter_state(INPUT_EVENT_ACK_STATE_CONSUMED); |
| 413 | 413 |
| 414 // Simulate a keyboard event. | 414 // Simulate a keyboard event. |
| 415 SimulateKeyboardEvent(WebInputEvent::RawKeyDown, false); | 415 SimulateKeyboardEvent(WebInputEvent::RawKeyDown, false); |
| (...skipping 1295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1711 client_overscroll = client_->GetAndResetOverscroll(); | 1711 client_overscroll = client_->GetAndResetOverscroll(); |
| 1712 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, | 1712 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, |
| 1713 client_overscroll.accumulated_overscroll); | 1713 client_overscroll.accumulated_overscroll); |
| 1714 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, | 1714 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, |
| 1715 client_overscroll.latest_overscroll_delta); | 1715 client_overscroll.latest_overscroll_delta); |
| 1716 EXPECT_EQ(wheel_overscroll.current_fling_velocity, | 1716 EXPECT_EQ(wheel_overscroll.current_fling_velocity, |
| 1717 client_overscroll.current_fling_velocity); | 1717 client_overscroll.current_fling_velocity); |
| 1718 } | 1718 } |
| 1719 | 1719 |
| 1720 } // namespace content | 1720 } // namespace content |
| OLD | NEW |