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

Unified Diff: chrome/browser/sessions/session_restore_browsertest.cc

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Added new files for added tests. Created 3 years, 7 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 side-by-side diff with in-line comments
Download patch
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_";
Avi (use Gerrit) 2017/06/01 19:54:31 typo: prefix
eugenebng 2017/06/07 10:42:12 Done.
+ 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());
+}

Powered by Google App Engine
This is Rietveld 408576698