Chromium Code Reviews| 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_count_(-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_count_; |
| 85 return 0; | 84 } |
| 85 | |
| 86 void TestNavigationManager::SetCurrentItemIndex(const int index) { | |
| 87 DCHECK(index == -1 || index >= 0 && index < GetItemCount()); | |
| 88 items_count_ = 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 items_.erase(items_.begin() + index); | |
| 105 SetCurrentItemIndex(GetItemCount() - 1); | |
|
Eugene But (OOO till 7-30)
2017/03/14 16:52:11
This is quite unexpected side effect. SessionContr
pkl (ping after 24h if needed)
2017/03/14 21:16:19
Thanks for pointing this out. To mimic what's curr
| |
| 106 return true; | |
| 101 } | 107 } |
| 102 | 108 |
| 103 bool TestNavigationManager::CanGoBack() const { | 109 bool TestNavigationManager::CanGoBack() const { |
| 104 NOTREACHED(); | 110 NOTREACHED(); |
| 105 return false; | 111 return false; |
| 106 } | 112 } |
| 107 | 113 |
| 108 bool TestNavigationManager::CanGoForward() const { | 114 bool TestNavigationManager::CanGoForward() const { |
| 109 NOTREACHED(); | 115 NOTREACHED(); |
| 110 return false; | 116 return false; |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 129 | 135 |
| 130 void TestNavigationManager::Reload(ReloadType reload_type, | 136 void TestNavigationManager::Reload(ReloadType reload_type, |
| 131 bool check_for_repost) { | 137 bool check_for_repost) { |
| 132 NOTREACHED(); | 138 NOTREACHED(); |
| 133 } | 139 } |
| 134 | 140 |
| 135 void TestNavigationManager::OverrideDesktopUserAgentForNextPendingItem() { | 141 void TestNavigationManager::OverrideDesktopUserAgentForNextPendingItem() { |
| 136 NOTREACHED(); | 142 NOTREACHED(); |
| 137 } | 143 } |
| 138 | 144 |
| 145 // Adds a new navigation item of |transition| type at the end of this | |
| 146 // navigation manager. | |
| 147 void TestNavigationManager::AddItem(const std::string& url_spec, | |
| 148 ui::PageTransition transition) { | |
| 149 items_.push_back(web::NavigationItem::Create()); | |
| 150 items_.back()->SetTransitionType(transition); | |
| 151 items_.back()->SetURL(GURL(url_spec)); | |
| 152 SetCurrentItemIndex(GetItemCount() - 1); | |
| 153 } | |
| 154 | |
| 139 } // namespace web | 155 } // namespace web |
| OLD | NEW |