OLD | NEW |
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 "chrome/browser/sessions/persistent_tab_restore_service.h" | 5 #include "chrome/browser/sessions/persistent_tab_restore_service.h" |
6 | 6 |
7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/sessions/session_service.h" | 10 #include "chrome/browser/sessions/session_service.h" |
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 } | 585 } |
586 | 586 |
587 TEST_F(PersistentTabRestoreServiceTest, PruneEntries) { | 587 TEST_F(PersistentTabRestoreServiceTest, PruneEntries) { |
588 service_->ClearEntries(); | 588 service_->ClearEntries(); |
589 ASSERT_TRUE(service_->entries().empty()); | 589 ASSERT_TRUE(service_->entries().empty()); |
590 | 590 |
591 const size_t max_entries = kMaxEntries; | 591 const size_t max_entries = kMaxEntries; |
592 for (size_t i = 0; i < max_entries + 5; i++) { | 592 for (size_t i = 0; i < max_entries + 5; i++) { |
593 TabNavigation navigation = | 593 TabNavigation navigation = |
594 SessionTypesTestHelper::CreateNavigation( | 594 SessionTypesTestHelper::CreateNavigation( |
595 StringPrintf("http://%d", static_cast<int>(i)), | 595 base::StringPrintf("http://%d", static_cast<int>(i)), |
596 StringPrintf("%d", static_cast<int>(i))); | 596 base::StringPrintf("%d", static_cast<int>(i))); |
597 | 597 |
598 Tab* tab = new Tab(); | 598 Tab* tab = new Tab(); |
599 tab->navigations.push_back(navigation); | 599 tab->navigations.push_back(navigation); |
600 tab->current_navigation_index = 0; | 600 tab->current_navigation_index = 0; |
601 | 601 |
602 mutable_entries()->push_back(tab); | 602 mutable_entries()->push_back(tab); |
603 } | 603 } |
604 | 604 |
605 // Only keep kMaxEntries around. | 605 // Only keep kMaxEntries around. |
606 EXPECT_EQ(max_entries + 5, service_->entries().size()); | 606 EXPECT_EQ(max_entries + 5, service_->entries().size()); |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 TEST_F(PersistentTabRestoreServiceTest, PruneIsCalled) { | 676 TEST_F(PersistentTabRestoreServiceTest, PruneIsCalled) { |
677 CreateSessionServiceWithOneWindow(false); | 677 CreateSessionServiceWithOneWindow(false); |
678 | 678 |
679 SessionServiceFactory::GetForProfile(profile())-> | 679 SessionServiceFactory::GetForProfile(profile())-> |
680 MoveCurrentSessionToLastSession(); | 680 MoveCurrentSessionToLastSession(); |
681 | 681 |
682 profile()->set_restored_last_session(true); | 682 profile()->set_restored_last_session(true); |
683 | 683 |
684 const size_t max_entries = kMaxEntries; | 684 const size_t max_entries = kMaxEntries; |
685 for (size_t i = 0; i < max_entries + 5; i++) { | 685 for (size_t i = 0; i < max_entries + 5; i++) { |
686 NavigateAndCommit(GURL(StringPrintf("http://%d", static_cast<int>(i)))); | 686 NavigateAndCommit( |
| 687 GURL(base::StringPrintf("http://%d", static_cast<int>(i)))); |
687 service_->CreateHistoricalTab(web_contents(), -1); | 688 service_->CreateHistoricalTab(web_contents(), -1); |
688 } | 689 } |
689 | 690 |
690 EXPECT_EQ(max_entries, service_->entries().size()); | 691 EXPECT_EQ(max_entries, service_->entries().size()); |
691 // This should not crash. | 692 // This should not crash. |
692 service_->LoadTabsFromLastSession(); | 693 service_->LoadTabsFromLastSession(); |
693 EXPECT_EQ(max_entries, service_->entries().size()); | 694 EXPECT_EQ(max_entries, service_->entries().size()); |
694 } | 695 } |
OLD | NEW |