| 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/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 | 729 |
| 730 // Don't prune pinned NTPs. | 730 // Don't prune pinned NTPs. |
| 731 tab = new Tab(); | 731 tab = new Tab(); |
| 732 tab->pinned = true; | 732 tab->pinned = true; |
| 733 tab->current_navigation_index = 0; | 733 tab->current_navigation_index = 0; |
| 734 tab->navigations.push_back(navigation); | 734 tab->navigations.push_back(navigation); |
| 735 mutable_entries()->push_front(tab); | 735 mutable_entries()->push_front(tab); |
| 736 EXPECT_EQ(max_entries + 1, service_->entries().size()); | 736 EXPECT_EQ(max_entries + 1, service_->entries().size()); |
| 737 PruneEntries(); | 737 PruneEntries(); |
| 738 EXPECT_EQ(max_entries, service_->entries().size()); | 738 EXPECT_EQ(max_entries, service_->entries().size()); |
| 739 EXPECT_TRUE(chrome::IsNTPURL( | 739 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 740 static_cast<Tab*>(service_->entries().front())-> | 740 static_cast<Tab*>(service_->entries().front())-> |
| 741 navigations[0].virtual_url(), profile())); | 741 navigations[0].virtual_url()); |
| 742 | 742 |
| 743 // Don't prune NTPs that have multiple navigations. | 743 // Don't prune NTPs that have multiple navigations. |
| 744 // (Erase the last NTP first.) | 744 // (Erase the last NTP first.) |
| 745 delete service_->entries().front(); | 745 delete service_->entries().front(); |
| 746 mutable_entries()->erase(mutable_entries()->begin()); | 746 mutable_entries()->erase(mutable_entries()->begin()); |
| 747 tab = new Tab(); | 747 tab = new Tab(); |
| 748 tab->current_navigation_index = 1; | 748 tab->current_navigation_index = 1; |
| 749 tab->navigations.push_back(navigation); | 749 tab->navigations.push_back(navigation); |
| 750 tab->navigations.push_back(navigation); | 750 tab->navigations.push_back(navigation); |
| 751 mutable_entries()->push_front(tab); | 751 mutable_entries()->push_front(tab); |
| 752 EXPECT_EQ(max_entries, service_->entries().size()); | 752 EXPECT_EQ(max_entries, service_->entries().size()); |
| 753 PruneEntries(); | 753 PruneEntries(); |
| 754 EXPECT_EQ(max_entries, service_->entries().size()); | 754 EXPECT_EQ(max_entries, service_->entries().size()); |
| 755 EXPECT_TRUE(chrome::IsNTPURL( | 755 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL), |
| 756 static_cast<Tab*>(service_->entries().front())-> | 756 static_cast<Tab*>(service_->entries().front())-> |
| 757 navigations[1].virtual_url(), profile())); | 757 navigations[1].virtual_url()); |
| 758 } | 758 } |
| 759 | 759 |
| 760 // Regression test for crbug.com/106082 | 760 // Regression test for crbug.com/106082 |
| 761 TEST_F(PersistentTabRestoreServiceTest, PruneIsCalled) { | 761 TEST_F(PersistentTabRestoreServiceTest, PruneIsCalled) { |
| 762 CreateSessionServiceWithOneWindow(false); | 762 CreateSessionServiceWithOneWindow(false); |
| 763 | 763 |
| 764 SessionServiceFactory::GetForProfile(profile())-> | 764 SessionServiceFactory::GetForProfile(profile())-> |
| 765 MoveCurrentSessionToLastSession(); | 765 MoveCurrentSessionToLastSession(); |
| 766 | 766 |
| 767 profile()->set_restored_last_session(true); | 767 profile()->set_restored_last_session(true); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 791 | 791 |
| 792 EXPECT_FALSE(service_->IsLoaded()); | 792 EXPECT_FALSE(service_->IsLoaded()); |
| 793 TestTabRestoreServiceObserver observer; | 793 TestTabRestoreServiceObserver observer; |
| 794 service_->AddObserver(&observer); | 794 service_->AddObserver(&observer); |
| 795 EXPECT_EQ(max_entries, service_->entries().size()); | 795 EXPECT_EQ(max_entries, service_->entries().size()); |
| 796 SynchronousLoadTabsFromLastSession(); | 796 SynchronousLoadTabsFromLastSession(); |
| 797 EXPECT_TRUE(observer.got_loaded()); | 797 EXPECT_TRUE(observer.got_loaded()); |
| 798 EXPECT_TRUE(service_->IsLoaded()); | 798 EXPECT_TRUE(service_->IsLoaded()); |
| 799 service_->RemoveObserver(&observer); | 799 service_->RemoveObserver(&observer); |
| 800 } | 800 } |
| OLD | NEW |