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

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

Issue 2491773005: [ios] Removed canGoBack/canGoForward API from CRWSessionController. (Closed)
Patch Set: Fixed compilation. Created 4 years, 1 month 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_impl.mm ('k') | ios/web/public/navigation_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/web/navigation/navigation_manager_impl_unittest.mm
diff --git a/ios/web/navigation/navigation_manager_impl_unittest.mm b/ios/web/navigation/navigation_manager_impl_unittest.mm
index 34417a11a6a606de0fe2da81e946874aff659071..0aa0c84c451172f012a4d28f0d9c2f8c9ac8497e 100644
--- a/ios/web/navigation/navigation_manager_impl_unittest.mm
+++ b/ios/web/navigation/navigation_manager_impl_unittest.mm
@@ -93,4 +93,163 @@ TEST_F(NavigationManagerTest, GetPendingItemIndexWithIndexedPendingEntry) {
EXPECT_EQ(0, navigation_manager()->GetPendingItemIndex());
}
+// Tests that going back or negative offset is not possible without a committed
+// item.
+TEST_F(NavigationManagerTest, CanGoBackWithoutCommitedItem) {
+ EXPECT_FALSE(navigation_manager()->CanGoBack());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
+}
+
+// Tests that going back or negative offset is not possible if there is a
+// transient item, but not committed items.
+TEST_F(NavigationManagerTest, CanGoBackWithTransientItem) {
+ [session_controller() addTransientEntryWithURL:GURL("http://www.url.com")];
+
+ EXPECT_FALSE(navigation_manager()->CanGoBack());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
+}
+
+// Tests that going back or negative offset is possible if there is a transient
+// item and at least one committed item.
+TEST_F(NavigationManagerTest, CanGoBackWithTransientItemAndCommittedItem) {
+ [session_controller() addPendingEntry:GURL("http://www.url.com")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+ [session_controller() addTransientEntryWithURL:GURL("http://www.url.com/0")];
+
+ EXPECT_TRUE(navigation_manager()->CanGoBack());
+ EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
+}
+
+// Tests that going back or negative offset is not possible if there is ony one
+// committed item and no transient item.
+TEST_F(NavigationManagerTest, CanGoBackWithSingleCommitedItem) {
+ [session_controller() addPendingEntry:GURL("http://www.url.com")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+
+ EXPECT_FALSE(navigation_manager()->CanGoBack());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
+}
+
+// Tests going back possibility with multiple committed items.
+TEST_F(NavigationManagerTest, CanGoBackWithMultipleCommitedItems) {
+ [session_controller() addPendingEntry:GURL("http://www.url.com")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+ [session_controller() addPendingEntry:GURL("http://www.url.com/0")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+ [session_controller() addPendingEntry:GURL("http://www.url.com/1")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+
+ EXPECT_TRUE(navigation_manager()->CanGoBack());
+ EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
+
+ [session_controller() goToEntry:session_controller().entries[1]];
+ EXPECT_TRUE(navigation_manager()->CanGoBack());
+ EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
+
+ [session_controller() goToEntry:session_controller().entries[0]];
+ EXPECT_FALSE(navigation_manager()->CanGoBack());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(-1));
+
+ [session_controller() goToEntry:session_controller().entries[1]];
+ EXPECT_TRUE(navigation_manager()->CanGoBack());
+ EXPECT_TRUE(navigation_manager()->CanGoToOffset(-1));
+}
+
+// Tests that going forward or positive offset is not possible if there is a
+// pending entry.
+TEST_F(NavigationManagerTest, CanGoForwardWithPendingItem) {
+ [session_controller() addPendingEntry:GURL("http://www.url.com")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+ [session_controller() addPendingEntry:GURL("http://www.url.com/0")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+ [session_controller() goToEntry:session_controller().entries[0]];
+ [session_controller() addPendingEntry:GURL("http://www.url.com/1")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+
+ // Pending entry should not allow going forward.
+ EXPECT_FALSE(navigation_manager()->CanGoForward());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
+}
+
+// Tests that going forward or positive offset is not possible without a
+// committed item.
+TEST_F(NavigationManagerTest, CanGoForwardWithoutCommitedItem) {
+ EXPECT_FALSE(navigation_manager()->CanGoForward());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
+}
+
+// Tests that going forward or positive offset is not possible if there is ony
+// one committed item and no transient item.
+TEST_F(NavigationManagerTest, CanGoForwardWithSingleCommitedItem) {
+ [session_controller() addPendingEntry:GURL("http://www.url.com")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+
+ EXPECT_FALSE(navigation_manager()->CanGoForward());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
+}
+
+// Tests going forward possibility with multiple committed items.
+TEST_F(NavigationManagerTest, CanGoForwardWithMultipleCommitedEntries) {
+ [session_controller() addPendingEntry:GURL("http://www.url.com")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+ [session_controller() addPendingEntry:GURL("http://www.url.com/0")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+ [session_controller() addPendingEntry:GURL("http://www.url.com/1")
+ referrer:Referrer()
+ transition:ui::PAGE_TRANSITION_TYPED
+ rendererInitiated:NO];
+ [session_controller() commitPendingEntry];
+
+ EXPECT_FALSE(navigation_manager()->CanGoForward());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
+
+ [session_controller() goToEntry:session_controller().entries[1]];
+ EXPECT_TRUE(navigation_manager()->CanGoForward());
+ EXPECT_TRUE(navigation_manager()->CanGoToOffset(1));
+
+ [session_controller() goToEntry:session_controller().entries[0]];
+ EXPECT_TRUE(navigation_manager()->CanGoForward());
+ EXPECT_TRUE(navigation_manager()->CanGoToOffset(1));
+
+ [session_controller() goToEntry:session_controller().entries[1]];
+ EXPECT_TRUE(navigation_manager()->CanGoForward());
+ EXPECT_TRUE(navigation_manager()->CanGoToOffset(1));
+
+ [session_controller() goToEntry:session_controller().entries[2]];
+ EXPECT_FALSE(navigation_manager()->CanGoForward());
+ EXPECT_FALSE(navigation_manager()->CanGoToOffset(1));
+}
+
} // namespace web
« no previous file with comments | « ios/web/navigation/navigation_manager_impl.mm ('k') | ios/web/public/navigation_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698