Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(930)

Side by Side Diff: ios/web/public/test/fakes/test_navigation_manager.mm

Issue 2915303002: Added NavigationManager::GetIndexOfItem(). (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 : items_index_(-1), 10 : items_index_(-1),
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 int TestNavigationManager::GetItemCount() const { 70 int TestNavigationManager::GetItemCount() const {
71 return items_.size(); 71 return items_.size();
72 } 72 }
73 73
74 web::NavigationItem* TestNavigationManager::GetItemAtIndex(size_t index) const { 74 web::NavigationItem* TestNavigationManager::GetItemAtIndex(size_t index) const {
75 return items_[index].get(); 75 return items_[index].get();
76 } 76 }
77 77
78 int TestNavigationManager::GetIndexOfItem(
79 const web::NavigationItem* item) const {
80 for (size_t index = 0; index < items_.size(); ++index) {
81 if (items_[index].get() == item)
82 return index;
83 }
84 return NSNotFound;
Eugene But (OOO till 7-30) 2017/06/02 18:08:08 s/NSNotFound/-1
kkhorimoto 2017/06/02 18:28:58 Done.
85 }
86
78 void TestNavigationManager::SetLastCommittedItemIndex(const int index) { 87 void TestNavigationManager::SetLastCommittedItemIndex(const int index) {
79 DCHECK(index == -1 || index >= 0 && index < GetItemCount()); 88 DCHECK(index == -1 || index >= 0 && index < GetItemCount());
80 items_index_ = index; 89 items_index_ = index;
81 } 90 }
82 91
83 int TestNavigationManager::GetLastCommittedItemIndex() const { 92 int TestNavigationManager::GetLastCommittedItemIndex() const {
84 return items_index_; 93 return items_index_;
85 } 94 }
86 95
87 int TestNavigationManager::GetPendingItemIndex() const { 96 int TestNavigationManager::GetPendingItemIndex() const {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 // navigation manager. 164 // navigation manager.
156 void TestNavigationManager::AddItem(const GURL& url, 165 void TestNavigationManager::AddItem(const GURL& url,
157 ui::PageTransition transition) { 166 ui::PageTransition transition) {
158 items_.push_back(web::NavigationItem::Create()); 167 items_.push_back(web::NavigationItem::Create());
159 items_.back()->SetTransitionType(transition); 168 items_.back()->SetTransitionType(transition);
160 items_.back()->SetURL(url); 169 items_.back()->SetURL(url);
161 SetLastCommittedItemIndex(GetItemCount() - 1); 170 SetLastCommittedItemIndex(GetItemCount() - 1);
162 } 171 }
163 172
164 } // namespace web 173 } // namespace web
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698