Chromium Code Reviews| Index: chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper_unit_test.mm |
| diff --git a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper_unit_test.mm b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper_unit_test.mm |
| index 03b60997bbe78e17cb8ae2f015973355162c3939..dcd37e628b5d7a48bae705081bb1678bb65015f0 100644 |
| --- a/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper_unit_test.mm |
| +++ b/chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history_swiper_unit_test.mm |
| @@ -17,10 +17,8 @@ |
| - (BOOL)browserCanNavigateInDirection: |
| (history_swiper::NavigationDirection)forward |
| event:(NSEvent*)event; |
| -- (void)endHistorySwipe; |
| -- (void)beginHistorySwipeInDirection: |
| - (history_swiper::NavigationDirection)goForward |
| - event:(NSEvent*)event; |
| +- (void)removeHistoryOverlay; |
| +- (void)showHistoryOverlay:(history_swiper::NavigationDirection)direction; |
| - (void)navigateBrowserInDirection:(history_swiper::NavigationDirection)forward; |
| - (void)initiateMagicMouseHistorySwipe:(BOOL)isRightScroll |
| event:(NSEvent*)event; |
| @@ -51,22 +49,18 @@ class MacHistorySwiperTest : public CocoaTest { |
| browserCanNavigateInDirection:history_swiper::kBackwards |
| event:[OCMArg any]]; |
| [[[[mockHistorySwiper stub] andDo:^(NSInvocation* invocation) { |
| - ++begin_count_; |
| - // beginHistorySwipeInDirection: calls endHistorySwipe internally. |
| - --end_count_; |
| - }] andForwardToRealObject] |
| - beginHistorySwipeInDirection:history_swiper::kForwards |
| - event:[OCMArg any]]; |
| + ++begin_count_; |
| + // showHistoryOverlay: calls removeHistoryOverlay internally. |
| + --end_count_; |
| + }] andForwardToRealObject] showHistoryOverlay:history_swiper::kForwards]; |
| [[[[mockHistorySwiper stub] andDo:^(NSInvocation* invocation) { |
| - ++begin_count_; |
| - // beginHistorySwipeInDirection: calls endHistorySwipe internally. |
| - --end_count_; |
| - }] andForwardToRealObject] |
| - beginHistorySwipeInDirection:history_swiper::kBackwards |
| - event:[OCMArg any]]; |
| + ++begin_count_; |
| + // showHistoryOverlay: calls removeHistoryOverlay internally. |
| + --end_count_; |
| + }] andForwardToRealObject] showHistoryOverlay:history_swiper::kBackwards]; |
| [[[[mockHistorySwiper stub] andDo:^(NSInvocation* invocation) { |
| - ++end_count_; |
| - }] andForwardToRealObject] endHistorySwipe]; |
| + ++end_count_; |
| + }] andForwardToRealObject] removeHistoryOverlay]; |
| [[[mockHistorySwiper stub] andDo:^(NSInvocation* invocation) { |
| navigated_right_ = true; |
| }] navigateBrowserInDirection:history_swiper::kForwards]; |
| @@ -287,7 +281,7 @@ TEST_F(MacHistorySwiperTest, SwipeDiagonal) { |
| moveGestureAtPoint(makePoint(0.6, 0.59)); |
| endGestureAtPoint(makePoint(0.6, 0.59)); |
| - EXPECT_EQ(begin_count_, 1); |
| + EXPECT_EQ(begin_count_, 0); |
|
Lei Zhang
2014/10/17 23:56:10
preferably EXPECT_EQ(expected_, actual), but there
|
| EXPECT_EQ(end_count_, 1); |
| EXPECT_FALSE(navigated_right_); |
| EXPECT_FALSE(navigated_left_); |
| @@ -380,7 +374,7 @@ TEST_F(MacHistorySwiperTest, NoSwipe) { |
| // No movement. |
| endGestureAtPoint(makePoint(0.44, 0.44)); |
| - EXPECT_EQ(begin_count_, 1); |
| + EXPECT_EQ(begin_count_, 0); |
| EXPECT_EQ(end_count_, 1); |
| EXPECT_FALSE(navigated_right_); |
| EXPECT_FALSE(navigated_left_); |
| @@ -451,3 +445,30 @@ TEST_F(MacHistorySwiperTest, SwipeRightEventOrdering) { |
| EXPECT_TRUE(navigated_right_); |
| EXPECT_FALSE(navigated_left_); |
| } |
| + |
| +// Substantial vertical scrolling followed by horizontal scrolling should not |
| +// result in navigation. |
| +TEST_F(MacHistorySwiperTest, SubstantialVerticalThenHorizontal) { |
| + // These tests require 10.7+ APIs. |
| + if (![NSEvent |
| + respondsToSelector:@selector(isSwipeTrackingFromScrollEventsEnabled)]) |
| + return; |
| + |
| + startGestureInMiddle(); |
| + moveGestureInMiddle(); |
| + |
| + // Move up, then move down. |
| + for (CGFloat y = 0.51; y < 0.6; y += 0.01) |
| + moveGestureAtPoint(makePoint(0.5, y)); |
| + for (CGFloat y = 0.59; y > 0.5; y -= 0.01) |
| + moveGestureAtPoint(makePoint(0.5, y)); |
| + |
| + // Large movement to the right. |
| + moveGestureAtPoint(makePoint(0.6, 0.51)); |
| + endGestureAtPoint(makePoint(0.6, 0.51)); |
| + |
| + EXPECT_EQ(begin_count_, 0); |
| + EXPECT_EQ(end_count_, 1); |
| + EXPECT_FALSE(navigated_right_); |
| + EXPECT_FALSE(navigated_left_); |
| +} |