OLD | NEW |
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/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 EXPECT_FALSE(HasPendingEvents()); | 1182 EXPECT_FALSE(HasPendingEvents()); |
1183 } | 1183 } |
1184 } | 1184 } |
1185 | 1185 |
1186 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { | 1186 TEST_F(InputRouterImplTest, MouseTypesIgnoringAck) { |
1187 int start_type = static_cast<int>(WebInputEvent::kMouseDown); | 1187 int start_type = static_cast<int>(WebInputEvent::kMouseDown); |
1188 int end_type = static_cast<int>(WebInputEvent::kContextMenu); | 1188 int end_type = static_cast<int>(WebInputEvent::kContextMenu); |
1189 ASSERT_LT(start_type, end_type); | 1189 ASSERT_LT(start_type, end_type); |
1190 for (int i = start_type; i <= end_type; ++i) { | 1190 for (int i = start_type; i <= end_type; ++i) { |
1191 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); | 1191 WebInputEvent::Type type = static_cast<WebInputEvent::Type>(i); |
1192 int expected_in_flight_event_count = | |
1193 !ShouldBlockEventStream(GetEventWithType(type)) ? 0 : 1; | |
1194 | 1192 |
1195 // Note: Only MouseMove ack is forwarded to the ack handler. | |
1196 SimulateMouseEvent(type, 0, 0); | 1193 SimulateMouseEvent(type, 0, 0); |
1197 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); | 1194 EXPECT_EQ(1U, GetSentMessageCountAndResetSink()); |
1198 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); | 1195 |
1199 EXPECT_EQ(expected_in_flight_event_count, client_->in_flight_event_count()); | 1196 if (ShouldBlockEventStream(GetEventWithType(type))) { |
1200 if (expected_in_flight_event_count) { | 1197 EXPECT_EQ(0U, ack_handler_->GetAndResetAckCount()); |
| 1198 EXPECT_EQ(1, client_->in_flight_event_count()); |
| 1199 |
1201 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1200 SendInputEventACK(type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1202 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); | 1201 EXPECT_EQ(0U, GetSentMessageCountAndResetSink()); |
1203 uint32_t expected_ack_count = type == WebInputEvent::kMouseMove ? 1 : 0; | 1202 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
1204 EXPECT_EQ(expected_ack_count, ack_handler_->GetAndResetAckCount()); | 1203 EXPECT_EQ(0, client_->in_flight_event_count()); |
| 1204 } else { |
| 1205 // Note: events which don't block the event stream immediately receive |
| 1206 // synthetic ACKs. |
| 1207 EXPECT_EQ(1U, ack_handler_->GetAndResetAckCount()); |
1205 EXPECT_EQ(0, client_->in_flight_event_count()); | 1208 EXPECT_EQ(0, client_->in_flight_event_count()); |
1206 } | 1209 } |
1207 } | 1210 } |
1208 } | 1211 } |
1209 | 1212 |
1210 // Guard against breaking changes to the list of ignored event ack types in | 1213 // Guard against breaking changes to the list of ignored event ack types in |
1211 // |WebInputEventTraits::ShouldBlockEventStream|. | 1214 // |WebInputEventTraits::ShouldBlockEventStream|. |
1212 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { | 1215 TEST_F(InputRouterImplTest, RequiredEventAckTypes) { |
1213 const WebInputEvent::Type kRequiredEventAckTypes[] = { | 1216 const WebInputEvent::Type kRequiredEventAckTypes[] = { |
1214 WebInputEvent::kMouseMove, | 1217 WebInputEvent::kMouseMove, |
(...skipping 1285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2500 EXPECT_EQ(80, sent_event->data.fling_start.velocity_y); | 2503 EXPECT_EQ(80, sent_event->data.fling_start.velocity_y); |
2501 | 2504 |
2502 const WebGestureEvent* filter_event = | 2505 const WebGestureEvent* filter_event = |
2503 GetFilterWebInputEvent<WebGestureEvent>(); | 2506 GetFilterWebInputEvent<WebGestureEvent>(); |
2504 TestLocationInFilterEvent(filter_event, orig); | 2507 TestLocationInFilterEvent(filter_event, orig); |
2505 EXPECT_EQ(30, filter_event->data.fling_start.velocity_x); | 2508 EXPECT_EQ(30, filter_event->data.fling_start.velocity_x); |
2506 EXPECT_EQ(40, filter_event->data.fling_start.velocity_y); | 2509 EXPECT_EQ(40, filter_event->data.fling_start.velocity_y); |
2507 } | 2510 } |
2508 | 2511 |
2509 } // namespace content | 2512 } // namespace content |
OLD | NEW |