| 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 "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "chrome/common/chrome_constants.h" | 42 #include "chrome/common/chrome_constants.h" |
| 43 #include "chrome/common/chrome_paths.h" | 43 #include "chrome/common/chrome_paths.h" |
| 44 #include "chrome/common/chrome_switches.h" | 44 #include "chrome/common/chrome_switches.h" |
| 45 #include "chrome/common/logging_chrome.h" | 45 #include "chrome/common/logging_chrome.h" |
| 46 #include "chrome/common/url_constants.h" | 46 #include "chrome/common/url_constants.h" |
| 47 #include "chrome/renderer/chrome_content_renderer_client.h" | 47 #include "chrome/renderer/chrome_content_renderer_client.h" |
| 48 #include "chrome/test/base/chrome_test_suite.h" | 48 #include "chrome/test/base/chrome_test_suite.h" |
| 49 #include "chrome/test/base/test_launcher_utils.h" | 49 #include "chrome/test/base/test_launcher_utils.h" |
| 50 #include "chrome/test/base/testing_browser_process.h" | 50 #include "chrome/test/base/testing_browser_process.h" |
| 51 #include "components/google/core/browser/google_util.h" | 51 #include "components/google/core/browser/google_util.h" |
| 52 #include "components/os_crypt/os_crypt.h" | 52 #include "components/os_crypt/os_crypt_mocker.h" |
| 53 #include "content/public/browser/devtools_agent_host.h" | 53 #include "content/public/browser/devtools_agent_host.h" |
| 54 #include "content/public/browser/notification_service.h" | 54 #include "content/public/browser/notification_service.h" |
| 55 #include "content/public/browser/notification_types.h" | 55 #include "content/public/browser/notification_types.h" |
| 56 #include "content/public/common/content_switches.h" | 56 #include "content/public/common/content_switches.h" |
| 57 #include "content/public/test/browser_test_utils.h" | 57 #include "content/public/test/browser_test_utils.h" |
| 58 #include "content/public/test/test_launcher.h" | 58 #include "content/public/test/test_launcher.h" |
| 59 #include "content/public/test/test_navigation_observer.h" | 59 #include "content/public/test/test_navigation_observer.h" |
| 60 #include "net/test/embedded_test_server/embedded_test_server.h" | 60 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 61 | 61 |
| 62 #if defined(OS_MACOSX) | 62 #if defined(OS_MACOSX) |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 // Disable IME extension loading to avoid many browser tests failures. | 214 // Disable IME extension loading to avoid many browser tests failures. |
| 215 chromeos::input_method::DisableExtensionLoading(); | 215 chromeos::input_method::DisableExtensionLoading(); |
| 216 if (!command_line->HasSwitch(ash::switches::kAshHostWindowBounds)) { | 216 if (!command_line->HasSwitch(ash::switches::kAshHostWindowBounds)) { |
| 217 // Adjusting window location & size so that the ash desktop window fits | 217 // Adjusting window location & size so that the ash desktop window fits |
| 218 // inside the Xvfb'x defualt resolution. | 218 // inside the Xvfb'x defualt resolution. |
| 219 command_line->AppendSwitchASCII(ash::switches::kAshHostWindowBounds, | 219 command_line->AppendSwitchASCII(ash::switches::kAshHostWindowBounds, |
| 220 "0+0-1280x800"); | 220 "0+0-1280x800"); |
| 221 } | 221 } |
| 222 #endif // defined(OS_CHROMEOS) | 222 #endif // defined(OS_CHROMEOS) |
| 223 | 223 |
| 224 #if defined(OS_MACOSX) | |
| 225 // Always use the MockKeychain if OS encription is used (which is when | 224 // Always use the MockKeychain if OS encription is used (which is when |
| 226 // anything sensitive gets stored, including Cookies). Without this, | 225 // anything sensitive gets stored, including Cookies). Without this, |
| 227 // many tests will hang waiting for a user to approve KeyChain access. | 226 // many tests will hang waiting for a user to approve KeyChain access. |
| 228 OSCrypt::UseMockKeychain(true); | 227 OSCryptMocker::SetUpWithSingleton(); |
| 229 #endif | |
| 230 | 228 |
| 231 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) | 229 #if defined(ENABLE_CAPTIVE_PORTAL_DETECTION) |
| 232 CaptivePortalService::set_state_for_testing( | 230 CaptivePortalService::set_state_for_testing( |
| 233 CaptivePortalService::DISABLED_FOR_TESTING); | 231 CaptivePortalService::DISABLED_FOR_TESTING); |
| 234 #endif | 232 #endif |
| 235 | 233 |
| 236 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( | 234 chrome_browser_net::NetErrorTabHelper::set_state_for_testing( |
| 237 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); | 235 chrome_browser_net::NetErrorTabHelper::TESTING_FORCE_DISABLED); |
| 238 | 236 |
| 239 google_util::SetMockLinkDoctorBaseURLForTesting(); | 237 google_util::SetMockLinkDoctorBaseURLForTesting(); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 337 } |
| 340 return test_launcher_utils::OverrideUserDataDir(user_data_dir); | 338 return test_launcher_utils::OverrideUserDataDir(user_data_dir); |
| 341 } | 339 } |
| 342 | 340 |
| 343 void InProcessBrowserTest::TearDown() { | 341 void InProcessBrowserTest::TearDown() { |
| 344 DCHECK(!g_browser_process); | 342 DCHECK(!g_browser_process); |
| 345 #if defined(OS_WIN) | 343 #if defined(OS_WIN) |
| 346 com_initializer_.reset(); | 344 com_initializer_.reset(); |
| 347 #endif | 345 #endif |
| 348 BrowserTestBase::TearDown(); | 346 BrowserTestBase::TearDown(); |
| 347 OSCryptMocker::TearDown(); |
| 349 } | 348 } |
| 350 | 349 |
| 351 void InProcessBrowserTest::CloseBrowserSynchronously(Browser* browser) { | 350 void InProcessBrowserTest::CloseBrowserSynchronously(Browser* browser) { |
| 352 content::WindowedNotificationObserver observer( | 351 content::WindowedNotificationObserver observer( |
| 353 chrome::NOTIFICATION_BROWSER_CLOSED, | 352 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 354 content::Source<Browser>(browser)); | 353 content::Source<Browser>(browser)); |
| 355 CloseBrowserAsynchronously(browser); | 354 CloseBrowserAsynchronously(browser); |
| 356 observer.Wait(); | 355 observer.Wait(); |
| 357 } | 356 } |
| 358 | 357 |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 // On the Mac, this eventually reaches | 592 // On the Mac, this eventually reaches |
| 594 // -[BrowserWindowController windowWillClose:], which will post a deferred | 593 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 595 // -autorelease on itself to ultimately destroy the Browser object. The line | 594 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 596 // below is necessary to pump these pending messages to ensure all Browsers | 595 // below is necessary to pump these pending messages to ensure all Browsers |
| 597 // get deleted. | 596 // get deleted. |
| 598 content::RunAllPendingInMessageLoop(); | 597 content::RunAllPendingInMessageLoop(); |
| 599 delete autorelease_pool_; | 598 delete autorelease_pool_; |
| 600 autorelease_pool_ = NULL; | 599 autorelease_pool_ = NULL; |
| 601 #endif | 600 #endif |
| 602 } | 601 } |
| OLD | NEW |