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

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 102593002: Convert string16 to base::string16 in content. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/bind.h" 6 #include "base/bind.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/stl_util.h" 10 #include "base/stl_util.h"
(...skipping 903 matching lines...) Expand 10 before | Expand all | Expand 10 after
914 EXPECT_TRUE(controller.GetPendingEntry()); 914 EXPECT_TRUE(controller.GetPendingEntry());
915 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); 915 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex());
916 EXPECT_EQ(1, delegate->navigation_state_change_count()); 916 EXPECT_EQ(1, delegate->navigation_state_change_count());
917 917
918 // It may abort before committing, if it's a download or due to a stop or 918 // It may abort before committing, if it's a download or due to a stop or
919 // a new navigation from the user. 919 // a new navigation from the user.
920 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; 920 ViewHostMsg_DidFailProvisionalLoadWithError_Params params;
921 params.frame_id = 1; 921 params.frame_id = 1;
922 params.is_main_frame = true; 922 params.is_main_frame = true;
923 params.error_code = net::ERR_ABORTED; 923 params.error_code = net::ERR_ABORTED;
924 params.error_description = string16(); 924 params.error_description = base::string16();
925 params.url = kNewURL; 925 params.url = kNewURL;
926 params.showing_repost_interstitial = false; 926 params.showing_repost_interstitial = false;
927 test_rvh()->OnMessageReceived( 927 test_rvh()->OnMessageReceived(
928 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id 928 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
929 params)); 929 params));
930 930
931 // This should not clear the pending entry or notify of a navigation state 931 // This should not clear the pending entry or notify of a navigation state
932 // change, so that we keep displaying kNewURL (until the user clears it). 932 // change, so that we keep displaying kNewURL (until the user clears it).
933 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 933 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
934 EXPECT_TRUE(controller.GetPendingEntry()); 934 EXPECT_TRUE(controller.GetPendingEntry());
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 // We don't want to change the NavigationEntry's url, in case it cancels. 992 // We don't want to change the NavigationEntry's url, in case it cancels.
993 // Prevents regression of http://crbug.com/77786. 993 // Prevents regression of http://crbug.com/77786.
994 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL()); 994 EXPECT_EQ(kNewURL, controller.GetPendingEntry()->GetURL());
995 995
996 // It may abort before committing, if it's a download or due to a stop or 996 // It may abort before committing, if it's a download or due to a stop or
997 // a new navigation from the user. 997 // a new navigation from the user.
998 ViewHostMsg_DidFailProvisionalLoadWithError_Params params; 998 ViewHostMsg_DidFailProvisionalLoadWithError_Params params;
999 params.frame_id = 1; 999 params.frame_id = 1;
1000 params.is_main_frame = true; 1000 params.is_main_frame = true;
1001 params.error_code = net::ERR_ABORTED; 1001 params.error_code = net::ERR_ABORTED;
1002 params.error_description = string16(); 1002 params.error_description = base::string16();
1003 params.url = kRedirectURL; 1003 params.url = kRedirectURL;
1004 params.showing_repost_interstitial = false; 1004 params.showing_repost_interstitial = false;
1005 test_rvh()->OnMessageReceived( 1005 test_rvh()->OnMessageReceived(
1006 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id 1006 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
1007 params)); 1007 params));
1008 1008
1009 // Because the pending entry is renderer initiated and not visible, we 1009 // Because the pending entry is renderer initiated and not visible, we
1010 // clear it when it fails. 1010 // clear it when it fails.
1011 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 1011 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
1012 EXPECT_FALSE(controller.GetPendingEntry()); 1012 EXPECT_FALSE(controller.GetPendingEntry());
(...skipping 1322 matching lines...) Expand 10 before | Expand all | Expand 10 after
2335 our_controller.GetEntryAtIndex(0))->site_instance()); 2335 our_controller.GetEntryAtIndex(0))->site_instance());
2336 2336
2337 // This pending navigation may have caused a different navigation to fail, 2337 // This pending navigation may have caused a different navigation to fail,
2338 // which causes the pending entry to be cleared. 2338 // which causes the pending entry to be cleared.
2339 TestRenderViewHost* rvh = 2339 TestRenderViewHost* rvh =
2340 static_cast<TestRenderViewHost*>(our_contents->GetRenderViewHost()); 2340 static_cast<TestRenderViewHost*>(our_contents->GetRenderViewHost());
2341 ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params; 2341 ViewHostMsg_DidFailProvisionalLoadWithError_Params fail_load_params;
2342 fail_load_params.frame_id = 1; 2342 fail_load_params.frame_id = 1;
2343 fail_load_params.is_main_frame = true; 2343 fail_load_params.is_main_frame = true;
2344 fail_load_params.error_code = net::ERR_ABORTED; 2344 fail_load_params.error_code = net::ERR_ABORTED;
2345 fail_load_params.error_description = string16(); 2345 fail_load_params.error_description = base::string16();
2346 fail_load_params.url = url; 2346 fail_load_params.url = url;
2347 fail_load_params.showing_repost_interstitial = false; 2347 fail_load_params.showing_repost_interstitial = false;
2348 rvh->OnMessageReceived( 2348 rvh->OnMessageReceived(
2349 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id 2349 ViewHostMsg_DidFailProvisionalLoadWithError(0, // routing_id
2350 fail_load_params)); 2350 fail_load_params));
2351 2351
2352 // Now the pending restored entry commits. 2352 // Now the pending restored entry commits.
2353 ViewHostMsg_FrameNavigate_Params params; 2353 ViewHostMsg_FrameNavigate_Params params;
2354 params.page_id = 0; 2354 params.page_id = 0;
2355 params.url = url; 2355 params.url = url;
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 EXPECT_EQ(controller.GetEntryCount(), 1); 2890 EXPECT_EQ(controller.GetEntryCount(), 1);
2891 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); 2891 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0);
2892 } 2892 }
2893 2893
2894 // Make sure that on cloning a WebContentsImpl and going back needs_reload is 2894 // Make sure that on cloning a WebContentsImpl and going back needs_reload is
2895 // false. 2895 // false.
2896 TEST_F(NavigationControllerTest, CloneAndGoBack) { 2896 TEST_F(NavigationControllerTest, CloneAndGoBack) {
2897 NavigationControllerImpl& controller = controller_impl(); 2897 NavigationControllerImpl& controller = controller_impl();
2898 const GURL url1("http://foo1"); 2898 const GURL url1("http://foo1");
2899 const GURL url2("http://foo2"); 2899 const GURL url2("http://foo2");
2900 const string16 title(ASCIIToUTF16("Title")); 2900 const base::string16 title(ASCIIToUTF16("Title"));
2901 2901
2902 NavigateAndCommit(url1); 2902 NavigateAndCommit(url1);
2903 controller.GetVisibleEntry()->SetTitle(title); 2903 controller.GetVisibleEntry()->SetTitle(title);
2904 NavigateAndCommit(url2); 2904 NavigateAndCommit(url2);
2905 2905
2906 scoped_ptr<WebContents> clone(controller.GetWebContents()->Clone()); 2906 scoped_ptr<WebContents> clone(controller.GetWebContents()->Clone());
2907 2907
2908 ASSERT_EQ(2, clone->GetController().GetEntryCount()); 2908 ASSERT_EQ(2, clone->GetController().GetEntryCount());
2909 EXPECT_TRUE(clone->GetController().NeedsReload()); 2909 EXPECT_TRUE(clone->GetController().NeedsReload());
2910 clone->GetController().GoBack(); 2910 clone->GetController().GoBack();
2911 // Navigating back should have triggered needs_reload_ to go false. 2911 // Navigating back should have triggered needs_reload_ to go false.
2912 EXPECT_FALSE(clone->GetController().NeedsReload()); 2912 EXPECT_FALSE(clone->GetController().NeedsReload());
2913 2913
2914 // Ensure that the pending URL and its title are visible. 2914 // Ensure that the pending URL and its title are visible.
2915 EXPECT_EQ(url1, clone->GetController().GetVisibleEntry()->GetURL()); 2915 EXPECT_EQ(url1, clone->GetController().GetVisibleEntry()->GetURL());
2916 EXPECT_EQ(title, clone->GetTitle()); 2916 EXPECT_EQ(title, clone->GetTitle());
2917 } 2917 }
2918 2918
2919 // Make sure that reloading a cloned tab doesn't change its pending entry index. 2919 // Make sure that reloading a cloned tab doesn't change its pending entry index.
2920 // See http://crbug.com/234491. 2920 // See http://crbug.com/234491.
2921 TEST_F(NavigationControllerTest, CloneAndReload) { 2921 TEST_F(NavigationControllerTest, CloneAndReload) {
2922 NavigationControllerImpl& controller = controller_impl(); 2922 NavigationControllerImpl& controller = controller_impl();
2923 const GURL url1("http://foo1"); 2923 const GURL url1("http://foo1");
2924 const GURL url2("http://foo2"); 2924 const GURL url2("http://foo2");
2925 const string16 title(ASCIIToUTF16("Title")); 2925 const base::string16 title(ASCIIToUTF16("Title"));
2926 2926
2927 NavigateAndCommit(url1); 2927 NavigateAndCommit(url1);
2928 controller.GetVisibleEntry()->SetTitle(title); 2928 controller.GetVisibleEntry()->SetTitle(title);
2929 NavigateAndCommit(url2); 2929 NavigateAndCommit(url2);
2930 2930
2931 scoped_ptr<WebContents> clone(controller.GetWebContents()->Clone()); 2931 scoped_ptr<WebContents> clone(controller.GetWebContents()->Clone());
2932 clone->GetController().LoadIfNecessary(); 2932 clone->GetController().LoadIfNecessary();
2933 2933
2934 ASSERT_EQ(2, clone->GetController().GetEntryCount()); 2934 ASSERT_EQ(2, clone->GetController().GetEntryCount());
2935 EXPECT_EQ(1, clone->GetController().GetPendingEntryIndex()); 2935 EXPECT_EQ(1, clone->GetController().GetPendingEntryIndex());
(...skipping 899 matching lines...) Expand 10 before | Expand all | Expand 10 after
3835 EXPECT_EQ(1, controller.GetEntryCount()); 3835 EXPECT_EQ(1, controller.GetEntryCount());
3836 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 3836 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
3837 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 3837 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
3838 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 3838 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
3839 EXPECT_FALSE(controller.CanGoBack()); 3839 EXPECT_FALSE(controller.CanGoBack());
3840 EXPECT_FALSE(controller.CanGoForward()); 3840 EXPECT_FALSE(controller.CanGoForward());
3841 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); 3841 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
3842 } 3842 }
3843 3843
3844 } // namespace content 3844 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_controller_impl.cc ('k') | content/browser/frame_host/navigation_entry_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698