OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 // TouchpadTapSuppressionControllerClient | 67 // TouchpadTapSuppressionControllerClient |
68 void SendMouseEventImmediately( | 68 void SendMouseEventImmediately( |
69 const MouseEventWithLatencyInfo& event) override {} | 69 const MouseEventWithLatencyInfo& event) override {} |
70 | 70 |
71 protected: | 71 protected: |
72 static GestureEventQueue::Config DefaultConfig() { | 72 static GestureEventQueue::Config DefaultConfig() { |
73 return GestureEventQueue::Config(); | 73 return GestureEventQueue::Config(); |
74 } | 74 } |
75 | 75 |
| 76 void SetUpForGFCFilteringDisabled() { |
| 77 GestureEventQueue::Config config; |
| 78 config.enable_fling_cancel_filtering = false; |
| 79 queue_.reset(new GestureEventQueue(this, this, config)); |
| 80 } |
| 81 |
76 void SetUpForDebounce(int interval_ms) { | 82 void SetUpForDebounce(int interval_ms) { |
77 queue()->set_debounce_interval_time_ms_for_testing(interval_ms); | 83 queue()->set_debounce_interval_time_ms_for_testing(interval_ms); |
78 } | 84 } |
79 | 85 |
80 void SimulateGestureEvent(const WebGestureEvent& gesture) { | 86 void SimulateGestureEvent(const WebGestureEvent& gesture) { |
81 queue()->QueueEvent(GestureEventWithLatencyInfo(gesture)); | 87 queue()->QueueEvent(GestureEventWithLatencyInfo(gesture)); |
82 } | 88 } |
83 | 89 |
84 void SimulateGestureEvent(WebInputEvent::Type type, | 90 void SimulateGestureEvent(WebInputEvent::Type type, |
85 WebGestureDevice sourceDevice) { | 91 WebGestureDevice sourceDevice) { |
(...skipping 973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1059 EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type); | 1065 EXPECT_EQ(WebInputEvent::GestureFlingCancel, merged_event.type); |
1060 EXPECT_EQ(5U, GestureEventQueueSize()); | 1066 EXPECT_EQ(5U, GestureEventQueueSize()); |
1061 } | 1067 } |
1062 | 1068 |
1063 INSTANTIATE_TEST_CASE_P(AllSources, | 1069 INSTANTIATE_TEST_CASE_P(AllSources, |
1064 GestureEventQueueWithSourceTest, | 1070 GestureEventQueueWithSourceTest, |
1065 testing::Values(blink::WebGestureDeviceTouchscreen, | 1071 testing::Values(blink::WebGestureDeviceTouchscreen, |
1066 blink::WebGestureDeviceTouchpad)); | 1072 blink::WebGestureDeviceTouchpad)); |
1067 #endif // GTEST_HAS_PARAM_TEST | 1073 #endif // GTEST_HAS_PARAM_TEST |
1068 | 1074 |
| 1075 TEST_F(GestureEventQueueTest, GestureFlingCancelFilteringDisabled) { |
| 1076 SetUpForGFCFilteringDisabled(); |
| 1077 |
| 1078 // If so configured, GFC events should never be filtered, even if there are |
| 1079 // no active flings. |
| 1080 SimulateGestureEvent(WebInputEvent::GestureFlingCancel, |
| 1081 blink::WebGestureDeviceTouchscreen); |
| 1082 EXPECT_EQ(0, ActiveFlingCount()); |
| 1083 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
| 1084 EXPECT_EQ(1U, GestureEventQueueSize()); |
| 1085 } |
| 1086 |
1069 // Test that a GestureScrollEnd | GestureFlingStart are deferred during the | 1087 // Test that a GestureScrollEnd | GestureFlingStart are deferred during the |
1070 // debounce interval, that Scrolls are not and that the deferred events are | 1088 // debounce interval, that Scrolls are not and that the deferred events are |
1071 // sent after that timer fires. | 1089 // sent after that timer fires. |
1072 TEST_F(GestureEventQueueTest, DebounceDefersFollowingGestureEvents) { | 1090 TEST_F(GestureEventQueueTest, DebounceDefersFollowingGestureEvents) { |
1073 SetUpForDebounce(3); | 1091 SetUpForDebounce(3); |
1074 | 1092 |
1075 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, | 1093 SimulateGestureEvent(WebInputEvent::GestureScrollUpdate, |
1076 blink::WebGestureDeviceTouchscreen); | 1094 blink::WebGestureDeviceTouchscreen); |
1077 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); | 1095 EXPECT_EQ(1U, GetAndResetSentGestureEventCount()); |
1078 EXPECT_EQ(1U, GestureEventQueueSize()); | 1096 EXPECT_EQ(1U, GestureEventQueueSize()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1164 WebInputEvent::GestureScrollUpdate}; | 1182 WebInputEvent::GestureScrollUpdate}; |
1165 | 1183 |
1166 for (unsigned i = 0; i < sizeof(expected) / sizeof(WebInputEvent::Type); | 1184 for (unsigned i = 0; i < sizeof(expected) / sizeof(WebInputEvent::Type); |
1167 i++) { | 1185 i++) { |
1168 WebGestureEvent merged_event = GestureEventQueueEventAt(i); | 1186 WebGestureEvent merged_event = GestureEventQueueEventAt(i); |
1169 EXPECT_EQ(expected[i], merged_event.type); | 1187 EXPECT_EQ(expected[i], merged_event.type); |
1170 } | 1188 } |
1171 } | 1189 } |
1172 | 1190 |
1173 } // namespace content | 1191 } // namespace content |
OLD | NEW |