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

Side by Side Diff: chrome/browser/sessions/session_restore_browsertest.cc

Issue 2798143004: Fix for URL opening code (Closed)
Patch Set: Fixed class name usage. Created 3 years, 6 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 unified diff | Download patch
OLDNEW
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 <algorithm>
7 #include <set> 8 #include <set>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/base_switches.h" 11 #include "base/base_switches.h"
11 #include "base/command_line.h" 12 #include "base/command_line.h"
12 #include "base/files/file_path.h" 13 #include "base/files/file_path.h"
13 #include "base/files/scoped_temp_dir.h" 14 #include "base/files/scoped_temp_dir.h"
14 #include "base/macros.h" 15 #include "base/macros.h"
15 #include "base/memory/memory_pressure_listener.h" 16 #include "base/memory/memory_pressure_listener.h"
16 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 contents->GetController().LoadIfNecessary(); 205 contents->GetController().LoadIfNecessary();
205 content::WaitForLoadStop(contents); 206 content::WaitForLoadStop(contents);
206 } 207 }
207 } 208 }
208 209
209 GURL url1_; 210 GURL url1_;
210 GURL url2_; 211 GURL url2_;
211 GURL url3_; 212 GURL url3_;
212 213
213 const BrowserList* active_browser_list_; 214 const BrowserList* active_browser_list_;
215
216 private:
217 DISALLOW_COPY_AND_ASSIGN(SessionRestoreTest);
214 }; 218 };
215 219
216 // Activates the smart restore behaviour and tracks the loading of tabs. 220 // Activates the smart restore behaviour and tracks the loading of tabs.
217 class SmartSessionRestoreTest : public SessionRestoreTest, 221 class SmartSessionRestoreTest : public SessionRestoreTest,
218 public content::NotificationObserver { 222 public content::NotificationObserver {
219 public: 223 public:
220 SmartSessionRestoreTest() {} 224 SmartSessionRestoreTest() {}
221 void StartObserving(size_t num_tabs) { 225 void StartObserving(size_t num_tabs) {
222 // Start by clearing everything so it can be reused in the same test. 226 // Start by clearing everything so it can be reused in the same test.
223 web_contents_.clear(); 227 web_contents_.clear();
(...skipping 1391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1615 // automatically at the start of the test. 1619 // automatically at the start of the test.
1616 for (size_t i = 1; i < web_contents().size(); i++) { 1620 for (size_t i = 1; i < web_contents().size(); i++) {
1617 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]); 1621 GURL expected_url = GURL(kUrls[activation_order[kExpectedNumTabs - i]]);
1618 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL()); 1622 ASSERT_EQ(expected_url, web_contents()[i]->GetLastCommittedURL());
1619 if (i > 0) { 1623 if (i > 0) {
1620 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(), 1624 ASSERT_GT(web_contents()[i - 1]->GetLastActiveTime(),
1621 web_contents()[i]->GetLastActiveTime()); 1625 web_contents()[i]->GetLastActiveTime());
1622 } 1626 }
1623 } 1627 }
1624 } 1628 }
1629
1630 namespace {
1631
1632 const char kStartupURL[] = "http://example.com/";
1633 const char kSessionURL[] = "http://localhost/";
1634
1635 } // namespace
1636
1637 class SessionRestoreWithStartupURLTest : public SessionRestoreTest {
1638 public:
1639 SessionRestoreWithStartupURLTest() {}
1640
1641 protected:
1642 void SetUpCommandLine(base::CommandLine* command_line) override {
1643 // Add startup URL to command line, but only in main test body in order
1644 // to prevent that URL from beng opened twice.
1645 if (!base::StartsWith(
1646 testing::UnitTest::GetInstance()->current_test_info()->name(),
1647 "PRE_", base::CompareCase::SENSITIVE)) {
1648 command_line->AppendArg(kStartupURL);
1649 }
1650 SessionRestoreTest::SetUpCommandLine(command_line);
1651 }
1652
1653 private:
1654 DISALLOW_COPY_AND_ASSIGN(SessionRestoreWithStartupURLTest);
1655 };
1656
1657 IN_PROC_BROWSER_TEST_F(SessionRestoreWithStartupURLTest,
1658 PRE_StartupURLsWithSessionRestore) {
1659 // Prepare a session to restore in main test body.
1660 ui_test_utils::NavigateToURL(browser(), GURL(kSessionURL));
1661 }
1662
1663 IN_PROC_BROWSER_TEST_F(SessionRestoreWithStartupURLTest,
1664 StartupURLsWithSessionRestore) {
1665 // Check that browser is started with restored session and
1666 // tab with startup URL next to it.
1667 TabStripModel* tab_strip = browser()->tab_strip_model();
1668 ASSERT_EQ(2, tab_strip->count());
1669 EXPECT_EQ(kSessionURL,
1670 tab_strip->GetWebContentsAt(0)->GetURL().possibly_invalid_spec());
1671 EXPECT_EQ(kStartupURL,
1672 tab_strip->GetWebContentsAt(1)->GetURL().possibly_invalid_spec());
1673 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_restore.cc ('k') | content/public/test/repeated_notification_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698