| OLD | NEW |
| 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 "chrome/test/base/in_process_browser_test.h" | 5 #include "chrome/test/base/in_process_browser_test.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/lazy_instance.h" | 13 #include "base/lazy_instance.h" |
| 14 #include "base/location.h" | 14 #include "base/location.h" |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/path_service.h" | 16 #include "base/path_service.h" |
| 17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 18 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
| 19 #include "base/test/test_file_util.h" | 19 #include "base/test/test_file_util.h" |
| 20 #include "base/threading/non_thread_safe.h" | 20 #include "base/threading/non_thread_safe.h" |
| 21 #include "base/threading/thread_task_runner_handle.h" | 21 #include "base/threading/thread_task_runner_handle.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 #include "chrome/browser/after_startup_task_utils.h" | 23 #include "chrome/browser/after_startup_task_utils.h" |
| 24 #include "chrome/browser/browser_process.h" | 24 #include "chrome/browser/browser_process.h" |
| 25 #include "chrome/browser/chrome_content_browser_client.h" |
| 25 #include "chrome/browser/chrome_notification_types.h" | 26 #include "chrome/browser/chrome_notification_types.h" |
| 26 #include "chrome/browser/devtools/devtools_window.h" | 27 #include "chrome/browser/devtools/devtools_window.h" |
| 27 #include "chrome/browser/lifetime/application_lifetime.h" | 28 #include "chrome/browser/lifetime/application_lifetime.h" |
| 28 #include "chrome/browser/net/net_error_tab_helper.h" | 29 #include "chrome/browser/net/net_error_tab_helper.h" |
| 29 #include "chrome/browser/profiles/profile.h" | 30 #include "chrome/browser/profiles/profile.h" |
| 30 #include "chrome/browser/profiles/profile_manager.h" | 31 #include "chrome/browser/profiles/profile_manager.h" |
| 31 #include "chrome/browser/ui/browser.h" | 32 #include "chrome/browser/ui/browser.h" |
| 32 #include "chrome/browser/ui/browser_commands.h" | 33 #include "chrome/browser/ui/browser_commands.h" |
| 33 #include "chrome/browser/ui/browser_finder.h" | 34 #include "chrome/browser/ui/browser_finder.h" |
| 34 #include "chrome/browser/ui/browser_list.h" | 35 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 241 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) | 242 #if BUILDFLAG(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 242 CaptivePortalService::set_state_for_testing( | 243 CaptivePortalService::set_state_for_testing( |
| 243 CaptivePortalService::DISABLED_FOR_TESTING); | 244 CaptivePortalService::DISABLED_FOR_TESTING); |
| 244 #endif | 245 #endif |
| 245 | 246 |
| 246 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( | 247 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( |
| 247 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); | 248 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); |
| 248 | 249 |
| 249 google_util::SetMockLinkDoctorBaseURLForTesting(); | 250 google_util::SetMockLinkDoctorBaseURLForTesting(); |
| 250 | 251 |
| 252 // Use hardcoded quota settings to have a consistent testing environment. |
| 253 const int kQuota = 5 * 1024 * 1024; |
| 254 quota_settings_ = storage::QuotaSettings(kQuota * 5, kQuota, 0, 0); |
| 255 ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting( |
| 256 "a_settings_); |
| 257 |
| 251 BrowserTestBase::SetUp(); | 258 BrowserTestBase::SetUp(); |
| 252 } | 259 } |
| 253 | 260 |
| 254 void InProcessBrowserTest::SetUpDefaultCommandLine( | 261 void InProcessBrowserTest::SetUpDefaultCommandLine( |
| 255 base::CommandLine* command_line) { | 262 base::CommandLine* command_line) { |
| 256 // Propagate commandline settings from test_launcher_utils. | 263 // Propagate commandline settings from test_launcher_utils. |
| 257 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); | 264 test_launcher_utils::PrepareBrowserCommandLineForTests(command_line); |
| 258 | 265 |
| 259 // This is a Browser test. | 266 // This is a Browser test. |
| 260 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); | 267 command_line->AppendSwitchASCII(switches::kTestType, kBrowserTestType); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 350 return test_launcher_utils::OverrideUserDataDir(user_data_dir); | 357 return test_launcher_utils::OverrideUserDataDir(user_data_dir); |
| 351 } | 358 } |
| 352 | 359 |
| 353 void InProcessBrowserTest::TearDown() { | 360 void InProcessBrowserTest::TearDown() { |
| 354 DCHECK(!g_browser_process); | 361 DCHECK(!g_browser_process); |
| 355 #if defined(OS_WIN) | 362 #if defined(OS_WIN) |
| 356 com_initializer_.reset(); | 363 com_initializer_.reset(); |
| 357 #endif | 364 #endif |
| 358 BrowserTestBase::TearDown(); | 365 BrowserTestBase::TearDown(); |
| 359 OSCryptMocker::TearDown(); | 366 OSCryptMocker::TearDown(); |
| 367 ChromeContentBrowserClient::SetDefaultQuotaSettingsForTesting(nullptr); |
| 360 } | 368 } |
| 361 | 369 |
| 362 void InProcessBrowserTest::CloseBrowserSynchronously(Browser* browser) { | 370 void InProcessBrowserTest::CloseBrowserSynchronously(Browser* browser) { |
| 363 content::WindowedNotificationObserver observer( | 371 content::WindowedNotificationObserver observer( |
| 364 chrome::NOTIFICATION_BROWSER_CLOSED, | 372 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 365 content::Source<Browser>(browser)); | 373 content::Source<Browser>(browser)); |
| 366 CloseBrowserAsynchronously(browser); | 374 CloseBrowserAsynchronously(browser); |
| 367 observer.Wait(); | 375 observer.Wait(); |
| 368 } | 376 } |
| 369 | 377 |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 // On the Mac, this eventually reaches | 615 // On the Mac, this eventually reaches |
| 608 // -[BrowserWindowController windowWillClose:], which will post a deferred | 616 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 609 // -autorelease on itself to ultimately destroy the Browser object. The line | 617 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 610 // below is necessary to pump these pending messages to ensure all Browsers | 618 // below is necessary to pump these pending messages to ensure all Browsers |
| 611 // get deleted. | 619 // get deleted. |
| 612 content::RunAllPendingInMessageLoop(); | 620 content::RunAllPendingInMessageLoop(); |
| 613 delete autorelease_pool_; | 621 delete autorelease_pool_; |
| 614 autorelease_pool_ = NULL; | 622 autorelease_pool_ = NULL; |
| 615 #endif | 623 #endif |
| 616 } | 624 } |
| OLD | NEW |