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

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: Added a few checks. 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 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 void ReleaseTouchPoint(int index) { 229 void ReleaseTouchPoint(int index) {
230 touch_event_.ReleasePoint(index); 230 touch_event_.ReleasePoint(index);
231 SendTouchEvent(); 231 SendTouchEvent();
232 } 232 }
233 233
234 void CancelTouchPoint(int index) { 234 void CancelTouchPoint(int index) {
235 touch_event_.CancelPoint(index); 235 touch_event_.CancelPoint(index);
236 SendTouchEvent(); 236 SendTouchEvent();
237 } 237 }
238 238
239 void PrependTouchScrollNotification() {
240 queue_->PrependTouchScrollNotification();
241 }
242
239 void AdvanceTouchTime(double seconds) { 243 void AdvanceTouchTime(double seconds) {
240 touch_event_.timeStampSeconds += seconds; 244 touch_event_.timeStampSeconds += seconds;
241 } 245 }
242 246
243 void ResetTouchEvent() { 247 void ResetTouchEvent() {
244 touch_event_ = SyntheticWebTouchEvent(); 248 touch_event_ = SyntheticWebTouchEvent();
245 } 249 }
246 250
247 size_t GetAndResetAckedEventCount() { 251 size_t GetAndResetAckedEventCount() {
248 size_t count = acked_event_count_; 252 size_t count = acked_event_count_;
(...skipping 2362 matching lines...) Expand 10 before | Expand all | Expand 10 after
2611 2615
2612 // TouchMove should be allowed and test for touches state. 2616 // TouchMove should be allowed and test for touches state.
2613 const WebTouchEvent& event2 = sent_event(); 2617 const WebTouchEvent& event2 = sent_event();
2614 EXPECT_EQ(WebInputEvent::TouchMove, event2.type); 2618 EXPECT_EQ(WebInputEvent::TouchMove, event2.type);
2615 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state); 2619 EXPECT_EQ(WebTouchPoint::StateStationary, event2.touches[0].state);
2616 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state); 2620 EXPECT_EQ(WebTouchPoint::StateMoved, event2.touches[1].state);
2617 EXPECT_EQ(1U, GetAndResetSentEventCount()); 2621 EXPECT_EQ(1U, GetAndResetSentEventCount());
2618 EXPECT_EQ(1U, GetAndResetAckedEventCount()); 2622 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2619 } 2623 }
2620 2624
2625 // Tests touch-scroll-notification firing order when the event is placed at the
2626 // end of touch queue because of a pending ack for the head of the queue.
2627 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_EndOfQueue) {
2628 PressTouchPoint(1, 1);
2629
2630 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2631 EXPECT_EQ(1U, queued_event_count());
2632
2633 // Send the touch-scroll-notification when 3 events are in the queue.
2634 PrependTouchScrollNotification();
2635
2636 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2637 EXPECT_EQ(2U, queued_event_count());
2638
2639 // Receive an ACK for the touchstart.
2640 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2641
2642 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2643 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
2644 EXPECT_EQ(1U, queued_event_count());
2645
2646 // Receive an ACK for the touch-scroll-notification.
2647 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2648
2649 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2650 EXPECT_EQ(0U, queued_event_count());
2651
2652 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type);
2653 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type);
2654 EXPECT_EQ(2U, GetAndResetSentEventCount());
2655 }
2656
2657 // Tests touch-scroll-notification firing order when the event is placed in the
2658 // 2nd position in the touch queue between two events.
2659 TEST_F(TouchEventQueueTest, TouchScrollNotificationOrder_SecondPosition) {
2660 PressTouchPoint(1, 1);
2661 MoveTouchPoint(0, 5, 5);
2662 ReleaseTouchPoint(0);
2663
2664 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2665 EXPECT_EQ(3U, queued_event_count());
2666
2667 // Send the touch-scroll-notification when 3 events are in the queue.
2668 PrependTouchScrollNotification();
2669
2670 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2671 EXPECT_EQ(4U, queued_event_count());
2672
2673 // Receive an ACK for the touchstart.
2674 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2675
2676 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2677 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
2678 EXPECT_EQ(3U, queued_event_count());
2679
2680 // Receive an ACK for the touch-scroll-notification.
2681 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2682
2683 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2684 EXPECT_EQ(2U, queued_event_count());
2685
2686 // Receive an ACK for the touchmove.
2687 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2688
2689 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2690 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
2691 EXPECT_EQ(1U, queued_event_count());
2692
2693 // Receive an ACK for the touchend.
2694 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2695
2696 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2697 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type);
2698 EXPECT_EQ(0U, queued_event_count());
2699
2700 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type);
2701 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type);
2702 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type);
2703 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type);
2704 EXPECT_EQ(4U, GetAndResetSentEventCount());
2705 }
2706
2621 } // namespace content 2707 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698