Commit ece7002b authored by Xida Chen's avatar Xida Chen Committed by Commit Bot

[Code Health] Rename ScrollingTouchAction to ActiveTouchAction

In TouchActionFilterTest, there is a function named ScrollingTouchAction,
and this CL changes the name to ActiveTouchAction. It is called
ScrollingTouchAction because the corresponding variable in the
TouchActionFilter was named |scrolling_touch_action_|. Now that this
variable is renamed to |active_touch_action_|, we should change the
function name to ActiveTouchAction.

Bug: None
Change-Id: I34d51bba4b5604dbeab743f3ce6f6a27d315c7e9
Reviewed-on: https://chromium-review.googlesource.com/c/1323622Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Commit-Queue: Xida Chen <xidachen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#606530}
parent 8be79151
...@@ -35,7 +35,7 @@ class TouchActionFilterTest : public testing::Test, ...@@ -35,7 +35,7 @@ class TouchActionFilterTest : public testing::Test,
~TouchActionFilterTest() override {} ~TouchActionFilterTest() override {}
protected: protected:
base::Optional<cc::TouchAction> ScrollingTouchAction() const { base::Optional<cc::TouchAction> ActiveTouchAction() const {
return filter_.active_touch_action_; return filter_.active_touch_action_;
} }
void ResetTouchAction() { filter_.ResetTouchAction(); } void ResetTouchAction() { filter_.ResetTouchAction(); }
...@@ -983,7 +983,7 @@ TEST_P(TouchActionFilterTest, TouchActionNotResetWithinGestureSequence) { ...@@ -983,7 +983,7 @@ TEST_P(TouchActionFilterTest, TouchActionNotResetWithinGestureSequence) {
filter_.IncreaseActiveTouches(); filter_.IncreaseActiveTouches();
EXPECT_EQ(filter_.FilterGestureEvent(&tap_down), EXPECT_EQ(filter_.FilterGestureEvent(&tap_down),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(cc::kTouchActionPanY, ScrollingTouchAction().value()); EXPECT_EQ(cc::kTouchActionPanY, ActiveTouchAction().value());
EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin), EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
...@@ -993,7 +993,7 @@ TEST_P(TouchActionFilterTest, TouchActionNotResetWithinGestureSequence) { ...@@ -993,7 +993,7 @@ TEST_P(TouchActionFilterTest, TouchActionNotResetWithinGestureSequence) {
filter_.DecreaseActiveTouches(); filter_.DecreaseActiveTouches();
filter_.ReportAndResetTouchAction(); filter_.ReportAndResetTouchAction();
EXPECT_FALSE(filter_.allowed_touch_action().has_value()); EXPECT_FALSE(filter_.allowed_touch_action().has_value());
EXPECT_EQ(cc::kTouchActionPanY, ScrollingTouchAction().value()); EXPECT_EQ(cc::kTouchActionPanY, ActiveTouchAction().value());
// In fling or fling boosting case, we will see ScrollUpdate after the touch // In fling or fling boosting case, we will see ScrollUpdate after the touch
// end. // end.
EXPECT_EQ(filter_.FilterGestureEvent(&scroll_update), EXPECT_EQ(filter_.FilterGestureEvent(&scroll_update),
...@@ -1003,7 +1003,7 @@ TEST_P(TouchActionFilterTest, TouchActionNotResetWithinGestureSequence) { ...@@ -1003,7 +1003,7 @@ TEST_P(TouchActionFilterTest, TouchActionNotResetWithinGestureSequence) {
// The |allowed_touch_action_| should have been reset, but not the // The |allowed_touch_action_| should have been reset, but not the
// |scrolling_touch_action_|. // |scrolling_touch_action_|.
EXPECT_FALSE(filter_.allowed_touch_action().has_value()); EXPECT_FALSE(filter_.allowed_touch_action().has_value());
EXPECT_EQ(cc::kTouchActionPanY, ScrollingTouchAction().value()); EXPECT_EQ(cc::kTouchActionPanY, ActiveTouchAction().value());
} }
// The following 3 tests ensures that when the IPC message // The following 3 tests ensures that when the IPC message
...@@ -1017,7 +1017,7 @@ TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedDuringTap) { ...@@ -1017,7 +1017,7 @@ TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedDuringTap) {
EXPECT_EQ(filter_.FilterGestureEvent(&tap_down), EXPECT_EQ(filter_.FilterGestureEvent(&tap_down),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_TRUE(ScrollingTouchAction().has_value()); EXPECT_TRUE(ActiveTouchAction().has_value());
filter_.OnSetTouchAction(cc::kTouchActionPan); filter_.OnSetTouchAction(cc::kTouchActionPan);
// Simulate a simple tap gesture. // Simulate a simple tap gesture.
...@@ -1045,15 +1045,15 @@ TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedDuringDoubleTap) { ...@@ -1045,15 +1045,15 @@ TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedDuringDoubleTap) {
filter_.IncreaseActiveTouches(); filter_.IncreaseActiveTouches();
EXPECT_EQ(filter_.FilterGestureEvent(&tap_down), EXPECT_EQ(filter_.FilterGestureEvent(&tap_down),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionAuto); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionAuto);
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_EQ(filter_.FilterGestureEvent(&tap_cancel), EXPECT_EQ(filter_.FilterGestureEvent(&tap_cancel),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_TRUE(ScrollingTouchAction().has_value()); EXPECT_TRUE(ActiveTouchAction().has_value());
filter_.OnSetTouchAction(cc::kTouchActionPan); filter_.OnSetTouchAction(cc::kTouchActionPan);
EXPECT_EQ(filter_.FilterGestureEvent(&tap_down), EXPECT_EQ(filter_.FilterGestureEvent(&tap_down),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionPan); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionPan);
EXPECT_EQ(filter_.FilterGestureEvent(&tap_cancel), EXPECT_EQ(filter_.FilterGestureEvent(&tap_cancel),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(filter_.FilterGestureEvent(&double_tap), EXPECT_EQ(filter_.FilterGestureEvent(&double_tap),
...@@ -1085,7 +1085,7 @@ TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedDuringScroll) { ...@@ -1085,7 +1085,7 @@ TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedDuringScroll) {
filter_.OnSetTouchAction(cc::kTouchActionPan); filter_.OnSetTouchAction(cc::kTouchActionPan);
EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin), EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionPan); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionPan);
EXPECT_EQ(filter_.FilterGestureEvent(&scroll_update), EXPECT_EQ(filter_.FilterGestureEvent(&scroll_update),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(filter_.FilterGestureEvent(&scroll_end), EXPECT_EQ(filter_.FilterGestureEvent(&scroll_end),
...@@ -1110,10 +1110,10 @@ TEST_P(TouchActionFilterTest, ...@@ -1110,10 +1110,10 @@ TEST_P(TouchActionFilterTest,
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(filter_.FilterGestureEvent(&long_tap), EXPECT_EQ(filter_.FilterGestureEvent(&long_tap),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionAuto); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionAuto);
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_FALSE(ScrollingTouchAction().has_value()); EXPECT_FALSE(ActiveTouchAction().has_value());
filter_.OnHasTouchEventHandlers(false); filter_.OnHasTouchEventHandlers(false);
WebGestureEvent two_finger_tap = SyntheticWebGestureEventBuilder::Build( WebGestureEvent two_finger_tap = SyntheticWebGestureEventBuilder::Build(
...@@ -1125,31 +1125,31 @@ TEST_P(TouchActionFilterTest, ...@@ -1125,31 +1125,31 @@ TEST_P(TouchActionFilterTest,
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(filter_.FilterGestureEvent(&two_finger_tap), EXPECT_EQ(filter_.FilterGestureEvent(&two_finger_tap),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionAuto); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionAuto);
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_FALSE(ScrollingTouchAction().has_value()); EXPECT_FALSE(ActiveTouchAction().has_value());
} }
TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedAfterTouchStart) { TEST_P(TouchActionFilterTest, OnHasTouchEventHandlersReceivedAfterTouchStart) {
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_FALSE(ScrollingTouchAction().has_value()); EXPECT_FALSE(ActiveTouchAction().has_value());
EXPECT_FALSE(filter_.allowed_touch_action().has_value()); EXPECT_FALSE(filter_.allowed_touch_action().has_value());
// Receive a touch start ack, set the touch action. // Receive a touch start ack, set the touch action.
filter_.OnSetTouchAction(cc::kTouchActionPanY); filter_.OnSetTouchAction(cc::kTouchActionPanY);
filter_.IncreaseActiveTouches(); filter_.IncreaseActiveTouches();
filter_.OnHasTouchEventHandlers(false); filter_.OnHasTouchEventHandlers(false);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionPanY); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionPanY);
EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPanY); EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPanY);
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionPanY); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionPanY);
EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPanY); EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPanY);
} }
TEST_P(TouchActionFilterTest, ResetTouchActionWithActiveTouch) { TEST_P(TouchActionFilterTest, ResetTouchActionWithActiveTouch) {
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_FALSE(ScrollingTouchAction().has_value()); EXPECT_FALSE(ActiveTouchAction().has_value());
EXPECT_FALSE(filter_.allowed_touch_action().has_value()); EXPECT_FALSE(filter_.allowed_touch_action().has_value());
// Receive a touch start ack, set the touch action. // Receive a touch start ack, set the touch action.
...@@ -1165,7 +1165,7 @@ TEST_P(TouchActionFilterTest, ResetTouchActionWithActiveTouch) { ...@@ -1165,7 +1165,7 @@ TEST_P(TouchActionFilterTest, ResetTouchActionWithActiveTouch) {
// actions should still have value. // actions should still have value.
filter_.DecreaseActiveTouches(); filter_.DecreaseActiveTouches();
filter_.ReportAndResetTouchAction(); filter_.ReportAndResetTouchAction();
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionPanY); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionPanY);
EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPanY); EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPanY);
// The ack for the second touch end comes, the touch actions will be reset. // The ack for the second touch end comes, the touch actions will be reset.
...@@ -1197,29 +1197,29 @@ TEST_P(TouchActionFilterTest, ResetBeforeHasHandlerSet) { ...@@ -1197,29 +1197,29 @@ TEST_P(TouchActionFilterTest, ResetBeforeHasHandlerSet) {
// Auto. // Auto.
TEST_P(TouchActionFilterTest, ScrollBeginWithoutTapDown) { TEST_P(TouchActionFilterTest, ScrollBeginWithoutTapDown) {
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_FALSE(ScrollingTouchAction().has_value()); EXPECT_FALSE(ActiveTouchAction().has_value());
EXPECT_FALSE(filter_.allowed_touch_action().has_value()); EXPECT_FALSE(filter_.allowed_touch_action().has_value());
WebGestureEvent scroll_begin = WebGestureEvent scroll_begin =
SyntheticWebGestureEventBuilder::BuildScrollBegin(5, 0, kSourceDevice); SyntheticWebGestureEventBuilder::BuildScrollBegin(5, 0, kSourceDevice);
EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin), EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionAuto); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionAuto);
EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionAuto); EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionAuto);
} }
// This tests a gesture tap down with |num_of_active_touches_| == 0 // This tests a gesture tap down with |num_of_active_touches_| == 0
TEST_P(TouchActionFilterTest, TapDownWithZeroNumOfActiveTouches) { TEST_P(TouchActionFilterTest, TapDownWithZeroNumOfActiveTouches) {
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_FALSE(ScrollingTouchAction().has_value()); EXPECT_FALSE(ActiveTouchAction().has_value());
EXPECT_FALSE(filter_.allowed_touch_action().has_value()); EXPECT_FALSE(filter_.allowed_touch_action().has_value());
WebGestureEvent tap_down = SyntheticWebGestureEventBuilder::Build( WebGestureEvent tap_down = SyntheticWebGestureEventBuilder::Build(
WebInputEvent::kGestureTapDown, kSourceDevice); WebInputEvent::kGestureTapDown, kSourceDevice);
EXPECT_EQ(filter_.FilterGestureEvent(&tap_down), EXPECT_EQ(filter_.FilterGestureEvent(&tap_down),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_TRUE(ScrollingTouchAction().has_value()); EXPECT_TRUE(ActiveTouchAction().has_value());
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionAuto); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionAuto);
} }
// Regression test for crbug.com/771330. One can start one finger panning y, and // Regression test for crbug.com/771330. One can start one finger panning y, and
...@@ -1264,7 +1264,7 @@ TEST_P(TouchActionFilterTest, PinchZoomStartsWithOneFingerPanDisallowed) { ...@@ -1264,7 +1264,7 @@ TEST_P(TouchActionFilterTest, PinchZoomStartsWithOneFingerPanDisallowed) {
TEST_P(TouchActionFilterTest, ScrollBeginWithoutTapDownWithKnownTouchAction) { TEST_P(TouchActionFilterTest, ScrollBeginWithoutTapDownWithKnownTouchAction) {
filter_.OnHasTouchEventHandlers(true); filter_.OnHasTouchEventHandlers(true);
EXPECT_FALSE(ScrollingTouchAction().has_value()); EXPECT_FALSE(ActiveTouchAction().has_value());
EXPECT_FALSE(filter_.allowed_touch_action().has_value()); EXPECT_FALSE(filter_.allowed_touch_action().has_value());
filter_.OnSetTouchAction(cc::kTouchActionPan); filter_.OnSetTouchAction(cc::kTouchActionPan);
...@@ -1272,7 +1272,7 @@ TEST_P(TouchActionFilterTest, ScrollBeginWithoutTapDownWithKnownTouchAction) { ...@@ -1272,7 +1272,7 @@ TEST_P(TouchActionFilterTest, ScrollBeginWithoutTapDownWithKnownTouchAction) {
SyntheticWebGestureEventBuilder::BuildScrollBegin(5, 0, kSourceDevice); SyntheticWebGestureEventBuilder::BuildScrollBegin(5, 0, kSourceDevice);
EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin), EXPECT_EQ(filter_.FilterGestureEvent(&scroll_begin),
FilterGestureEventResult::kFilterGestureEventAllowed); FilterGestureEventResult::kFilterGestureEventAllowed);
EXPECT_EQ(ScrollingTouchAction().value(), cc::kTouchActionPan); EXPECT_EQ(ActiveTouchAction().value(), cc::kTouchActionPan);
EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPan); EXPECT_EQ(filter_.allowed_touch_action().value(), cc::kTouchActionPan);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment