| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_path.h" | 8 #include "base/file_path.h" |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/mac/scoped_nsautorelease_pool.h" | 10 #include "base/mac/scoped_nsautorelease_pool.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 } | 87 } |
| 88 | 88 |
| 89 InProcessBrowserTest::~InProcessBrowserTest() { | 89 InProcessBrowserTest::~InProcessBrowserTest() { |
| 90 } | 90 } |
| 91 | 91 |
| 92 void InProcessBrowserTest::SetUp() { | 92 void InProcessBrowserTest::SetUp() { |
| 93 // Create a temporary user data directory if required. | 93 // Create a temporary user data directory if required. |
| 94 ASSERT_TRUE(CreateUserDataDirectory()) | 94 ASSERT_TRUE(CreateUserDataDirectory()) |
| 95 << "Could not create user data directory."; | 95 << "Could not create user data directory."; |
| 96 | 96 |
| 97 #if defined(OS_WIN) |
| 98 // This is not really Windows-specific, the transition is just being done |
| 99 // in stages, and Windows is first. See below for more info. |
| 100 DCHECK(!g_browser_process); |
| 101 #else |
| 102 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. |
| 97 // The unit test suite creates a testingbrowser, but we want the real thing. | 103 // The unit test suite creates a testingbrowser, but we want the real thing. |
| 98 // Delete the current one. We'll install the testing one in TearDown. | 104 // Delete the current one. We'll install the testing one in TearDown. |
| 99 delete g_browser_process; | 105 delete g_browser_process; |
| 100 g_browser_process = NULL; | 106 g_browser_process = NULL; |
| 107 #endif |
| 101 | 108 |
| 102 // Allow subclasses the opportunity to make changes to the default user data | 109 // Allow subclasses the opportunity to make changes to the default user data |
| 103 // dir before running any tests. | 110 // dir before running any tests. |
| 104 ASSERT_TRUE(SetUpUserDataDirectory()) | 111 ASSERT_TRUE(SetUpUserDataDirectory()) |
| 105 << "Could not set up user data directory."; | 112 << "Could not set up user data directory."; |
| 106 | 113 |
| 107 // Don't delete the resources when BrowserMain returns. Many ui classes | 114 // Don't delete the resources when BrowserMain returns. Many ui classes |
| 108 // cache SkBitmaps in a static field so that if we delete the resource | 115 // cache SkBitmaps in a static field so that if we delete the resource |
| 109 // bundle we'll crash. | 116 // bundle we'll crash. |
| 110 browser_shutdown::delete_resources_on_shutdown = false; | 117 browser_shutdown::delete_resources_on_shutdown = false; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 } else { | 218 } else { |
| 212 LOG(ERROR) << "Could not create temporary user data directory \"" | 219 LOG(ERROR) << "Could not create temporary user data directory \"" |
| 213 << temp_user_data_dir_.path().value() << "\"."; | 220 << temp_user_data_dir_.path().value() << "\"."; |
| 214 return false; | 221 return false; |
| 215 } | 222 } |
| 216 } | 223 } |
| 217 return test_launcher_utils::OverrideUserDataDir(user_data_dir); | 224 return test_launcher_utils::OverrideUserDataDir(user_data_dir); |
| 218 } | 225 } |
| 219 | 226 |
| 220 void InProcessBrowserTest::TearDown() { | 227 void InProcessBrowserTest::TearDown() { |
| 228 #if defined(OS_WIN) |
| 229 // This is not really Windows-specific, the transition is just being done |
| 230 // in stages, and Windows is first. See below for more info. |
| 231 DCHECK(!g_browser_process); |
| 232 #else |
| 233 // TODO(phajdan.jr): Temporary, for http://crbug.com/61062. |
| 221 // Reinstall testing browser process. | 234 // Reinstall testing browser process. |
| 222 delete g_browser_process; | 235 delete g_browser_process; |
| 223 g_browser_process = new TestingBrowserProcess(); | 236 g_browser_process = new TestingBrowserProcess(); |
| 237 #endif |
| 224 | 238 |
| 225 browser_shutdown::delete_resources_on_shutdown = true; | 239 browser_shutdown::delete_resources_on_shutdown = true; |
| 226 | 240 |
| 227 #if defined(OS_WIN) | 241 #if defined(OS_WIN) |
| 228 BrowserFrameWin::SetShowState(-1); | 242 BrowserFrameWin::SetShowState(-1); |
| 229 #endif | 243 #endif |
| 230 } | 244 } |
| 231 | 245 |
| 232 void InProcessBrowserTest::AddTabAtIndexToBrowser( | 246 void InProcessBrowserTest::AddTabAtIndexToBrowser( |
| 233 Browser* browser, | 247 Browser* browser, |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 return; | 359 return; |
| 346 | 360 |
| 347 // Invoke CloseAllBrowsersAndMayExit on a running message loop. | 361 // Invoke CloseAllBrowsersAndMayExit on a running message loop. |
| 348 // CloseAllBrowsersAndMayExit exits the message loop after everything has been | 362 // CloseAllBrowsersAndMayExit exits the message loop after everything has been |
| 349 // shut down properly. | 363 // shut down properly. |
| 350 MessageLoopForUI::current()->PostTask( | 364 MessageLoopForUI::current()->PostTask( |
| 351 FROM_HERE, | 365 FROM_HERE, |
| 352 NewRunnableFunction(&BrowserList::AttemptExit)); | 366 NewRunnableFunction(&BrowserList::AttemptExit)); |
| 353 ui_test_utils::RunMessageLoop(); | 367 ui_test_utils::RunMessageLoop(); |
| 354 } | 368 } |
| OLD | NEW |