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

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

Issue 636673002: Remove navigation from TestRenderViewHost (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes from self-review Created 6 years, 2 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 unified diff | Download patch
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/files/file_util.h" 7 #include "base/files/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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
819 TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) { 819 TEST_F(NavigationControllerTest, LoadURL_PrivilegedPending) {
820 NavigationControllerImpl& controller = controller_impl(); 820 NavigationControllerImpl& controller = controller_impl();
821 TestNotificationTracker notifications; 821 TestNotificationTracker notifications;
822 RegisterForAllNavNotifications(&notifications, &controller); 822 RegisterForAllNavNotifications(&notifications, &controller);
823 823
824 // First make some history, starting with a privileged URL. 824 // First make some history, starting with a privileged URL.
825 const GURL kExistingURL1("http://privileged"); 825 const GURL kExistingURL1("http://privileged");
826 controller.LoadURL( 826 controller.LoadURL(
827 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 827 kExistingURL1, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
828 // Pretend it has bindings so we can tell if we incorrectly copy it. 828 // Pretend it has bindings so we can tell if we incorrectly copy it.
829 test_rvh()->AllowBindings(2); 829 main_test_rfh()->GetRenderViewHost()->AllowBindings(2);
830 main_test_rfh()->SendNavigate(0, kExistingURL1); 830 main_test_rfh()->SendNavigate(0, kExistingURL1);
831 EXPECT_EQ(1U, navigation_entry_committed_counter_); 831 EXPECT_EQ(1U, navigation_entry_committed_counter_);
832 navigation_entry_committed_counter_ = 0; 832 navigation_entry_committed_counter_ = 0;
833 833
834 // Navigate cross-process to a second URL. 834 // Navigate cross-process to a second URL.
835 const GURL kExistingURL2("http://foo/eh"); 835 const GURL kExistingURL2("http://foo/eh");
836 controller.LoadURL( 836 controller.LoadURL(
837 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string()); 837 kExistingURL2, Referrer(), ui::PAGE_TRANSITION_TYPED, std::string());
838 main_test_rfh()->SendBeforeUnloadACK(true); 838 main_test_rfh()->SendBeforeUnloadACK(true);
839 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame(); 839 TestRenderFrameHost* foo_rfh = contents()->GetPendingMainFrame();
(...skipping 3399 matching lines...) Expand 10 before | Expand all | Expand 10 after
4239 for (int i = 0; i < controller.GetEntryCount(); ++i) { 4239 for (int i = 0; i < controller.GetEntryCount(); ++i) {
4240 entry = NavigationEntryImpl::FromNavigationEntry( 4240 entry = NavigationEntryImpl::FromNavigationEntry(
4241 controller.GetEntryAtIndex(i)); 4241 controller.GetEntryAtIndex(i));
4242 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i 4242 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i
4243 << " not cleared"; 4243 << " not cleared";
4244 } 4244 }
4245 } 4245 }
4246 4246
4247 TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) { 4247 TEST_F(NavigationControllerTest, PushStateUpdatesTitleAndFavicon) {
4248 // Navigate. 4248 // Navigate.
4249 test_rvh()->SendNavigate(1, GURL("http://foo")); 4249 contents()->GetMainFrame()->SendNavigate(1, GURL("http://foo"));
Charlie Reis 2014/10/08 17:41:55 Again, why choose this over main_rfh() in some pla
ncarter (slow) 2014/10/08 22:39:28 Discussed in previous comment.
4250 4250
4251 // Set title and favicon. 4251 // Set title and favicon.
4252 base::string16 title(base::ASCIIToUTF16("Title")); 4252 base::string16 title(base::ASCIIToUTF16("Title"));
4253 FaviconStatus favicon; 4253 FaviconStatus favicon;
4254 favicon.valid = true; 4254 favicon.valid = true;
4255 favicon.url = GURL("http://foo/favicon.ico"); 4255 favicon.url = GURL("http://foo/favicon.ico");
4256 controller().GetLastCommittedEntry()->SetTitle(title); 4256 controller().GetLastCommittedEntry()->SetTitle(title);
4257 controller().GetLastCommittedEntry()->GetFavicon() = favicon; 4257 controller().GetLastCommittedEntry()->GetFavicon() = favicon;
4258 4258
4259 // history.pushState() is called. 4259 // history.pushState() is called.
4260 FrameHostMsg_DidCommitProvisionalLoad_Params params; 4260 FrameHostMsg_DidCommitProvisionalLoad_Params params;
4261 GURL url("http://foo#foo"); 4261 GURL url("http://foo#foo");
4262 params.page_id = 2; 4262 params.page_id = 2;
4263 params.url = url; 4263 params.url = url;
4264 params.page_state = PageState::CreateFromURL(url); 4264 params.page_state = PageState::CreateFromURL(url);
4265 params.was_within_same_page = true; 4265 params.was_within_same_page = true;
4266 test_rvh()->SendNavigateWithParams(&params); 4266 contents()->GetMainFrame()->SendNavigateWithParams(&params);
4267 4267
4268 // The title should immediately be visible on the new NavigationEntry. 4268 // The title should immediately be visible on the new NavigationEntry.
4269 base::string16 new_title = 4269 base::string16 new_title =
4270 controller().GetLastCommittedEntry()->GetTitleForDisplay(std::string()); 4270 controller().GetLastCommittedEntry()->GetTitleForDisplay(std::string());
4271 EXPECT_EQ(title, new_title); 4271 EXPECT_EQ(title, new_title);
4272 FaviconStatus new_favicon = 4272 FaviconStatus new_favicon =
4273 controller().GetLastCommittedEntry()->GetFavicon(); 4273 controller().GetLastCommittedEntry()->GetFavicon();
4274 EXPECT_EQ(favicon.valid, new_favicon.valid); 4274 EXPECT_EQ(favicon.valid, new_favicon.valid);
4275 EXPECT_EQ(favicon.url, new_favicon.url); 4275 EXPECT_EQ(favicon.url, new_favicon.url);
4276 } 4276 }
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
4354 params.post_id = -1; 4354 params.post_id = -1;
4355 test_rvh()->SendNavigateWithParams(&params); 4355 test_rvh()->SendNavigateWithParams(&params);
4356 4356
4357 // Now reload. replaceState overrides the POST, so we should not show a 4357 // Now reload. replaceState overrides the POST, so we should not show a
4358 // repost warning dialog. 4358 // repost warning dialog.
4359 controller_impl().Reload(true); 4359 controller_impl().Reload(true);
4360 EXPECT_EQ(0, delegate->repost_form_warning_count()); 4360 EXPECT_EQ(0, delegate->repost_form_warning_count());
4361 } 4361 }
4362 4362
4363 } // namespace content 4363 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698