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

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

Issue 1113333003: Don't create a new profile when cleaning up stale ephemeral profiles. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: fix? Created 5 years, 7 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/command_line.h" 6 #include "base/command_line.h"
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/password_manager/password_store_factory.h" 9 #include "chrome/browser/password_manager/password_store_factory.h"
10 #include "chrome/browser/profiles/profile_info_cache.h" 10 #include "chrome/browser/profiles/profile_info_cache.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 ProfileRemovalObserver observer; 156 ProfileRemovalObserver observer;
157 157
158 // We should start out with 1 profile. 158 // We should start out with 1 profile.
159 ASSERT_EQ(cache.GetNumberOfProfiles(), 1U); 159 ASSERT_EQ(cache.GetNumberOfProfiles(), 1U);
160 160
161 // Delete singleton profile. 161 // Delete singleton profile.
162 base::FilePath singleton_profile_path = cache.GetPathOfProfileAtIndex(0); 162 base::FilePath singleton_profile_path = cache.GetPathOfProfileAtIndex(0);
163 EXPECT_FALSE(singleton_profile_path.empty()); 163 EXPECT_FALSE(singleton_profile_path.empty());
164 base::RunLoop run_loop; 164 base::RunLoop run_loop;
165 profile_manager->ScheduleProfileForDeletion( 165 profile_manager->ScheduleProfileForDeletion(
166 singleton_profile_path, 166 singleton_profile_path, false /* suppress_profile_creation */,
167 base::Bind(&OnUnblockOnProfileCreation, &run_loop)); 167 base::Bind(&OnUnblockOnProfileCreation, &run_loop));
168 168
169 // Run the message loop until the profile is actually deleted (as indicated 169 // Run the message loop until the profile is actually deleted (as indicated
170 // by the callback above being called). 170 // by the callback above being called).
171 run_loop.Run(); 171 run_loop.Run();
172 172
173 // Make sure a new profile was created automatically. 173 // Make sure a new profile was created automatically.
174 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); 174 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U);
175 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); 175 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0);
176 EXPECT_NE(new_profile_path.value(), singleton_profile_path.value()); 176 EXPECT_NE(new_profile_path.value(), singleton_profile_path.value());
(...skipping 27 matching lines...) Expand all
204 // terminated by OnUnblockOnProfileCreation when the profile is created. 204 // terminated by OnUnblockOnProfileCreation when the profile is created.
205 run_loop.Run(); 205 run_loop.Run();
206 206
207 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); 207 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U);
208 208
209 // Delete all profiles. 209 // Delete all profiles.
210 base::FilePath profile_path1 = cache.GetPathOfProfileAtIndex(0); 210 base::FilePath profile_path1 = cache.GetPathOfProfileAtIndex(0);
211 base::FilePath profile_path2 = cache.GetPathOfProfileAtIndex(1); 211 base::FilePath profile_path2 = cache.GetPathOfProfileAtIndex(1);
212 EXPECT_FALSE(profile_path1.empty()); 212 EXPECT_FALSE(profile_path1.empty());
213 EXPECT_FALSE(profile_path2.empty()); 213 EXPECT_FALSE(profile_path2.empty());
214 profile_manager->ScheduleProfileForDeletion(profile_path1, 214 profile_manager->ScheduleProfileForDeletion(
215 ProfileManager::CreateCallback()); 215 profile_path1, false /* suppress_profile_creation */,
216 profile_manager->ScheduleProfileForDeletion(profile_path2, 216 ProfileManager::CreateCallback());
217 ProfileManager::CreateCallback()); 217 profile_manager->ScheduleProfileForDeletion(
218 profile_path2, false /* suppress_profile_creation */,
219 ProfileManager::CreateCallback());
218 220
219 // Spin things so deletion can take place. 221 // Spin things so deletion can take place.
220 content::RunAllPendingInMessageLoop(); 222 content::RunAllPendingInMessageLoop();
221 223
222 // Make sure a new profile was created automatically. 224 // Make sure a new profile was created automatically.
223 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); 225 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U);
224 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); 226 base::FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0);
225 EXPECT_NE(new_profile_path, profile_path1); 227 EXPECT_NE(new_profile_path, profile_path1);
226 EXPECT_NE(new_profile_path, profile_path2); 228 EXPECT_NE(new_profile_path, profile_path2);
227 229
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 450
449 password_store->AddLogin(form); 451 password_store->AddLogin(form);
450 PasswordStoreConsumerVerifier verify_add; 452 PasswordStoreConsumerVerifier verify_add;
451 password_store->GetAutofillableLogins(&verify_add); 453 password_store->GetAutofillableLogins(&verify_add);
452 verify_add.Wait(); 454 verify_add.Wait();
453 EXPECT_EQ(1u, verify_add.GetPasswords().size()); 455 EXPECT_EQ(1u, verify_add.GetPasswords().size());
454 456
455 ProfileManager* profile_manager = g_browser_process->profile_manager(); 457 ProfileManager* profile_manager = g_browser_process->profile_manager();
456 base::RunLoop run_loop; 458 base::RunLoop run_loop;
457 profile_manager->ScheduleProfileForDeletion( 459 profile_manager->ScheduleProfileForDeletion(
458 profile->GetPath(), base::Bind(&OnUnblockOnProfileCreation, &run_loop)); 460 profile->GetPath(), false /* suppress_profile_creation */,
461 base::Bind(&OnUnblockOnProfileCreation, &run_loop));
459 run_loop.Run(); 462 run_loop.Run();
460 463
461 PasswordStoreConsumerVerifier verify_delete; 464 PasswordStoreConsumerVerifier verify_delete;
462 password_store->GetAutofillableLogins(&verify_delete); 465 password_store->GetAutofillableLogins(&verify_delete);
463 verify_delete.Wait(); 466 verify_delete.Wait();
464 EXPECT_EQ(0u, verify_delete.GetPasswords().size()); 467 EXPECT_EQ(0u, verify_delete.GetPasswords().size());
465 } 468 }
466 #endif // !defined(OS_WIN) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS) 469 #endif // !defined(OS_WIN) && !defined(OS_ANDROID) && !defined(OS_CHROMEOS)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698