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

Side by Side Diff: chrome/browser/ui/cocoa/cocoa_profile_test.mm

Issue 24120005: Cleanup and IWYU-ify CocoaProfileTest and related tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: include order Created 7 years, 3 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) 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/browser/ui/cocoa/cocoa_profile_test.h" 5 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
6 6
7 #include "base/run_loop.h"
7 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 8 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
8 #include "chrome/browser/bookmarks/bookmark_test_helpers.h" 9 #include "chrome/browser/bookmarks/bookmark_test_helpers.h"
9 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/search_engines/template_url_service_factory.h" 11 #include "chrome/browser/search_engines/template_url_service_factory.h"
12 #include "chrome/browser/ui/browser.h"
11 #include "chrome/browser/ui/browser_commands.h" 13 #include "chrome/browser/ui/browser_commands.h"
12 #include "chrome/browser/ui/browser_tabstrip.h" 14 #include "chrome/browser/ui/browser_tabstrip.h"
13 #include "chrome/browser/ui/host_desktop.h" 15 #include "chrome/browser/ui/host_desktop.h"
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" 16 #include "chrome/browser/ui/tabs/tab_strip_model.h"
15 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
16 #include "content/public/test/test_browser_thread.h" 18 #include "chrome/test/base/testing_profile.h"
17 19 #include "content/public/test/test_browser_thread_bundle.h"
18 using content::BrowserThread;
19 20
20 CocoaProfileTest::CocoaProfileTest() 21 CocoaProfileTest::CocoaProfileTest()
21 : ui_thread_(BrowserThread::UI, &message_loop_), 22 : profile_manager_(TestingBrowserProcess::GetGlobal()),
22 profile_manager_(TestingBrowserProcess::GetGlobal()),
23 profile_(NULL), 23 profile_(NULL),
24 file_user_blocking_thread_(new content::TestBrowserThread( 24 thread_bundle_(new content::TestBrowserThreadBundle) {}
25 BrowserThread::FILE_USER_BLOCKING, &message_loop_)),
26 file_thread_(new content::TestBrowserThread(BrowserThread::FILE,
27 &message_loop_)),
28 io_thread_(new content::TestBrowserThread(BrowserThread::IO,
29 &message_loop_)) {
30 }
31 25
32 CocoaProfileTest::~CocoaProfileTest() { 26 CocoaProfileTest::~CocoaProfileTest() {
33 // 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
34 // browser, since it may trigger accesses to the profile upon destruction. 28 // browser, since it may trigger accesses to the profile upon destruction.
35 browser_.reset(); 29 browser_.reset();
36 30
37 message_loop_.RunUntilIdle(); 31 base::RunLoop().RunUntilIdle();
32
38 // Some services created on the TestingProfile require deletion on the UI 33 // Some services created on the TestingProfile require deletion on the UI
39 // thread. If the scoper in TestingBrowserProcess, owned by ChromeTestSuite, 34 // thread. If the scoper in TestingBrowserProcess, owned by ChromeTestSuite,
40 // were to delete the ProfileManager, the UI thread would at that point no 35 // were to delete the ProfileManager, the UI thread would at that point no
41 // longer exist. 36 // longer exist.
42 TestingBrowserProcess::GetGlobal()->SetProfileManager( 37 TestingBrowserProcess::GetGlobal()->SetProfileManager(NULL);
43 NULL);
44 38
45 // Make sure any pending tasks run before we destroy other threads. 39 // Make sure any pending tasks run before we destroy other threads.
46 message_loop_.RunUntilIdle(); 40 base::RunLoop().RunUntilIdle();
47
48 // Drop any new tasks for the IO and FILE threads.
49 io_thread_.reset();
50 file_user_blocking_thread_.reset();
51 file_thread_.reset();
52
53 message_loop_.RunUntilIdle();
54 } 41 }
55 42
56 void CocoaProfileTest::SetUp() { 43 void CocoaProfileTest::SetUp() {
57 CocoaTest::SetUp(); 44 CocoaTest::SetUp();
58 45
59 ASSERT_TRUE(profile_manager_.SetUp()); 46 ASSERT_TRUE(profile_manager_.SetUp());
60 47
61 profile_ = profile_manager_.CreateTestingProfile("default"); 48 profile_ = profile_manager_.CreateTestingProfile("default");
62 ASSERT_TRUE(profile_); 49 ASSERT_TRUE(profile_);
63 50
(...skipping 27 matching lines...) Expand all
91 browser_->tab_strip_model()->CloseAllTabs(); 78 browser_->tab_strip_model()->CloseAllTabs();
92 chrome::CloseWindow(browser_.get()); 79 chrome::CloseWindow(browser_.get());
93 // |browser_| will be deleted by its BrowserWindowController. 80 // |browser_| will be deleted by its BrowserWindowController.
94 ignore_result(browser_.release()); 81 ignore_result(browser_.release());
95 } 82 }
96 83
97 Browser* CocoaProfileTest::CreateBrowser() { 84 Browser* CocoaProfileTest::CreateBrowser() {
98 return new Browser(Browser::CreateParams(profile(), 85 return new Browser(Browser::CreateParams(profile(),
99 chrome::GetActiveDesktop())); 86 chrome::GetActiveDesktop()));
100 } 87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698