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 "base/run_loop.h" | 7 #include "base/run_loop.h" |
8 #include "chrome/browser/profiles/profile_destroyer.h" | 8 #include "chrome/browser/profiles/profile_destroyer.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
10 #include "chrome/browser/ui/browser_navigator.h" | 10 #include "chrome/browser/ui/browser_navigator.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 aura_test_helper_->SetUp(); | 58 aura_test_helper_->SetUp(); |
59 #endif // USE_AURA | 59 #endif // USE_AURA |
60 | 60 |
61 // Subclasses can provide their own Profile. | 61 // Subclasses can provide their own Profile. |
62 profile_ = CreateProfile(); | 62 profile_ = CreateProfile(); |
63 // Subclasses can provide their own test BrowserWindow. If they return NULL | 63 // Subclasses can provide their own test BrowserWindow. If they return NULL |
64 // then Browser will create the a production BrowserWindow and the subclass | 64 // then Browser will create the a production BrowserWindow and the subclass |
65 // is responsible for cleaning it up (usually by NativeWidget destruction). | 65 // is responsible for cleaning it up (usually by NativeWidget destruction). |
66 window_.reset(CreateBrowserWindow()); | 66 window_.reset(CreateBrowserWindow()); |
67 | 67 |
68 Browser::CreateParams params(profile(), host_desktop_type_); | 68 browser_.reset(CreateBrowser(profile(), host_desktop_type_, window_.get())); |
69 params.window = window_.get(); | |
70 browser_.reset(new Browser(params)); | |
71 } | 69 } |
72 | 70 |
73 void BrowserWithTestWindowTest::TearDown() { | 71 void BrowserWithTestWindowTest::TearDown() { |
74 // Some tests end up posting tasks to the DB thread that must be completed | 72 // Some tests end up posting tasks to the DB thread that must be completed |
75 // before the profile can be destroyed and the test safely shut down. | 73 // before the profile can be destroyed and the test safely shut down. |
76 base::RunLoop().RunUntilIdle(); | 74 base::RunLoop().RunUntilIdle(); |
77 | 75 |
78 // Reset the profile here because some profile keyed services (like the | 76 // Reset the profile here because some profile keyed services (like the |
79 // audio service) depend on test stubs that the helpers below will remove. | 77 // audio service) depend on test stubs that the helpers below will remove. |
80 DestroyBrowserAndProfile(); | 78 DestroyBrowserAndProfile(); |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 return new TestingProfile(); | 186 return new TestingProfile(); |
189 } | 187 } |
190 | 188 |
191 void BrowserWithTestWindowTest::DestroyProfile(TestingProfile* profile) { | 189 void BrowserWithTestWindowTest::DestroyProfile(TestingProfile* profile) { |
192 delete profile; | 190 delete profile; |
193 } | 191 } |
194 | 192 |
195 BrowserWindow* BrowserWithTestWindowTest::CreateBrowserWindow() { | 193 BrowserWindow* BrowserWithTestWindowTest::CreateBrowserWindow() { |
196 return new TestBrowserWindow(); | 194 return new TestBrowserWindow(); |
197 } | 195 } |
| 196 |
| 197 Browser* BrowserWithTestWindowTest::CreateBrowser( |
| 198 Profile* profile, |
| 199 chrome::HostDesktopType host_desktop_type, |
| 200 BrowserWindow* browser_window) { |
| 201 Browser::CreateParams params(profile, host_desktop_type); |
| 202 params.window = browser_window; |
| 203 return new Browser(params); |
| 204 } |
OLD | NEW |