Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: chrome/browser/profiles/profile_manager_browsertest.cc

Issue 1913373002: Revert "Refactor ProfileInfoCache in most of c/b/profiles" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "build/build_config.h" 11 #include "build/build_config.h"
12 #include "chrome/browser/password_manager/password_store_factory.h" 12 #include "chrome/browser/password_manager/password_store_factory.h"
13 #include "chrome/browser/profiles/profile_attributes_entry.h" 13 #include "chrome/browser/profiles/profile_info_cache.h"
14 #include "chrome/browser/profiles/profile_attributes_storage.h" 14 #include "chrome/browser/profiles/profile_info_cache_observer.h"
15 #include "chrome/browser/profiles/profile_manager.h" 15 #include "chrome/browser/profiles/profile_manager.h"
16 #include "chrome/browser/profiles/profile_window.h" 16 #include "chrome/browser/profiles/profile_window.h"
17 #include "chrome/browser/profiles/profiles_state.h" 17 #include "chrome/browser/profiles/profiles_state.h"
18 #include "chrome/browser/ui/browser_finder.h" 18 #include "chrome/browser/ui/browser_finder.h"
19 #include "chrome/browser/ui/browser_list.h" 19 #include "chrome/browser/ui/browser_list.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/common/pref_names.h" 21 #include "chrome/common/pref_names.h"
22 #include "chrome/test/base/in_process_browser_test.h" 22 #include "chrome/test/base/in_process_browser_test.h"
23 #include "chrome/test/base/test_switches.h" 23 #include "chrome/test/base/test_switches.h"
24 #include "chrome/test/base/testing_browser_process.h" 24 #include "chrome/test/base/testing_browser_process.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 base::MessageLoop::current()->QuitWhenIdle(); 60 base::MessageLoop::current()->QuitWhenIdle();
61 } 61 }
62 62
63 void EphemeralProfileCreationComplete(Profile* profile, 63 void EphemeralProfileCreationComplete(Profile* profile,
64 Profile::CreateStatus status) { 64 Profile::CreateStatus status) {
65 if (status == Profile::CREATE_STATUS_INITIALIZED) 65 if (status == Profile::CREATE_STATUS_INITIALIZED)
66 profile->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, true); 66 profile->GetPrefs()->SetBoolean(prefs::kForceEphemeralProfiles, true);
67 ProfileCreationComplete(profile, status); 67 ProfileCreationComplete(profile, status);
68 } 68 }
69 69
70 class ProfileRemovalObserver : public ProfileAttributesStorage::Observer { 70 class ProfileRemovalObserver : public ProfileInfoCacheObserver {
71 public: 71 public:
72 ProfileRemovalObserver() { 72 ProfileRemovalObserver() {
73 g_browser_process->profile_manager()->GetProfileAttributesStorage(). 73 g_browser_process->profile_manager()->GetProfileInfoCache().AddObserver(
74 AddObserver(this); 74 this);
75 } 75 }
76 76
77 ~ProfileRemovalObserver() override { 77 ~ProfileRemovalObserver() override {
78 g_browser_process->profile_manager()->GetProfileAttributesStorage(). 78 g_browser_process->profile_manager()->GetProfileInfoCache().RemoveObserver(
79 RemoveObserver(this); 79 this);
80 } 80 }
81 81
82 std::string last_used_profile_name() { return last_used_profile_name_; } 82 std::string last_used_profile_name() { return last_used_profile_name_; }
83 83
84 // ProfileAttributesStorage::Observer overrides: 84 // ProfileInfoCacheObserver overrides:
85 void OnProfileWillBeRemoved(const base::FilePath& profile_path) override { 85 void OnProfileWillBeRemoved(const base::FilePath& profile_path) override {
86 last_used_profile_name_ = g_browser_process->local_state()->GetString( 86 last_used_profile_name_ = g_browser_process->local_state()->GetString(
87 prefs::kProfileLastUsed); 87 prefs::kProfileLastUsed);
88 } 88 }
89 89
90 private: 90 private:
91 std::string last_used_profile_name_; 91 std::string last_used_profile_name_;
92 92
93 DISALLOW_COPY_AND_ASSIGN(ProfileRemovalObserver); 93 DISALLOW_COPY_AND_ASSIGN(ProfileRemovalObserver);
94 }; 94 };
(...skipping 15 matching lines...) Expand all
110 110
111 const std::vector<autofill::PasswordForm*>& GetPasswords() const { 111 const std::vector<autofill::PasswordForm*>& GetPasswords() const {
112 return password_entries_.get(); 112 return password_entries_.get();
113 } 113 }
114 114
115 private: 115 private:
116 base::RunLoop run_loop_; 116 base::RunLoop run_loop_;
117 ScopedVector<autofill::PasswordForm> password_entries_; 117 ScopedVector<autofill::PasswordForm> password_entries_;
118 }; 118 };
119 119
120 static base::FilePath GetFirstNonSigninProfile( 120 static base::FilePath GetFirstNonSigninProfile(const ProfileInfoCache& cache) {
121 ProfileAttributesStorage& storage) {
122 std::vector<ProfileAttributesEntry*> entries =
123 storage.GetAllProfilesAttributesSortedByName();
124 #if defined(OS_CHROMEOS) 121 #if defined(OS_CHROMEOS)
125 const base::FilePath signin_path = 122 const base::FilePath signin_path =
126 chromeos::ProfileHelper::GetSigninProfileDir(); 123 chromeos::ProfileHelper::GetSigninProfileDir();
127 for (ProfileAttributesEntry* entry : entries) { 124 size_t i, profile_num = cache.GetNumberOfProfiles();
128 base::FilePath profile_path = entry->GetPath(); 125 for (i = 0; i != profile_num; ++i) {
126 base::FilePath profile_path = cache.GetPathOfProfileAtIndex(i);
129 if (profile_path != signin_path) 127 if (profile_path != signin_path)
130 return profile_path; 128 return profile_path;
131 } 129 }
132 return base::FilePath(); 130 return base::FilePath();
133 #else 131 #else
134 return entries.front()->GetPath(); 132 return cache.GetPathOfProfileAtIndex(0);
135 #endif 133 #endif
136 } 134 }
137 135
138 } // namespace 136 } // namespace
139 137
140 // This file contains tests for the ProfileManager that require a heavyweight 138 // This file contains tests for the ProfileManager that require a heavyweight
141 // InProcessBrowserTest. These include tests involving profile deletion. 139 // InProcessBrowserTest. These include tests involving profile deletion.
142 140
143 // TODO(jeremy): crbug.com/103355 - These tests should be enabled on all 141 // TODO(jeremy): crbug.com/103355 - These tests should be enabled on all
144 // platforms. 142 // platforms.
145 class ProfileManagerBrowserTest : public InProcessBrowserTest { 143 class ProfileManagerBrowserTest : public InProcessBrowserTest {
146 protected: 144 protected:
147 void SetUpCommandLine(base::CommandLine* command_line) override { 145 void SetUpCommandLine(base::CommandLine* command_line) override {
148 #if defined(OS_CHROMEOS) 146 #if defined(OS_CHROMEOS)
149 command_line->AppendSwitch( 147 command_line->AppendSwitch(
150 chromeos::switches::kIgnoreUserProfileMappingForTests); 148 chromeos::switches::kIgnoreUserProfileMappingForTests);
151 #endif 149 #endif
152 } 150 }
153 }; 151 };
154 152
155 #if defined(OS_MACOSX) 153 #if defined(OS_MACOSX)
156 154
157 // Delete single profile and make sure a new one is created. 155 // Delete single profile and make sure a new one is created.
158 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DeleteSingletonProfile) { 156 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DeleteSingletonProfile) {
159 ProfileManager* profile_manager = g_browser_process->profile_manager(); 157 ProfileManager* profile_manager = g_browser_process->profile_manager();
160 ProfileAttributesStorage& storage = 158 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
161 profile_manager->GetProfileAttributesStorage();
162 ProfileRemovalObserver observer; 159 ProfileRemovalObserver observer;
163 160
164 // We should start out with 1 profile. 161 // We should start out with 1 profile.
165 ASSERT_EQ(1u, storage.GetNumberOfProfiles()); 162 ASSERT_EQ(cache.GetNumberOfProfiles(), 1U);
166 163
167 // Delete singleton profile. 164 // Delete singleton profile.
168 base::FilePath singleton_profile_path = 165 base::FilePath singleton_profile_path = cache.GetPathOfProfileAtIndex(0);
169 storage.GetAllProfilesAttributes().front()->GetPath();
170 EXPECT_FALSE(singleton_profile_path.empty()); 166 EXPECT_FALSE(singleton_profile_path.empty());
171 base::RunLoop run_loop; 167 base::RunLoop run_loop;
172 profile_manager->ScheduleProfileForDeletion( 168 profile_manager->ScheduleProfileForDeletion(
173 singleton_profile_path, 169 singleton_profile_path,
174 base::Bind(&OnUnblockOnProfileCreation, &run_loop)); 170 base::Bind(&OnUnblockOnProfileCreation, &run_loop));
175 171
176 // Run the message loop until the profile is actually deleted (as indicated 172 // Run the message loop until the profile is actually deleted (as indicated
177 // by the callback above being called). 173 // by the callback above being called).
178 run_loop.Run(); 174 run_loop.Run();
179 175
180 // Make sure a new profile was created automatically. 176 // Make sure a new profile was created automatically.
181 EXPECT_EQ(1u, storage.GetNumberOfProfiles()); 177 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U);
182 base::FilePath new_profile_path = 178 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0);
183 storage.GetAllProfilesAttributes().front()->GetPath();
184 EXPECT_NE(new_profile_path.value(), singleton_profile_path.value()); 179 EXPECT_NE(new_profile_path.value(), singleton_profile_path.value());
185 180
186 // Make sure that last used profile preference is set correctly. 181 // Make sure that last used profile preference is set correctly.
187 Profile* last_used = ProfileManager::GetLastUsedProfile(); 182 Profile* last_used = ProfileManager::GetLastUsedProfile();
188 EXPECT_EQ(new_profile_path.value(), last_used->GetPath().value()); 183 EXPECT_EQ(new_profile_path.value(), last_used->GetPath().value());
189 184
190 // Make sure the last used profile was set correctly before the notification 185 // Make sure the last used profile was set correctly before the notification
191 // was sent. 186 // was sent.
192 std::string last_used_profile_name = 187 std::string last_used_profile_name =
193 last_used->GetPath().BaseName().MaybeAsASCII(); 188 last_used->GetPath().BaseName().MaybeAsASCII();
194 EXPECT_EQ(last_used_profile_name, observer.last_used_profile_name()); 189 EXPECT_EQ(last_used_profile_name, observer.last_used_profile_name());
195 } 190 }
196 191
197 // Delete all profiles in a multi profile setup and make sure a new one is 192 // Delete all profiles in a multi profile setup and make sure a new one is
198 // created. 193 // created.
199 // Crashes/CHECKs. See crbug.com/104851 194 // Crashes/CHECKs. See crbug.com/104851
200 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DISABLED_DeleteAllProfiles) { 195 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DISABLED_DeleteAllProfiles) {
201 ProfileManager* profile_manager = g_browser_process->profile_manager(); 196 ProfileManager* profile_manager = g_browser_process->profile_manager();
202 ProfileAttributesStorage& storage = 197 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
203 profile_manager->GetProfileAttributesStorage();
204 198
205 // Create an additional profile. 199 // Create an additional profile.
206 base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath(); 200 base::FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath();
207 base::RunLoop run_loop; 201 base::RunLoop run_loop;
208 profile_manager->CreateProfileAsync( 202 profile_manager->CreateProfileAsync(
209 new_path, base::Bind(&OnUnblockOnProfileCreation, &run_loop), 203 new_path, base::Bind(&OnUnblockOnProfileCreation, &run_loop),
210 base::string16(), std::string(), std::string()); 204 base::string16(), std::string(), std::string());
211 205
212 // Run the message loop to allow profile creation to take place; the loop is 206 // Run the message loop to allow profile creation to take place; the loop is
213 // terminated by OnUnblockOnProfileCreation when the profile is created. 207 // terminated by OnUnblockOnProfileCreation when the profile is created.
214 run_loop.Run(); 208 run_loop.Run();
215 209
216 ASSERT_EQ(2u, storage.GetNumberOfProfiles()); 210 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U);
217 211
218 // Delete all profiles. 212 // Delete all profiles.
219 std::vector<ProfileAttributesEntry*> entries = 213 base::FilePath profile_path1 = cache.GetPathOfProfileAtIndex(0);
220 storage.GetAllProfilesAttributes(); 214 base::FilePath profile_path2 = cache.GetPathOfProfileAtIndex(1);
221 std::vector<base::FilePath> old_profile_paths; 215 EXPECT_FALSE(profile_path1.empty());
222 for (ProfileAttributesEntry* entry : entries) { 216 EXPECT_FALSE(profile_path2.empty());
223 base::FilePath profile_path = entry->GetPath(); 217 profile_manager->ScheduleProfileForDeletion(profile_path1,
224 EXPECT_FALSE(profile_path.empty()); 218 ProfileManager::CreateCallback());
225 profile_manager->ScheduleProfileForDeletion( 219 profile_manager->ScheduleProfileForDeletion(profile_path2,
226 profile_path, ProfileManager::CreateCallback()); 220 ProfileManager::CreateCallback());
227 old_profile_paths.push_back(profile_path);
228 }
229 221
230 // Spin things so deletion can take place. 222 // Spin things so deletion can take place.
231 content::RunAllPendingInMessageLoop(); 223 content::RunAllPendingInMessageLoop();
232 224
233 // Make sure a new profile was created automatically. 225 // Make sure a new profile was created automatically.
234 EXPECT_EQ(1u, storage.GetNumberOfProfiles()); 226 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U);
235 base::FilePath new_profile_path = 227 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0);
236 storage.GetAllProfilesAttributes().front()->GetPath(); 228 EXPECT_NE(new_profile_path, profile_path1);
237 for (const base::FilePath& old_profile_path : old_profile_paths) 229 EXPECT_NE(new_profile_path, profile_path2);
238 EXPECT_NE(old_profile_path, new_profile_path);
239 230
240 // Make sure that last used profile preference is set correctly. 231 // Make sure that last used profile preference is set correctly.
241 Profile* last_used = ProfileManager::GetLastUsedProfile(); 232 Profile* last_used = ProfileManager::GetLastUsedProfile();
242 EXPECT_EQ(new_profile_path, last_used->GetPath()); 233 EXPECT_EQ(new_profile_path, last_used->GetPath());
243 } 234 }
244 #endif // OS_MACOSX 235 #endif // OS_MACOSX
245 236
246 #if defined(OS_CHROMEOS) 237 #if defined(OS_CHROMEOS)
247 238
248 class ProfileManagerCrOSBrowserTest : public ProfileManagerBrowserTest { 239 class ProfileManagerCrOSBrowserTest : public ProfileManagerBrowserTest {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 296 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
306 switches::kAshBrowserTests)) 297 switches::kAshBrowserTests))
307 return; 298 return;
308 #endif 299 #endif
309 300
310 // If multiprofile mode is not enabled, you can't switch between profiles. 301 // If multiprofile mode is not enabled, you can't switch between profiles.
311 if (!profiles::IsMultipleProfilesEnabled()) 302 if (!profiles::IsMultipleProfilesEnabled())
312 return; 303 return;
313 304
314 ProfileManager* profile_manager = g_browser_process->profile_manager(); 305 ProfileManager* profile_manager = g_browser_process->profile_manager();
315 ProfileAttributesStorage& storage = 306 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
316 profile_manager->GetProfileAttributesStorage();
317 size_t initial_profile_count = profile_manager->GetNumberOfProfiles(); 307 size_t initial_profile_count = profile_manager->GetNumberOfProfiles();
318 base::FilePath path_profile1 = GetFirstNonSigninProfile(storage); 308 base::FilePath path_profile1 = GetFirstNonSigninProfile(cache);
319 309
320 ASSERT_NE(0U, initial_profile_count); 310 ASSERT_NE(0U, initial_profile_count);
321 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 311 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
322 312
323 // Create an additional profile. 313 // Create an additional profile.
324 base::FilePath path_profile2 = 314 base::FilePath path_profile2 =
325 profile_manager->GenerateNextProfileDirectoryPath(); 315 profile_manager->GenerateNextProfileDirectoryPath();
326 base::RunLoop run_loop; 316 base::RunLoop run_loop;
327 profile_manager->CreateProfileAsync( 317 profile_manager->CreateProfileAsync(
328 path_profile2, base::Bind(&OnUnblockOnProfileCreation, &run_loop), 318 path_profile2, base::Bind(&OnUnblockOnProfileCreation, &run_loop),
329 base::string16(), std::string(), std::string()); 319 base::string16(), std::string(), std::string());
330 320
331 // Run the message loop to allow profile creation to take place; the loop is 321 // Run the message loop to allow profile creation to take place; the loop is
332 // terminated by OnUnblockOnProfileCreation when the profile is created. 322 // terminated by OnUnblockOnProfileCreation when the profile is created.
333 run_loop.Run(); 323 run_loop.Run();
334 324
335 BrowserList* browser_list = BrowserList::GetInstance(); 325 BrowserList* browser_list = BrowserList::GetInstance();
336 ASSERT_EQ(initial_profile_count + 1U, storage.GetNumberOfProfiles()); 326 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles());
337 EXPECT_EQ(1U, browser_list->size()); 327 EXPECT_EQ(1U, browser_list->size());
338 328
339 // Open a browser window for the first profile. 329 // Open a browser window for the first profile.
340 profiles::SwitchToProfile(path_profile1, false, kOnProfileSwitchDoNothing, 330 profiles::SwitchToProfile(path_profile1, false, kOnProfileSwitchDoNothing,
341 ProfileMetrics::SWITCH_PROFILE_ICON); 331 ProfileMetrics::SWITCH_PROFILE_ICON);
342 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 332 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
343 EXPECT_EQ(1U, browser_list->size()); 333 EXPECT_EQ(1U, browser_list->size());
344 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); 334 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath());
345 335
346 // Open a browser window for the second profile. 336 // Open a browser window for the second profile.
(...skipping 25 matching lines...) Expand all
372 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 362 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
373 switches::kAshBrowserTests)) 363 switches::kAshBrowserTests))
374 return; 364 return;
375 #endif 365 #endif
376 366
377 // If multiprofile mode is not enabled, you can't switch between profiles. 367 // If multiprofile mode is not enabled, you can't switch between profiles.
378 if (!profiles::IsMultipleProfilesEnabled()) 368 if (!profiles::IsMultipleProfilesEnabled())
379 return; 369 return;
380 370
381 ProfileManager* profile_manager = g_browser_process->profile_manager(); 371 ProfileManager* profile_manager = g_browser_process->profile_manager();
382 ProfileAttributesStorage& storage = 372 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
383 profile_manager->GetProfileAttributesStorage();
384 size_t initial_profile_count = profile_manager->GetNumberOfProfiles(); 373 size_t initial_profile_count = profile_manager->GetNumberOfProfiles();
385 base::FilePath path_profile1 = GetFirstNonSigninProfile(storage); 374 base::FilePath path_profile1 = GetFirstNonSigninProfile(cache);
386 375
387 ASSERT_NE(0U, initial_profile_count); 376 ASSERT_NE(0U, initial_profile_count);
388 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 377 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
389 378
390 // Create an ephemeral profile. 379 // Create an ephemeral profile.
391 base::FilePath path_profile2 = 380 base::FilePath path_profile2 =
392 profile_manager->GenerateNextProfileDirectoryPath(); 381 profile_manager->GenerateNextProfileDirectoryPath();
393 profile_manager->CreateProfileAsync( 382 profile_manager->CreateProfileAsync(
394 path_profile2, 383 path_profile2,
395 base::Bind(&EphemeralProfileCreationComplete), 384 base::Bind(&EphemeralProfileCreationComplete),
396 base::string16(), std::string(), std::string()); 385 base::string16(), std::string(), std::string());
397 386
398 // Spin to allow profile creation to take place. 387 // Spin to allow profile creation to take place.
399 content::RunMessageLoop(); 388 content::RunMessageLoop();
400 389
401 BrowserList* browser_list = BrowserList::GetInstance(); 390 BrowserList* browser_list = BrowserList::GetInstance();
402 ASSERT_EQ(initial_profile_count + 1U, storage.GetNumberOfProfiles()); 391 ASSERT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles());
403 EXPECT_EQ(1U, browser_list->size()); 392 EXPECT_EQ(1U, browser_list->size());
404 393
405 // Open a browser window for the second profile. 394 // Open a browser window for the second profile.
406 profiles::SwitchToProfile(path_profile2, false, kOnProfileSwitchDoNothing, 395 profiles::SwitchToProfile(path_profile2, false, kOnProfileSwitchDoNothing,
407 ProfileMetrics::SWITCH_PROFILE_ICON); 396 ProfileMetrics::SWITCH_PROFILE_ICON);
408 EXPECT_EQ(2U, chrome::GetTotalBrowserCount()); 397 EXPECT_EQ(2U, chrome::GetTotalBrowserCount());
409 EXPECT_EQ(2U, browser_list->size()); 398 EXPECT_EQ(2U, browser_list->size());
410 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); 399 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
411 400
412 // Create a second window for the ephemeral profile. 401 // Create a second window for the ephemeral profile.
413 profiles::SwitchToProfile(path_profile2, true, kOnProfileSwitchDoNothing, 402 profiles::SwitchToProfile(path_profile2, true, kOnProfileSwitchDoNothing,
414 ProfileMetrics::SWITCH_PROFILE_ICON); 403 ProfileMetrics::SWITCH_PROFILE_ICON);
415 EXPECT_EQ(3U, chrome::GetTotalBrowserCount()); 404 EXPECT_EQ(3U, chrome::GetTotalBrowserCount());
416 EXPECT_EQ(3U, browser_list->size()); 405 EXPECT_EQ(3U, browser_list->size());
417 406
418 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); 407 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath());
419 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); 408 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath());
420 EXPECT_EQ(path_profile2, browser_list->get(2)->profile()->GetPath()); 409 EXPECT_EQ(path_profile2, browser_list->get(2)->profile()->GetPath());
421 410
422 // Closing the first window of the ephemeral profile should not delete it. 411 // Closing the first window of the ephemeral profile should not delete it.
423 CloseBrowserSynchronously(browser_list->get(2)); 412 CloseBrowserSynchronously(browser_list->get(2));
424 EXPECT_EQ(2U, browser_list->size()); 413 EXPECT_EQ(2U, browser_list->size());
425 EXPECT_EQ(initial_profile_count + 1U, storage.GetNumberOfProfiles()); 414 EXPECT_EQ(initial_profile_count + 1, cache.GetNumberOfProfiles());
426 415
427 // The second should though. 416 // The second should though.
428 CloseBrowserSynchronously(browser_list->get(1)); 417 CloseBrowserSynchronously(browser_list->get(1));
429 EXPECT_EQ(1U, browser_list->size()); 418 EXPECT_EQ(1U, browser_list->size());
430 EXPECT_EQ(initial_profile_count, storage.GetNumberOfProfiles()); 419 EXPECT_EQ(initial_profile_count, cache.GetNumberOfProfiles());
431 } 420 }
432 421
433 // The test makes sense on those platforms where the keychain exists. 422 // The test makes sense on those platforms where the keychain exists.
434 #if !defined(OS_WIN) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 423 #if !defined(OS_WIN) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
435 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DeletePasswords) { 424 IN_PROC_BROWSER_TEST_F(ProfileManagerBrowserTest, DeletePasswords) {
436 Profile* profile = ProfileManager::GetActiveUserProfile(); 425 Profile* profile = ProfileManager::GetActiveUserProfile();
437 ASSERT_TRUE(profile); 426 ASSERT_TRUE(profile);
438 427
439 autofill::PasswordForm form; 428 autofill::PasswordForm form;
440 form.scheme = autofill::PasswordForm::SCHEME_HTML; 429 form.scheme = autofill::PasswordForm::SCHEME_HTML;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 496
508 EXPECT_FALSE(profile->HasOffTheRecordProfile()); 497 EXPECT_FALSE(profile->HasOffTheRecordProfile());
509 EXPECT_FALSE(profile_manager->IsValidProfile(incognito_profile)); 498 EXPECT_FALSE(profile_manager->IsValidProfile(incognito_profile));
510 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles()); 499 EXPECT_EQ(initial_profile_count, profile_manager->GetNumberOfProfiles());
511 // After destroying the incognito profile incognito preferences should be 500 // After destroying the incognito profile incognito preferences should be
512 // cleared so the default save path should be taken from the main profile. 501 // cleared so the default save path should be taken from the main profile.
513 EXPECT_FALSE(profile->GetOffTheRecordPrefs() 502 EXPECT_FALSE(profile->GetOffTheRecordPrefs()
514 ->GetFilePath(prefs::kSaveFileDefaultDirectory) 503 ->GetFilePath(prefs::kSaveFileDefaultDirectory)
515 .empty()); 504 .empty());
516 } 505 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/profiles/profile_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698