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

Side by Side Diff: chrome/browser/lifetime/browser_close_manager_browsertest.cc

Issue 624173002: replace OVERRIDE and FINAL with override and final in chrome/browser/[j-q]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase on master 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
« no previous file with comments | « no previous file | chrome/browser/local_discovery/cloud_device_list.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "chrome/browser/background/background_mode_manager.h" 9 #include "chrome/browser/background/background_mode_manager.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 96
97 class RepeatedNotificationObserver : public content::NotificationObserver { 97 class RepeatedNotificationObserver : public content::NotificationObserver {
98 public: 98 public:
99 explicit RepeatedNotificationObserver(int type, int count) 99 explicit RepeatedNotificationObserver(int type, int count)
100 : num_outstanding_(count), running_(false) { 100 : num_outstanding_(count), running_(false) {
101 registrar_.Add(this, type, content::NotificationService::AllSources()); 101 registrar_.Add(this, type, content::NotificationService::AllSources());
102 } 102 }
103 103
104 virtual void Observe(int type, 104 virtual void Observe(int type,
105 const content::NotificationSource& source, 105 const content::NotificationSource& source,
106 const content::NotificationDetails& details) OVERRIDE { 106 const content::NotificationDetails& details) override {
107 ASSERT_GT(num_outstanding_, 0); 107 ASSERT_GT(num_outstanding_, 0);
108 if (!--num_outstanding_ && running_) { 108 if (!--num_outstanding_ && running_) {
109 content::BrowserThread::PostTask( 109 content::BrowserThread::PostTask(
110 content::BrowserThread::UI, FROM_HERE, run_loop_.QuitClosure()); 110 content::BrowserThread::UI, FROM_HERE, run_loop_.QuitClosure());
111 } 111 }
112 } 112 }
113 113
114 void Wait() { 114 void Wait() {
115 if (num_outstanding_ <= 0) 115 if (num_outstanding_ <= 0)
116 return; 116 return;
(...skipping 25 matching lines...) Expand all
142 new TestBrowserCloseManager(user_choice); 142 new TestBrowserCloseManager(user_choice);
143 browser_shutdown::SetTryingToQuit(true); 143 browser_shutdown::SetTryingToQuit(true);
144 browser_close_manager->StartClosingBrowsers(); 144 browser_close_manager->StartClosingBrowsers();
145 } 145 }
146 146
147 protected: 147 protected:
148 virtual ~TestBrowserCloseManager() {} 148 virtual ~TestBrowserCloseManager() {}
149 149
150 virtual void ConfirmCloseWithPendingDownloads( 150 virtual void ConfirmCloseWithPendingDownloads(
151 int download_count, 151 int download_count,
152 const base::Callback<void(bool)>& callback) OVERRIDE { 152 const base::Callback<void(bool)>& callback) override {
153 EXPECT_NE(NO_USER_CHOICE, user_choice_); 153 EXPECT_NE(NO_USER_CHOICE, user_choice_);
154 switch (user_choice_) { 154 switch (user_choice_) {
155 case NO_USER_CHOICE: 155 case NO_USER_CHOICE:
156 case USER_CHOICE_USER_CANCELS_CLOSE: { 156 case USER_CHOICE_USER_CANCELS_CLOSE: {
157 callback.Run(false); 157 callback.Run(false);
158 break; 158 break;
159 } 159 }
160 case USER_CHOICE_USER_ALLOWS_CLOSE: { 160 case USER_CHOICE_USER_ALLOWS_CLOSE: {
161 callback.Run(true); 161 callback.Run(true);
162 break; 162 break;
(...skipping 13 matching lines...) Expand all
176 class TestDownloadManagerDelegate : public ChromeDownloadManagerDelegate { 176 class TestDownloadManagerDelegate : public ChromeDownloadManagerDelegate {
177 public: 177 public:
178 explicit TestDownloadManagerDelegate(Profile* profile) 178 explicit TestDownloadManagerDelegate(Profile* profile)
179 : ChromeDownloadManagerDelegate(profile) { 179 : ChromeDownloadManagerDelegate(profile) {
180 GetDownloadIdReceiverCallback().Run(content::DownloadItem::kInvalidId + 1); 180 GetDownloadIdReceiverCallback().Run(content::DownloadItem::kInvalidId + 1);
181 } 181 }
182 virtual ~TestDownloadManagerDelegate() {} 182 virtual ~TestDownloadManagerDelegate() {}
183 183
184 virtual bool DetermineDownloadTarget( 184 virtual bool DetermineDownloadTarget(
185 content::DownloadItem* item, 185 content::DownloadItem* item,
186 const content::DownloadTargetCallback& callback) OVERRIDE { 186 const content::DownloadTargetCallback& callback) override {
187 content::DownloadTargetCallback dangerous_callback = 187 content::DownloadTargetCallback dangerous_callback =
188 base::Bind(&TestDownloadManagerDelegate::SetDangerous, callback); 188 base::Bind(&TestDownloadManagerDelegate::SetDangerous, callback);
189 return ChromeDownloadManagerDelegate::DetermineDownloadTarget( 189 return ChromeDownloadManagerDelegate::DetermineDownloadTarget(
190 item, dangerous_callback); 190 item, dangerous_callback);
191 } 191 }
192 192
193 static void SetDangerous( 193 static void SetDangerous(
194 const content::DownloadTargetCallback& callback, 194 const content::DownloadTargetCallback& callback,
195 const base::FilePath& target_path, 195 const base::FilePath& target_path,
196 content::DownloadItem::TargetDisposition disp, 196 content::DownloadItem::TargetDisposition disp,
197 content::DownloadDangerType danger_type, 197 content::DownloadDangerType danger_type,
198 const base::FilePath& intermediate_path) { 198 const base::FilePath& intermediate_path) {
199 callback.Run(target_path, 199 callback.Run(target_path,
200 disp, 200 disp,
201 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL, 201 content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL,
202 intermediate_path); 202 intermediate_path);
203 } 203 }
204 }; 204 };
205 205
206 class FakeBackgroundModeManager : public BackgroundModeManager { 206 class FakeBackgroundModeManager : public BackgroundModeManager {
207 public: 207 public:
208 FakeBackgroundModeManager() 208 FakeBackgroundModeManager()
209 : BackgroundModeManager( 209 : BackgroundModeManager(
210 CommandLine::ForCurrentProcess(), 210 CommandLine::ForCurrentProcess(),
211 &g_browser_process->profile_manager()->GetProfileInfoCache()), 211 &g_browser_process->profile_manager()->GetProfileInfoCache()),
212 suspended_(false) {} 212 suspended_(false) {}
213 213
214 virtual void SuspendBackgroundMode() OVERRIDE { 214 virtual void SuspendBackgroundMode() override {
215 BackgroundModeManager::SuspendBackgroundMode(); 215 BackgroundModeManager::SuspendBackgroundMode();
216 suspended_ = true; 216 suspended_ = true;
217 } 217 }
218 218
219 virtual void ResumeBackgroundMode() OVERRIDE { 219 virtual void ResumeBackgroundMode() override {
220 BackgroundModeManager::ResumeBackgroundMode(); 220 BackgroundModeManager::ResumeBackgroundMode();
221 suspended_ = false; 221 suspended_ = false;
222 } 222 }
223 223
224 bool IsBackgroundModeSuspended() { 224 bool IsBackgroundModeSuspended() {
225 return suspended_; 225 return suspended_;
226 } 226 }
227 227
228 private: 228 private:
229 bool suspended_; 229 bool suspended_;
230 230
231 DISALLOW_COPY_AND_ASSIGN(FakeBackgroundModeManager); 231 DISALLOW_COPY_AND_ASSIGN(FakeBackgroundModeManager);
232 }; 232 };
233 233
234 } // namespace 234 } // namespace
235 235
236 class BrowserCloseManagerBrowserTest 236 class BrowserCloseManagerBrowserTest
237 : public InProcessBrowserTest, 237 : public InProcessBrowserTest,
238 public testing::WithParamInterface<bool> { 238 public testing::WithParamInterface<bool> {
239 protected: 239 protected:
240 virtual void SetUpOnMainThread() OVERRIDE { 240 virtual void SetUpOnMainThread() override {
241 InProcessBrowserTest::SetUpOnMainThread(); 241 InProcessBrowserTest::SetUpOnMainThread();
242 SessionStartupPref::SetStartupPref( 242 SessionStartupPref::SetStartupPref(
243 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST)); 243 browser()->profile(), SessionStartupPref(SessionStartupPref::LAST));
244 browsers_.push_back(browser()); 244 browsers_.push_back(browser());
245 dialogs_.Start(); 245 dialogs_.Start();
246 content::BrowserThread::PostTask( 246 content::BrowserThread::PostTask(
247 content::BrowserThread::IO, 247 content::BrowserThread::IO,
248 FROM_HERE, 248 FROM_HERE,
249 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true)); 249 base::Bind(&chrome_browser_net::SetUrlRequestMocksEnabled, true));
250 } 250 }
251 251
252 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 252 virtual void SetUpCommandLine(CommandLine* command_line) override {
253 if (GetParam()) 253 if (GetParam())
254 command_line->AppendSwitch(switches::kEnableFastUnload); 254 command_line->AppendSwitch(switches::kEnableFastUnload);
255 #if defined(OS_CHROMEOS) 255 #if defined(OS_CHROMEOS)
256 command_line->AppendSwitch( 256 command_line->AppendSwitch(
257 chromeos::switches::kIgnoreUserProfileMappingForTests); 257 chromeos::switches::kIgnoreUserProfileMappingForTests);
258 #endif 258 #endif
259 } 259 }
260 260
261 void CreateStalledDownload(Browser* browser) { 261 void CreateStalledDownload(Browser* browser) {
262 content::DownloadTestObserverInProgress observer( 262 content::DownloadTestObserverInProgress observer(
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerBrowserTest, 705 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerBrowserTest,
706 BrowserCloseManagerBrowserTest, 706 BrowserCloseManagerBrowserTest,
707 testing::Bool()); 707 testing::Bool());
708 708
709 class BrowserCloseManagerWithDownloadsBrowserTest : 709 class BrowserCloseManagerWithDownloadsBrowserTest :
710 public BrowserCloseManagerBrowserTest { 710 public BrowserCloseManagerBrowserTest {
711 public: 711 public:
712 BrowserCloseManagerWithDownloadsBrowserTest() {} 712 BrowserCloseManagerWithDownloadsBrowserTest() {}
713 virtual ~BrowserCloseManagerWithDownloadsBrowserTest() {} 713 virtual ~BrowserCloseManagerWithDownloadsBrowserTest() {}
714 714
715 virtual void SetUpOnMainThread() OVERRIDE { 715 virtual void SetUpOnMainThread() override {
716 BrowserCloseManagerBrowserTest::SetUpOnMainThread(); 716 BrowserCloseManagerBrowserTest::SetUpOnMainThread();
717 ASSERT_TRUE(scoped_download_directory_.CreateUniqueTempDir()); 717 ASSERT_TRUE(scoped_download_directory_.CreateUniqueTempDir());
718 } 718 }
719 719
720 void SetDownloadPathForProfile(Profile* profile) { 720 void SetDownloadPathForProfile(Profile* profile) {
721 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(profile); 721 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(profile);
722 download_prefs->SetDownloadPath(download_path()); 722 download_prefs->SetDownloadPath(download_path());
723 } 723 }
724 724
725 const base::FilePath& download_path() const { 725 const base::FilePath& download_path() const {
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 888
889 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithDownloadsBrowserTest, 889 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithDownloadsBrowserTest,
890 BrowserCloseManagerWithDownloadsBrowserTest, 890 BrowserCloseManagerWithDownloadsBrowserTest,
891 testing::Bool()); 891 testing::Bool());
892 892
893 class BrowserCloseManagerWithBackgroundModeBrowserTest 893 class BrowserCloseManagerWithBackgroundModeBrowserTest
894 : public BrowserCloseManagerBrowserTest { 894 : public BrowserCloseManagerBrowserTest {
895 public: 895 public:
896 BrowserCloseManagerWithBackgroundModeBrowserTest() {} 896 BrowserCloseManagerWithBackgroundModeBrowserTest() {}
897 897
898 virtual void SetUpOnMainThread() OVERRIDE { 898 virtual void SetUpOnMainThread() override {
899 BrowserCloseManagerBrowserTest::SetUpOnMainThread(); 899 BrowserCloseManagerBrowserTest::SetUpOnMainThread();
900 g_browser_process->set_background_mode_manager_for_test( 900 g_browser_process->set_background_mode_manager_for_test(
901 scoped_ptr<BackgroundModeManager>(new FakeBackgroundModeManager)); 901 scoped_ptr<BackgroundModeManager>(new FakeBackgroundModeManager));
902 } 902 }
903 903
904 bool IsBackgroundModeSuspended() { 904 bool IsBackgroundModeSuspended() {
905 return static_cast<FakeBackgroundModeManager*>( 905 return static_cast<FakeBackgroundModeManager*>(
906 g_browser_process->background_mode_manager()) 906 g_browser_process->background_mode_manager())
907 ->IsBackgroundModeSuspended(); 907 ->IsBackgroundModeSuspended();
908 } 908 }
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 977
978 chrome::CloseAllBrowsers(); 978 chrome::CloseAllBrowsers();
979 EXPECT_FALSE(browser_shutdown::IsTryingToQuit()); 979 EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
980 EXPECT_TRUE(chrome::BrowserIterator().done()); 980 EXPECT_TRUE(chrome::BrowserIterator().done());
981 EXPECT_TRUE(IsBackgroundModeSuspended()); 981 EXPECT_TRUE(IsBackgroundModeSuspended());
982 } 982 }
983 983
984 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithBackgroundModeBrowserTest, 984 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
985 BrowserCloseManagerWithBackgroundModeBrowserTest, 985 BrowserCloseManagerWithBackgroundModeBrowserTest,
986 testing::Bool()); 986 testing::Bool());
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/local_discovery/cloud_device_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698