| 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/memory/scoped_temp_dir.h" | 8 #include "base/memory/scoped_temp_dir.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "base/system_monitor/system_monitor.h" | |
| 12 #include "base/values.h" | 11 #include "base/values.h" |
| 13 #include "chrome/browser/prefs/browser_prefs.h" | 12 #include "chrome/browser/prefs/browser_prefs.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #include "chrome/browser/profiles/profile_manager.h" | 14 #include "chrome/browser/profiles/profile_manager.h" |
| 16 #include "chrome/common/chrome_constants.h" | 15 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
| 18 #include "chrome/common/chrome_switches.h" | 17 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/pref_names.h" | 18 #include "chrome/common/pref_names.h" |
| 20 #include "chrome/test/testing_browser_process_test.h" | 19 #include "chrome/test/testing_browser_process_test.h" |
| 21 #include "chrome/test/testing_pref_service.h" | 20 #include "chrome/test/testing_pref_service.h" |
| 22 #include "content/browser/browser_thread.h" | 21 #include "content/browser/browser_thread.h" |
| 23 #include "content/common/notification_service.h" | 22 #include "content/common/notification_service.h" |
| 24 #include "testing/gmock/include/gmock/gmock.h" | 23 #include "testing/gmock/include/gmock/gmock.h" |
| 25 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 #include "ui/base/system_monitor/system_monitor.h" |
| 26 | 26 |
| 27 namespace { | 27 namespace { |
| 28 // This global variable is used to check that value returned to different | 28 // This global variable is used to check that value returned to different |
| 29 // observers is the same. | 29 // observers is the same. |
| 30 Profile* g_created_profile; | 30 Profile* g_created_profile; |
| 31 | 31 |
| 32 } // namespace | 32 } // namespace |
| 33 | 33 |
| 34 class ProfileManagerTest : public TestingBrowserProcessTest { | 34 class ProfileManagerTest : public TestingBrowserProcessTest { |
| 35 protected: | 35 protected: |
| (...skipping 18 matching lines...) Expand all Loading... |
| 54 MOCK_METHOD1(OnProfileCreated, void(Profile* profile)); | 54 MOCK_METHOD1(OnProfileCreated, void(Profile* profile)); |
| 55 }; | 55 }; |
| 56 | 56 |
| 57 // The path to temporary directory used to contain the test operations. | 57 // The path to temporary directory used to contain the test operations. |
| 58 ScopedTempDir temp_dir_; | 58 ScopedTempDir temp_dir_; |
| 59 | 59 |
| 60 MessageLoopForUI message_loop_; | 60 MessageLoopForUI message_loop_; |
| 61 BrowserThread ui_thread_; | 61 BrowserThread ui_thread_; |
| 62 BrowserThread file_thread_; | 62 BrowserThread file_thread_; |
| 63 | 63 |
| 64 base::SystemMonitor system_monitor_dummy_; | 64 ui::SystemMonitor system_monitor_dummy_; |
| 65 | 65 |
| 66 // Also will test profile deletion. | 66 // Also will test profile deletion. |
| 67 scoped_ptr<ProfileManager> profile_manager_; | 67 scoped_ptr<ProfileManager> profile_manager_; |
| 68 | 68 |
| 69 ScopedTestingLocalState local_state_; | 69 ScopedTestingLocalState local_state_; |
| 70 }; | 70 }; |
| 71 | 71 |
| 72 TEST_F(ProfileManagerTest, GetProfile) { | 72 TEST_F(ProfileManagerTest, GetProfile) { |
| 73 FilePath dest_path = temp_dir_.path(); | 73 FilePath dest_path = temp_dir_.path(); |
| 74 dest_path = dest_path.Append(FILE_PATH_LITERAL("New Profile")); | 74 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")); | 222 temp_dir_.path().Append(FILE_PATH_LITERAL("New Profile 2")); |
| 223 | 223 |
| 224 MockObserver mock_observer; | 224 MockObserver mock_observer; |
| 225 EXPECT_CALL(mock_observer, OnProfileCreated(testing::NotNull())).Times(2); | 225 EXPECT_CALL(mock_observer, OnProfileCreated(testing::NotNull())).Times(2); |
| 226 | 226 |
| 227 profile_manager_->CreateProfileAsync(dest_path1, &mock_observer); | 227 profile_manager_->CreateProfileAsync(dest_path1, &mock_observer); |
| 228 profile_manager_->CreateProfileAsync(dest_path2, &mock_observer); | 228 profile_manager_->CreateProfileAsync(dest_path2, &mock_observer); |
| 229 | 229 |
| 230 message_loop_.RunAllPending(); | 230 message_loop_.RunAllPending(); |
| 231 } | 231 } |
| OLD | NEW |