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 db9b2bc784e1cb7ed035745fffd1cee480317f5b..574f8491c962d2534f9576a6b8a203bc6642eb8f 100644 |
| --- a/chrome/browser/sessions/session_restore_browsertest.cc |
| +++ b/chrome/browser/sessions/session_restore_browsertest.cc |
| @@ -4,6 +4,7 @@ |
| #include <stddef.h> |
| +#include <algorithm> |
| #include <set> |
| #include <vector> |
| @@ -211,6 +212,9 @@ class SessionRestoreTest : public InProcessBrowserTest { |
| GURL url3_; |
| const BrowserList* active_browser_list_; |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(SessionRestoreTest); |
| }; |
| // Activates the smart restore behaviour and tracks the loading of tabs. |
| @@ -1622,3 +1626,49 @@ IN_PROC_BROWSER_TEST_F(SmartSessionRestoreTest, MAYBE_CorrectLoadingOrder) { |
| } |
| } |
| } |
| + |
| +namespace { |
| + |
| +const char kStartupURL[] = "http://example.com/"; |
| +const char kSessionURL[] = "http://localhost/"; |
| + |
| +} // namespace |
| + |
| +class SessionRestoreWithStartupURLTest : public SessionRestoreTest { |
| + public: |
| + SessionRestoreWithStartupURLTest() {} |
| + |
| + protected: |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + std::string test_name = |
| + testing::UnitTest::GetInstance()->current_test_info()->name(); |
| + // Add startup URL to command line, but only in main test body in order |
| + // to prevent that URL from beng opened twice. |
| + std::string pre_ptefix = "PRE_"; |
| + if (test_name.substr(0, pre_ptefix.length()) != pre_ptefix) { |
| + command_line->AppendArg(kStartupURL); |
| + } |
| + SessionRestoreTest::SetUpCommandLine(command_line); |
| + } |
| + |
| + private: |
| + DISALLOW_COPY_AND_ASSIGN(SessionRestoreWithStartupURLTest); |
| +}; |
| + |
| +IN_PROC_BROWSER_TEST_F(SessionRestoreWithStartupURLTest, |
| + PRE_StartupURLsWithSessionRestore) { |
| + // Prepare a session to restore in main test body. |
| + ui_test_utils::NavigateToURL(browser(), GURL(kSessionURL)); |
| +} |
| + |
| +IN_PROC_BROWSER_TEST_F(SessionRestoreWithStartupURLTest, |
| + StartupURLsWithSessionRestore) { |
| + // Check that browser is started with restored session and |
| + // tab with startup URL next to it. |
| + TabStripModel* tab_strip = browser()->tab_strip_model(); |
| + ASSERT_EQ(2, tab_strip->count()); |
| + EXPECT_EQ(kSessionURL, |
| + tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec()); |
| + EXPECT_EQ(kStartupURL, |
| + tab_strip->GetWebContentsAt(1)->GetURL().possibly_invalid_spec()); |
| +} |
|
Avi (use Gerrit)
2017/05/17 15:51:09
You need to test all the branches. In the Mac code
|