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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 aura_test_helper_->SetUp(); | 73 aura_test_helper_->SetUp(); |
74 new wm::DefaultActivationClient(aura_test_helper_->root_window()); | 74 new wm::DefaultActivationClient(aura_test_helper_->root_window()); |
75 #endif // USE_AURA | 75 #endif // USE_AURA |
76 #if defined(TOOLKIT_VIEWS) | 76 #if defined(TOOLKIT_VIEWS) |
77 views_delegate_.reset(CreateViewsDelegate()); | 77 views_delegate_.reset(CreateViewsDelegate()); |
78 views::ViewsDelegate::views_delegate = views_delegate_.get(); | 78 views::ViewsDelegate::views_delegate = views_delegate_.get(); |
79 #endif | 79 #endif |
80 | 80 |
81 // Subclasses can provide their own Profile. | 81 // Subclasses can provide their own Profile. |
82 profile_ = CreateProfile(); | 82 profile_ = CreateProfile(); |
83 | |
84 CustomizeServiceFactories(); | |
85 | |
83 // Subclasses can provide their own test BrowserWindow. If they return NULL | 86 // Subclasses can provide their own test BrowserWindow. If they return NULL |
84 // then Browser will create the a production BrowserWindow and the subclass | 87 // then Browser will create the a production BrowserWindow and the subclass |
85 // is responsible for cleaning it up (usually by NativeWidget destruction). | 88 // is responsible for cleaning it up (usually by NativeWidget destruction). |
86 window_.reset(CreateBrowserWindow()); | 89 window_.reset(CreateBrowserWindow()); |
87 | 90 |
88 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, | 91 browser_.reset(CreateBrowser(profile(), browser_type_, hosted_app_, |
89 host_desktop_type_, window_.get())); | 92 host_desktop_type_, window_.get())); |
90 } | 93 } |
91 | 94 |
92 void BrowserWithTestWindowTest::TearDown() { | 95 void BrowserWithTestWindowTest::TearDown() { |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
206 // subclass to free it after the profile. | 209 // subclass to free it after the profile. |
207 if (profile_) | 210 if (profile_) |
208 DestroyProfile(profile_); | 211 DestroyProfile(profile_); |
209 profile_ = NULL; | 212 profile_ = NULL; |
210 } | 213 } |
211 | 214 |
212 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { | 215 TestingProfile* BrowserWithTestWindowTest::CreateProfile() { |
213 return new TestingProfile(); | 216 return new TestingProfile(); |
214 } | 217 } |
215 | 218 |
219 void BrowserWithTestWindowTest::CustomizeServiceFactories() { | |
Paweł Hajdan Jr.
2014/05/05 11:28:09
Why not just override CreateProfile?
| |
220 } | |
221 | |
216 void BrowserWithTestWindowTest::DestroyProfile(TestingProfile* profile) { | 222 void BrowserWithTestWindowTest::DestroyProfile(TestingProfile* profile) { |
217 delete profile; | 223 delete profile; |
218 } | 224 } |
219 | 225 |
220 BrowserWindow* BrowserWithTestWindowTest::CreateBrowserWindow() { | 226 BrowserWindow* BrowserWithTestWindowTest::CreateBrowserWindow() { |
221 return new TestBrowserWindow(); | 227 return new TestBrowserWindow(); |
222 } | 228 } |
223 | 229 |
224 Browser* BrowserWithTestWindowTest::CreateBrowser( | 230 Browser* BrowserWithTestWindowTest::CreateBrowser( |
225 Profile* profile, | 231 Profile* profile, |
(...skipping 13 matching lines...) Expand all Loading... | |
239 } | 245 } |
240 params.window = browser_window; | 246 params.window = browser_window; |
241 return new Browser(params); | 247 return new Browser(params); |
242 } | 248 } |
243 | 249 |
244 #if defined(TOOLKIT_VIEWS) | 250 #if defined(TOOLKIT_VIEWS) |
245 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { | 251 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { |
246 return new views::TestViewsDelegate; | 252 return new views::TestViewsDelegate; |
247 } | 253 } |
248 #endif | 254 #endif |
OLD | NEW |