Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(291)

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue_unittest.cc

Issue 1800143002: Notify Blink about start of gesture scroll through a queued event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/browser/renderer_host/input/touch_event_queue.h" 5 #include "content/browser/renderer_host/input/touch_event_queue.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 void ReleaseTouchPoint(int index) { 228 void ReleaseTouchPoint(int index) {
229 touch_event_.ReleasePoint(index); 229 touch_event_.ReleasePoint(index);
230 SendTouchEvent(); 230 SendTouchEvent();
231 } 231 }
232 232
233 void CancelTouchPoint(int index) { 233 void CancelTouchPoint(int index) {
234 touch_event_.CancelPoint(index); 234 touch_event_.CancelPoint(index);
235 SendTouchEvent(); 235 SendTouchEvent();
236 } 236 }
237 237
238 void PrependTouchScrollNotification() {
239 queue_->PrependTouchScrollNotification();
240 }
241
238 void AdvanceTouchTime(double seconds) { 242 void AdvanceTouchTime(double seconds) {
239 touch_event_.timeStampSeconds += seconds; 243 touch_event_.timeStampSeconds += seconds;
240 } 244 }
241 245
242 void ResetTouchEvent() { 246 void ResetTouchEvent() {
243 touch_event_ = SyntheticWebTouchEvent(); 247 touch_event_ = SyntheticWebTouchEvent();
244 } 248 }
245 249
246 size_t GetAndResetAckedEventCount() { 250 size_t GetAndResetAckedEventCount() {
247 size_t count = acked_event_count_; 251 size_t count = acked_event_count_;
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2610 2614
2611 // TouchMove should be allowed and test for touches state. 2615 // TouchMove should be allowed and test for touches state.
2612 const WebTouchEvent& event2 = sent_event(); 2616 const WebTouchEvent& event2 = sent_event();
2613 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); 2617 EXPECT_EQ(WebInputEvent::TouchMove, event2.type);
2614 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); 2618 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state);
2615 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); 2619 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state);
2616 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2620 EXPECT_EQ(1U, GetAndResetSentEventCount());
2617 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2621 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2618 } 2622 }
2619 2623
2624 // Tests that touch-scroll-notification event is placed at the correct position
2625 // in the queue.
2626 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder) {
2627 // === Test 1: touch-scroll-notification in an empty queue ===
tdresser 2016/04/01 19:03:20 There isn't much code duplication incurred by spli
mustaq 2016/04/01 21:49:52 Done.
2628 PrependTouchScrollNotification();
2629
2630 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2631 EXPECT_EQ(1U, queued_event_count());
2632
2633 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2634
2635 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2636 EXPECT_EQ(0U, queued_event_count());
2637
2638 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[0].type);
2639 EXPECT_EQ(1U, GetAndResetSentEventCount());
2640
2641
2642 // === Test 2: touch-scroll-notification when the queue has one event ===
2643 PressTouchPoint(1, 1);
2644
2645 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2646 EXPECT_EQ(1U, queued_event_count());
2647
2648 // Send the touch-scroll-notification when 3 events are in the queue.
2649 PrependTouchScrollNotification();
2650
2651 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2652 EXPECT_EQ(2U, queued_event_count());
2653
2654 // Receive an ACK for the touchstart.
2655 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2656
2657 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2658 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
2659 EXPECT_EQ(1U, queued_event_count());
2660
2661 // Receive an ACK for the touch-scroll-notification.
2662 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2663
2664 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2665 EXPECT_EQ(0U, queued_event_count());
2666
2667 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type);
2668 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type);
2669 EXPECT_EQ(2U, GetAndResetSentEventCount());
2670
2671
2672 // === Test 3: touch-scroll-notification when the queue has 2+ events ===
2673 PressTouchPoint(1, 1);
2674 MoveTouchPoint(0, 5, 5);
2675 ReleaseTouchPoint(0);
2676
2677 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2678 EXPECT_EQ(3U, queued_event_count());
2679
2680 // Send the touch-scroll-notification when 3 events are in the queue.
2681 PrependTouchScrollNotification();
2682
2683 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2684 EXPECT_EQ(4U, queued_event_count());
2685
2686 // Receive an ACK for the touchstart.
2687 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2688
2689 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2690 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
2691 EXPECT_EQ(3U, queued_event_count());
2692
2693 // Receive an ACK for the touch-scroll-notification.
2694 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2695
2696 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2697 EXPECT_EQ(2U, queued_event_count());
2698
2699 // Receive an ACK for the touchmove.
2700 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2701
2702 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2703 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
2704 EXPECT_EQ(1U, queued_event_count());
2705
2706 // Receive an ACK for the touchend.
2707 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2708
2709 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2710 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type);
2711 EXPECT_EQ(0U, queued_event_count());
2712
2713 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type);
2714 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type);
2715 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type);
2716 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type);
2717 EXPECT_EQ(4U, GetAndResetSentEventCount());
2718 }
2719
2620 } // namespace content 2720 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698