| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/public/test/fakes/test_navigation_manager.h" | 5 #import "ios/web/public/test/fakes/test_navigation_manager.h" |
| 6 | 6 |
| 7 namespace web { | 7 namespace web { |
| 8 | 8 |
| 9 TestNavigationManager::TestNavigationManager() | 9 TestNavigationManager::TestNavigationManager() |
| 10 : pending_item_(nullptr), | 10 : items_index_(-1), |
| 11 pending_item_(nullptr), |
| 11 last_committed_item_(nullptr), | 12 last_committed_item_(nullptr), |
| 12 visible_item_(nullptr) {} | 13 visible_item_(nullptr) {} |
| 13 | 14 |
| 14 TestNavigationManager::~TestNavigationManager() {} | 15 TestNavigationManager::~TestNavigationManager() {} |
| 15 | 16 |
| 16 BrowserState* TestNavigationManager::GetBrowserState() const { | 17 BrowserState* TestNavigationManager::GetBrowserState() const { |
| 17 NOTREACHED(); | 18 NOTREACHED(); |
| 18 return nullptr; | 19 return nullptr; |
| 19 } | 20 } |
| 20 | 21 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 const NavigationManager::WebLoadParams& params) { | 65 const NavigationManager::WebLoadParams& params) { |
| 65 NOTREACHED(); | 66 NOTREACHED(); |
| 66 } | 67 } |
| 67 | 68 |
| 68 void TestNavigationManager::AddTransientURLRewriter( | 69 void TestNavigationManager::AddTransientURLRewriter( |
| 69 BrowserURLRewriter::URLRewriter rewriter) { | 70 BrowserURLRewriter::URLRewriter rewriter) { |
| 70 NOTREACHED(); | 71 NOTREACHED(); |
| 71 } | 72 } |
| 72 | 73 |
| 73 int TestNavigationManager::GetItemCount() const { | 74 int TestNavigationManager::GetItemCount() const { |
| 74 NOTREACHED(); | 75 return items_.size(); |
| 75 return 0; | |
| 76 } | 76 } |
| 77 | 77 |
| 78 web::NavigationItem* TestNavigationManager::GetItemAtIndex(size_t index) const { | 78 web::NavigationItem* TestNavigationManager::GetItemAtIndex(size_t index) const { |
| 79 NOTREACHED(); | 79 return items_[index].get(); |
| 80 return nullptr; | |
| 81 } | 80 } |
| 82 | 81 |
| 83 int TestNavigationManager::GetCurrentItemIndex() const { | 82 int TestNavigationManager::GetCurrentItemIndex() const { |
| 84 NOTREACHED(); | 83 return items_index_; |
| 85 return 0; | 84 } |
| 85 |
| 86 void TestNavigationManager::SetCurrentItemIndex(const int index) { |
| 87 DCHECK(index == -1 || index >= 0 && index < GetItemCount()); |
| 88 items_index_ = index; |
| 86 } | 89 } |
| 87 | 90 |
| 88 int TestNavigationManager::GetLastCommittedItemIndex() const { | 91 int TestNavigationManager::GetLastCommittedItemIndex() const { |
| 89 NOTREACHED(); | 92 NOTREACHED(); |
| 90 return 0; | 93 return 0; |
| 91 } | 94 } |
| 92 | 95 |
| 93 int TestNavigationManager::GetPendingItemIndex() const { | 96 int TestNavigationManager::GetPendingItemIndex() const { |
| 94 NOTREACHED(); | 97 NOTREACHED(); |
| 95 return 0; | 98 return 0; |
| 96 } | 99 } |
| 97 | 100 |
| 98 bool TestNavigationManager::RemoveItemAtIndex(int index) { | 101 bool TestNavigationManager::RemoveItemAtIndex(int index) { |
| 99 NOTREACHED(); | 102 if (index < 0 || index >= GetItemCount()) |
| 100 return false; | 103 return false; |
| 104 DCHECK(items_index_ != index); |
| 105 items_.erase(items_.begin() + index); |
| 106 if (items_index_ > index) |
| 107 --items_index_; |
| 108 return true; |
| 101 } | 109 } |
| 102 | 110 |
| 103 bool TestNavigationManager::CanGoBack() const { | 111 bool TestNavigationManager::CanGoBack() const { |
| 104 NOTREACHED(); | 112 NOTREACHED(); |
| 105 return false; | 113 return false; |
| 106 } | 114 } |
| 107 | 115 |
| 108 bool TestNavigationManager::CanGoForward() const { | 116 bool TestNavigationManager::CanGoForward() const { |
| 109 NOTREACHED(); | 117 NOTREACHED(); |
| 110 return false; | 118 return false; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 129 | 137 |
| 130 void TestNavigationManager::Reload(ReloadType reload_type, | 138 void TestNavigationManager::Reload(ReloadType reload_type, |
| 131 bool check_for_repost) { | 139 bool check_for_repost) { |
| 132 NOTREACHED(); | 140 NOTREACHED(); |
| 133 } | 141 } |
| 134 | 142 |
| 135 void TestNavigationManager::OverrideDesktopUserAgentForNextPendingItem() { | 143 void TestNavigationManager::OverrideDesktopUserAgentForNextPendingItem() { |
| 136 NOTREACHED(); | 144 NOTREACHED(); |
| 137 } | 145 } |
| 138 | 146 |
| 147 // Adds a new navigation item of |transition| type at the end of this |
| 148 // navigation manager. |
| 149 void TestNavigationManager::AddItem(const GURL& url, |
| 150 ui::PageTransition transition) { |
| 151 items_.push_back(web::NavigationItem::Create()); |
| 152 items_.back()->SetTransitionType(transition); |
| 153 items_.back()->SetURL(url); |
| 154 SetCurrentItemIndex(GetItemCount() - 1); |
| 155 } |
| 156 |
| 139 } // namespace web | 157 } // namespace web |
| OLD | NEW |