Chromium Code Reviews| 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/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 152 | 152 |
| 153 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 153 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 154 | 154 |
| 155 // Auto-reload breaks many browser tests, which assume error pages won't be | 155 // Auto-reload breaks many browser tests, which assume error pages won't be |
| 156 // reloaded out from under them. Tests that expect or desire this behavior can | 156 // reloaded out from under them. Tests that expect or desire this behavior can |
| 157 // append switches::kEnableOfflineAutoReload, which will override the disable | 157 // append switches::kEnableOfflineAutoReload, which will override the disable |
| 158 // here. | 158 // here. |
| 159 command_line->AppendSwitch(switches::kDisableOfflineAutoReload); | 159 command_line->AppendSwitch(switches::kDisableOfflineAutoReload); |
| 160 | 160 |
| 161 // Allow subclasses to change the command line before running any tests. | 161 // Allow subclasses to change the command line before running any tests. |
| 162 std::vector<BrowserTestBase::Admixture*> admixtures = GetAdmixtures(); | |
| 163 for (std::vector<BrowserTestBase::Admixture*>::iterator it = | |
| 164 admixtures.begin(); | |
| 165 it != admixtures.end(); | |
| 166 ++it) { | |
| 167 (*it)->SetUpCommandLine(command_line); | |
| 168 } | |
| 169 | |
| 162 SetUpCommandLine(command_line); | 170 SetUpCommandLine(command_line); |
| 163 // Add command line arguments that are used by all InProcessBrowserTests. | 171 // Add command line arguments that are used by all InProcessBrowserTests. |
| 164 PrepareTestCommandLine(command_line); | 172 PrepareTestCommandLine(command_line); |
| 165 | 173 |
| 166 // Create a temporary user data directory if required. | 174 // Create a temporary user data directory if required. |
| 167 ASSERT_TRUE(CreateUserDataDirectory()) | 175 ASSERT_TRUE(CreateUserDataDirectory()) |
| 168 << "Could not create user data directory."; | 176 << "Could not create user data directory."; |
| 169 | 177 |
| 170 // Allow subclasses the opportunity to make changes to the default user data | 178 // Allow subclasses the opportunity to make changes to the default user data |
| 171 // dir before running any tests. | 179 // dir before running any tests. |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 412 // deallocation via an autorelease pool (such as browser window closure and | 420 // deallocation via an autorelease pool (such as browser window closure and |
| 413 // browser shutdown). To avoid this, the following pool is recycled after each | 421 // browser shutdown). To avoid this, the following pool is recycled after each |
| 414 // time code is directly executed. | 422 // time code is directly executed. |
| 415 autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool; | 423 autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool; |
| 416 #endif | 424 #endif |
| 417 | 425 |
| 418 // Pump any pending events that were created as a result of creating a | 426 // Pump any pending events that were created as a result of creating a |
| 419 // browser. | 427 // browser. |
| 420 content::RunAllPendingInMessageLoop(); | 428 content::RunAllPendingInMessageLoop(); |
| 421 | 429 |
| 430 std::vector<BrowserTestBase::Admixture*> admixtures = GetAdmixtures(); | |
| 431 for (std::vector<BrowserTestBase::Admixture*>::iterator it = | |
| 432 admixtures.begin(); | |
| 433 it != admixtures.end(); | |
| 434 ++it) { | |
| 435 (*it)->SetUpInProcessBrowserTestFixture(); | |
|
dzhioev (left Google)
2014/08/18 12:11:46
We should call SetUpOnMainThread here, not SetUpIn
Lisa Ignatyeva
2014/08/18 12:20:41
Done.
| |
| 436 } | |
| 422 SetUpOnMainThread(); | 437 SetUpOnMainThread(); |
| 423 #if defined(OS_MACOSX) | 438 #if defined(OS_MACOSX) |
| 424 autorelease_pool_->Recycle(); | 439 autorelease_pool_->Recycle(); |
| 425 #endif | 440 #endif |
| 426 | 441 |
| 427 if (!HasFatalFailure()) | 442 if (!HasFatalFailure()) |
| 428 RunTestOnMainThread(); | 443 RunTestOnMainThread(); |
| 429 #if defined(OS_MACOSX) | 444 #if defined(OS_MACOSX) |
| 430 autorelease_pool_->Recycle(); | 445 autorelease_pool_->Recycle(); |
| 431 #endif | 446 #endif |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 473 // On the Mac, this eventually reaches | 488 // On the Mac, this eventually reaches |
| 474 // -[BrowserWindowController windowWillClose:], which will post a deferred | 489 // -[BrowserWindowController windowWillClose:], which will post a deferred |
| 475 // -autorelease on itself to ultimately destroy the Browser object. The line | 490 // -autorelease on itself to ultimately destroy the Browser object. The line |
| 476 // below is necessary to pump these pending messages to ensure all Browsers | 491 // below is necessary to pump these pending messages to ensure all Browsers |
| 477 // get deleted. | 492 // get deleted. |
| 478 content::RunAllPendingInMessageLoop(); | 493 content::RunAllPendingInMessageLoop(); |
| 479 delete autorelease_pool_; | 494 delete autorelease_pool_; |
| 480 autorelease_pool_ = NULL; | 495 autorelease_pool_ = NULL; |
| 481 #endif | 496 #endif |
| 482 } | 497 } |
| OLD | NEW |