| 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 #import "ios/web/navigation/navigation_manager_impl.h" | 5 #import "ios/web/navigation/navigation_manager_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #import "base/mac/scoped_nsobject.h" | 8 #import "base/mac/scoped_nsobject.h" |
| 9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" | 9 #import "ios/web/navigation/crw_session_controller+private_constructors.h" |
| 10 #import "ios/web/navigation/navigation_manager_delegate.h" | 10 #import "ios/web/navigation/navigation_manager_delegate.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 TestBrowserState browser_state_; | 44 TestBrowserState browser_state_; |
| 45 TestNavigationManagerDelegate delegate_; | 45 TestNavigationManagerDelegate delegate_; |
| 46 std::unique_ptr<NavigationManagerImpl> manager_; | 46 std::unique_ptr<NavigationManagerImpl> manager_; |
| 47 base::scoped_nsobject<CRWSessionController> controller_; | 47 base::scoped_nsobject<CRWSessionController> controller_; |
| 48 }; | 48 }; |
| 49 | 49 |
| 50 // Tests state of an empty navigation manager. | 50 // Tests state of an empty navigation manager. |
| 51 TEST_F(NavigationManagerTest, EmptyManager) { | 51 TEST_F(NavigationManagerTest, EmptyManager) { |
| 52 EXPECT_EQ(0, navigation_manager()->GetItemCount()); | 52 EXPECT_EQ(0, navigation_manager()->GetItemCount()); |
| 53 EXPECT_EQ(-1, navigation_manager()->GetCurrentItemIndex()); | 53 EXPECT_EQ(-1, navigation_manager()->GetCurrentItemIndex()); |
| 54 EXPECT_FALSE(navigation_manager()->GetPreviousItem()); | |
| 55 EXPECT_EQ(-1, navigation_manager()->GetCurrentItemIndex()); | 54 EXPECT_EQ(-1, navigation_manager()->GetCurrentItemIndex()); |
| 56 EXPECT_FALSE(navigation_manager()->GetPendingItem()); | 55 EXPECT_FALSE(navigation_manager()->GetPendingItem()); |
| 57 EXPECT_EQ(-1, navigation_manager()->GetPendingItemIndex()); | 56 EXPECT_EQ(-1, navigation_manager()->GetPendingItemIndex()); |
| 58 EXPECT_EQ(-1, navigation_manager()->GetIndexForOffset(0)); | 57 EXPECT_EQ(-1, navigation_manager()->GetIndexForOffset(0)); |
| 59 } | 58 } |
| 60 | 59 |
| 61 // Tests that GetPendingItemIndex() returns -1 if there is no pending entry. | 60 // Tests that GetPendingItemIndex() returns -1 if there is no pending entry. |
| 62 TEST_F(NavigationManagerTest, GetPendingItemIndexWithoutPendingEntry) { | 61 TEST_F(NavigationManagerTest, GetPendingItemIndexWithoutPendingEntry) { |
| 63 navigation_manager()->AddPendingItem( | 62 navigation_manager()->AddPendingItem( |
| 64 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | 63 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 navigation_manager()->OverrideDesktopUserAgentForNextPendingItem(); | 508 navigation_manager()->OverrideDesktopUserAgentForNextPendingItem(); |
| 510 navigation_manager()->AddPendingItem( | 509 navigation_manager()->AddPendingItem( |
| 511 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, | 510 GURL("http://www.url.com"), Referrer(), ui::PAGE_TRANSITION_TYPED, |
| 512 web::NavigationInitiationType::USER_INITIATED); | 511 web::NavigationInitiationType::USER_INITIATED); |
| 513 [session_controller() commitPendingItem]; | 512 [session_controller() commitPendingItem]; |
| 514 NavigationItem* visible_item = navigation_manager()->GetVisibleItem(); | 513 NavigationItem* visible_item = navigation_manager()->GetVisibleItem(); |
| 515 EXPECT_TRUE(visible_item->IsOverridingUserAgent()); | 514 EXPECT_TRUE(visible_item->IsOverridingUserAgent()); |
| 516 } | 515 } |
| 517 | 516 |
| 518 } // namespace web | 517 } // namespace web |
| OLD | NEW |