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

Unified Diff: ios/web/public/test/fakes/test_navigation_manager.mm

Issue 2742173002: Removed use of CRWSessionController from NativeAppNavigationUtilsTest. (Closed)
Patch Set: fixed parameter naming Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/web/public/test/fakes/test_navigation_manager.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/public/test/fakes/test_navigation_manager.mm
diff --git a/ios/web/public/test/fakes/test_navigation_manager.mm b/ios/web/public/test/fakes/test_navigation_manager.mm
index b6ca37e002771992e2c13f8a3f85c708963d09ab..442aa0e0972d45aea553fa82991783ebd3da715f 100644
--- a/ios/web/public/test/fakes/test_navigation_manager.mm
+++ b/ios/web/public/test/fakes/test_navigation_manager.mm
@@ -7,7 +7,8 @@
namespace web {
TestNavigationManager::TestNavigationManager()
- : pending_item_(nullptr),
+ : items_index_(-1),
+ pending_item_(nullptr),
last_committed_item_(nullptr),
visible_item_(nullptr) {}
@@ -71,18 +72,20 @@ void TestNavigationManager::AddTransientURLRewriter(
}
int TestNavigationManager::GetItemCount() const {
- NOTREACHED();
- return 0;
+ return items_.size();
}
web::NavigationItem* TestNavigationManager::GetItemAtIndex(size_t index) const {
- NOTREACHED();
- return nullptr;
+ return items_[index].get();
}
int TestNavigationManager::GetCurrentItemIndex() const {
- NOTREACHED();
- return 0;
+ return items_index_;
+}
+
+void TestNavigationManager::SetCurrentItemIndex(const int index) {
+ DCHECK(index == -1 || index >= 0 && index < GetItemCount());
+ items_index_ = index;
}
int TestNavigationManager::GetLastCommittedItemIndex() const {
@@ -96,8 +99,13 @@ int TestNavigationManager::GetPendingItemIndex() const {
}
bool TestNavigationManager::RemoveItemAtIndex(int index) {
- NOTREACHED();
- return false;
+ if (index < 0 || index >= GetItemCount())
+ return false;
+ DCHECK(items_index_ != index);
+ items_.erase(items_.begin() + index);
+ if (items_index_ > index)
+ --items_index_;
+ return true;
}
bool TestNavigationManager::CanGoBack() const {
@@ -136,4 +144,14 @@ void TestNavigationManager::OverrideDesktopUserAgentForNextPendingItem() {
NOTREACHED();
}
+// Adds a new navigation item of |transition| type at the end of this
+// navigation manager.
+void TestNavigationManager::AddItem(const GURL& url,
+ ui::PageTransition transition) {
+ items_.push_back(web::NavigationItem::Create());
+ items_.back()->SetTransitionType(transition);
+ items_.back()->SetURL(url);
+ SetCurrentItemIndex(GetItemCount() - 1);
+}
+
} // namespace web
« no previous file with comments | « ios/web/public/test/fakes/test_navigation_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698