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

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

Issue 648653003: Standardize usage of virtual/override/final in chrome/browser/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "base/basictypes.h" 5 #include "base/basictypes.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/files/file_path.h" 7 #include "base/files/file_path.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 30 matching lines...) Expand all
41 class WaitForLoadObserver : public TabRestoreServiceObserver { 41 class WaitForLoadObserver : public TabRestoreServiceObserver {
42 public: 42 public:
43 explicit WaitForLoadObserver(Browser* browser) 43 explicit WaitForLoadObserver(Browser* browser)
44 : tab_restore_service_( 44 : tab_restore_service_(
45 TabRestoreServiceFactory::GetForProfile(browser->profile())), 45 TabRestoreServiceFactory::GetForProfile(browser->profile())),
46 do_wait_(!tab_restore_service_->IsLoaded()) { 46 do_wait_(!tab_restore_service_->IsLoaded()) {
47 if (do_wait_) 47 if (do_wait_)
48 tab_restore_service_->AddObserver(this); 48 tab_restore_service_->AddObserver(this);
49 } 49 }
50 50
51 virtual ~WaitForLoadObserver() { 51 ~WaitForLoadObserver() override {
52 if (do_wait_) 52 if (do_wait_)
53 tab_restore_service_->RemoveObserver(this); 53 tab_restore_service_->RemoveObserver(this);
54 } 54 }
55 55
56 void Wait() { 56 void Wait() {
57 if (do_wait_) 57 if (do_wait_)
58 run_loop_.Run(); 58 run_loop_.Run();
59 } 59 }
60 60
61 private: 61 private:
62 // Overridden from TabRestoreServiceObserver: 62 // Overridden from TabRestoreServiceObserver:
63 virtual void TabRestoreServiceChanged(TabRestoreService* service) override {} 63 void TabRestoreServiceChanged(TabRestoreService* service) override {}
64 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) override { 64 void TabRestoreServiceDestroyed(TabRestoreService* service) override {}
65 } 65 void TabRestoreServiceLoaded(TabRestoreService* service) override {
66 virtual void TabRestoreServiceLoaded(TabRestoreService* service) override {
67 DCHECK(do_wait_); 66 DCHECK(do_wait_);
68 run_loop_.Quit(); 67 run_loop_.Quit();
69 } 68 }
70 69
71 TabRestoreService* tab_restore_service_; 70 TabRestoreService* tab_restore_service_;
72 const bool do_wait_; 71 const bool do_wait_;
73 base::RunLoop run_loop_; 72 base::RunLoop run_loop_;
74 73
75 DISALLOW_COPY_AND_ASSIGN(WaitForLoadObserver); 74 DISALLOW_COPY_AND_ASSIGN(WaitForLoadObserver);
76 }; 75 };
77 76
78 class TabRestoreTest : public InProcessBrowserTest { 77 class TabRestoreTest : public InProcessBrowserTest {
79 public: 78 public:
80 TabRestoreTest() : active_browser_list_(NULL) { 79 TabRestoreTest() : active_browser_list_(NULL) {
81 url1_ = ui_test_utils::GetTestUrl( 80 url1_ = ui_test_utils::GetTestUrl(
82 base::FilePath().AppendASCII("session_history"), 81 base::FilePath().AppendASCII("session_history"),
83 base::FilePath().AppendASCII("bot1.html")); 82 base::FilePath().AppendASCII("bot1.html"));
84 url2_ = ui_test_utils::GetTestUrl( 83 url2_ = ui_test_utils::GetTestUrl(
85 base::FilePath().AppendASCII("session_history"), 84 base::FilePath().AppendASCII("session_history"),
86 base::FilePath().AppendASCII("bot2.html")); 85 base::FilePath().AppendASCII("bot2.html"));
87 } 86 }
88 87
89 protected: 88 protected:
90 virtual void SetUpOnMainThread() override { 89 void SetUpOnMainThread() override {
91 active_browser_list_ = BrowserList::GetInstance(chrome::GetActiveDesktop()); 90 active_browser_list_ = BrowserList::GetInstance(chrome::GetActiveDesktop());
92 InProcessBrowserTest::SetUpOnMainThread(); 91 InProcessBrowserTest::SetUpOnMainThread();
93 } 92 }
94 93
95 Browser* GetBrowser(int index) { 94 Browser* GetBrowser(int index) {
96 CHECK(static_cast<int>(active_browser_list_->size()) > index); 95 CHECK(static_cast<int>(active_browser_list_->size()) > index);
97 return active_browser_list_->get(index); 96 return active_browser_list_->get(index);
98 } 97 }
99 98
100 // Adds tabs to the given browser, all navigated to url1_. Returns 99 // Adds tabs to the given browser, all navigated to url1_. Returns
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 while (browser()->tab_strip_model()->count()) 634 while (browser()->tab_strip_model()->count())
636 CloseTab(0); 635 CloseTab(0);
637 } 636 }
638 637
639 // Verifies restoring a tab works on startup. 638 // Verifies restoring a tab works on startup.
640 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreOnStartup) { 639 IN_PROC_BROWSER_TEST_F(TabRestoreTest, RestoreOnStartup) {
641 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1)); 640 ASSERT_NO_FATAL_FAILURE(RestoreTab(0, 1));
642 EXPECT_EQ(url1_, 641 EXPECT_EQ(url1_,
643 browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL()); 642 browser()->tab_strip_model()->GetWebContentsAt(1)->GetURL());
644 } 643 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_tab_helper.h ('k') | chrome/browser/sessions/tab_restore_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698