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

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 TouchEventQueue test 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) {
tdresser 2016/04/01 14:50:24 Aren't there a few cases we should test? 1. Queue
mustaq 2016/04/01 18:31:05 Added all, including #2 where the notification is
2627 PressTouchPoint(1, 1);
2628 MoveTouchPoint(0, 5, 5);
2629 ReleaseTouchPoint(0);
2630
2631 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2632 EXPECT_EQ(3U, queued_event_count());
2633
2634 // Send the touch-scroll-notification when 3 events are in the queue.
2635 PrependTouchScrollNotification();
2636
2637 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2638 EXPECT_EQ(4U, queued_event_count());
2639
2640 // Receive an ACK for the touchstart.
2641 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2642
2643 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2644 EXPECT_EQ(WebInputEvent::TouchStart, acked_event().type);
2645 EXPECT_EQ(3U, queued_event_count());
2646
2647 // Receive an ACK for the touch-scroll-notification.
2648 SendTouchEventAck(INPUT_EVENT_ACK_STATE_IGNORED);
2649
2650 EXPECT_EQ(0U, GetAndResetAckedEventCount());
2651 EXPECT_EQ(2U, queued_event_count());
2652
2653 // Receive an ACK for the touchmove.
2654 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2655
2656 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2657 EXPECT_EQ(WebInputEvent::TouchMove, acked_event().type);
2658 EXPECT_EQ(1U, queued_event_count());
2659
2660 // Receive an ACK for the touchend.
2661 SendTouchEventAck(INPUT_EVENT_ACK_STATE_CONSUMED);
2662
2663 EXPECT_EQ(1U, GetAndResetAckedEventCount());
2664 EXPECT_EQ(WebInputEvent::TouchEnd, acked_event().type);
2665 EXPECT_EQ(0U, queued_event_count());
2666
2667 EXPECT_EQ(4U, all_sent_events().size());
2668 EXPECT_EQ(WebInputEvent::TouchStart, all_sent_events()[0].type);
2669 EXPECT_EQ(WebInputEvent::TouchScrollStarted, all_sent_events()[1].type);
2670 EXPECT_EQ(WebInputEvent::TouchMove, all_sent_events()[2].type);
2671 EXPECT_EQ(WebInputEvent::TouchEnd, all_sent_events()[3].type);
2672 }
2673
2620 } // namespace content 2674 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698