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

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

Issue 308143004: Immediately SetTitle on a new NavigationEntry created via history.pushState (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | 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 4157 matching lines...) Expand 10 before | Expand all | Expand 10 after
4168 controller.ClearAllScreenshots(); 4168 controller.ClearAllScreenshots();
4169 EXPECT_EQ(0, screenshot_manager->GetScreenshotCount()); 4169 EXPECT_EQ(0, screenshot_manager->GetScreenshotCount());
4170 for (int i = 0; i < controller.GetEntryCount(); ++i) { 4170 for (int i = 0; i < controller.GetEntryCount(); ++i) {
4171 entry = NavigationEntryImpl::FromNavigationEntry( 4171 entry = NavigationEntryImpl::FromNavigationEntry(
4172 controller.GetEntryAtIndex(i)); 4172 controller.GetEntryAtIndex(i));
4173 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i 4173 EXPECT_FALSE(entry->screenshot().get()) << "Screenshot " << i
4174 << " not cleared"; 4174 << " not cleared";
4175 } 4175 }
4176 } 4176 }
4177 4177
4178 TEST_F(NavigationControllerTest, PushStateUpdatesTitle) {
4179
4180 // Navigate
4181 test_rvh()->SendNavigate(1, GURL("http://foo"));
4182
4183 // Set title
4184 base::string16 title(base::ASCIIToUTF16("Title"));
4185 controller().GetVisibleEntry()->SetTitle(title);
nasko 2014/05/30 19:04:55 GetLastCommittedEntry, since it should already be
Nate Chapin 2014/05/30 19:10:05 Done.
4186
4187 // history.pushState() is called.
4188 FrameHostMsg_DidCommitProvisionalLoad_Params params;
4189 params.page_id = 2;
4190 params.url = GURL("http://foo#foo");
4191 params.was_within_same_page = true;
4192 test_rvh()->SendNavigateWithParams(&params);
4193
4194 // The title should immediately be visible on the new NavigationEntry.
4195 EXPECT_EQ(title,
4196 controller().GetVisibleEntry()->GetTitleForDisplay(std::string()));
nasko 2014/05/30 19:04:55 ditto on GetLastCommittedEntry
Nate Chapin 2014/05/30 19:10:05 Done.
4197 }
4198
4178 // Test that the navigation controller clears its session history when a 4199 // Test that the navigation controller clears its session history when a
4179 // navigation commits with the clear history list flag set. 4200 // navigation commits with the clear history list flag set.
4180 TEST_F(NavigationControllerTest, ClearHistoryList) { 4201 TEST_F(NavigationControllerTest, ClearHistoryList) {
4181 const GURL url1("http://foo1"); 4202 const GURL url1("http://foo1");
4182 const GURL url2("http://foo2"); 4203 const GURL url2("http://foo2");
4183 const GURL url3("http://foo3"); 4204 const GURL url3("http://foo3");
4184 const GURL url4("http://foo4"); 4205 const GURL url4("http://foo4");
4185 4206
4186 NavigationControllerImpl& controller = controller_impl(); 4207 NavigationControllerImpl& controller = controller_impl();
4187 4208
(...skipping 30 matching lines...) Expand all
4218 EXPECT_EQ(1, controller.GetEntryCount()); 4239 EXPECT_EQ(1, controller.GetEntryCount());
4219 EXPECT_EQ(0, controller.GetCurrentEntryIndex()); 4240 EXPECT_EQ(0, controller.GetCurrentEntryIndex());
4220 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 4241 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
4221 EXPECT_EQ(-1, controller.GetPendingEntryIndex()); 4242 EXPECT_EQ(-1, controller.GetPendingEntryIndex());
4222 EXPECT_FALSE(controller.CanGoBack()); 4243 EXPECT_FALSE(controller.CanGoBack());
4223 EXPECT_FALSE(controller.CanGoForward()); 4244 EXPECT_FALSE(controller.CanGoForward());
4224 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL()); 4245 EXPECT_EQ(url4, controller.GetVisibleEntry()->GetURL());
4225 } 4246 }
4226 4247
4227 } // namespace content 4248 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698