| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/scoped_temp_dir.h" | 10 #include "base/scoped_temp_dir.h" |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // observers is the same. | 30 // observers is the same. |
| 31 Profile* g_created_profile; | 31 Profile* g_created_profile; |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 class ProfileManagerTest : public TestingBrowserProcessTest { | 35 class ProfileManagerTest : public TestingBrowserProcessTest { |
| 36 protected: | 36 protected: |
| 37 ProfileManagerTest() | 37 ProfileManagerTest() |
| 38 : ui_thread_(BrowserThread::UI, &message_loop_), | 38 : ui_thread_(BrowserThread::UI, &message_loop_), |
| 39 file_thread_(BrowserThread::FILE, &message_loop_), | 39 file_thread_(BrowserThread::FILE, &message_loop_), |
| 40 io_thread_(BrowserThread::IO, &message_loop_), | |
| 41 profile_manager_(new ProfileManagerWithoutInit), | 40 profile_manager_(new ProfileManagerWithoutInit), |
| 42 local_state_(testing_browser_process_.get()) { | 41 local_state_(testing_browser_process_.get()) { |
| 43 #if defined(OS_MACOSX) | 42 #if defined(OS_MACOSX) |
| 44 base::SystemMonitor::AllocateSystemIOPorts(); | 43 base::SystemMonitor::AllocateSystemIOPorts(); |
| 45 #endif | 44 #endif |
| 46 system_monitor_dummy_.reset(new base::SystemMonitor); | 45 system_monitor_dummy_.reset(new base::SystemMonitor); |
| 47 } | 46 } |
| 48 | 47 |
| 49 virtual void SetUp() { | 48 virtual void SetUp() { |
| 50 // Create a new temporary directory, and store the path | 49 // Create a new temporary directory, and store the path |
| 51 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 50 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 52 } | 51 } |
| 53 | 52 |
| 54 virtual void TearDown() { | 53 virtual void TearDown() { |
| 55 profile_manager_.reset(); | 54 profile_manager_.reset(); |
| 56 message_loop_.RunAllPending(); | |
| 57 } | 55 } |
| 58 | 56 |
| 59 class MockObserver : public ProfileManagerObserver { | 57 class MockObserver : public ProfileManagerObserver { |
| 60 public: | 58 public: |
| 61 MOCK_METHOD1(OnProfileCreated, void(Profile* profile)); | 59 MOCK_METHOD1(OnProfileCreated, void(Profile* profile)); |
| 62 }; | 60 }; |
| 63 | 61 |
| 64 // The path to temporary directory used to contain the test operations. | 62 // The path to temporary directory used to contain the test operations. |
| 65 ScopedTempDir temp_dir_; | 63 ScopedTempDir temp_dir_; |
| 66 | 64 |
| 67 MessageLoopForUI message_loop_; | 65 MessageLoopForUI message_loop_; |
| 68 BrowserThread ui_thread_; | 66 BrowserThread ui_thread_; |
| 69 BrowserThread file_thread_; | 67 BrowserThread file_thread_; |
| 70 BrowserThread io_thread_; | |
| 71 | 68 |
| 72 scoped_ptr<base::SystemMonitor> system_monitor_dummy_; | 69 scoped_ptr<base::SystemMonitor> system_monitor_dummy_; |
| 73 | 70 |
| 74 // Also will test profile deletion. | 71 // Also will test profile deletion. |
| 75 scoped_ptr<ProfileManager> profile_manager_; | 72 scoped_ptr<ProfileManager> profile_manager_; |
| 76 | 73 |
| 77 ScopedTestingLocalState local_state_; | 74 ScopedTestingLocalState local_state_; |
| 78 }; | 75 }; |
| 79 | 76 |
| 80 TEST_F(ProfileManagerTest, GetProfile) { | 77 TEST_F(ProfileManagerTest, GetProfile) { |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile 2")); | 227 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile 2")); |
| 231 | 228 |
| 232 MockObserver mock_observer; | 229 MockObserver mock_observer; |
| 233 EXPECT_CALL(mock_observer, OnProfileCreated(testing::NotNull())).Times(2); | 230 EXPECT_CALL(mock_observer, OnProfileCreated(testing::NotNull())).Times(2); |
| 234 | 231 |
| 235 profile_manager_->CreateProfileAsync(dest_path1, &mock_observer); | 232 profile_manager_->CreateProfileAsync(dest_path1, &mock_observer); |
| 236 profile_manager_->CreateProfileAsync(dest_path2, &mock_observer); | 233 profile_manager_->CreateProfileAsync(dest_path2, &mock_observer); |
| 237 | 234 |
| 238 message_loop_.RunAllPending(); | 235 message_loop_.RunAllPending(); |
| 239 } | 236 } |
| OLD | NEW |