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