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