| 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/cocoa_profile_test.h" | 5 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/test/base/testing_browser_process.h" | 8 #include "chrome/test/base/testing_browser_process.h" |
| 9 #include "content/test/test_browser_thread.h" | 9 #include "content/test/test_browser_thread.h" |
| 10 | 10 |
| 11 using content::BrowserThread; | 11 using content::BrowserThread; |
| 12 | 12 |
| 13 CocoaProfileTest::CocoaProfileTest() | 13 CocoaProfileTest::CocoaProfileTest() |
| 14 : ui_thread_(BrowserThread::UI, &message_loop_), | 14 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 15 profile_manager_(static_cast<TestingBrowserProcess*>(g_browser_process)), | 15 profile_manager_(static_cast<TestingBrowserProcess*>(g_browser_process)), |
| 16 profile_(NULL), | 16 profile_(NULL), |
| 17 file_user_blocking_thread_(new content::TestBrowserThread( |
| 18 BrowserThread::FILE_USER_BLOCKING, &message_loop_)), |
| 17 file_thread_(new content::TestBrowserThread(BrowserThread::FILE, | 19 file_thread_(new content::TestBrowserThread(BrowserThread::FILE, |
| 18 &message_loop_)), | 20 &message_loop_)), |
| 19 io_thread_(new content::TestBrowserThread(BrowserThread::IO, | 21 io_thread_(new content::TestBrowserThread(BrowserThread::IO, |
| 20 &message_loop_)) { | 22 &message_loop_)) { |
| 21 } | 23 } |
| 22 | 24 |
| 23 CocoaProfileTest::~CocoaProfileTest() { | 25 CocoaProfileTest::~CocoaProfileTest() { |
| 24 // Delete the testing profile on the UI thread. But first release the | 26 // Delete the testing profile on the UI thread. But first release the |
| 25 // browser, since it may trigger accesses to the profile upon destruction. | 27 // browser, since it may trigger accesses to the profile upon destruction. |
| 26 browser_.reset(); | 28 browser_.reset(); |
| 27 | 29 |
| 28 // Some services created on the TestingProfile require deletion on the UI | 30 // Some services created on the TestingProfile require deletion on the UI |
| 29 // thread. If the scoper in TestingBrowserProcess, owned by ChromeTestSuite, | 31 // thread. If the scoper in TestingBrowserProcess, owned by ChromeTestSuite, |
| 30 // were to delete the ProfileManager, the UI thread would at that point no | 32 // were to delete the ProfileManager, the UI thread would at that point no |
| 31 // longer exist. | 33 // longer exist. |
| 32 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( | 34 static_cast<TestingBrowserProcess*>(g_browser_process)->SetProfileManager( |
| 33 NULL); | 35 NULL); |
| 34 | 36 |
| 35 // Make sure any pending tasks run before we destroy other threads. | 37 // Make sure any pending tasks run before we destroy other threads. |
| 36 message_loop_.RunAllPending(); | 38 message_loop_.RunAllPending(); |
| 37 | 39 |
| 38 // Drop any new tasks for the IO and FILE threads. | 40 // Drop any new tasks for the IO and FILE threads. |
| 39 io_thread_.reset(); | 41 io_thread_.reset(); |
| 40 file_thread_.reset(); | 42 file_thread_.reset(); |
| 43 file_user_blocking_thread_.reset(); |
| 41 | 44 |
| 42 message_loop_.RunAllPending(); | 45 message_loop_.RunAllPending(); |
| 43 } | 46 } |
| 44 | 47 |
| 45 void CocoaProfileTest::SetUp() { | 48 void CocoaProfileTest::SetUp() { |
| 46 CocoaTest::SetUp(); | 49 CocoaTest::SetUp(); |
| 47 | 50 |
| 48 ASSERT_TRUE(profile_manager_.SetUp()); | 51 ASSERT_TRUE(profile_manager_.SetUp()); |
| 49 | 52 |
| 50 profile_ = profile_manager_.CreateTestingProfile("default"); | 53 profile_ = profile_manager_.CreateTestingProfile("default"); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 78 } | 81 } |
| 79 | 82 |
| 80 void CocoaProfileTest::CloseBrowserWindow() { | 83 void CocoaProfileTest::CloseBrowserWindow() { |
| 81 // Check to make sure a window was actually created. | 84 // Check to make sure a window was actually created. |
| 82 DCHECK(browser_->window()); | 85 DCHECK(browser_->window()); |
| 83 browser_->CloseAllTabs(); | 86 browser_->CloseAllTabs(); |
| 84 browser_->CloseWindow(); | 87 browser_->CloseWindow(); |
| 85 // |browser_| will be deleted by its BrowserWindowController. | 88 // |browser_| will be deleted by its BrowserWindowController. |
| 86 ignore_result(browser_.release()); | 89 ignore_result(browser_.release()); |
| 87 } | 90 } |
| OLD | NEW |