| 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 |
| 23 browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); | 25 browser_.reset(new Browser(Browser::TYPE_TABBED, profile_.get())); |
| 24 } | 26 } |
| 25 | 27 |
| 26 BrowserTestHelper::~BrowserTestHelper() { | 28 BrowserTestHelper::~BrowserTestHelper() { |
| 27 // Delete the testing profile on the UI thread. But first release the | 29 // Delete the testing profile on the UI thread. But first release the |
| 28 // browser, since it may trigger accesses to the profile upon destruction. | 30 // browser, since it may trigger accesses to the profile upon destruction. |
| 29 browser_.reset(); | 31 browser_.reset(); |
| 30 message_loop_.DeleteSoon(FROM_HERE, profile_.release()); | 32 message_loop_.DeleteSoon(FROM_HERE, profile_.release()); |
| 31 | 33 |
| 32 // Make sure any pending tasks run before we destroy other threads. | 34 // Make sure any pending tasks run before we destroy other threads. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 49 } | 51 } |
| 50 | 52 |
| 51 void BrowserTestHelper::CloseBrowserWindow() { | 53 void BrowserTestHelper::CloseBrowserWindow() { |
| 52 // Check to make sure a window was actually created. | 54 // Check to make sure a window was actually created. |
| 53 DCHECK(browser_->window()); | 55 DCHECK(browser_->window()); |
| 54 browser_->CloseAllTabs(); | 56 browser_->CloseAllTabs(); |
| 55 browser_->CloseWindow(); | 57 browser_->CloseWindow(); |
| 56 // |browser_| will be deleted by its BrowserWindowController. | 58 // |browser_| will be deleted by its BrowserWindowController. |
| 57 ignore_result(browser_.release()); | 59 ignore_result(browser_.release()); |
| 58 } | 60 } |
| 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 |