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/browser/ui/cocoa/cocoa_profile_test.h" | 5 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
6 | 6 |
7 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 7 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/search_engines/template_url_service_factory.h" | 9 #include "chrome/browser/search_engines/template_url_service_factory.h" |
10 #include "chrome/browser/ui/browser_commands.h" | 10 #include "chrome/browser/ui/browser_commands.h" |
11 #include "chrome/browser/ui/browser_tabstrip.h" | 11 #include "chrome/browser/ui/browser_tabstrip.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/test/base/testing_browser_process.h" | 13 #include "chrome/test/base/testing_browser_process.h" |
14 #include "content/public/test/test_browser_thread.h" | 14 #include "content/public/test/test_browser_thread.h" |
15 | 15 |
16 using content::BrowserThread; | 16 using content::BrowserThread; |
17 | 17 |
18 CocoaProfileTest::CocoaProfileTest() | 18 CocoaProfileTest::CocoaProfileTest() |
19 : ui_thread_(BrowserThread::UI, &message_loop_), | 19 : ui_thread_(BrowserThread::UI, &message_loop_), |
20 profile_manager_(static_cast<TestingBrowserProcess*>(g_browser_process)), | 20 profile_manager_(TestingBrowserProcess::GetGlobal()), |
21 profile_(NULL), | 21 profile_(NULL), |
22 file_user_blocking_thread_(new content::TestBrowserThread( | 22 file_user_blocking_thread_(new content::TestBrowserThread( |
23 BrowserThread::FILE_USER_BLOCKING, &message_loop_)), | 23 BrowserThread::FILE_USER_BLOCKING, &message_loop_)), |
24 file_thread_(new content::TestBrowserThread(BrowserThread::FILE, | 24 file_thread_(new content::TestBrowserThread(BrowserThread::FILE, |
25 &message_loop_)), | 25 &message_loop_)), |
26 io_thread_(new content::TestBrowserThread(BrowserThread::IO, | 26 io_thread_(new content::TestBrowserThread(BrowserThread::IO, |
27 &message_loop_)) { | 27 &message_loop_)) { |
28 } | 28 } |
29 | 29 |
30 CocoaProfileTest::~CocoaProfileTest() { | 30 CocoaProfileTest::~CocoaProfileTest() { |
31 // Delete the testing profile on the UI thread. But first release the | 31 // Delete the testing profile on the UI thread. But first release the |
32 // browser, since it may trigger accesses to the profile upon destruction. | 32 // browser, since it may trigger accesses to the profile upon destruction. |
33 browser_.reset(); | 33 browser_.reset(); |
34 | 34 |
35 message_loop_.RunUntilIdle(); | 35 message_loop_.RunUntilIdle(); |
36 // Some services created on the TestingProfile require deletion on the UI | 36 // Some services created on the TestingProfile require deletion on the UI |
37 // thread. If the scoper in TestingBrowserProcess, owned by ChromeTestSuite, | 37 // thread. If the scoper in TestingBrowserProcess, owned by ChromeTestSuite, |
38 // were to delete the ProfileManager, the UI thread would at that point no | 38 // were to delete the ProfileManager, the UI thread would at that point no |
39 // longer exist. | 39 // longer exist. |
40 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( | 40 TestingBrowserProcess::GetGlobal()->SetProfileManager( |
41 NULL); | 41 NULL); |
42 | 42 |
43 // Make sure any pending tasks run before we destroy other threads. | 43 // Make sure any pending tasks run before we destroy other threads. |
44 message_loop_.RunUntilIdle(); | 44 message_loop_.RunUntilIdle(); |
45 | 45 |
46 // Drop any new tasks for the IO and FILE threads. | 46 // Drop any new tasks for the IO and FILE threads. |
47 io_thread_.reset(); | 47 io_thread_.reset(); |
48 file_user_blocking_thread_.reset(); | 48 file_user_blocking_thread_.reset(); |
49 file_thread_.reset(); | 49 file_thread_.reset(); |
50 | 50 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 DCHECK(browser_->window()); | 88 DCHECK(browser_->window()); |
89 browser_->tab_strip_model()->CloseAllTabs(); | 89 browser_->tab_strip_model()->CloseAllTabs(); |
90 chrome::CloseWindow(browser_.get()); | 90 chrome::CloseWindow(browser_.get()); |
91 // |browser_| will be deleted by its BrowserWindowController. | 91 // |browser_| will be deleted by its BrowserWindowController. |
92 ignore_result(browser_.release()); | 92 ignore_result(browser_.release()); |
93 } | 93 } |
94 | 94 |
95 Browser* CocoaProfileTest::CreateBrowser() { | 95 Browser* CocoaProfileTest::CreateBrowser() { |
96 return new Browser(Browser::CreateParams(profile())); | 96 return new Browser(Browser::CreateParams(profile())); |
97 } | 97 } |
OLD | NEW |