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

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

Issue 19699007: Ensure we don't crash if user navigates back from NTP to Chrome sign-in page before it has fully lo… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add test coverage for removing a pending entry. Created 7 years, 5 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 #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 2383 matching lines...) Expand 10 before | Expand all | Expand 10 after
2394 url3, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 2394 url3, Referrer(), PAGE_TRANSITION_TYPED, std::string());
2395 test_rvh()->SendNavigate(2, url3); 2395 test_rvh()->SendNavigate(2, url3);
2396 controller.LoadURL( 2396 controller.LoadURL(
2397 url4, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 2397 url4, Referrer(), PAGE_TRANSITION_TYPED, std::string());
2398 test_rvh()->SendNavigate(3, url4); 2398 test_rvh()->SendNavigate(3, url4);
2399 controller.LoadURL( 2399 controller.LoadURL(
2400 url5, Referrer(), PAGE_TRANSITION_TYPED, std::string()); 2400 url5, Referrer(), PAGE_TRANSITION_TYPED, std::string());
2401 test_rvh()->SendNavigate(4, url5); 2401 test_rvh()->SendNavigate(4, url5);
2402 2402
2403 // Try to remove the last entry. Will fail because it is the current entry. 2403 // Try to remove the last entry. Will fail because it is the current entry.
2404 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); 2404 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
2405 EXPECT_EQ(5, controller.GetEntryCount()); 2405 EXPECT_EQ(5, controller.GetEntryCount());
2406 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex()); 2406 EXPECT_EQ(4, controller.GetLastCommittedEntryIndex());
2407 2407
2408 // Go back and remove the last entry. 2408 // Go back, but don't commit yet. Check that we can't delete the current
2409 // and pending entries.
2409 controller.GoBack(); 2410 controller.GoBack();
2411 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
2412 EXPECT_FALSE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 2));
2413
2414 // Now commit and delete the last entry.
2410 test_rvh()->SendNavigate(3, url4); 2415 test_rvh()->SendNavigate(3, url4);
2411 controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1); 2416 EXPECT_TRUE(controller.RemoveEntryAtIndex(controller.GetEntryCount() - 1));
2412 EXPECT_EQ(4, controller.GetEntryCount()); 2417 EXPECT_EQ(4, controller.GetEntryCount());
2413 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); 2418 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex());
2414 EXPECT_FALSE(controller.GetPendingEntry()); 2419 EXPECT_FALSE(controller.GetPendingEntry());
2415 2420
2416 // Remove an entry which is not the last committed one. 2421 // Remove an entry which is not the last committed one.
2417 controller.RemoveEntryAtIndex(0); 2422 EXPECT_TRUE(controller.RemoveEntryAtIndex(0));
2418 EXPECT_EQ(3, controller.GetEntryCount()); 2423 EXPECT_EQ(3, controller.GetEntryCount());
2419 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 2424 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
2420 EXPECT_FALSE(controller.GetPendingEntry()); 2425 EXPECT_FALSE(controller.GetPendingEntry());
2421 2426
2422 // Remove the 2 remaining entries. 2427 // Remove the 2 remaining entries.
2423 controller.RemoveEntryAtIndex(1); 2428 controller.RemoveEntryAtIndex(1);
2424 controller.RemoveEntryAtIndex(0); 2429 controller.RemoveEntryAtIndex(0);
2425 2430
2426 // This should leave us with only the last committed entry. 2431 // This should leave us with only the last committed entry.
2427 EXPECT_EQ(1, controller.GetEntryCount()); 2432 EXPECT_EQ(1, controller.GetEntryCount());
(...skipping 1446 matching lines...) Expand 10 before | Expand all | Expand 10 after
3874 PAGE_TRANSITION_LINK); 3879 PAGE_TRANSITION_LINK);
3875 session_helper_.AssertNavigationEquals(nav, 3880 session_helper_.AssertNavigationEquals(nav,
3876 windows_[0]->tabs[0]->navigations[0]); 3881 windows_[0]->tabs[0]->navigations[0]);
3877 nav.set_url(url2); 3882 nav.set_url(url2);
3878 session_helper_.AssertNavigationEquals(nav, 3883 session_helper_.AssertNavigationEquals(nav,
3879 windows_[0]->tabs[0]->navigations[1]); 3884 windows_[0]->tabs[0]->navigations[1]);
3880 } 3885 }
3881 */ 3886 */
3882 3887
3883 } // namespace content 3888 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698