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

Unified Diff: ios/web/navigation/navigation_manager_util_unittest.mm

Issue 2875153003: Added web::GetCommittedItemWithUniqueID function. (Closed)
Patch Set: Added GetCommittedItemIndexWithUniqueID Created 3 years, 7 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/navigation/navigation_manager_util.mm ('k') | ios/web/net/crw_ssl_status_updater.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/navigation/navigation_manager_util_unittest.mm
diff --git a/ios/web/navigation/navigation_manager_util_unittest.mm b/ios/web/navigation/navigation_manager_util_unittest.mm
new file mode 100644
index 0000000000000000000000000000000000000000..da2297af2fcbf3ede86da7ea59eb4959d42229f7
--- /dev/null
+++ b/ios/web/navigation/navigation_manager_util_unittest.mm
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ios/web/navigation/navigation_manager_util.h"
+
+#include "base/memory/ptr_util.h"
+#import "ios/web/navigation/crw_session_controller+private_constructors.h"
+#import "ios/web/navigation/crw_session_controller.h"
+#import "ios/web/navigation/navigation_manager_impl.h"
+#import "ios/web/public/navigation_item.h"
+#include "ios/web/public/test/fakes/test_browser_state.h"
+#include "testing/platform_test.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+namespace web {
+
+// Test fixture testing navigation_manager_util.h functions.
+class NavigationManagerUtilTest : public PlatformTest {
+ protected:
+ NavigationManagerUtilTest()
+ : controller_([[CRWSessionController alloc]
+ initWithBrowserState:&browser_state_]) {
+ manager_.SetSessionController(controller_);
+ }
+
+ NavigationManagerImpl manager_;
+ CRWSessionController* controller_;
+
+ private:
+ TestBrowserState browser_state_;
+};
+
+// Tests GetCommittedItemWithUniqueID and GetCommittedItemIndexWithUniqueID
+// functions.
+TEST_F(NavigationManagerUtilTest, GetCommittedItemWithUniqueID) {
+ // Start with NavigationManager that only has a pending item.
+ manager_.AddPendingItem(
+ GURL("http://chromium.org"), Referrer(), ui::PAGE_TRANSITION_TYPED,
+ web::NavigationInitiationType::USER_INITIATED,
+ web::NavigationManager::UserAgentOverrideOption::INHERIT);
+ NavigationItem* item = manager_.GetPendingItem();
+ int unique_id = item->GetUniqueID();
+ EXPECT_FALSE(GetCommittedItemWithUniqueID(&manager_, unique_id));
+ EXPECT_EQ(-1, GetCommittedItemIndexWithUniqueID(&manager_, unique_id));
+
+ // Commit that pending item.
+ [controller_ commitPendingItem];
+ EXPECT_EQ(item, GetCommittedItemWithUniqueID(&manager_, unique_id));
+ EXPECT_EQ(0, GetCommittedItemIndexWithUniqueID(&manager_, unique_id));
+
+ // Remove committed item.
+ manager_.RemoveItemAtIndex(0);
+ EXPECT_FALSE(GetCommittedItemWithUniqueID(&manager_, unique_id));
+ EXPECT_EQ(-1, GetCommittedItemIndexWithUniqueID(&manager_, unique_id));
+}
+
+} // namespace web
« no previous file with comments | « ios/web/navigation/navigation_manager_util.mm ('k') | ios/web/net/crw_ssl_status_updater.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698