| OLD | NEW |
| 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 <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
| (...skipping 840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 851 | 851 |
| 852 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); | 852 Browser* new_browser = QuitBrowserAndRestore(browser(), 1); |
| 853 ASSERT_EQ(1u, active_browser_list_->size()); | 853 ASSERT_EQ(1u, active_browser_list_->size()); |
| 854 ASSERT_EQ(url2_, | 854 ASSERT_EQ(url2_, |
| 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, StartupPagesWithOnlyNtp) { |
| 862 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL)); |
| 863 SessionStartupPref pref(SessionStartupPref::URLS); |
| 864 pref.urls.push_back(url1_); |
| 865 pref.urls.push_back(url2_); |
| 866 SessionStartupPref::SetStartupPref(browser()->profile(), pref); |
| 867 |
| 868 SessionRestore::OpenStartupPagesAfterCrash(browser()); |
| 869 |
| 870 ASSERT_EQ(1u, active_browser_list_->size()); |
| 871 ASSERT_EQ(2, browser()->tab_strip_model()->count()); |
| 872 EXPECT_EQ(url1_, browser()->tab_strip_model()->GetWebContentsAt(0)->GetURL()); |
| 873 EXPECT_EQ(url2_, browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL()); |
| 874 } |
| 875 |
| 876 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, StartupPagesWithExistingPages) { |
| 877 ui_test_utils::NavigateToURL(browser(), url3_); |
| 878 |
| 879 SessionStartupPref pref(SessionStartupPref::URLS); |
| 880 pref.urls.push_back(url1_); |
| 881 pref.urls.push_back(url2_); |
| 882 SessionStartupPref::SetStartupPref(browser()->profile(), pref); |
| 883 |
| 884 SessionRestore::OpenStartupPagesAfterCrash(browser()); |
| 885 |
| 886 ASSERT_EQ(1u, active_browser_list_->size()); |
| 887 ASSERT_EQ(3, browser()->tab_strip_model()->count()); |
| 888 EXPECT_EQ(url3_, browser()->tab_strip_model()->GetWebContentsAt(0)->GetURL()); |
| 889 EXPECT_EQ(url1_, browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL()); |
| 890 EXPECT_EQ(url2_, browser()->tab_strip_model()->GetWebContentsAt(2)->GetURL()); |
| 891 } |
| 892 |
| 861 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NoMemoryPressureLoadsAllTabs) { | 893 IN_PROC_BROWSER_TEST_F(SessionRestoreTest, NoMemoryPressureLoadsAllTabs) { |
| 862 // Add several tabs to the browser. Restart the browser and check that all | 894 // Add several tabs to the browser. Restart the browser and check that all |
| 863 // tabs got loaded properly. | 895 // tabs got loaded properly. |
| 864 ui_test_utils::NavigateToURLWithDisposition( | 896 ui_test_utils::NavigateToURLWithDisposition( |
| 865 browser(), GURL(url::kAboutBlankURL), | 897 browser(), GURL(url::kAboutBlankURL), |
| 866 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 898 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| 867 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 899 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 868 ui_test_utils::NavigateToURLWithDisposition( | 900 ui_test_utils::NavigateToURLWithDisposition( |
| 869 browser(), GURL(url::kAboutBlankURL), | 901 browser(), GURL(url::kAboutBlankURL), |
| 870 WindowOpenDisposition::NEW_FOREGROUND_TAB, | 902 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
| (...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 // automatically at the start of the test. | 1610 // automatically at the start of the test. |
| 1579 for (size_t i = 1; i < web_contents().size(); i++) { | 1611 for (size_t i = 1; i < web_contents().size(); i++) { |
| 1580 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); | 1612 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); |
| 1581 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); | 1613 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); |
| 1582 if (i > 0) { | 1614 if (i > 0) { |
| 1583 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), | 1615 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), |
| 1584 web_contents()[i]->GetLastActiveTime()); | 1616 web_contents()[i]->GetLastActiveTime()); |
| 1585 } | 1617 } |
| 1586 } | 1618 } |
| 1587 } | 1619 } |
| OLD | NEW |