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

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

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