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..30bb3493d900612ed8873c67aa7e073a1d17c4c6 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> |
| @@ -1622,3 +1623,51 @@ IN_PROC_BROWSER_TEST_F(SmartSessionRestoreTest, MAYBE_CorrectLoadingOrder) { |
| } |
| } |
| } |
| + |
| +namespace { |
| + |
| +const char kStartupURL[] = "http://example.com/"; |
| +const char kSessionURL[] = "http://localhost/"; |
| + |
| +template <class Container> |
| +bool BeginsWith(const Container& container, const Container& prefix) { |
|
sky
2017/05/04 23:40:46
Why are you using a template here? Can't you use s
eugenebng
2017/05/15 06:17:09
Done.
|
| + return container.size() >= prefix.size() && |
| + equal(prefix.begin(), prefix.end(), container.begin()); |
| +} |
| + |
| +} // namespace |
| + |
| +class SessionRestoreWithStartupURLTest : public SessionRestoreTest { |
| + protected: |
| + void SetUpCommandLine(base::CommandLine* command_line) override { |
| + // Add startup URL to command line |
| + const testing::TestInfo* const test_info = |
| + testing::UnitTest::GetInstance()->current_test_info(); |
| + std::string test_name = test_info->name(); |
| + // Do not add startup URL in PRE_ test to prevent it from opening twice |
| + // in main test body. |
| + if (!BeginsWith(test_name, std::string("PRE_"))) { |
| + command_line->AppendArg(kStartupURL); |
| + } |
| + SessionRestoreTest::SetUpCommandLine(command_line); |
| + } |
| +}; |
|
sky
2017/05/04 23:40:46
private: DISALLOW...
eugenebng
2017/05/15 06:17:08
Done.
|
| + |
| +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. |
| + // ui_test_utils::NavigateToURL(browser(),GURL(kSessionURL)); |
|
sky
2017/05/04 23:40:46
Why is this commented out?
eugenebng
2017/05/15 06:17:08
Done.
|
| + 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()); |
|
eugenebng
2017/05/03 16:05:30
Added test.
|
| +} |