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

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

Issue 586553002: Allow repeated handler removal/addition with the TouchEventQueue (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 3 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
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 277
278 InputRouterImpl* input_router() const { 278 InputRouterImpl* input_router() const {
279 return input_router_.get(); 279 return input_router_.get();
280 } 280 }
281 281
282 bool TouchEventQueueEmpty() const { 282 bool TouchEventQueueEmpty() const {
283 return input_router()->touch_event_queue_.empty(); 283 return input_router()->touch_event_queue_.empty();
284 } 284 }
285 285
286 bool TouchEventTimeoutEnabled() const { 286 bool TouchEventTimeoutEnabled() const {
287 return input_router()->touch_event_queue_.ack_timeout_enabled(); 287 return input_router()->touch_event_queue_.IsAckTimeoutEnabled();
288 } 288 }
289 289
290 void Flush() const { 290 void Flush() const {
291 return input_router_->Flush(); 291 return input_router_->Flush();
292 } 292 }
293 293
294 size_t GetAndResetDidFlushCount() { 294 size_t GetAndResetDidFlushCount() {
295 return client_->GetAndResetDidFlushCount(); 295 return client_->GetAndResetDidFlushCount();
296 } 296 }
297 297
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
1098 TEST_F(InputRouterImplTest, 1098 TEST_F(InputRouterImplTest,
1099 TouchAckTimeoutDisabledForTouchSequenceAfterTouchActionNone) { 1099 TouchAckTimeoutDisabledForTouchSequenceAfterTouchActionNone) {
1100 const int timeout_ms = 1; 1100 const int timeout_ms = 1;
1101 SetUpForTouchAckTimeoutTest(timeout_ms); 1101 SetUpForTouchAckTimeoutTest(timeout_ms);
1102 ASSERT_TRUE(TouchEventTimeoutEnabled()); 1102 ASSERT_TRUE(TouchEventTimeoutEnabled());
1103 OnHasTouchEventHandlers(true); 1103 OnHasTouchEventHandlers(true);
1104 1104
1105 // Start a touch sequence. 1105 // Start a touch sequence.
1106 PressTouchPoint(1, 1); 1106 PressTouchPoint(1, 1);
1107 SendTouchEvent(); 1107 SendTouchEvent();
1108 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1108 1109
1109 // TOUCH_ACTION_NONE should disable the timeout. 1110 // TOUCH_ACTION_NONE should disable the timeout.
1110 OnSetTouchAction(TOUCH_ACTION_NONE); 1111 OnSetTouchAction(TOUCH_ACTION_NONE);
1111 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED); 1112 SendInputEventACK(WebInputEvent::TouchStart, INPUT_EVENT_ACK_STATE_CONSUMED);
1113 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1112 EXPECT_FALSE(TouchEventTimeoutEnabled()); 1114 EXPECT_FALSE(TouchEventTimeoutEnabled());
1113 1115
1116 MoveTouchPoint(0, 1, 1);
1117 SendTouchEvent();
1118 EXPECT_FALSE(TouchEventTimeoutEnabled());
1119 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1120
1121 // Delay the move ack. The timeout should not fire.
1122 RunTasksAndWait(base::TimeDelta::FromMilliseconds(timeout_ms + 1));
1123 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1124 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1125 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED);
1126 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1127
1114 // End the touch sequence. 1128 // End the touch sequence.
1115 ReleaseTouchPoint(0); 1129 ReleaseTouchPoint(0);
1116 SendTouchEvent(); 1130 SendTouchEvent();
1117 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED); 1131 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED);
1118 EXPECT_FALSE(TouchEventTimeoutEnabled()); 1132 EXPECT_FALSE(TouchEventTimeoutEnabled());
1119 ack_handler_->GetAndResetAckCount(); 1133 ack_handler_->GetAndResetAckCount();
1120 GetSentMessageCountAndResetSink(); 1134 GetSentMessageCountAndResetSink();
1121 1135
1122 // Start another touch sequence. While this does restore the touch timeout 1136 // Start another touch sequence. This should restore the touch timeout.
1123 // the timeout will not apply until the *next* touch sequence. This affords a
1124 // touch-action response from the renderer without racing against the timeout.
1125 PressTouchPoint(1, 1); 1137 PressTouchPoint(1, 1);
1126 SendTouchEvent(); 1138 SendTouchEvent();
1127 EXPECT_TRUE(TouchEventTimeoutEnabled()); 1139 EXPECT_TRUE(TouchEventTimeoutEnabled());
1128 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); 1140 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1129
1130 // Delay the ack. The timeout should *not* fire.
1131 RunTasksAndWait(base::TimeDelta::FromMilliseconds(timeout_ms + 1));
1132 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); 1141 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1133 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1134
1135 // Finally send the ack. The touch sequence should not have been cancelled.
1136 SendInputEventACK(WebInputEvent::TouchStart,
1137 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
1138 EXPECT_TRUE(TouchEventTimeoutEnabled());
1139 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1140 EXPECT_EQ(0U, GetSentMessageCountAndResetSink());
1141
1142 // End the sequence.
1143 ReleaseTouchPoint(0);
1144 SendTouchEvent();
1145 SendInputEventACK(WebInputEvent::TouchEnd, INPUT_EVENT_ACK_STATE_CONSUMED);
1146 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1147 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1148
1149 // A new touch sequence should (finally) be subject to the timeout.
1150 PressTouchPoint(1, 1);
1151 SendTouchEvent();
1152 EXPECT_TRUE(TouchEventTimeoutEnabled());
1153 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount());
1154 EXPECT_EQ(1U, GetSentMessageCountAndResetSink());
1155 1142
1156 // Wait for the touch ack timeout to fire. 1143 // Wait for the touch ack timeout to fire.
1157 RunTasksAndWait(base::TimeDelta::FromMilliseconds(timeout_ms + 1)); 1144 RunTasksAndWait(base::TimeDelta::FromMilliseconds(timeout_ms + 1));
1158 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); 1145 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount());
1159 } 1146 }
1160 1147
1161 // Test that TouchActionFilter::ResetTouchAction is called before the 1148 // Test that TouchActionFilter::ResetTouchAction is called before the
1162 // first touch event for a touch sequence reaches the renderer. 1149 // first touch event for a touch sequence reaches the renderer.
1163 TEST_F(InputRouterImplTest, TouchActionResetBeforeEventReachesRenderer) { 1150 TEST_F(InputRouterImplTest, TouchActionResetBeforeEventReachesRenderer) {
1164 OnHasTouchEventHandlers(true); 1151 OnHasTouchEventHandlers(true);
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
1724 client_overscroll = client_->GetAndResetOverscroll(); 1711 client_overscroll = client_->GetAndResetOverscroll();
1725 EXPECT_EQ(wheel_overscroll.accumulated_overscroll, 1712 EXPECT_EQ(wheel_overscroll.accumulated_overscroll,
1726 client_overscroll.accumulated_overscroll); 1713 client_overscroll.accumulated_overscroll);
1727 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta, 1714 EXPECT_EQ(wheel_overscroll.latest_overscroll_delta,
1728 client_overscroll.latest_overscroll_delta); 1715 client_overscroll.latest_overscroll_delta);
1729 EXPECT_EQ(wheel_overscroll.current_fling_velocity, 1716 EXPECT_EQ(wheel_overscroll.current_fling_velocity,
1730 client_overscroll.current_fling_velocity); 1717 client_overscroll.current_fling_velocity);
1731 } 1718 }
1732 1719
1733 } // namespace content 1720 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/renderer_host/input/touch_event_queue.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698