| 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" |
| 11 #import "third_party/ocmock/OCMock/OCMock.h" | 11 #import "third_party/ocmock/OCMock/OCMock.h" |
| 12 #import "third_party/ocmock/ocmock_extensions.h" | 12 #import "third_party/ocmock/ocmock_extensions.h" |
| 13 #include "third_party/WebKit/public/web/WebInputEvent.h" | 13 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 14 | 14 |
| 15 @interface HistorySwiper (MacHistorySwiperTest) | 15 @interface HistorySwiper (MacHistorySwiperTest) |
| 16 - (BOOL)systemSettingsAllowHistorySwiping:(NSEvent*)event; | 16 - (BOOL)systemSettingsAllowHistorySwiping:(NSEvent*)event; |
| 17 - (BOOL)browserCanNavigateInDirection: | 17 - (BOOL)browserCanNavigateInDirection: |
| 18 (history_swiper::NavigationDirection)forward | 18 (history_swiper::NavigationDirection)forward |
| 19 event:(NSEvent*)event; | 19 event:(NSEvent*)event; |
| 20 - (void)removeHistoryOverlay; | 20 - (void)removeHistoryOverlay; |
| 21 - (void)showHistoryOverlay:(history_swiper::NavigationDirection)direction; | 21 - (void)showHistoryOverlay:(history_swiper::NavigationDirection)direction; |
| 22 - (void)navigateBrowserInDirection:(history_swiper::NavigationDirection)forward; | 22 - (void)navigateBrowserInDirection:(history_swiper::NavigationDirection)forward; |
| 23 - (void)initiateMagicMouseHistorySwipe:(BOOL)isRightScroll | 23 - (void)initiateMagicMouseHistorySwipe:(BOOL)isRightScroll |
| 24 event:(NSEvent*)event; | 24 event:(NSEvent*)event; |
| 25 @end | 25 @end |
| 26 | 26 |
| 27 class MacHistorySwiperTest : public CocoaTest { | 27 class MacHistorySwiperTest : public CocoaTest { |
| 28 public: | 28 public: |
| 29 virtual void SetUp() override { | 29 void SetUp() override { |
| 30 CocoaTest::SetUp(); | 30 CocoaTest::SetUp(); |
| 31 | 31 |
| 32 [HistorySwiper resetMagicMouseState]; | 32 [HistorySwiper resetMagicMouseState]; |
| 33 | 33 |
| 34 view_ = [[NSView alloc] init]; | 34 view_ = [[NSView alloc] init]; |
| 35 id mockDelegate = | 35 id mockDelegate = |
| 36 [OCMockObject mockForProtocol:@protocol(HistorySwiperDelegate)]; | 36 [OCMockObject mockForProtocol:@protocol(HistorySwiperDelegate)]; |
| 37 [[[mockDelegate stub] andReturn:view_] viewThatWantsHistoryOverlay]; | 37 [[[mockDelegate stub] andReturn:view_] viewThatWantsHistoryOverlay]; |
| 38 [[[mockDelegate stub] andReturnBool:YES] shouldAllowHistorySwiping]; | 38 [[[mockDelegate stub] andReturnBool:YES] shouldAllowHistorySwiping]; |
| 39 | 39 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 historySwiper_ = [mockHistorySwiper retain]; | 78 historySwiper_ = [mockHistorySwiper retain]; |
| 79 | 79 |
| 80 begin_count_ = 0; | 80 begin_count_ = 0; |
| 81 end_count_ = 0; | 81 end_count_ = 0; |
| 82 navigated_right_ = false; | 82 navigated_right_ = false; |
| 83 navigated_left_ = false; | 83 navigated_left_ = false; |
| 84 magic_mouse_history_swipe_ = false; | 84 magic_mouse_history_swipe_ = false; |
| 85 } | 85 } |
| 86 | 86 |
| 87 virtual void TearDown() override { | 87 void TearDown() override { |
| 88 [view_ release]; | 88 [view_ release]; |
| 89 [historySwiper_ release]; | 89 [historySwiper_ release]; |
| 90 CocoaTest::TearDown(); | 90 CocoaTest::TearDown(); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void startGestureInMiddle(); | 93 void startGestureInMiddle(); |
| 94 void moveGestureInMiddle(); | 94 void moveGestureInMiddle(); |
| 95 void moveGestureAtPoint(NSPoint point); | 95 void moveGestureAtPoint(NSPoint point); |
| 96 void momentumMoveGestureAtPoint(NSPoint point); | 96 void momentumMoveGestureAtPoint(NSPoint point); |
| 97 void endGestureAtPoint(NSPoint point); | 97 void endGestureAtPoint(NSPoint point); |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 // Large movement to the right. | 466 // Large movement to the right. |
| 467 moveGestureAtPoint(makePoint(0.6, 0.51)); | 467 moveGestureAtPoint(makePoint(0.6, 0.51)); |
| 468 endGestureAtPoint(makePoint(0.6, 0.51)); | 468 endGestureAtPoint(makePoint(0.6, 0.51)); |
| 469 | 469 |
| 470 EXPECT_EQ(begin_count_, 0); | 470 EXPECT_EQ(begin_count_, 0); |
| 471 EXPECT_EQ(end_count_, 1); | 471 EXPECT_EQ(end_count_, 1); |
| 472 EXPECT_FALSE(navigated_right_); | 472 EXPECT_FALSE(navigated_right_); |
| 473 EXPECT_FALSE(navigated_left_); | 473 EXPECT_FALSE(navigated_left_); |
| 474 } | 474 } |
| OLD | NEW |