Chromium Code Reviews| Index: chrome/browser/sessions/session_restore_browsertest.cc |
| diff --git a/chrome/browser/sessions/session_restore_browsertest.cc b/chrome/browser/sessions/session_restore_browsertest.cc |
| index ba9fe9d622040d654e7e93bb7165a2cfb30516a3..e211a19e3bbb35f409c01a703ffb9e1aa63f4e9a 100644 |
| --- a/chrome/browser/sessions/session_restore_browsertest.cc |
| +++ b/chrome/browser/sessions/session_restore_browsertest.cc |
| @@ -2,6 +2,8 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| +#include <vector> |
| + |
| #include "base/command_line.h" |
| #include "base/files/file_path.h" |
| #include "base/process/launch.h" |
| @@ -365,7 +367,11 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreIndividualTabFromWindow) { |
| // If this tab held url2, then restore this single tab. |
| if (tab.navigations[0].virtual_url() == url2) { |
| timestamp = tab.navigations[0].timestamp(); |
| - service->RestoreEntryById(NULL, tab.id, host_desktop_type, UNKNOWN); |
| + std::vector<content::WebContents*> content = |
| + service->RestoreEntryById(NULL, tab.id, host_desktop_type, UNKNOWN); |
| + EXPECT_EQ(1U, content.size()); |
|
sky
2013/08/05 16:16:17
This should be an assert. As if the size isn't 1,
Kristen Dwan
2013/08/05 18:01:38
Done.
|
| + ASSERT_TRUE(content[0]); |
| + EXPECT_EQ(url2, content[0]->GetURL()); |
| break; |
| } |
| } |
| @@ -413,7 +419,11 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, WindowWithOneTab) { |
| static_cast<TabRestoreService::Tab*>(service->entries().front()); |
| // Restore the tab. |
| - service->RestoreEntryById(NULL, tab->id, host_desktop_type, UNKNOWN); |
| + std::vector<content::WebContents*> content = |
| + service->RestoreEntryById(NULL, tab->id, host_desktop_type, UNKNOWN); |
| + EXPECT_EQ(1U, content.size()); |
|
sky
2013/08/05 16:16:17
ASSERT
sky
2013/08/05 16:16:17
ASSERT
Kristen Dwan
2013/08/05 18:01:38
Done.
|
| + ASSERT_TRUE(content[0]); |
| + EXPECT_EQ(url, content[0]->GetURL()); |
| // Make sure the restore was successful. |
| EXPECT_EQ(0U, service->entries().size()); |
| @@ -496,11 +506,12 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { |
| ASSERT_EQ(1, browser()->tab_strip_model()->count()); |
| // Restore in the current tab. |
| + content::WebContents* tab_content = NULL; |
| { |
| content::WindowedNotificationObserver observer( |
| content::NOTIFICATION_LOAD_STOP, |
| content::NotificationService::AllSources()); |
| - SessionRestore::RestoreForeignSessionTab( |
| + tab_content = SessionRestore::RestoreForeignSessionTab( |
| browser()->tab_strip_model()->GetActiveWebContents(), tab, CURRENT_TAB); |
| observer.Wait(); |
| } |
| @@ -509,13 +520,16 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { |
| browser()->tab_strip_model()->GetWebContentsAt(0); |
| VerifyNavigationEntries(web_contents->GetController(), url1, url2); |
| ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); |
| + ASSERT_TRUE(tab_content); |
| + ASSERT_EQ(url2, tab_content->GetURL()); |
| // Restore in a new tab. |
| + tab_content = NULL; |
| { |
| content::WindowedNotificationObserver observer( |
| content::NOTIFICATION_LOAD_STOP, |
| content::NotificationService::AllSources()); |
| - SessionRestore::RestoreForeignSessionTab( |
| + tab_content = SessionRestore::RestoreForeignSessionTab( |
| browser()->tab_strip_model()->GetActiveWebContents(), |
| tab, NEW_BACKGROUND_TAB); |
| observer.Wait(); |
| @@ -525,15 +539,18 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { |
| web_contents = browser()->tab_strip_model()->GetWebContentsAt(1); |
| VerifyNavigationEntries(web_contents->GetController(), url1, url2); |
| ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); |
| + ASSERT_TRUE(tab_content); |
| + ASSERT_EQ(url2, tab_content->GetURL()); |
| // Restore in a new window. |
| Browser* new_browser = NULL; |
| + tab_content = NULL; |
| { |
| ui_test_utils::BrowserAddedObserver browser_observer; |
| content::WindowedNotificationObserver observer( |
| content::NOTIFICATION_LOAD_STOP, |
| content::NotificationService::AllSources()); |
| - SessionRestore::RestoreForeignSessionTab( |
| + tab_content = SessionRestore::RestoreForeignSessionTab( |
| browser()->tab_strip_model()->GetActiveWebContents(), tab, NEW_WINDOW); |
| new_browser = browser_observer.WaitForSingleNewBrowser(); |
| observer.Wait(); |
| @@ -543,6 +560,8 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignTab) { |
| web_contents = new_browser->tab_strip_model()->GetWebContentsAt(0); |
| VerifyNavigationEntries(web_contents->GetController(), url1, url2); |
| ASSERT_TRUE(web_contents->GetUserAgentOverride().empty()); |
| + ASSERT_TRUE(tab_content); |
| + ASSERT_EQ(url2, tab_content->GetURL()); |
| } |
| IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignSession) { |
| @@ -583,13 +602,19 @@ IN_PROC_BROWSER_TEST_F(SessionRestoreTest, RestoreForeignSession) { |
| session.push_back(static_cast<const SessionWindow*>(&window)); |
| ui_test_utils::BrowserAddedObserver window_observer; |
| - SessionRestore::RestoreForeignSessionWindows( |
| - profile, browser()->host_desktop_type(), session.begin(), session.end()); |
| + std::vector<Browser*> browsers = |
| + SessionRestore::RestoreForeignSessionWindows( |
| + profile, browser()->host_desktop_type(), session.begin(), |
| + session.end()); |
| Browser* new_browser = window_observer.WaitForSingleNewBrowser(); |
| ASSERT_TRUE(new_browser); |
| ASSERT_EQ(2u, active_browser_list_->size()); |
| ASSERT_EQ(2, new_browser->tab_strip_model()->count()); |
| + ASSERT_EQ(1u, browsers.size()); |
| + ASSERT_TRUE(browsers[0]); |
| + ASSERT_EQ(2, browsers[0]->tab_strip_model()->count()); |
| + |
| content::WebContents* web_contents_1 = |
| new_browser->tab_strip_model()->GetWebContentsAt(0); |
| content::WebContents* web_contents_2 = |