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

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

Issue 2248873002: Convert WindowOpenDisposition to an enum class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/base_switches.h" 9 #include "base/base_switches.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 WaitForTabsToLoad(new_browser); 155 WaitForTabsToLoad(new_browser);
156 156
157 keep_alive.reset(); 157 keep_alive.reset();
158 158
159 return new_browser; 159 return new_browser;
160 } 160 }
161 161
162 void GoBack(Browser* browser) { 162 void GoBack(Browser* browser) {
163 content::TestNavigationObserver observer( 163 content::TestNavigationObserver observer(
164 browser->tab_strip_model()->GetActiveWebContents()); 164 browser->tab_strip_model()->GetActiveWebContents());
165 chrome::GoBack(browser, CURRENT_TAB); 165 chrome::GoBack(browser, WindowOpenDisposition::CURRENT_TAB);
166 observer.Wait(); 166 observer.Wait();
167 } 167 }
168 168
169 void GoForward(Browser* browser) { 169 void GoForward(Browser* browser) {
170 content::TestNavigationObserver observer( 170 content::TestNavigationObserver observer(
171 browser->tab_strip_model()->GetActiveWebContents()); 171 browser->tab_strip_model()->GetActiveWebContents());
172 chrome::GoForward(browser, CURRENT_TAB); 172 chrome::GoForward(browser, WindowOpenDisposition::CURRENT_TAB);
173 observer.Wait(); 173 observer.Wait();
174 } 174 }
175 175
176 void AssertOneWindowWithOneTab(Browser* browser) { 176 void AssertOneWindowWithOneTab(Browser* browser) {
177 ASSERT_EQ(1u, active_browser_list_->size()); 177 ASSERT_EQ(1u, active_browser_list_->size());
178 ASSERT_EQ(1, browser->tab_strip_model()->count()); 178 ASSERT_EQ(1, browser->tab_strip_model()->count());
179 } 179 }
180 180
181 int RenderProcessHostCount() { 181 int RenderProcessHostCount() {
182 content::RenderProcessHost::iterator hosts = 182 content::RenderProcessHost::iterator hosts =
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 "http://google.com/4", 266 "http://google.com/4",
267 "http://google.com/5", 267 "http://google.com/5",
268 "http://google.com/6"}; 268 "http://google.com/6"};
269 269
270 // Verifies that restored tabs have a root window. This is important 270 // Verifies that restored tabs have a root window. This is important
271 // otherwise the wrong information is communicated to the renderer. 271 // otherwise the wrong information is communicated to the renderer.
272 // (http://crbug.com/342672). 272 // (http://crbug.com/342672).
273 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoredTabsShouldHaveWindow) { 273 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoredTabsShouldHaveWindow) {
274 // Create tabs. 274 // Create tabs.
275 ui_test_utils::NavigateToURLWithDisposition( 275 ui_test_utils::NavigateToURLWithDisposition(
276 browser(), 276 browser(), GURL(url::kAboutBlankURL),
277 GURL(url::kAboutBlankURL), 277 WindowOpenDisposition::NEW_FOREGROUND_TAB,
278 NEW_FOREGROUND_TAB,
279 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 278 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
280 ui_test_utils::NavigateToURLWithDisposition( 279 ui_test_utils::NavigateToURLWithDisposition(
281 browser(), 280 browser(), GURL(url::kAboutBlankURL),
282 GURL(url::kAboutBlankURL), 281 WindowOpenDisposition::NEW_BACKGROUND_TAB,
283 NEW_BACKGROUND_TAB,
284 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 282 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
285 283
286 // Restart and session restore the tabs. 284 // Restart and session restore the tabs.
287 Browser* restored = QuitBrowserAndRestore(browser(), 3); 285 Browser* restored = QuitBrowserAndRestore(browser(), 3);
288 TabStripModel* tab_strip_model = restored->tab_strip_model(); 286 TabStripModel* tab_strip_model = restored->tab_strip_model();
289 const int tabs = tab_strip_model->count(); 287 const int tabs = tab_strip_model->count();
290 ASSERT_EQ(3, tabs); 288 ASSERT_EQ(3, tabs);
291 289
292 // Check the restored tabs have a window to get screen info from. 290 // Check the restored tabs have a window to get screen info from.
293 // On Aura it should also have a root window. 291 // On Aura it should also have a root window.
294 for (int i = 0; i < tabs; ++i) { 292 for (int i = 0; i < tabs; ++i) {
295 content::WebContents* contents = tab_strip_model->GetWebContentsAt(i); 293 content::WebContents* contents = tab_strip_model->GetWebContentsAt(i);
296 EXPECT_TRUE(contents->GetTopLevelNativeWindow()); 294 EXPECT_TRUE(contents->GetTopLevelNativeWindow());
297 #if defined(USE_AURA) 295 #if defined(USE_AURA)
298 EXPECT_TRUE(contents->GetNativeView()->GetRootWindow()); 296 EXPECT_TRUE(contents->GetNativeView()->GetRootWindow());
299 #endif 297 #endif
300 } 298 }
301 } 299 }
302 300
303 // Verify that restored tabs have correct disposition. Only one tab should 301 // Verify that restored tabs have correct disposition. Only one tab should
304 // have "visible" visibility state, the rest should not. 302 // have "visible" visibility state, the rest should not.
305 // (http://crbug.com/155365 http://crbug.com/118269) 303 // (http://crbug.com/155365 http://crbug.com/118269)
306 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, 304 IN_PROC_BROWSER_TEST_F(SessionRestoreTest,
307 RestoredTabsHaveCorrectVisibilityState) { 305 RestoredTabsHaveCorrectVisibilityState) {
308 // Create tabs. 306 // Create tabs.
309 GURL test_page(ui_test_utils::GetTestUrl(base::FilePath(), 307 GURL test_page(ui_test_utils::GetTestUrl(base::FilePath(),
310 base::FilePath(FILE_PATH_LITERAL("tab-restore-visibility.html")))); 308 base::FilePath(FILE_PATH_LITERAL("tab-restore-visibility.html"))));
311 ui_test_utils::NavigateToURLWithDisposition( 309 ui_test_utils::NavigateToURLWithDisposition(
312 browser(), test_page, NEW_FOREGROUND_TAB, 310 browser(), test_page, WindowOpenDisposition::NEW_FOREGROUND_TAB,
313 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 311 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
314 ui_test_utils::NavigateToURLWithDisposition( 312 ui_test_utils::NavigateToURLWithDisposition(
315 browser(), test_page, NEW_BACKGROUND_TAB, 313 browser(), test_page, WindowOpenDisposition::NEW_BACKGROUND_TAB,
316 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 314 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
317 315
318 // Restart and session restore the tabs. 316 // Restart and session restore the tabs.
319 content::DOMMessageQueue message_queue; 317 content::DOMMessageQueue message_queue;
320 Browser* restored = QuitBrowserAndRestore(browser(), 3); 318 Browser* restored = QuitBrowserAndRestore(browser(), 3);
321 for (int i = 0; i < 2; ++i) { 319 for (int i = 0; i < 2; ++i) {
322 std::string message; 320 std::string message;
323 EXPECT_TRUE(message_queue.WaitForMessage(&message)); 321 EXPECT_TRUE(message_queue.WaitForMessage(&message));
324 EXPECT_EQ("\"READY\"", message); 322 EXPECT_EQ("\"READY\"", message);
325 } 323 }
(...skipping 18 matching lines...) Expand all
344 } 342 }
345 } 343 }
346 } 344 }
347 345
348 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoredTabsHaveCorrectInitialSize) { 346 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoredTabsHaveCorrectInitialSize) {
349 // Create tabs. 347 // Create tabs.
350 GURL test_page(ui_test_utils::GetTestUrl( 348 GURL test_page(ui_test_utils::GetTestUrl(
351 base::FilePath(), 349 base::FilePath(),
352 base::FilePath(FILE_PATH_LITERAL("tab-restore-visibility.html")))); 350 base::FilePath(FILE_PATH_LITERAL("tab-restore-visibility.html"))));
353 ui_test_utils::NavigateToURLWithDisposition( 351 ui_test_utils::NavigateToURLWithDisposition(
354 browser(), test_page, NEW_FOREGROUND_TAB, 352 browser(), test_page, WindowOpenDisposition::NEW_FOREGROUND_TAB,
355 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 353 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
356 ui_test_utils::NavigateToURLWithDisposition( 354 ui_test_utils::NavigateToURLWithDisposition(
357 browser(), test_page, NEW_BACKGROUND_TAB, 355 browser(), test_page, WindowOpenDisposition::NEW_BACKGROUND_TAB,
358 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 356 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
359 357
360 // Restart and session restore the tabs. 358 // Restart and session restore the tabs.
361 content::DOMMessageQueue message_queue; 359 content::DOMMessageQueue message_queue;
362 Browser* restored = QuitBrowserAndRestore(browser(), 3); 360 Browser* restored = QuitBrowserAndRestore(browser(), 3);
363 for (int i = 0; i < 2; ++i) { 361 for (int i = 0; i < 2; ++i) {
364 std::string message; 362 std::string message;
365 EXPECT_TRUE(message_queue.WaitForMessage(&message)); 363 EXPECT_TRUE(message_queue.WaitForMessage(&message));
366 EXPECT_EQ("\"READY\"", message); 364 EXPECT_EQ("\"READY\"", message);
367 } 365 }
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // Find the SessionID for entry2. Since the session service was destroyed, 548 // Find the SessionID for entry2. Since the session service was destroyed,
551 // there is no guarantee that the SessionID for the tab has remained the same. 549 // there is no guarantee that the SessionID for the tab has remained the same.
552 base::Time timestamp; 550 base::Time timestamp;
553 int http_status_code = 0; 551 int http_status_code = 0;
554 for (const auto& tab_ptr : window->tabs) { 552 for (const auto& tab_ptr : window->tabs) {
555 const sessions::TabRestoreService::Tab& tab = *tab_ptr; 553 const sessions::TabRestoreService::Tab& tab = *tab_ptr;
556 // If this tab held url2, then restore this single tab. 554 // If this tab held url2, then restore this single tab.
557 if (tab.navigations[0].virtual_url() == url2) { 555 if (tab.navigations[0].virtual_url() == url2) {
558 timestamp = tab.navigations[0].timestamp(); 556 timestamp = tab.navigations[0].timestamp();
559 http_status_code = tab.navigations[0].http_status_code(); 557 http_status_code = tab.navigations[0].http_status_code();
560 std::vector<sessions::LiveTab*> content = 558 std::vector<sessions::LiveTab*> content = service->RestoreEntryById(
561 service->RestoreEntryById(NULL, tab.id, UNKNOWN); 559 NULL, tab.id, WindowOpenDisposition::UNKNOWN);
562 ASSERT_EQ(1U, content.size()); 560 ASSERT_EQ(1U, content.size());
563 sessions::ContentLiveTab* live_tab = 561 sessions::ContentLiveTab* live_tab =
564 static_cast<sessions::ContentLiveTab*>(content[0]); 562 static_cast<sessions::ContentLiveTab*>(content[0]);
565 ASSERT_TRUE(live_tab); 563 ASSERT_TRUE(live_tab);
566 EXPECT_EQ(url2, live_tab->web_contents()->GetURL()); 564 EXPECT_EQ(url2, live_tab->web_contents()->GetURL());
567 break; 565 break;
568 } 566 }
569 } 567 }
570 EXPECT_FALSE(timestamp.is_null()); 568 EXPECT_FALSE(timestamp.is_null());
571 EXPECT_EQ(200, http_status_code); 569 EXPECT_EQ(200, http_status_code);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
613 browser()->window()->Close(); 611 browser()->window()->Close();
614 612
615 // Expect the window to be converted to a tab by the TRS. 613 // Expect the window to be converted to a tab by the TRS.
616 EXPECT_EQ(1U, service->entries().size()); 614 EXPECT_EQ(1U, service->entries().size());
617 ASSERT_EQ(sessions::TabRestoreService::TAB, service->entries().front()->type); 615 ASSERT_EQ(sessions::TabRestoreService::TAB, service->entries().front()->type);
618 auto* tab = static_cast<const sessions::TabRestoreService::Tab*>( 616 auto* tab = static_cast<const sessions::TabRestoreService::Tab*>(
619 service->entries().front().get()); 617 service->entries().front().get());
620 618
621 // Restore the tab. 619 // Restore the tab.
622 std::vector<sessions::LiveTab*> content = 620 std::vector<sessions::LiveTab*> content =
623 service->RestoreEntryById(NULL, tab->id, UNKNOWN); 621 service->RestoreEntryById(NULL, tab->id, WindowOpenDisposition::UNKNOWN);
624 ASSERT_EQ(1U, content.size()); 622 ASSERT_EQ(1U, content.size());
625 ASSERT_TRUE(content[0]); 623 ASSERT_TRUE(content[0]);
626 EXPECT_EQ(url, static_cast<sessions::ContentLiveTab*>(content[0]) 624 EXPECT_EQ(url, static_cast<sessions::ContentLiveTab*>(content[0])
627 ->web_contents() 625 ->web_contents()
628 ->GetURL()); 626 ->GetURL());
629 627
630 // Make sure the restore was successful. 628 // Make sure the restore was successful.
631 EXPECT_EQ(0U, service->entries().size()); 629 EXPECT_EQ(0U, service->entries().size());
632 } 630 }
633 631
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
707 705
708 ASSERT_EQ(1, browser()->tab_strip_model()->count()); 706 ASSERT_EQ(1, browser()->tab_strip_model()->count());
709 707
710 // Restore in the current tab. 708 // Restore in the current tab.
711 content::WebContents* tab_content = NULL; 709 content::WebContents* tab_content = NULL;
712 { 710 {
713 content::WindowedNotificationObserver observer( 711 content::WindowedNotificationObserver observer(
714 content::NOTIFICATION_LOAD_STOP, 712 content::NOTIFICATION_LOAD_STOP,
715 content::NotificationService::AllSources()); 713 content::NotificationService::AllSources());
716 tab_content = SessionRestore::RestoreForeignSessionTab( 714 tab_content = SessionRestore::RestoreForeignSessionTab(
717 browser()->tab_strip_model()->GetActiveWebContents(), tab, CURRENT_TAB); 715 browser()->tab_strip_model()->GetActiveWebContents(), tab,
716 WindowOpenDisposition::CURRENT_TAB);
718 observer.Wait(); 717 observer.Wait();
719 } 718 }
720 ASSERT_EQ(1, browser()->tab_strip_model()->count()); 719 ASSERT_EQ(1, browser()->tab_strip_model()->count());
721 content::WebContents* web_contents = 720 content::WebContents* web_contents =
722 browser()->tab_strip_model()->GetWebContentsAt(0); 721 browser()->tab_strip_model()->GetWebContentsAt(0);
723 VerifyNavigationEntries(web_contents->GetController(), url1, url2); 722 VerifyNavigationEntries(web_contents->GetController(), url1, url2);
724 ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); 723 ASSERT_TRUE(web_contents->GetUserAgentOverride().empty());
725 ASSERT_TRUE(tab_content); 724 ASSERT_TRUE(tab_content);
726 ASSERT_EQ(url2, tab_content->GetURL()); 725 ASSERT_EQ(url2, tab_content->GetURL());
727 726
728 // Restore in a new tab. 727 // Restore in a new tab.
729 tab_content = NULL; 728 tab_content = NULL;
730 { 729 {
731 content::WindowedNotificationObserver observer( 730 content::WindowedNotificationObserver observer(
732 content::NOTIFICATION_LOAD_STOP, 731 content::NOTIFICATION_LOAD_STOP,
733 content::NotificationService::AllSources()); 732 content::NotificationService::AllSources());
734 tab_content = SessionRestore::RestoreForeignSessionTab( 733 tab_content = SessionRestore::RestoreForeignSessionTab(
735 browser()->tab_strip_model()->GetActiveWebContents(), 734 browser()->tab_strip_model()->GetActiveWebContents(), tab,
736 tab, NEW_BACKGROUND_TAB); 735 WindowOpenDisposition::NEW_BACKGROUND_TAB);
737 observer.Wait(); 736 observer.Wait();
738 } 737 }
739 ASSERT_EQ(2, browser()->tab_strip_model()->count()); 738 ASSERT_EQ(2, browser()->tab_strip_model()->count());
740 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); 739 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
741 web_contents = browser()->tab_strip_model()->GetWebContentsAt(1); 740 web_contents = browser()->tab_strip_model()->GetWebContentsAt(1);
742 VerifyNavigationEntries(web_contents->GetController(), url1, url2); 741 VerifyNavigationEntries(web_contents->GetController(), url1, url2);
743 ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); 742 ASSERT_TRUE(web_contents->GetUserAgentOverride().empty());
744 ASSERT_TRUE(tab_content); 743 ASSERT_TRUE(tab_content);
745 ASSERT_EQ(url2, tab_content->GetURL()); 744 ASSERT_EQ(url2, tab_content->GetURL());
746 745
747 // Restore in a new window. 746 // Restore in a new window.
748 Browser* new_browser = NULL; 747 Browser* new_browser = NULL;
749 tab_content = NULL; 748 tab_content = NULL;
750 { 749 {
751 ui_test_utils::BrowserAddedObserver browser_observer; 750 ui_test_utils::BrowserAddedObserver browser_observer;
752 content::WindowedNotificationObserver observer( 751 content::WindowedNotificationObserver observer(
753 content::NOTIFICATION_LOAD_STOP, 752 content::NOTIFICATION_LOAD_STOP,
754 content::NotificationService::AllSources()); 753 content::NotificationService::AllSources());
755 tab_content = SessionRestore::RestoreForeignSessionTab( 754 tab_content = SessionRestore::RestoreForeignSessionTab(
756 browser()->tab_strip_model()->GetActiveWebContents(), tab, NEW_WINDOW); 755 browser()->tab_strip_model()->GetActiveWebContents(), tab,
756 WindowOpenDisposition::NEW_WINDOW);
757 new_browser = browser_observer.WaitForSingleNewBrowser(); 757 new_browser = browser_observer.WaitForSingleNewBrowser();
758 observer.Wait(); 758 observer.Wait();
759 } 759 }
760 760
761 ASSERT_EQ(1, new_browser->tab_strip_model()->count()); 761 ASSERT_EQ(1, new_browser->tab_strip_model()->count());
762 web_contents = new_browser->tab_strip_model()->GetWebContentsAt(0); 762 web_contents = new_browser->tab_strip_model()->GetWebContentsAt(0);
763 VerifyNavigationEntries(web_contents->GetController(), url1, url2); 763 VerifyNavigationEntries(web_contents->GetController(), url1, url2);
764 ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); 764 ASSERT_TRUE(web_contents->GetUserAgentOverride().empty());
765 ASSERT_TRUE(tab_content); 765 ASSERT_TRUE(tab_content);
766 ASSERT_EQ(url2, tab_content->GetURL()); 766 ASSERT_EQ(url2, tab_content->GetURL());
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 855 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
856 GoBack(new_browser); 856 GoBack(new_browser);
857 ASSERT_EQ(url1_, 857 ASSERT_EQ(url1_,
858 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 858 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
859 } 859 }
860 860
861 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NoMemoryPressureLoadsAllTabs) { 861 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NoMemoryPressureLoadsAllTabs) {
862 // Add several tabs to the browser. Restart the browser and check that all 862 // Add several tabs to the browser. Restart the browser and check that all
863 // tabs got loaded properly. 863 // tabs got loaded properly.
864 ui_test_utils::NavigateToURLWithDisposition( 864 ui_test_utils::NavigateToURLWithDisposition(
865 browser(), 865 browser(), GURL(url::kAboutBlankURL),
866 GURL(url::kAboutBlankURL), 866 WindowOpenDisposition::NEW_FOREGROUND_TAB,
867 NEW_FOREGROUND_TAB,
868 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 867 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
869 ui_test_utils::NavigateToURLWithDisposition( 868 ui_test_utils::NavigateToURLWithDisposition(
870 browser(), 869 browser(), GURL(url::kAboutBlankURL),
871 GURL(url::kAboutBlankURL), 870 WindowOpenDisposition::NEW_FOREGROUND_TAB,
872 NEW_FOREGROUND_TAB,
873 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 871 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
874 Browser* restored = 872 Browser* restored =
875 QuitBrowserAndRestoreWithURL(browser(), 1, GURL(), true); 873 QuitBrowserAndRestoreWithURL(browser(), 1, GURL(), true);
876 TabStripModel* tab_strip_model = restored->tab_strip_model(); 874 TabStripModel* tab_strip_model = restored->tab_strip_model();
877 875
878 ASSERT_EQ(1u, active_browser_list_->size()); 876 ASSERT_EQ(1u, active_browser_list_->size());
879 877
880 ASSERT_EQ(3, tab_strip_model->count()); 878 ASSERT_EQ(3, tab_strip_model->count());
881 // All render widgets should be initialized by now. 879 // All render widgets should be initialized by now.
882 ASSERT_TRUE( 880 ASSERT_TRUE(
883 tab_strip_model->GetWebContentsAt(0)->GetRenderWidgetHostView() && 881 tab_strip_model->GetWebContentsAt(0)->GetRenderWidgetHostView() &&
884 tab_strip_model->GetWebContentsAt(1)->GetRenderWidgetHostView() && 882 tab_strip_model->GetWebContentsAt(1)->GetRenderWidgetHostView() &&
885 tab_strip_model->GetWebContentsAt(2)->GetRenderWidgetHostView()); 883 tab_strip_model->GetWebContentsAt(2)->GetRenderWidgetHostView());
886 } 884 }
887 885
888 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, MemoryPressureLoadsNotAllTabs) { 886 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, MemoryPressureLoadsNotAllTabs) {
889 // Add several tabs to the browser. Restart the browser and check that all 887 // Add several tabs to the browser. Restart the browser and check that all
890 // tabs got loaded properly. 888 // tabs got loaded properly.
891 ui_test_utils::NavigateToURLWithDisposition( 889 ui_test_utils::NavigateToURLWithDisposition(
892 browser(), 890 browser(), GURL(url::kAboutBlankURL),
893 GURL(url::kAboutBlankURL), 891 WindowOpenDisposition::NEW_FOREGROUND_TAB,
894 NEW_FOREGROUND_TAB,
895 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 892 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
896 ui_test_utils::NavigateToURLWithDisposition( 893 ui_test_utils::NavigateToURLWithDisposition(
897 browser(), 894 browser(), GURL(url::kAboutBlankURL),
898 GURL(url::kAboutBlankURL), 895 WindowOpenDisposition::NEW_FOREGROUND_TAB,
899 NEW_FOREGROUND_TAB,
900 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 896 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
901 // Restore the brwoser, but instead of directly waiting, we issue a critical 897 // Restore the brwoser, but instead of directly waiting, we issue a critical
902 // memory pressure event and finish then the loading. 898 // memory pressure event and finish then the loading.
903 Browser* restored = 899 Browser* restored =
904 QuitBrowserAndRestoreWithURL(browser(), 1, GURL(), false); 900 QuitBrowserAndRestoreWithURL(browser(), 1, GURL(), false);
905 901
906 TabStripModel* tab_strip_model = restored->tab_strip_model(); 902 TabStripModel* tab_strip_model = restored->tab_strip_model();
907 903
908 ASSERT_EQ(1u, active_browser_list_->size()); 904 ASSERT_EQ(1u, active_browser_list_->size());
909 905
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 GURL go_forward_url("javascript:history.forward();"); 1005 GURL go_forward_url("javascript:history.forward();");
1010 ui_test_utils::NavigateToURL(new_browser, go_forward_url); 1006 ui_test_utils::NavigateToURL(new_browser, go_forward_url);
1011 ASSERT_EQ(url2_, 1007 ASSERT_EQ(url2_,
1012 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 1008 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
1013 } 1009 }
1014 1010
1015 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, TwoTabsSecondSelected) { 1011 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, TwoTabsSecondSelected) {
1016 ui_test_utils::NavigateToURL(browser(), url1_); 1012 ui_test_utils::NavigateToURL(browser(), url1_);
1017 1013
1018 ui_test_utils::NavigateToURLWithDisposition( 1014 ui_test_utils::NavigateToURLWithDisposition(
1019 browser(), url2_, NEW_FOREGROUND_TAB, 1015 browser(), url2_, WindowOpenDisposition::NEW_FOREGROUND_TAB,
1020 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1016 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1021 1017
1022 Browser* new_browser = QuitBrowserAndRestore(browser(), 2); 1018 Browser* new_browser = QuitBrowserAndRestore(browser(), 2);
1023 1019
1024 ASSERT_EQ(1u, active_browser_list_->size()); 1020 ASSERT_EQ(1u, active_browser_list_->size());
1025 ASSERT_EQ(2, new_browser->tab_strip_model()->count()); 1021 ASSERT_EQ(2, new_browser->tab_strip_model()->count());
1026 ASSERT_EQ(1, new_browser->tab_strip_model()->active_index()); 1022 ASSERT_EQ(1, new_browser->tab_strip_model()->active_index());
1027 ASSERT_EQ(url2_, 1023 ASSERT_EQ(url2_,
1028 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 1024 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
1029 1025
1030 ASSERT_EQ(url1_, 1026 ASSERT_EQ(url1_,
1031 new_browser->tab_strip_model()->GetWebContentsAt(0)->GetURL()); 1027 new_browser->tab_strip_model()->GetWebContentsAt(0)->GetURL());
1032 } 1028 }
1033 1029
1034 // Creates two tabs, closes one, quits and makes sure only one tab is restored. 1030 // Creates two tabs, closes one, quits and makes sure only one tab is restored.
1035 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClosedTabStaysClosed) { 1031 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClosedTabStaysClosed) {
1036 ui_test_utils::NavigateToURL(browser(), url1_); 1032 ui_test_utils::NavigateToURL(browser(), url1_);
1037 1033
1038 ui_test_utils::NavigateToURLWithDisposition( 1034 ui_test_utils::NavigateToURLWithDisposition(
1039 browser(), url2_, NEW_FOREGROUND_TAB, 1035 browser(), url2_, WindowOpenDisposition::NEW_FOREGROUND_TAB,
1040 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1036 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1041 chrome::CloseTab(browser()); 1037 chrome::CloseTab(browser());
1042 1038
1043 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 1039 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
1044 1040
1045 AssertOneWindowWithOneTab(new_browser); 1041 AssertOneWindowWithOneTab(new_browser);
1046 ASSERT_EQ(url1_, 1042 ASSERT_EQ(url1_,
1047 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 1043 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
1048 } 1044 }
1049 1045
1050 // Ensures active tab properly restored when tabs before it closed. 1046 // Ensures active tab properly restored when tabs before it closed.
1051 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ActiveIndexUpdatedAtClose) { 1047 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ActiveIndexUpdatedAtClose) {
1052 ui_test_utils::NavigateToURL(browser(), url1_); 1048 ui_test_utils::NavigateToURL(browser(), url1_);
1053 ui_test_utils::NavigateToURLWithDisposition( 1049 ui_test_utils::NavigateToURLWithDisposition(
1054 browser(), url2_, NEW_FOREGROUND_TAB, 1050 browser(), url2_, WindowOpenDisposition::NEW_FOREGROUND_TAB,
1055 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1051 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1056 ui_test_utils::NavigateToURLWithDisposition( 1052 ui_test_utils::NavigateToURLWithDisposition(
1057 browser(), url3_, NEW_BACKGROUND_TAB, 1053 browser(), url3_, WindowOpenDisposition::NEW_BACKGROUND_TAB,
1058 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1054 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1059 1055
1060 browser()->tab_strip_model()->CloseWebContentsAt( 1056 browser()->tab_strip_model()->CloseWebContentsAt(
1061 0, 1057 0,
1062 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB); 1058 TabStripModel::CLOSE_CREATE_HISTORICAL_TAB);
1063 1059
1064 Browser* new_browser = QuitBrowserAndRestore(browser(), 2); 1060 Browser* new_browser = QuitBrowserAndRestore(browser(), 2);
1065 1061
1066 ASSERT_EQ(url2_, 1062 ASSERT_EQ(url2_,
1067 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 1063 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
1068 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 0); 1064 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 0);
1069 } 1065 }
1070 1066
1071 // Ensures active tab properly restored when tabs are inserted before it . 1067 // Ensures active tab properly restored when tabs are inserted before it .
1072 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ActiveIndexUpdatedAtInsert) { 1068 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ActiveIndexUpdatedAtInsert) {
1073 ui_test_utils::NavigateToURL(browser(), url1_); 1069 ui_test_utils::NavigateToURL(browser(), url1_);
1074 ui_test_utils::NavigateToURLWithDisposition( 1070 ui_test_utils::NavigateToURLWithDisposition(
1075 browser(), url2_, NEW_BACKGROUND_TAB, 1071 browser(), url2_, WindowOpenDisposition::NEW_BACKGROUND_TAB,
1076 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1072 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1077 1073
1078 chrome::NavigateParams navigate_params(browser(), url3_, 1074 chrome::NavigateParams navigate_params(browser(), url3_,
1079 ui::PAGE_TRANSITION_TYPED); 1075 ui::PAGE_TRANSITION_TYPED);
1080 navigate_params.tabstrip_index = 0; 1076 navigate_params.tabstrip_index = 0;
1081 navigate_params.disposition = NEW_BACKGROUND_TAB; 1077 navigate_params.disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB;
1082 ui_test_utils::NavigateToURL(&navigate_params); 1078 ui_test_utils::NavigateToURL(&navigate_params);
1083 1079
1084 Browser* new_browser = QuitBrowserAndRestore(browser(), 3); 1080 Browser* new_browser = QuitBrowserAndRestore(browser(), 3);
1085 1081
1086 ASSERT_EQ(url1_, 1082 ASSERT_EQ(url1_,
1087 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 1083 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
1088 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 1); 1084 ASSERT_EQ(new_browser->tab_strip_model()->active_index(), 1);
1089 } 1085 }
1090 1086
1091 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX) 1087 #if !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 } 1120 }
1125 1121
1126 #endif // !defined(OS_CHROMEOS) && !defined(OS_MACOSX) 1122 #endif // !defined(OS_CHROMEOS) && !defined(OS_MACOSX)
1127 1123
1128 // Creates two windows, closes one, restores, make sure only one window open. 1124 // Creates two windows, closes one, restores, make sure only one window open.
1129 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, TwoWindowsCloseOneRestoreOnlyOne) { 1125 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, TwoWindowsCloseOneRestoreOnlyOne) {
1130 ui_test_utils::NavigateToURL(browser(), url1_); 1126 ui_test_utils::NavigateToURL(browser(), url1_);
1131 1127
1132 // Open a second window. 1128 // Open a second window.
1133 ui_test_utils::NavigateToURLWithDisposition( 1129 ui_test_utils::NavigateToURLWithDisposition(
1134 browser(), 1130 browser(), GURL(url::kAboutBlankURL), WindowOpenDisposition::NEW_WINDOW,
1135 GURL(url::kAboutBlankURL),
1136 NEW_WINDOW,
1137 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER); 1131 ui_test_utils::BROWSER_TEST_WAIT_FOR_BROWSER);
1138 1132
1139 ASSERT_EQ(2u, active_browser_list_->size()); 1133 ASSERT_EQ(2u, active_browser_list_->size());
1140 1134
1141 // Close it. 1135 // Close it.
1142 Browser* new_window = active_browser_list_->get(1); 1136 Browser* new_window = active_browser_list_->get(1);
1143 CloseBrowserSynchronously(new_window); 1137 CloseBrowserSynchronously(new_window);
1144 1138
1145 // Restart and make sure we have only one window with one tab and the url 1139 // Restart and make sure we have only one window with one tab and the url
1146 // is url1_. 1140 // is url1_.
(...skipping 12 matching lines...) Expand all
1159 // as a special case in process-per-site-instance so that it only ever uses one 1153 // as a special case in process-per-site-instance so that it only ever uses one
1160 // process.) 1154 // process.)
1161 // 1155 //
1162 // Flaky: http://code.google.com/p/chromium/issues/detail?id=52022 1156 // Flaky: http://code.google.com/p/chromium/issues/detail?id=52022
1163 // Unfortunately, the fix at http://codereview.chromium.org/6546078 1157 // Unfortunately, the fix at http://codereview.chromium.org/6546078
1164 // breaks NTP background image refreshing, so ThemeSource had to revert to 1158 // breaks NTP background image refreshing, so ThemeSource had to revert to
1165 // replacing the existing data source. 1159 // replacing the existing data source.
1166 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ShareProcessesOnRestore) { 1160 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ShareProcessesOnRestore) {
1167 // Create two new tabs. 1161 // Create two new tabs.
1168 ui_test_utils::NavigateToURLWithDisposition( 1162 ui_test_utils::NavigateToURLWithDisposition(
1169 browser(), 1163 browser(), GURL(url::kAboutBlankURL),
1170 GURL(url::kAboutBlankURL), 1164 WindowOpenDisposition::NEW_FOREGROUND_TAB,
1171 NEW_FOREGROUND_TAB,
1172 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1165 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1173 ui_test_utils::NavigateToURLWithDisposition( 1166 ui_test_utils::NavigateToURLWithDisposition(
1174 browser(), 1167 browser(), GURL(url::kAboutBlankURL),
1175 GURL(url::kAboutBlankURL), 1168 WindowOpenDisposition::NEW_FOREGROUND_TAB,
1176 NEW_FOREGROUND_TAB,
1177 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1169 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1178 1170
1179 int expected_process_count = RenderProcessHostCount(); 1171 int expected_process_count = RenderProcessHostCount();
1180 1172
1181 // Restart. 1173 // Restart.
1182 Browser* new_browser = QuitBrowserAndRestore(browser(), 3); 1174 Browser* new_browser = QuitBrowserAndRestore(browser(), 3);
1183 1175
1184 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); 1176 ASSERT_EQ(3, new_browser->tab_strip_model()->count());
1185 1177
1186 ASSERT_EQ(expected_process_count, RenderProcessHostCount()); 1178 ASSERT_EQ(expected_process_count, RenderProcessHostCount());
1187 } 1179 }
1188 1180
1189 // Test that changing the user agent override will persist it to disk. 1181 // Test that changing the user agent override will persist it to disk.
1190 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, PersistAndRestoreUserAgentOverride) { 1182 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, PersistAndRestoreUserAgentOverride) {
1191 // Create a tab with an overridden user agent. 1183 // Create a tab with an overridden user agent.
1192 ui_test_utils::NavigateToURL(browser(), url1_); 1184 ui_test_utils::NavigateToURL(browser(), url1_);
1193 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); 1185 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
1194 browser()->tab_strip_model()->GetWebContentsAt(0)-> 1186 browser()->tab_strip_model()->GetWebContentsAt(0)->
1195 SetUserAgentOverride("override"); 1187 SetUserAgentOverride("override");
1196 1188
1197 // Create a tab without an overridden user agent. 1189 // Create a tab without an overridden user agent.
1198 ui_test_utils::NavigateToURLWithDisposition( 1190 ui_test_utils::NavigateToURLWithDisposition(
1199 browser(), url2_, NEW_FOREGROUND_TAB, 1191 browser(), url2_, WindowOpenDisposition::NEW_FOREGROUND_TAB,
1200 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1192 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1201 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 1193 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
1202 1194
1203 // Kill the original browser then open a new one to trigger a restore. 1195 // Kill the original browser then open a new one to trigger a restore.
1204 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 1196 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
1205 ASSERT_EQ(1u, active_browser_list_->size()); 1197 ASSERT_EQ(1u, active_browser_list_->size());
1206 ASSERT_EQ(2, new_browser->tab_strip_model()->count()); 1198 ASSERT_EQ(2, new_browser->tab_strip_model()->count());
1207 ASSERT_EQ(1, new_browser->tab_strip_model()->active_index()); 1199 ASSERT_EQ(1, new_browser->tab_strip_model()->active_index());
1208 1200
1209 // Confirm that the user agent overrides are properly set. 1201 // Confirm that the user agent overrides are properly set.
1210 EXPECT_EQ("override", 1202 EXPECT_EQ("override",
1211 new_browser->tab_strip_model()->GetWebContentsAt(0)-> 1203 new_browser->tab_strip_model()->GetWebContentsAt(0)->
1212 GetUserAgentOverride()); 1204 GetUserAgentOverride());
1213 EXPECT_EQ("", 1205 EXPECT_EQ("",
1214 new_browser->tab_strip_model()->GetWebContentsAt(1)-> 1206 new_browser->tab_strip_model()->GetWebContentsAt(1)->
1215 GetUserAgentOverride()); 1207 GetUserAgentOverride());
1216 } 1208 }
1217 1209
1218 // Regression test for crbug.com/125958. When restoring a pinned selected tab in 1210 // Regression test for crbug.com/125958. When restoring a pinned selected tab in
1219 // a setting where there are existing tabs, the selected index computation was 1211 // a setting where there are existing tabs, the selected index computation was
1220 // wrong, leading to the wrong tab getting selected, DCHECKs firing, and the 1212 // wrong, leading to the wrong tab getting selected, DCHECKs firing, and the
1221 // pinned tab not getting loaded. 1213 // pinned tab not getting loaded.
1222 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestorePinnedSelectedTab) { 1214 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestorePinnedSelectedTab) {
1223 // Create a pinned tab. 1215 // Create a pinned tab.
1224 ui_test_utils::NavigateToURL(browser(), url1_); 1216 ui_test_utils::NavigateToURL(browser(), url1_);
1225 browser()->tab_strip_model()->SetTabPinned(0, true); 1217 browser()->tab_strip_model()->SetTabPinned(0, true);
1226 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); 1218 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
1227 // Create a nonpinned tab. 1219 // Create a nonpinned tab.
1228 ui_test_utils::NavigateToURLWithDisposition( 1220 ui_test_utils::NavigateToURLWithDisposition(
1229 browser(), url2_, NEW_FOREGROUND_TAB, 1221 browser(), url2_, WindowOpenDisposition::NEW_FOREGROUND_TAB,
1230 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1222 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1231 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 1223 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
1232 // Select the pinned tab. 1224 // Select the pinned tab.
1233 browser()->tab_strip_model()->ActivateTabAt(0, true); 1225 browser()->tab_strip_model()->ActivateTabAt(0, true);
1234 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); 1226 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
1235 Profile* profile = browser()->profile(); 1227 Profile* profile = browser()->profile();
1236 1228
1237 // This will also initiate a session restore, but we're not interested in it. 1229 // This will also initiate a session restore, but we're not interested in it.
1238 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 1230 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
1239 ASSERT_EQ(1u, active_browser_list_->size()); 1231 ASSERT_EQ(1u, active_browser_list_->size());
(...skipping 21 matching lines...) Expand all
1261 EXPECT_EQ(url2_, 1253 EXPECT_EQ(url2_,
1262 new_browser->tab_strip_model()->GetWebContentsAt(1)->GetURL()); 1254 new_browser->tab_strip_model()->GetWebContentsAt(1)->GetURL());
1263 } 1255 }
1264 1256
1265 // Regression test for crbug.com/240156. When restoring tabs with a navigation, 1257 // Regression test for crbug.com/240156. When restoring tabs with a navigation,
1266 // the navigation should take active tab focus. 1258 // the navigation should take active tab focus.
1267 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWithNavigateSelectedTab) { 1259 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreWithNavigateSelectedTab) {
1268 // Create 2 tabs. 1260 // Create 2 tabs.
1269 ui_test_utils::NavigateToURL(browser(), url1_); 1261 ui_test_utils::NavigateToURL(browser(), url1_);
1270 ui_test_utils::NavigateToURLWithDisposition( 1262 ui_test_utils::NavigateToURLWithDisposition(
1271 browser(), url2_, NEW_FOREGROUND_TAB, 1263 browser(), url2_, WindowOpenDisposition::NEW_FOREGROUND_TAB,
1272 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1264 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1273 1265
1274 // Restore the session by calling chrome::Navigate(). 1266 // Restore the session by calling chrome::Navigate().
1275 Browser* new_browser = 1267 Browser* new_browser =
1276 QuitBrowserAndRestoreWithURL(browser(), 3, url3_, true); 1268 QuitBrowserAndRestoreWithURL(browser(), 3, url3_, true);
1277 ASSERT_EQ(1u, active_browser_list_->size()); 1269 ASSERT_EQ(1u, active_browser_list_->size());
1278 ASSERT_EQ(3, new_browser->tab_strip_model()->count()); 1270 ASSERT_EQ(3, new_browser->tab_strip_model()->count());
1279 // Navigated url should be the active tab. 1271 // Navigated url should be the active tab.
1280 ASSERT_EQ(url3_, 1272 ASSERT_EQ(url3_,
1281 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL()); 1273 new_browser->tab_strip_model()->GetActiveWebContents()->GetURL());
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 EXPECT_EQ(subframe_url.possibly_invalid_spec(), actual_frame_url); 1311 EXPECT_EQ(subframe_url.possibly_invalid_spec(), actual_frame_url);
1320 } 1312 }
1321 1313
1322 // Do a clobber restore from the new tab page. This test follows the code path 1314 // Do a clobber restore from the new tab page. This test follows the code path
1323 // of a crash followed by the user clicking restore from the new tab page. 1315 // of a crash followed by the user clicking restore from the new tab page.
1324 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClobberRestoreTest) { 1316 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, ClobberRestoreTest) {
1325 // Create 2 tabs. 1317 // Create 2 tabs.
1326 ui_test_utils::NavigateToURL(browser(), url1_); 1318 ui_test_utils::NavigateToURL(browser(), url1_);
1327 ASSERT_EQ(0, browser()->tab_strip_model()->active_index()); 1319 ASSERT_EQ(0, browser()->tab_strip_model()->active_index());
1328 ui_test_utils::NavigateToURLWithDisposition( 1320 ui_test_utils::NavigateToURLWithDisposition(
1329 browser(), url2_, NEW_FOREGROUND_TAB, 1321 browser(), url2_, WindowOpenDisposition::NEW_FOREGROUND_TAB,
1330 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1322 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1331 ASSERT_EQ(1, browser()->tab_strip_model()->active_index()); 1323 ASSERT_EQ(1, browser()->tab_strip_model()->active_index());
1332 Profile* profile = browser()->profile(); 1324 Profile* profile = browser()->profile();
1333 1325
1334 // This will also initiate a session restore, but we're not interested in it. 1326 // This will also initiate a session restore, but we're not interested in it.
1335 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); 1327 Browser* new_browser = QuitBrowserAndRestore(browser(), 1);
1336 ASSERT_EQ(1u, active_browser_list_->size()); 1328 ASSERT_EQ(1u, active_browser_list_->size());
1337 ASSERT_EQ(2, new_browser->tab_strip_model()->count()); 1329 ASSERT_EQ(2, new_browser->tab_strip_model()->count());
1338 ASSERT_EQ(1, new_browser->tab_strip_model()->active_index()); 1330 ASSERT_EQ(1, new_browser->tab_strip_model()->active_index());
1339 // Close the first tab. 1331 // Close the first tab.
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1418 1410
1419 IN_PROC_BROWSER_TEST_F(SmartSessionRestoreTest, PRE_CorrectLoadingOrder) { 1411 IN_PROC_BROWSER_TEST_F(SmartSessionRestoreTest, PRE_CorrectLoadingOrder) {
1420 Profile* profile = browser()->profile(); 1412 Profile* profile = browser()->profile();
1421 1413
1422 const int activation_order[] = {4, 2, 1, 5, 0, 3}; 1414 const int activation_order[] = {4, 2, 1, 5, 0, 3};
1423 1415
1424 // Replace the first tab and add the other tabs. 1416 // Replace the first tab and add the other tabs.
1425 ui_test_utils::NavigateToURL(browser(), GURL(kUrls[0])); 1417 ui_test_utils::NavigateToURL(browser(), GURL(kUrls[0]));
1426 for (size_t i = 1; i < kExpectedNumTabs; i++) { 1418 for (size_t i = 1; i < kExpectedNumTabs; i++) {
1427 ui_test_utils::NavigateToURLWithDisposition( 1419 ui_test_utils::NavigateToURLWithDisposition(
1428 browser(), GURL(kUrls[i]), NEW_FOREGROUND_TAB, 1420 browser(), GURL(kUrls[i]), WindowOpenDisposition::NEW_FOREGROUND_TAB,
1429 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); 1421 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
1430 } 1422 }
1431 1423
1432 ASSERT_EQ(static_cast<int>(kExpectedNumTabs), 1424 ASSERT_EQ(static_cast<int>(kExpectedNumTabs),
1433 browser()->tab_strip_model()->count()); 1425 browser()->tab_strip_model()->count());
1434 1426
1435 // Activate the tabs one by one following the specified activation order. 1427 // Activate the tabs one by one following the specified activation order.
1436 for (int i : activation_order) 1428 for (int i : activation_order)
1437 browser()->tab_strip_model()->ActivateTabAt(i, true); 1429 browser()->tab_strip_model()->ActivateTabAt(i, true);
1438 1430
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
1506 // automatically at the start of the test. 1498 // automatically at the start of the test.
1507 for (size_t i = 1; i < web_contents().size(); i++) { 1499 for (size_t i = 1; i < web_contents().size(); i++) {
1508 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); 1500 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]);
1509 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); 1501 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL());
1510 if (i > 0) { 1502 if (i > 0) {
1511 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), 1503 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(),
1512 web_contents()[i]->GetLastActiveTime()); 1504 web_contents()[i]->GetLastActiveTime());
1513 } 1505 }
1514 } 1506 }
1515 } 1507 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore_android.cc ('k') | chrome/browser/sessions/tab_restore_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698