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

Unified Diff: chrome/test/base/browser_with_test_window_test.cc

Issue 2804913002: mash: Test ChromeLauncherControllerImpl more like production use. (Closed)
Patch Set: Address comments. Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/test/base/browser_with_test_window_test.cc
diff --git a/chrome/test/base/browser_with_test_window_test.cc b/chrome/test/base/browser_with_test_window_test.cc
index 08a9dd7ab2e11003e9966c62b718e8181912b179..955e36b601937d4ed87c6bdd3635224d1fba5178 100644
--- a/chrome/test/base/browser_with_test_window_test.cc
+++ b/chrome/test/base/browser_with_test_window_test.cc
@@ -87,9 +87,11 @@ void BrowserWithTestWindowTest::TearDown() {
// before the profile can be destroyed and the test safely shut down.
base::RunLoop().RunUntilIdle();
- // Reset the profile here because some profile keyed services (like the
- // audio service) depend on test stubs that the helpers below will remove.
- DestroyBrowserAndProfile();
+ // Close the browser tabs and destroy the browser and window instances.
+ if (browser_)
+ browser_->tab_strip_model()->CloseAllTabs();
+ browser_.reset();
+ window_.reset();
if (content::IsBrowserSideNavigationEnabled())
content::BrowserSideNavigationTearDown();
@@ -99,15 +101,23 @@ void BrowserWithTestWindowTest::TearDown() {
#endif
#if defined(OS_CHROMEOS)
+ // Destroy the shell before the profile to match production shutdown ordering.
ash_test_helper_->TearDown();
#elif defined(TOOLKIT_VIEWS)
views_test_helper_.reset();
#endif
+ // Destroy the profile here - otherwise, if the profile is freed in the
+ // destructor, and a test subclass owns a resource that the profile depends
+ // on (such as g_browser_process()->local_state()) there's no way for the
+ // subclass to free it after the profile.
+ if (profile_)
+ DestroyProfile(profile_);
+ profile_ = nullptr;
+
testing::Test::TearDown();
- // A Task is leaked if we don't destroy everything, then run the message
- // loop.
+ // A Task is leaked if we don't destroy everything, then run the message loop.
base::ThreadTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
base::RunLoop().Run();
@@ -164,23 +174,6 @@ void BrowserWithTestWindowTest::NavigateAndCommitActiveTabWithTitle(
contents->UpdateTitleForEntry(controller->GetActiveEntry(), title);
}
-void BrowserWithTestWindowTest::DestroyBrowserAndProfile() {
- if (browser_.get()) {
- // Make sure we close all tabs, otherwise Browser isn't happy in its
- // destructor.
- browser()->tab_strip_model()->CloseAllTabs();
- browser_.reset(NULL);
- }
- window_.reset(NULL);
- // Destroy the profile here - otherwise, if the profile is freed in the
- // destructor, and a test subclass owns a resource that the profile depends
- // on (such as g_browser_process()->local_state()) there's no way for the
- // subclass to free it after the profile.
- if (profile_)
- DestroyProfile(profile_);
- profile_ = NULL;
-}
-
TestingProfile* BrowserWithTestWindowTest::CreateProfile() {
return new TestingProfile();
}
« no previous file with comments | « chrome/test/base/browser_with_test_window_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698