Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(303)

Side by Side Diff: chrome/browser/ui/cocoa/browser_test_helper.cc

Issue 6627060: ImportantFileWriter: check return value of PostTask... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_->CreateTemplateURLModel(); 21 profile_->CreateTemplateURLModel();
22 22
23 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get())); 23 browser_.reset(new Browser(Browser::TYPE_NORMAL, profile_.get()));
24 } 24 }
25 25
26 BrowserTestHelper::~BrowserTestHelper() { 26 BrowserTestHelper::~BrowserTestHelper() {
27 // 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
28 // browser, since it may trigger accesses to the profile upon destruction. 28 // browser, since it may trigger accesses to the profile upon destruction.
29 browser_.reset(); 29 browser_.reset();
30 message_loop_.DeleteSoon(FROM_HERE, profile_.release());
31
32 // Make sure any pending tasks run before we destroy other threads.
33 message_loop_.RunAllPending();
30 34
31 // Drop any new tasks for the IO and FILE threads. 35 // Drop any new tasks for the IO and FILE threads.
32 io_thread_.reset(); 36 io_thread_.reset();
33 file_thread_.reset(); 37 file_thread_.reset();
34 38
35 message_loop_.DeleteSoon(FROM_HERE, profile_.release());
36 message_loop_.RunAllPending(); 39 message_loop_.RunAllPending();
37 } 40 }
38 41
39 TestingProfile* BrowserTestHelper::profile() const { 42 TestingProfile* BrowserTestHelper::profile() const {
40 return profile_.get(); 43 return profile_.get();
41 } 44 }
42 45
43 BrowserWindow* BrowserTestHelper::CreateBrowserWindow() { 46 BrowserWindow* BrowserTestHelper::CreateBrowserWindow() {
44 browser_->CreateBrowserWindow(); 47 browser_->CreateBrowserWindow();
45 return browser_->window(); 48 return browser_->window();
46 } 49 }
47 50
48 void BrowserTestHelper::CloseBrowserWindow() { 51 void BrowserTestHelper::CloseBrowserWindow() {
49 // Check to make sure a window was actually created. 52 // Check to make sure a window was actually created.
50 DCHECK(browser_->window()); 53 DCHECK(browser_->window());
51 browser_->CloseAllTabs(); 54 browser_->CloseAllTabs();
52 browser_->CloseWindow(); 55 browser_->CloseWindow();
53 // |browser_| will be deleted by its BrowserWindowController. 56 // |browser_| will be deleted by its BrowserWindowController.
54 ignore_result(browser_.release()); 57 ignore_result(browser_.release());
55 } 58 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_setup_wizard_unittest.cc ('k') | chrome/browser/ui/views/bookmarks/bookmark_bar_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698