| 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 "testing/gtest/include/gtest/gtest.h" | 5 #include "testing/gtest/include/gtest/gtest.h" |
| 6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 7 | 7 |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #import "base/mac/sdk_forward_declarations.h" | 9 #import "base/mac/sdk_forward_declarations.h" |
| 10 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history
_swiper.h" | 10 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_history
_swiper.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 - (void)beginHistorySwipeInDirection: | 21 - (void)beginHistorySwipeInDirection: |
| 22 (history_swiper::NavigationDirection)goForward | 22 (history_swiper::NavigationDirection)goForward |
| 23 event:(NSEvent*)event; | 23 event:(NSEvent*)event; |
| 24 - (void)navigateBrowserInDirection:(history_swiper::NavigationDirection)forward; | 24 - (void)navigateBrowserInDirection:(history_swiper::NavigationDirection)forward; |
| 25 - (void)initiateMagicMouseHistorySwipe:(BOOL)isRightScroll | 25 - (void)initiateMagicMouseHistorySwipe:(BOOL)isRightScroll |
| 26 event:(NSEvent*)event; | 26 event:(NSEvent*)event; |
| 27 @end | 27 @end |
| 28 | 28 |
| 29 class MacHistorySwiperTest : public CocoaTest { | 29 class MacHistorySwiperTest : public CocoaTest { |
| 30 public: | 30 public: |
| 31 virtual void SetUp() OVERRIDE { | 31 virtual void SetUp() override { |
| 32 CocoaTest::SetUp(); | 32 CocoaTest::SetUp(); |
| 33 | 33 |
| 34 [HistorySwiper resetMagicMouseState]; | 34 [HistorySwiper resetMagicMouseState]; |
| 35 | 35 |
| 36 view_ = [[NSView alloc] init]; | 36 view_ = [[NSView alloc] init]; |
| 37 id mockDelegate = | 37 id mockDelegate = |
| 38 [OCMockObject mockForProtocol:@protocol(HistorySwiperDelegate)]; | 38 [OCMockObject mockForProtocol:@protocol(HistorySwiperDelegate)]; |
| 39 [[[mockDelegate stub] andReturn:view_] viewThatWantsHistoryOverlay]; | 39 [[[mockDelegate stub] andReturn:view_] viewThatWantsHistoryOverlay]; |
| 40 [[[mockDelegate stub] andReturnBool:YES] shouldAllowHistorySwiping]; | 40 [[[mockDelegate stub] andReturnBool:YES] shouldAllowHistorySwiping]; |
| 41 | 41 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 | 83 |
| 84 historySwiper_ = [mockHistorySwiper retain]; | 84 historySwiper_ = [mockHistorySwiper retain]; |
| 85 | 85 |
| 86 begin_count_ = 0; | 86 begin_count_ = 0; |
| 87 end_count_ = 0; | 87 end_count_ = 0; |
| 88 navigated_right_ = false; | 88 navigated_right_ = false; |
| 89 navigated_left_ = false; | 89 navigated_left_ = false; |
| 90 magic_mouse_history_swipe_ = false; | 90 magic_mouse_history_swipe_ = false; |
| 91 } | 91 } |
| 92 | 92 |
| 93 virtual void TearDown() OVERRIDE { | 93 virtual void TearDown() override { |
| 94 [view_ release]; | 94 [view_ release]; |
| 95 [historySwiper_ release]; | 95 [historySwiper_ release]; |
| 96 CocoaTest::TearDown(); | 96 CocoaTest::TearDown(); |
| 97 } | 97 } |
| 98 | 98 |
| 99 void startGestureInMiddle(); | 99 void startGestureInMiddle(); |
| 100 void moveGestureInMiddle(); | 100 void moveGestureInMiddle(); |
| 101 void moveGestureAtPoint(NSPoint point); | 101 void moveGestureAtPoint(NSPoint point); |
| 102 void momentumMoveGestureAtPoint(NSPoint point); | 102 void momentumMoveGestureAtPoint(NSPoint point); |
| 103 void endGestureAtPoint(NSPoint point); | 103 void endGestureAtPoint(NSPoint point); |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 444 moveGestureAtPoint(makePoint(0.60, 0.5)); | 444 moveGestureAtPoint(makePoint(0.60, 0.5)); |
| 445 scrollEvent = scrollWheelEventWithPhase(NSEventPhaseChanged); | 445 scrollEvent = scrollWheelEventWithPhase(NSEventPhaseChanged); |
| 446 [historySwiper_ handleEvent:scrollEvent]; | 446 [historySwiper_ handleEvent:scrollEvent]; |
| 447 endGestureAtPoint(makePoint(0.70, 0.5)); | 447 endGestureAtPoint(makePoint(0.70, 0.5)); |
| 448 | 448 |
| 449 EXPECT_EQ(begin_count_, 1); | 449 EXPECT_EQ(begin_count_, 1); |
| 450 EXPECT_EQ(end_count_, 1); | 450 EXPECT_EQ(end_count_, 1); |
| 451 EXPECT_TRUE(navigated_right_); | 451 EXPECT_TRUE(navigated_right_); |
| 452 EXPECT_FALSE(navigated_left_); | 452 EXPECT_FALSE(navigated_left_); |
| 453 } | 453 } |
| OLD | NEW |