OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/browser/ui/cocoa/browser_test_helper.h" | 5 #include "chrome/browser/ui/cocoa/browser_test_helper.h" |
6 | 6 |
7 BrowserTestHelper::BrowserTestHelper() | 7 BrowserTestHelper::BrowserTestHelper() |
8 : ui_thread_(BrowserThread::UI, &message_loop_), | 8 : ui_thread_(BrowserThread::UI, &message_loop_), |
9 file_thread_(new BrowserThread(BrowserThread::FILE, &message_loop_)), | 9 file_thread_(new BrowserThread(BrowserThread::FILE, &message_loop_)), |
10 io_thread_(new BrowserThread(BrowserThread::IO, &message_loop_)) { | 10 io_thread_(new BrowserThread(BrowserThread::IO, &message_loop_)) { |
11 profile_.reset(new TestingProfile()); | 11 profile_.reset(new TestingProfile()); |
12 profile_->CreateBookmarkModel(true); | 12 profile_->CreateBookmarkModel(true); |
13 profile_->BlockUntilBookmarkModelLoaded(); | 13 profile_->BlockUntilBookmarkModelLoaded(); |
14 | 14 |
15 // TODO(shess): These are needed in case someone creates a browser | 15 // TODO(shess): These are needed in case someone creates a browser |
16 // window off of browser_. pkasting indicates that other | 16 // window off of browser_. pkasting indicates that other |
17 // platforms use a stub |BrowserWindow| and thus don't need to do | 17 // platforms use a stub |BrowserWindow| and thus don't need to do |
18 // this. | 18 // this. |
19 // http://crbug.com/39725 | 19 // http://crbug.com/39725 |
20 profile_->CreateAutocompleteClassifier(); | 20 profile_->CreateAutocompleteClassifier(); |
21 profile_->CreateTemplateURLService(); | 21 profile_->CreateTemplateURLService(); |
22 | 22 |
23 SetUpProfileManager(); | |
24 | |
25 browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); | 23 browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); |
26 } | 24 } |
27 | 25 |
28 BrowserTestHelper::~BrowserTestHelper() { | 26 BrowserTestHelper::~BrowserTestHelper() { |
29 // Delete the testing profile on the UI thread. But first release the | 27 // Delete the testing profile on the UI thread. But first release the |
30 // browser, since it may trigger accesses to the profile upon destruction. | 28 // browser, since it may trigger accesses to the profile upon destruction. |
31 browser_.reset(); | 29 browser_.reset(); |
32 message_loop_.DeleteSoon(FROM_HERE, profile_.release()); | 30 message_loop_.DeleteSoon(FROM_HERE, profile_.release()); |
33 | 31 |
34 // Make sure any pending tasks run before we destroy other threads. | 32 // Make sure any pending tasks run before we destroy other threads. |
(...skipping 16 matching lines...) Expand all Loading... |
51 } | 49 } |
52 | 50 |
53 void BrowserTestHelper::CloseBrowserWindow() { | 51 void BrowserTestHelper::CloseBrowserWindow() { |
54 // Check to make sure a window was actually created. | 52 // Check to make sure a window was actually created. |
55 DCHECK(browser_->window()); | 53 DCHECK(browser_->window()); |
56 browser_->CloseAllTabs(); | 54 browser_->CloseAllTabs(); |
57 browser_->CloseWindow(); | 55 browser_->CloseWindow(); |
58 // |browser_| will be deleted by its BrowserWindowController. | 56 // |browser_| will be deleted by its BrowserWindowController. |
59 ignore_result(browser_.release()); | 57 ignore_result(browser_.release()); |
60 } | 58 } |
61 | |
62 void BrowserTestHelper::SetUpProfileManager() { | |
63 profile_manager_ = new TestingProfileManager; // Owned by browser_process_. | |
64 browser_process()->SetProfileManager(profile_manager_); | |
65 | |
66 profile_info_.reset(profile_manager_->CreateFakeInfo("Testing Profile")); | |
67 profile_manager_->AddTestingProfile(profile(), profile_info_.get()); | |
68 } | |
OLD | NEW |