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

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

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

Powered by Google App Engine
This is Rietveld 408576698