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

Side by Side Diff: chrome/browser/sessions/persistent_tab_restore_service_browsertest.cc

Issue 58903004: InstantExtended: update tests for Instant Extended (part 2). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 1 month 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 (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"
11 #include "base/threading/sequenced_worker_pool.h" 11 #include "base/threading/sequenced_worker_pool.h"
12 #include "chrome/browser/chrome_notification_types.h" 12 #include "chrome/browser/chrome_notification_types.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/search/search.h"
15 #include "chrome/browser/sessions/session_service.h" 14 #include "chrome/browser/sessions/session_service.h"
16 #include "chrome/browser/sessions/session_service_factory.h" 15 #include "chrome/browser/sessions/session_service_factory.h"
17 #include "chrome/browser/sessions/session_types.h" 16 #include "chrome/browser/sessions/session_types.h"
18 #include "chrome/browser/sessions/tab_restore_service_factory.h" 17 #include "chrome/browser/sessions/tab_restore_service_factory.h"
19 #include "chrome/browser/sessions/tab_restore_service_observer.h" 18 #include "chrome/browser/sessions/tab_restore_service_observer.h"
20 #include "chrome/browser/ui/browser_window.h" 19 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/common/url_constants.h" 20 #include "chrome/common/url_constants.h"
22 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 21 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
23 #include "chrome/test/base/chrome_render_view_test.h" 22 #include "chrome/test/base/chrome_render_view_test.h"
24 #include "chrome/test/base/in_process_browser_test.h" 23 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 728
730 // Don't prune pinned NTPs. 729 // Don't prune pinned NTPs.
731 tab = new Tab(); 730 tab = new Tab();
732 tab->pinned = true; 731 tab->pinned = true;
733 tab->current_navigation_index = 0; 732 tab->current_navigation_index = 0;
734 tab->navigations.push_back(navigation); 733 tab->navigations.push_back(navigation);
735 mutable_entries()->push_front(tab); 734 mutable_entries()->push_front(tab);
736 EXPECT_EQ(max_entries + 1, service_->entries().size()); 735 EXPECT_EQ(max_entries + 1, service_->entries().size());
737 PruneEntries(); 736 PruneEntries();
738 EXPECT_EQ(max_entries, service_->entries().size()); 737 EXPECT_EQ(max_entries, service_->entries().size());
739 EXPECT_TRUE(chrome::IsNTPURL( 738 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
740 static_cast<Tab*>(service_->entries().front())-> 739 static_cast<Tab*>(service_->entries().front())->
741 navigations[0].virtual_url(), profile())); 740 navigations[0].virtual_url());
742 741
743 // Don't prune NTPs that have multiple navigations. 742 // Don't prune NTPs that have multiple navigations.
744 // (Erase the last NTP first.) 743 // (Erase the last NTP first.)
745 delete service_->entries().front(); 744 delete service_->entries().front();
746 mutable_entries()->erase(mutable_entries()->begin()); 745 mutable_entries()->erase(mutable_entries()->begin());
747 tab = new Tab(); 746 tab = new Tab();
748 tab->current_navigation_index = 1; 747 tab->current_navigation_index = 1;
749 tab->navigations.push_back(navigation); 748 tab->navigations.push_back(navigation);
750 tab->navigations.push_back(navigation); 749 tab->navigations.push_back(navigation);
751 mutable_entries()->push_front(tab); 750 mutable_entries()->push_front(tab);
752 EXPECT_EQ(max_entries, service_->entries().size()); 751 EXPECT_EQ(max_entries, service_->entries().size());
753 PruneEntries(); 752 PruneEntries();
754 EXPECT_EQ(max_entries, service_->entries().size()); 753 EXPECT_EQ(max_entries, service_->entries().size());
755 EXPECT_TRUE(chrome::IsNTPURL( 754 EXPECT_EQ(GURL(chrome::kChromeUINewTabURL),
756 static_cast<Tab*>(service_->entries().front())-> 755 static_cast<Tab*>(service_->entries().front())->
757 navigations[1].virtual_url(), profile())); 756 navigations[1].virtual_url());
758 } 757 }
759 758
760 // Regression test for crbug.com/106082 759 // Regression test for crbug.com/106082
761 TEST_F(PersistentTabRestoreServiceTest, PruneIsCalled) { 760 TEST_F(PersistentTabRestoreServiceTest, PruneIsCalled) {
762 CreateSessionServiceWithOneWindow(false); 761 CreateSessionServiceWithOneWindow(false);
763 762
764 SessionServiceFactory::GetForProfile(profile())-> 763 SessionServiceFactory::GetForProfile(profile())->
765 MoveCurrentSessionToLastSession(); 764 MoveCurrentSessionToLastSession();
766 765
767 profile()->set_restored_last_session(true); 766 profile()->set_restored_last_session(true);
(...skipping 23 matching lines...) Expand all
791 790
792 EXPECT_FALSE(service_->IsLoaded()); 791 EXPECT_FALSE(service_->IsLoaded());
793 TestTabRestoreServiceObserver observer; 792 TestTabRestoreServiceObserver observer;
794 service_->AddObserver(&observer); 793 service_->AddObserver(&observer);
795 EXPECT_EQ(max_entries, service_->entries().size()); 794 EXPECT_EQ(max_entries, service_->entries().size());
796 SynchronousLoadTabsFromLastSession(); 795 SynchronousLoadTabsFromLastSession();
797 EXPECT_TRUE(observer.got_loaded()); 796 EXPECT_TRUE(observer.got_loaded());
798 EXPECT_TRUE(service_->IsLoaded()); 797 EXPECT_TRUE(service_->IsLoaded());
799 service_->RemoveObserver(&observer); 798 service_->RemoveObserver(&observer);
800 } 799 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698