| Index: content/browser/renderer_host/render_widget_host_unittest.cc
|
| diff --git a/content/browser/renderer_host/render_widget_host_unittest.cc b/content/browser/renderer_host/render_widget_host_unittest.cc
|
| index f6bb1084ff210c440c59a5a89af27a3a772275c5..9b17c16334523a0b40d78850d0d783e64f61b6df 100644
|
| --- a/content/browser/renderer_host/render_widget_host_unittest.cc
|
| +++ b/content/browser/renderer_host/render_widget_host_unittest.cc
|
| @@ -356,17 +356,35 @@ class RenderWidgetHostTest : public testing::Test {
|
| host_->ForwardWheelEvent(wheel_event);
|
| }
|
|
|
| - // Inject synthetic WebGestureEvent instances.
|
| - void SimulateGestureEvent(float dX, float dY, int modifiers,
|
| - WebInputEvent::Type type) {
|
| + // Inject simple synthetic WebGestureEvent instances.
|
| + void SimulateGestureEvent(WebInputEvent::Type type) {
|
| WebGestureEvent gesture_event;
|
| gesture_event.type = type;
|
| + host_->ForwardGestureEvent(gesture_event);
|
| + }
|
| +
|
| + void SimulateGestureScrollUpdateEvent(float dX, float dY, int modifiers) {
|
| + WebGestureEvent gesture_event;
|
| + gesture_event.type = WebInputEvent::GestureScrollUpdate;
|
| gesture_event.deltaX = dX;
|
| gesture_event.deltaY = dY;
|
| + gesture_event.data.scrollUpdate.deltaX = dX;
|
| + gesture_event.data.scrollUpdate.deltaY = dY;
|
| gesture_event.modifiers = modifiers;
|
| host_->ForwardGestureEvent(gesture_event);
|
| }
|
|
|
| + // Inject simple synthetic WebGestureEvent instances.
|
| + void SimulateGestureFlingStartEvent(float velocityX, float velocityY) {
|
| + WebGestureEvent gesture_event;
|
| + gesture_event.type = WebInputEvent::GestureFlingStart;
|
| + gesture_event.deltaX = velocityX;
|
| + gesture_event.deltaY = velocityY;
|
| + gesture_event.data.flingStart.velocityX = velocityX;
|
| + gesture_event.data.flingStart.velocityY = velocityY;
|
| + host_->ForwardGestureEvent(gesture_event);
|
| + }
|
| +
|
| MessageLoopForUI message_loop_;
|
|
|
| scoped_ptr<content::TestBrowserContext> browser_context_;
|
| @@ -806,10 +824,10 @@ TEST_F(RenderWidgetHostTest, CoalescesGesturesEvents) {
|
| // Simulate gesture events.
|
|
|
| // Sent.
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureScrollBegin);
|
| + SimulateGestureEvent(WebInputEvent::GestureScrollBegin);
|
|
|
| // Enqueued.
|
| - SimulateGestureEvent(8, -5, 0, WebInputEvent::GestureScrollUpdate);
|
| + SimulateGestureScrollUpdateEvent(8, -5, 0);
|
|
|
| // Make sure that the queue contains what we think it should.
|
| WebGestureEvent merged_event = host_->GestureEventLastQueueEvent();
|
| @@ -817,17 +835,17 @@ TEST_F(RenderWidgetHostTest, CoalescesGesturesEvents) {
|
| EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type);
|
|
|
| // Coalesced.
|
| - SimulateGestureEvent(8, -6, 0, WebInputEvent::GestureScrollUpdate);
|
| + SimulateGestureScrollUpdateEvent(8, -6, 0);
|
|
|
| // Check that coalescing updated the correct values.
|
| merged_event = host_->GestureEventLastQueueEvent();
|
| EXPECT_EQ(WebInputEvent::GestureScrollUpdate, merged_event.type);
|
| EXPECT_EQ(0, merged_event.modifiers);
|
| - EXPECT_EQ(16, merged_event.deltaX);
|
| - EXPECT_EQ(-11, merged_event.deltaY);
|
| + EXPECT_EQ(16, merged_event.data.scrollUpdate.deltaX);
|
| + EXPECT_EQ(-11, merged_event.data.scrollUpdate.deltaY);
|
|
|
| // Enqueued.
|
| - SimulateGestureEvent(8, -7, 1, WebInputEvent::GestureScrollUpdate);
|
| + SimulateGestureScrollUpdateEvent(8, -7, 1);
|
|
|
| // Check that we didn't wrongly coalesce.
|
| merged_event = host_->GestureEventLastQueueEvent();
|
| @@ -835,7 +853,7 @@ TEST_F(RenderWidgetHostTest, CoalescesGesturesEvents) {
|
| EXPECT_EQ(1, merged_event.modifiers);
|
|
|
| // Different.
|
| - SimulateGestureEvent(9, -8, 0, WebInputEvent::GestureScrollEnd);
|
| + SimulateGestureEvent(WebInputEvent::GestureScrollEnd);
|
|
|
| // Check that only the first event was sent.
|
| EXPECT_EQ(1U, process_->sink().message_count());
|
| @@ -876,17 +894,17 @@ TEST_F(RenderWidgetHostTest, CoalescesGesturesEvents) {
|
| TEST_F(RenderWidgetHostTest, GestureFlingCancelsFiltered) {
|
| process_->sink().ClearMessages();
|
| // GFC without previous GFS is dropped.
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel);
|
| + SimulateGestureEvent(WebInputEvent::GestureFlingCancel);
|
| EXPECT_EQ(0U, process_->sink().message_count());
|
| EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
|
|
|
| // GFC after previous GFS is dispatched and acked.
|
| process_->sink().ClearMessages();
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart);
|
| + SimulateGestureFlingStartEvent(0, -10);
|
| EXPECT_TRUE(host_->FlingInProgress());
|
| SendInputEventACK(WebInputEvent::GestureFlingStart, true);
|
| MessageLoop::current()->RunAllPending();
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel);
|
| + SimulateGestureEvent(WebInputEvent::GestureFlingCancel);
|
| EXPECT_FALSE(host_->FlingInProgress());
|
| EXPECT_EQ(2U, process_->sink().message_count());
|
| SendInputEventACK(WebInputEvent::GestureFlingCancel, true);
|
| @@ -895,9 +913,9 @@ TEST_F(RenderWidgetHostTest, GestureFlingCancelsFiltered) {
|
|
|
| // GFC before previous GFS is acked.
|
| process_->sink().ClearMessages();
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart);
|
| + SimulateGestureFlingStartEvent(0, -10);
|
| EXPECT_TRUE(host_->FlingInProgress());
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel);
|
| + SimulateGestureEvent(WebInputEvent::GestureFlingCancel);
|
| EXPECT_FALSE(host_->FlingInProgress());
|
| EXPECT_EQ(1U, process_->sink().message_count());
|
| EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
|
| @@ -911,8 +929,8 @@ TEST_F(RenderWidgetHostTest, GestureFlingCancelsFiltered) {
|
|
|
| // GFS is added to the queue if another event is pending
|
| process_->sink().ClearMessages();
|
| - SimulateGestureEvent(8, -7, 0, WebInputEvent::GestureScrollUpdate);
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart);
|
| + SimulateGestureScrollUpdateEvent(8, -7, 0);
|
| + SimulateGestureFlingStartEvent(0, -10);
|
| EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
|
| EXPECT_EQ(1U, process_->sink().message_count());
|
| WebGestureEvent merged_event = host_->GestureEventLastQueueEvent();
|
| @@ -921,33 +939,33 @@ TEST_F(RenderWidgetHostTest, GestureFlingCancelsFiltered) {
|
| EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
|
|
|
| // GFS in queue means that a GFC is added to the queue
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel);
|
| + SimulateGestureEvent(WebInputEvent::GestureFlingCancel);
|
| merged_event =host_->GestureEventLastQueueEvent();
|
| EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type);
|
| EXPECT_FALSE(host_->FlingInProgress());
|
| EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize());
|
|
|
| // Adding a second GFC is dropped.
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel);
|
| + SimulateGestureEvent(WebInputEvent::GestureFlingCancel);
|
| EXPECT_FALSE(host_->FlingInProgress());
|
| EXPECT_EQ(3U, host_->GestureEventLastQueueEventSize());
|
|
|
| // Adding another GFS will add it to the queue.
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingStart);
|
| + SimulateGestureFlingStartEvent(0, -10);
|
| merged_event = host_->GestureEventLastQueueEvent();
|
| EXPECT_EQ(WebInputEvent::GestureFlingStart, merged_event.type);
|
| EXPECT_TRUE(host_->FlingInProgress());
|
| EXPECT_EQ(4U, host_->GestureEventLastQueueEventSize());
|
|
|
| // GFS in queue means that a GFC is added to the queue
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel);
|
| + SimulateGestureEvent(WebInputEvent::GestureFlingCancel);
|
| merged_event = host_->GestureEventLastQueueEvent();
|
| EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type);
|
| EXPECT_FALSE(host_->FlingInProgress());
|
| EXPECT_EQ(5U, host_->GestureEventLastQueueEventSize());
|
|
|
| // Adding another GFC with a GFC already there is dropped.
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureFlingCancel);
|
| + SimulateGestureEvent(WebInputEvent::GestureFlingCancel);
|
| merged_event = host_->GestureEventLastQueueEvent();
|
| EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type);
|
| EXPECT_FALSE(host_->FlingInProgress());
|
| @@ -961,7 +979,7 @@ TEST_F(RenderWidgetHostTest, DeferredGestureTapDown) {
|
| // Set some sort of short deferral timeout
|
| host_->set_maximum_tap_gap_time_ms(5);
|
|
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureTapDown);
|
| + SimulateGestureEvent(WebInputEvent::GestureTapDown);
|
| EXPECT_EQ(0U, process_->sink().message_count());
|
| EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
|
|
|
| @@ -981,11 +999,11 @@ TEST_F(RenderWidgetHostTest, DeferredGestureTapDownSentOnTap) {
|
| // Set some sort of short deferral timeout
|
| host_->set_maximum_tap_gap_time_ms(5);
|
|
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureTapDown);
|
| + SimulateGestureEvent(WebInputEvent::GestureTapDown);
|
| EXPECT_EQ(0U, process_->sink().message_count());
|
| EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
|
|
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureTap);
|
| + SimulateGestureEvent(WebInputEvent::GestureTap);
|
| EXPECT_EQ(1U, process_->sink().message_count());
|
| EXPECT_EQ(2U, host_->GestureEventLastQueueEventSize());
|
|
|
| @@ -1004,11 +1022,11 @@ TEST_F(RenderWidgetHostTest, DeferredGestureTapDownAnulledOnScroll) {
|
| // Set some sort of short deferral timeout
|
| host_->set_maximum_tap_gap_time_ms(5);
|
|
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureTapDown);
|
| + SimulateGestureEvent(WebInputEvent::GestureTapDown);
|
| EXPECT_EQ(0U, process_->sink().message_count());
|
| EXPECT_EQ(0U, host_->GestureEventLastQueueEventSize());
|
|
|
| - SimulateGestureEvent(0, -10, 0, WebInputEvent::GestureScrollBegin);
|
| + SimulateGestureEvent(WebInputEvent::GestureScrollBegin);
|
| EXPECT_EQ(1U, process_->sink().message_count());
|
| EXPECT_EQ(1U, host_->GestureEventLastQueueEventSize());
|
|
|
|
|