Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: chrome/test/base/in_process_browser_test.cc

Issue 468493003: Admixtures in BrowserTestBase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: minor style fixes Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 ScopedVector<BrowserTestBase::Admixture> admixtures = GetAdmixtures();
163 for (ScopedVector<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.
180 for (ScopedVector<BrowserTestBase::Admixture>::iterator it =
181 admixtures.begin();
182 it != admixtures.end();
183 ++it) {
184 ASSERT_TRUE((*it)->SetUpUserDataDirectory())
185 << "Could not set up user data directory.";
186 }
187 BrowserTestBase::ReturnAdmixtures(admixtures.Pass());
172 ASSERT_TRUE(SetUpUserDataDirectory()) 188 ASSERT_TRUE(SetUpUserDataDirectory())
173 << "Could not set up user data directory."; 189 << "Could not set up user data directory.";
174 190
175 #if defined(OS_CHROMEOS) 191 #if defined(OS_CHROMEOS)
176 // Make sure that the log directory exists. 192 // Make sure that the log directory exists.
177 base::FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName(); 193 base::FilePath log_dir = logging::GetSessionLogFile(*command_line).DirName();
178 base::CreateDirectory(log_dir); 194 base::CreateDirectory(log_dir);
179 #endif // defined(OS_CHROMEOS) 195 #endif // defined(OS_CHROMEOS)
180 196
181 #if defined(OS_MACOSX) 197 #if defined(OS_MACOSX)
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // deallocation via an autorelease pool (such as browser window closure and 428 // deallocation via an autorelease pool (such as browser window closure and
413 // browser shutdown). To avoid this, the following pool is recycled after each 429 // browser shutdown). To avoid this, the following pool is recycled after each
414 // time code is directly executed. 430 // time code is directly executed.
415 autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool; 431 autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool;
416 #endif 432 #endif
417 433
418 // Pump any pending events that were created as a result of creating a 434 // Pump any pending events that were created as a result of creating a
419 // browser. 435 // browser.
420 content::RunAllPendingInMessageLoop(); 436 content::RunAllPendingInMessageLoop();
421 437
438 ScopedVector<BrowserTestBase::Admixture> admixtures = GetAdmixtures();
439 for (ScopedVector<BrowserTestBase::Admixture>::iterator it =
440 admixtures.begin();
441 it != admixtures.end();
442 ++it) {
443 (*it)->SetUpInProcessBrowserTestFixture();
444 }
445 BrowserTestBase::ReturnAdmixtures(admixtures.Pass());
422 SetUpOnMainThread(); 446 SetUpOnMainThread();
423 #if defined(OS_MACOSX) 447 #if defined(OS_MACOSX)
424 autorelease_pool_->Recycle(); 448 autorelease_pool_->Recycle();
425 #endif 449 #endif
426 450
427 if (!HasFatalFailure()) 451 if (!HasFatalFailure())
428 RunTestOnMainThread(); 452 RunTestOnMainThread();
429 #if defined(OS_MACOSX) 453 #if defined(OS_MACOSX)
430 autorelease_pool_->Recycle(); 454 autorelease_pool_->Recycle();
431 #endif 455 #endif
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 // On the Mac, this eventually reaches 497 // On the Mac, this eventually reaches
474 // -[BrowserWindowController windowWillClose:], which will post a deferred 498 // -[BrowserWindowController windowWillClose:], which will post a deferred
475 // -autorelease on itself to ultimately destroy the Browser object. The line 499 // -autorelease on itself to ultimately destroy the Browser object. The line
476 // below is necessary to pump these pending messages to ensure all Browsers 500 // below is necessary to pump these pending messages to ensure all Browsers
477 // get deleted. 501 // get deleted.
478 content::RunAllPendingInMessageLoop(); 502 content::RunAllPendingInMessageLoop();
479 delete autorelease_pool_; 503 delete autorelease_pool_;
480 autorelease_pool_ = NULL; 504 autorelease_pool_ = NULL;
481 #endif 505 #endif
482 } 506 }
OLDNEW
« no previous file with comments | « no previous file | content/public/test/browser_test_base.h » ('j') | content/public/test/browser_test_base.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698