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

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

Issue 2742173002: Removed use of CRWSessionController from NativeAppNavigationUtilsTest. (Closed)
Patch Set: moved test set up code to web::TestNavigationManager 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
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..ad5d686cbf0100353c9578f42ab51e8d5d10394a 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_count_(-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_count_;
+}
+
+void TestNavigationManager::SetCurrentItemIndex(const int index) {
+ DCHECK(index == -1 || index >= 0 && index < GetItemCount());
+ items_count_ = index;
}
int TestNavigationManager::GetLastCommittedItemIndex() const {
@@ -96,8 +99,11 @@ int TestNavigationManager::GetPendingItemIndex() const {
}
bool TestNavigationManager::RemoveItemAtIndex(int index) {
- NOTREACHED();
- return false;
+ if (index < 0 || index >= GetItemCount())
+ return false;
+ items_.erase(items_.begin() + index);
+ 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
+ return true;
}
bool TestNavigationManager::CanGoBack() const {
@@ -136,4 +142,14 @@ void TestNavigationManager::OverrideDesktopUserAgentForNextPendingItem() {
NOTREACHED();
}
+// Adds a new navigation item of |transition| type at the end of this
+// navigation manager.
+void TestNavigationManager::AddItem(const std::string& url_spec,
+ ui::PageTransition transition) {
+ items_.push_back(web::NavigationItem::Create());
+ items_.back()->SetTransitionType(transition);
+ items_.back()->SetURL(GURL(url_spec));
+ SetCurrentItemIndex(GetItemCount() - 1);
+}
+
} // namespace web

Powered by Google App Engine
This is Rietveld 408576698