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

Side by Side Diff: ios/web/navigation/crw_session_controller_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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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/navigation/crw_session_controller.h" 5 #import "ios/web/navigation/crw_session_controller.h"
6 6
7 #import <Foundation/Foundation.h> 7 #import <Foundation/Foundation.h>
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 670 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 ASSERT_EQ(1, [session_controller_ currentNavigationIndex]); 681 ASSERT_EQ(1, [session_controller_ currentNavigationIndex]);
682 ASSERT_EQ(2, [session_controller_ previousNavigationIndex]); 682 ASSERT_EQ(2, [session_controller_ previousNavigationIndex]);
683 683
684 // Go forward 1 entry. 684 // Go forward 1 entry.
685 EXPECT_TRUE([session_controller_ canGoDelta:1]); 685 EXPECT_TRUE([session_controller_ canGoDelta:1]);
686 [session_controller_ goDelta:1]; 686 [session_controller_ goDelta:1];
687 ASSERT_EQ(2, [session_controller_ currentNavigationIndex]); 687 ASSERT_EQ(2, [session_controller_ currentNavigationIndex]);
688 ASSERT_EQ(1, [session_controller_ previousNavigationIndex]); 688 ASSERT_EQ(1, [session_controller_ previousNavigationIndex]);
689 } 689 }
690 690
691 TEST_F(CRWSessionControllerTest, CanGoBackWithoutCommitedEntry) {
692 EXPECT_FALSE([session_controller_ canGoBack]);
693 EXPECT_FALSE([session_controller_ canGoDelta:-1]);
694 }
695
696 // Tests that |canGoBack| returns NO if there is a transient entry, but no
697 // committed entries.
698 TEST_F(CRWSessionControllerTest, CanGoBackWithTransientEntry) {
699 [session_controller_ addTransientEntryWithURL:GURL("http://www.url.com")];
700
701 EXPECT_FALSE([session_controller_ canGoBack]);
702 }
703
704 // Tests that |canGoBack| returns YES if there is a transient entry and at least
705 // one committed entry.
706 TEST_F(CRWSessionControllerTest, CanGoBackWithTransientEntryAndCommittedEntry) {
707 [session_controller_ addPendingEntry:GURL("http://www.url.com")
708 referrer:MakeReferrer("http://www.referer.com")
709 transition:ui::PAGE_TRANSITION_TYPED
710 rendererInitiated:NO];
711 [session_controller_ commitPendingEntry];
712 [session_controller_ addTransientEntryWithURL:GURL("http://www.url.com")];
713
714 EXPECT_TRUE([session_controller_ canGoBack]);
715 }
716
717 TEST_F(CRWSessionControllerTest, CanGoBackWithSingleCommitedEntry) {
718 [session_controller_
719 addPendingEntry:GURL("http://www.url.com")
720 referrer:MakeReferrer("http://www.referer.com")
721 transition:ui::PAGE_TRANSITION_TYPED
722 rendererInitiated:NO];
723 [session_controller_ commitPendingEntry];
724
725 EXPECT_FALSE([session_controller_ canGoBack]);
726 EXPECT_FALSE([session_controller_ canGoDelta:-1]);
727 }
728
729 TEST_F(CRWSessionControllerTest, CanGoForwardWithoutCommitedEntry) {
730 EXPECT_FALSE([session_controller_ canGoForward]);
731 EXPECT_FALSE([session_controller_ canGoDelta:1]);
732 }
733
734 TEST_F(CRWSessionControllerTest, CanGoForwardWithSingleCommitedEntry) {
735 [session_controller_
736 addPendingEntry:GURL("http://www.url.com")
737 referrer:MakeReferrer("http://www.referer.com")
738 transition:ui::PAGE_TRANSITION_TYPED
739 rendererInitiated:NO];
740 [session_controller_ commitPendingEntry];
741
742 EXPECT_FALSE([session_controller_ canGoForward]);
743 EXPECT_FALSE([session_controller_ canGoDelta:1]);
744 }
745
746 // Helper to create a NavigationItem. Caller is responsible for freeing 691 // Helper to create a NavigationItem. Caller is responsible for freeing
747 // the memory. 692 // the memory.
748 web::NavigationItem* CreateNavigationItem(const std::string& url, 693 web::NavigationItem* CreateNavigationItem(const std::string& url,
749 const std::string& referrer, 694 const std::string& referrer,
750 NSString* title) { 695 NSString* title) {
751 web::Referrer referrer_object(GURL(referrer), 696 web::Referrer referrer_object(GURL(referrer),
752 web::ReferrerPolicyDefault); 697 web::ReferrerPolicyDefault);
753 web::NavigationItemImpl* navigation_item = new web::NavigationItemImpl(); 698 web::NavigationItemImpl* navigation_item = new web::NavigationItemImpl();
754 navigation_item->SetURL(GURL(url)); 699 navigation_item->SetURL(GURL(url));
755 navigation_item->SetReferrer(referrer_object); 700 navigation_item->SetReferrer(referrer_object);
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
1217 1162
1218 [session_controller_ setPendingEntryIndex:0]; 1163 [session_controller_ setPendingEntryIndex:0];
1219 1164
1220 web::NavigationItem* visible_item = 1165 web::NavigationItem* visible_item =
1221 [[session_controller_ visibleEntry] navigationItem]; 1166 [[session_controller_ visibleEntry] navigationItem];
1222 ASSERT_TRUE(visible_item); 1167 ASSERT_TRUE(visible_item);
1223 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec()); 1168 EXPECT_EQ("http://www.example.com/0", visible_item->GetURL().spec());
1224 } 1169 }
1225 1170
1226 } // anonymous namespace 1171 } // anonymous namespace
OLDNEW
« no previous file with comments | « ios/web/navigation/crw_session_controller.mm ('k') | ios/web/navigation/navigation_manager_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698