| 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/browser_with_test_window_test.h" | 5 #include "chrome/test/base/browser_with_test_window_test.h" |
| 6 | 6 |
| 7 #include "ash/common/material_design/material_design_controller.h" | 7 #include "ash/common/material_design/material_design_controller.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/single_thread_task_runner.h" | 10 #include "base/single_thread_task_runner.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 | 74 |
| 75 // Subclasses can provide their own Profile. | 75 // Subclasses can provide their own Profile. |
| 76 profile_ = CreateProfile(); | 76 profile_ = CreateProfile(); |
| 77 // Subclasses can provide their own test BrowserWindow. If they return NULL | 77 // Subclasses can provide their own test BrowserWindow. If they return NULL |
| 78 // then Browser will create the a production BrowserWindow and the subclass | 78 // then Browser will create the a production BrowserWindow and the subclass |
| 79 // is responsible for cleaning it up (usually by NativeWidget destruction). | 79 // is responsible for cleaning it up (usually by NativeWidget destruction). |
| 80 window_.reset(CreateBrowserWindow()); | 80 window_.reset(CreateBrowserWindow()); |
| 81 | 81 |
| 82 browser_.reset( | 82 browser_.reset( |
| 83 CreateBrowser(profile(), browser_type_, hosted_app_, window_.get())); | 83 CreateBrowser(profile(), browser_type_, hosted_app_, window_.get())); |
| 84 |
| 85 rvh_test_enabler_.SetUp(); |
| 84 } | 86 } |
| 85 | 87 |
| 86 void BrowserWithTestWindowTest::TearDown() { | 88 void BrowserWithTestWindowTest::TearDown() { |
| 87 // Some tests end up posting tasks to the DB thread that must be completed | 89 // Some tests end up posting tasks to the DB thread that must be completed |
| 88 // before the profile can be destroyed and the test safely shut down. | 90 // before the profile can be destroyed and the test safely shut down. |
| 89 base::RunLoop().RunUntilIdle(); | 91 base::RunLoop().RunUntilIdle(); |
| 90 | 92 |
| 91 // Reset the profile here because some profile keyed services (like the | 93 // Reset the profile here because some profile keyed services (like the |
| 92 // audio service) depend on test stubs that the helpers below will remove. | 94 // audio service) depend on test stubs that the helpers below will remove. |
| 93 DestroyBrowserAndProfile(); | 95 DestroyBrowserAndProfile(); |
| 94 | 96 |
| 95 if (content::IsBrowserSideNavigationEnabled()) | 97 if (content::IsBrowserSideNavigationEnabled()) |
| 96 content::BrowserSideNavigationTearDown(); | 98 content::BrowserSideNavigationTearDown(); |
| 97 | 99 |
| 98 #if defined(TOOLKIT_VIEWS) | 100 #if defined(TOOLKIT_VIEWS) |
| 99 constrained_window::SetConstrainedWindowViewsClient(nullptr); | 101 constrained_window::SetConstrainedWindowViewsClient(nullptr); |
| 100 #endif | 102 #endif |
| 101 | 103 |
| 102 #if defined(OS_CHROMEOS) | 104 #if defined(OS_CHROMEOS) |
| 103 ash_test_helper_->TearDown(); | 105 ash_test_helper_->TearDown(); |
| 104 #elif defined(TOOLKIT_VIEWS) | 106 #elif defined(TOOLKIT_VIEWS) |
| 105 views_test_helper_.reset(); | 107 views_test_helper_.reset(); |
| 106 #endif | 108 #endif |
| 107 | 109 |
| 110 rvh_test_enabler_.TearDown(); |
| 111 |
| 108 testing::Test::TearDown(); | 112 testing::Test::TearDown(); |
| 109 | 113 |
| 110 // A Task is leaked if we don't destroy everything, then run the message | 114 // A Task is leaked if we don't destroy everything, then run the message |
| 111 // loop. | 115 // loop. |
| 112 base::ThreadTaskRunnerHandle::Get()->PostTask( | 116 base::ThreadTaskRunnerHandle::Get()->PostTask( |
| 113 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); | 117 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); |
| 114 base::RunLoop().Run(); | 118 base::RunLoop().Run(); |
| 115 } | 119 } |
| 116 | 120 |
| 117 gfx::NativeWindow BrowserWithTestWindowTest::GetContext() { | 121 gfx::NativeWindow BrowserWithTestWindowTest::GetContext() { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 Browser::CreateParams params(profile); | 206 Browser::CreateParams params(profile); |
| 203 if (hosted_app) { | 207 if (hosted_app) { |
| 204 params = Browser::CreateParams::CreateForApp( | 208 params = Browser::CreateParams::CreateForApp( |
| 205 "Test", true /* trusted_source */, gfx::Rect(), profile); | 209 "Test", true /* trusted_source */, gfx::Rect(), profile); |
| 206 } else { | 210 } else { |
| 207 params.type = browser_type; | 211 params.type = browser_type; |
| 208 } | 212 } |
| 209 params.window = browser_window; | 213 params.window = browser_window; |
| 210 return new Browser(params); | 214 return new Browser(params); |
| 211 } | 215 } |
| OLD | NEW |