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

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

Powered by Google App Engine
This is Rietveld 408576698