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/test/base/testing_profile_manager.h" | 5 #include "chrome/test/base/testing_profile_manager.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "build/build_config.h" | 12 #include "build/build_config.h" |
13 #include "chrome/browser/profiles/profile_attributes_storage.h" | 13 #include "chrome/browser/profiles/profile_attributes_storage.h" |
14 #include "chrome/browser/profiles/profile_info_cache.h" | 14 #include "chrome/browser/profiles/profile_info_cache.h" |
15 #include "chrome/browser/profiles/profile_manager.h" | 15 #include "chrome/browser/profiles/profile_manager.h" |
16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
18 #include "components/syncable_prefs/pref_service_syncable.h" | 18 #include "components/sync_preferences/pref_service_syncable.h" |
19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
20 | 20 |
21 #if defined(OS_CHROMEOS) | 21 #if defined(OS_CHROMEOS) |
22 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 22 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
23 #endif | 23 #endif |
24 | 24 |
25 const char kGuestProfileName[] = "Guest"; | 25 const char kGuestProfileName[] = "Guest"; |
26 const char kSystemProfileName[] = "System"; | 26 const char kSystemProfileName[] = "System"; |
27 | 27 |
28 namespace testing { | 28 namespace testing { |
(...skipping 24 matching lines...) Expand all Loading... |
53 browser_process_->SetProfileManager(NULL); | 53 browser_process_->SetProfileManager(NULL); |
54 } | 54 } |
55 | 55 |
56 bool TestingProfileManager::SetUp() { | 56 bool TestingProfileManager::SetUp() { |
57 SetUpInternal(); | 57 SetUpInternal(); |
58 return called_set_up_; | 58 return called_set_up_; |
59 } | 59 } |
60 | 60 |
61 TestingProfile* TestingProfileManager::CreateTestingProfile( | 61 TestingProfile* TestingProfileManager::CreateTestingProfile( |
62 const std::string& profile_name, | 62 const std::string& profile_name, |
63 std::unique_ptr<syncable_prefs::PrefServiceSyncable> prefs, | 63 std::unique_ptr<sync_preferences::PrefServiceSyncable> prefs, |
64 const base::string16& user_name, | 64 const base::string16& user_name, |
65 int avatar_id, | 65 int avatar_id, |
66 const std::string& supervised_user_id, | 66 const std::string& supervised_user_id, |
67 const TestingProfile::TestingFactories& factories) { | 67 const TestingProfile::TestingFactories& factories) { |
68 DCHECK(called_set_up_); | 68 DCHECK(called_set_up_); |
69 | 69 |
70 // Create a path for the profile based on the name. | 70 // Create a path for the profile based on the name. |
71 base::FilePath profile_path(profiles_dir_.GetPath()); | 71 base::FilePath profile_path(profiles_dir_.GetPath()); |
72 #if defined(OS_CHROMEOS) | 72 #if defined(OS_CHROMEOS) |
73 if (profile_name != chrome::kInitialProfile) { | 73 if (profile_name != chrome::kInitialProfile) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 testing_profiles_.insert(std::make_pair(profile_name, profile)); | 109 testing_profiles_.insert(std::make_pair(profile_name, profile)); |
110 | 110 |
111 return profile; | 111 return profile; |
112 } | 112 } |
113 | 113 |
114 TestingProfile* TestingProfileManager::CreateTestingProfile( | 114 TestingProfile* TestingProfileManager::CreateTestingProfile( |
115 const std::string& name) { | 115 const std::string& name) { |
116 DCHECK(called_set_up_); | 116 DCHECK(called_set_up_); |
117 return CreateTestingProfile( | 117 return CreateTestingProfile( |
118 name, std::unique_ptr<syncable_prefs::PrefServiceSyncable>(), | 118 name, std::unique_ptr<sync_preferences::PrefServiceSyncable>(), |
119 base::UTF8ToUTF16(name), 0, std::string(), | 119 base::UTF8ToUTF16(name), 0, std::string(), |
120 TestingProfile::TestingFactories()); | 120 TestingProfile::TestingFactories()); |
121 } | 121 } |
122 | 122 |
123 TestingProfile* TestingProfileManager::CreateGuestProfile() { | 123 TestingProfile* TestingProfileManager::CreateGuestProfile() { |
124 DCHECK(called_set_up_); | 124 DCHECK(called_set_up_); |
125 | 125 |
126 // Create the profile and register it. | 126 // Create the profile and register it. |
127 TestingProfile::Builder builder; | 127 TestingProfile::Builder builder; |
128 builder.SetGuestSession(); | 128 builder.SetGuestSession(); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 // Set up the directory for profiles. | 247 // Set up the directory for profiles. |
248 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); | 248 ASSERT_TRUE(profiles_dir_.CreateUniqueTempDir()); |
249 | 249 |
250 profile_manager_ = new testing::ProfileManager(profiles_dir_.GetPath()); | 250 profile_manager_ = new testing::ProfileManager(profiles_dir_.GetPath()); |
251 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. | 251 browser_process_->SetProfileManager(profile_manager_); // Takes ownership. |
252 | 252 |
253 profile_manager_->GetProfileInfoCache(). | 253 profile_manager_->GetProfileInfoCache(). |
254 set_disable_avatar_download_for_testing(true); | 254 set_disable_avatar_download_for_testing(true); |
255 called_set_up_ = true; | 255 called_set_up_ = true; |
256 } | 256 } |
OLD | NEW |