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

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: fixed teardown 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
« no previous file with comments | « no previous file | content/public/test/browser_test_base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 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 }
162 SetUpCommandLine(command_line); 169 SetUpCommandLine(command_line);
163 // Add command line arguments that are used by all InProcessBrowserTests. 170 // Add command line arguments that are used by all InProcessBrowserTests.
164 PrepareTestCommandLine(command_line); 171 PrepareTestCommandLine(command_line);
165 172
166 // Create a temporary user data directory if required. 173 // Create a temporary user data directory if required.
167 ASSERT_TRUE(CreateUserDataDirectory()) 174 ASSERT_TRUE(CreateUserDataDirectory())
168 << "Could not create user data directory."; 175 << "Could not create user data directory.";
169 176
170 // Allow subclasses the opportunity to make changes to the default user data 177 // Allow subclasses the opportunity to make changes to the default user data
171 // dir before running any tests. 178 // dir before running any tests.
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 // deallocation via an autorelease pool (such as browser window closure and 419 // deallocation via an autorelease pool (such as browser window closure and
413 // browser shutdown). To avoid this, the following pool is recycled after each 420 // browser shutdown). To avoid this, the following pool is recycled after each
414 // time code is directly executed. 421 // time code is directly executed.
415 autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool; 422 autorelease_pool_ = new base::mac::ScopedNSAutoreleasePool;
416 #endif 423 #endif
417 424
418 // Pump any pending events that were created as a result of creating a 425 // Pump any pending events that were created as a result of creating a
419 // browser. 426 // browser.
420 content::RunAllPendingInMessageLoop(); 427 content::RunAllPendingInMessageLoop();
421 428
429 std::vector<BrowserTestBase::Admixture*> admixtures = GetAdmixtures();
430 for (std::vector<BrowserTestBase::Admixture*>::iterator it =
431 admixtures.begin();
432 it != admixtures.end();
433 ++it) {
434 (*it)->SetUpOnMainThread();
435 }
422 SetUpOnMainThread(); 436 SetUpOnMainThread();
423 #if defined(OS_MACOSX) 437 #if defined(OS_MACOSX)
424 autorelease_pool_->Recycle(); 438 autorelease_pool_->Recycle();
425 #endif 439 #endif
426 440
427 if (!HasFatalFailure()) 441 if (!HasFatalFailure())
428 RunTestOnMainThread(); 442 RunTestOnMainThread();
429 #if defined(OS_MACOSX) 443 #if defined(OS_MACOSX)
430 autorelease_pool_->Recycle(); 444 autorelease_pool_->Recycle();
431 #endif 445 #endif
432 446
433 // Invoke cleanup and quit even if there are failures. This is similar to 447 // Invoke cleanup and quit even if there are failures. This is similar to
434 // gtest in that it invokes TearDown even if Setup fails. 448 // gtest in that it invokes TearDown even if Setup fails.
435 TearDownOnMainThread(); 449 TearDownOnMainThread();
450 for (std::vector<BrowserTestBase::Admixture*>::reverse_iterator it =
451 admixtures.rbegin();
452 it != admixtures.rend();
453 ++it) {
454 (*it)->TearDownOnMainThread();
455 }
436 #if defined(OS_MACOSX) 456 #if defined(OS_MACOSX)
437 autorelease_pool_->Recycle(); 457 autorelease_pool_->Recycle();
438 #endif 458 #endif
439 459
440 // Sometimes tests leave Quit tasks in the MessageLoop (for shame), so let's 460 // Sometimes tests leave Quit tasks in the MessageLoop (for shame), so let's
441 // run all pending messages here to avoid preempting the QuitBrowsers tasks. 461 // run all pending messages here to avoid preempting the QuitBrowsers tasks.
442 // TODO(jbates) Once crbug.com/134753 is fixed, this can be removed because it 462 // TODO(jbates) Once crbug.com/134753 is fixed, this can be removed because it
443 // will not be possible to post Quit tasks. 463 // will not be possible to post Quit tasks.
444 content::RunAllPendingInMessageLoop(); 464 content::RunAllPendingInMessageLoop();
445 465
(...skipping 27 matching lines...) Expand all
473 // On the Mac, this eventually reaches 493 // On the Mac, this eventually reaches
474 // -[BrowserWindowController windowWillClose:], which will post a deferred 494 // -[BrowserWindowController windowWillClose:], which will post a deferred
475 // -autorelease on itself to ultimately destroy the Browser object. The line 495 // -autorelease on itself to ultimately destroy the Browser object. The line
476 // below is necessary to pump these pending messages to ensure all Browsers 496 // below is necessary to pump these pending messages to ensure all Browsers
477 // get deleted. 497 // get deleted.
478 content::RunAllPendingInMessageLoop(); 498 content::RunAllPendingInMessageLoop();
479 delete autorelease_pool_; 499 delete autorelease_pool_;
480 autorelease_pool_ = NULL; 500 autorelease_pool_ = NULL;
481 #endif 501 #endif
482 } 502 }
OLDNEW
« no previous file with comments | « no previous file | content/public/test/browser_test_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698