Index: chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc |
diff --git a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc |
index 6a9bfd39987695777eff93be4ca5388fbeb2c63c..e4b7d9e5caff6b4f6dc033ce9fae02946913fc45 100644 |
--- a/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc |
+++ b/chrome/browser/profiles/profile_shortcut_manager_unittest_win.cc |
@@ -14,6 +14,8 @@ |
#include "base/test/test_shortcut_win.h" |
#include "base/win/shortcut.h" |
#include "chrome/browser/profiles/profile.h" |
+#include "chrome/browser/profiles/profile_attributes_entry.h" |
+#include "chrome/browser/profiles/profile_attributes_storage.h" |
#include "chrome/browser/profiles/profile_manager.h" |
#include "chrome/browser/profiles/profile_shortcut_manager.h" |
#include "chrome/browser/profiles/profile_shortcut_manager_win.h" |
@@ -36,7 +38,7 @@ class ProfileShortcutManagerTest : public testing::Test { |
ProfileShortcutManagerTest() |
: ui_thread_(BrowserThread::UI, &message_loop_), |
file_thread_(BrowserThread::FILE, &message_loop_), |
- profile_info_cache_(NULL), |
+ profile_attributes_storage_(NULL), |
fake_user_desktop_(base::DIR_USER_DESKTOP), |
fake_system_desktop_(base::DIR_COMMON_DESKTOP) { |
} |
@@ -48,7 +50,8 @@ class ProfileShortcutManagerTest : public testing::Test { |
TestingBrowserProcess::GetGlobal(); |
profile_manager_.reset(new TestingProfileManager(browser_process)); |
ASSERT_TRUE(profile_manager_->SetUp()); |
- profile_info_cache_ = profile_manager_->profile_info_cache(); |
+ profile_attributes_storage_ = |
+ profile_manager_->profile_attributes_storage(); |
profile_shortcut_manager_.reset( |
ProfileShortcutManager::Create(profile_manager_->profile_manager())); |
profile_1_name_ = L"My profile"; |
@@ -63,13 +66,13 @@ class ProfileShortcutManagerTest : public testing::Test { |
message_loop_.RunUntilIdle(); |
// Delete all profiles and ensure their shortcuts got removed. |
- const int num_profiles = profile_info_cache_->GetNumberOfProfiles(); |
+ const int num_profiles = profile_attributes_storage_->GetNumberOfProfiles(); |
for (int i = 0; i < num_profiles; ++i) { |
- const base::FilePath profile_path = |
- profile_info_cache_->GetPathOfProfileAtIndex(0); |
- base::string16 profile_name = |
- profile_info_cache_->GetNameOfProfileAtIndex(0); |
- profile_info_cache_->DeleteProfileFromCache(profile_path); |
+ std::vector<ProfileAttributesEntry*> entries = |
+ profile_attributes_storage_->GetAllProfilesAttributes(); |
+ const base::FilePath profile_path = entries[0]->GetPath(); |
+ base::string16 profile_name = entries[0]->GetName(); |
+ profile_attributes_storage_->RemoveProfile(profile_path); |
RunPendingTasks(); |
ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)); |
// The icon file is not deleted until the profile directory is deleted. |
@@ -81,7 +84,7 @@ class ProfileShortcutManagerTest : public testing::Test { |
base::FilePath CreateProfileDirectory(const base::string16& profile_name) { |
const base::FilePath profile_path = |
- profile_info_cache_->GetUserDataDir().Append(profile_name); |
+ profile_attributes_storage_->GetUserDataDir().Append(profile_name); |
base::CreateDirectory(profile_path); |
return profile_path; |
} |
@@ -93,13 +96,13 @@ class ProfileShortcutManagerTest : public testing::Test { |
} |
void SetupDefaultProfileShortcut(const tracked_objects::Location& location) { |
- ASSERT_EQ(0, profile_info_cache_->GetNumberOfProfiles()) |
+ ASSERT_EQ(0, profile_attributes_storage_->GetNumberOfProfiles()) |
<< location.ToString(); |
ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_1_name_)) |
<< location.ToString(); |
- profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_, |
- std::string(), base::string16(), 0, |
- std::string()); |
+ profile_attributes_storage_->AddProfile(profile_1_path_, profile_1_name_, |
+ std::string(), base::string16(), 0, |
+ std::string()); |
// Also create a non-badged shortcut for Chrome, which is conveniently done |
// by |CreateProfileShortcut()| since there is only one profile. |
profile_shortcut_manager_->CreateProfileShortcut(profile_1_path_); |
@@ -186,9 +189,9 @@ class ProfileShortcutManagerTest : public testing::Test { |
const base::FilePath& profile_path) { |
ASSERT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_name)) |
<< location.ToString(); |
- profile_info_cache_->AddProfileToCache(profile_path, profile_name, |
- std::string(), base::string16(), 0, |
- std::string()); |
+ profile_attributes_storage_->AddProfile(profile_path, profile_name, |
+ std::string(), base::string16(), 0, |
+ std::string()); |
profile_shortcut_manager_->CreateProfileShortcut(profile_path); |
RunPendingTasks(); |
ValidateProfileShortcut(location, profile_name, profile_path); |
@@ -237,13 +240,11 @@ class ProfileShortcutManagerTest : public testing::Test { |
void RenameProfile(const tracked_objects::Location& location, |
const base::FilePath& profile_path, |
const base::string16& new_profile_name) { |
- const size_t profile_index = |
- profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_); |
- ASSERT_NE(std::string::npos, profile_index); |
- ASSERT_NE(profile_info_cache_->GetNameOfProfileAtIndex(profile_index), |
- new_profile_name); |
- profile_info_cache_->SetNameOfProfileAtIndex(profile_index, |
- new_profile_name); |
+ ProfileAttributesEntry* entry; |
+ ASSERT_TRUE(profile_attributes_storage_->GetProfileAttributesWithPath( |
+ profile_2_path_, &entry)); |
+ ASSERT_NE(entry->GetName(), new_profile_name); |
+ entry->SetName(new_profile_name); |
RunPendingTasks(); |
} |
@@ -280,7 +281,7 @@ class ProfileShortcutManagerTest : public testing::Test { |
content::TestBrowserThread file_thread_; |
scoped_ptr<TestingProfileManager> profile_manager_; |
scoped_ptr<ProfileShortcutManager> profile_shortcut_manager_; |
- ProfileInfoCache* profile_info_cache_; |
+ ProfileAttributesStorage* profile_attributes_storage_; |
base::ScopedPathOverride fake_user_desktop_; |
base::ScopedPathOverride fake_system_desktop_; |
base::string16 profile_1_name_; |
@@ -335,7 +336,7 @@ TEST_F(ProfileShortcutManagerTest, UnbadgedShortcutFilename) { |
TEST_F(ProfileShortcutManagerTest, ShortcutFlags) { |
const base::string16 kProfileName = L"MyProfileX"; |
const base::FilePath profile_path = |
- profile_info_cache_->GetUserDataDir().Append(kProfileName); |
+ profile_attributes_storage_->GetUserDataDir().Append(kProfileName); |
EXPECT_EQ(L"--profile-directory=\"" + kProfileName + L"\"", |
profiles::internal::CreateProfileShortcutFlags(profile_path)); |
} |
@@ -365,9 +366,9 @@ TEST_F(ProfileShortcutManagerTest, CreateSecondProfileBadgesFirstShortcut) { |
ASSERT_TRUE(ProfileShortcutExistsAtDefaultPath(base::string16())); |
// Create a second profile without a shortcut. |
- profile_info_cache_->AddProfileToCache(profile_2_path_, profile_2_name_, |
- std::string(), base::string16(), 0, |
- std::string()); |
+ profile_attributes_storage_->AddProfile(profile_2_path_, profile_2_name_, |
+ std::string(), base::string16(), 0, |
+ std::string()); |
RunPendingTasks(); |
// Ensure that the second profile doesn't have a shortcut and that the first |
@@ -381,7 +382,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsDeleteSecondToLast) { |
SetupAndCreateTwoShortcuts(FROM_HERE); |
// Delete one shortcut. |
- profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_2_path_); |
RunPendingTasks(); |
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); |
@@ -406,7 +407,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithoutShortcut) { |
ASSERT_TRUE(base::PathExists(profile_2_shortcut_path)); |
// Delete the profile that doesn't have a shortcut. |
- profile_info_cache_->DeleteProfileFromCache(profile_1_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_1_path_); |
RunPendingTasks(); |
// Verify that the remaining shortcut does not have a profile name. |
@@ -430,7 +431,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteSecondToLastProfileWithShortcut) { |
ASSERT_TRUE(base::PathExists(profile_2_shortcut_path)); |
// Delete the profile that has a shortcut. |
- profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_2_path_); |
RunPendingTasks(); |
// Verify that the remaining shortcut does not have a profile name. |
@@ -465,7 +466,7 @@ TEST_F(ProfileShortcutManagerTest, DeleteOnlyProfileWithShortcuts) { |
// Delete the third profile and check that its shortcut is gone and no |
// shortcuts have been re-created. |
- profile_info_cache_->DeleteProfileFromCache(profile_3_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_3_path_); |
RunPendingTasks(); |
ASSERT_FALSE(base::PathExists(profile_1_shortcut_path)); |
ASSERT_FALSE(base::PathExists(profile_2_shortcut_path)); |
@@ -477,7 +478,7 @@ TEST_F(ProfileShortcutManagerTest, DesktopShortcutsCreateSecond) { |
SetupAndCreateTwoShortcuts(FROM_HERE); |
// Delete one shortcut. |
- profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_2_path_); |
RunPendingTasks(); |
// Verify that a default shortcut exists (no profile name/avatar). |
@@ -544,7 +545,7 @@ TEST_F(ProfileShortcutManagerTest, RenamedDesktopShortcutsGetDeleted) { |
EXPECT_TRUE(base::PathExists(preserved_profile_1_shortcut_path)); |
// Delete the profile and ensure both shortcuts were also deleted. |
- profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_2_path_); |
RunPendingTasks(); |
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_1)); |
EXPECT_FALSE(base::PathExists(profile_2_shortcut_path_2)); |
@@ -688,11 +689,11 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) { |
CreateRegularSystemLevelShortcut(FROM_HERE); |
// Create the initial profile. |
- profile_info_cache_->AddProfileToCache(profile_1_path_, profile_1_name_, |
- std::string(), base::string16(), 0, |
- std::string()); |
+ profile_attributes_storage_->AddProfile(profile_1_path_, profile_1_name_, |
+ std::string(), base::string16(), 0, |
+ std::string()); |
RunPendingTasks(); |
- ASSERT_EQ(1U, profile_info_cache_->GetNumberOfProfiles()); |
+ ASSERT_EQ(1U, profile_attributes_storage_->GetNumberOfProfiles()); |
// Ensure system-level continues to exist and user-level was not created. |
EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); |
@@ -707,32 +708,33 @@ TEST_F(ProfileShortcutManagerTest, ProfileShortcutsWithSystemLevelShortcut) { |
EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); |
// Create a third profile without a shortcut and ensure it doesn't get one. |
- profile_info_cache_->AddProfileToCache(profile_3_path_, profile_3_name_, |
- std::string(), base::string16(), 0, |
- std::string()); |
+ profile_attributes_storage_->AddProfile(profile_3_path_, profile_3_name_, |
+ std::string(), base::string16(), 0, |
+ std::string()); |
RunPendingTasks(); |
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); |
+ ProfileAttributesEntry* profile_3_entry; |
+ ASSERT_TRUE(profile_attributes_storage_->GetProfileAttributesWithPath( |
+ profile_3_path_, &profile_3_entry)); |
// Ensure that changing the avatar icon and the name does not result in a |
// shortcut being created. |
- profile_info_cache_->SetAvatarIconOfProfileAtIndex( |
- profile_info_cache_->GetIndexOfProfileWithPath(profile_3_path_), 3); |
+ profile_3_entry->SetAvatarIconIndex(3); |
RunPendingTasks(); |
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); |
const base::string16 new_profile_3_name = L"New Name 3"; |
- profile_info_cache_->SetNameOfProfileAtIndex( |
- profile_info_cache_->GetIndexOfProfileWithPath(profile_3_path_), |
- new_profile_3_name); |
+ profile_3_entry->SetName(new_profile_3_name); |
RunPendingTasks(); |
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_3_name_)); |
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(new_profile_3_name)); |
+ ProfileAttributesEntry* profile_2_entry; |
+ ASSERT_TRUE(profile_attributes_storage_->GetProfileAttributesWithPath( |
+ profile_2_path_, &profile_2_entry)); |
// Rename the second profile and ensure its shortcut got renamed. |
const base::string16 new_profile_2_name = L"New Name 2"; |
- profile_info_cache_->SetNameOfProfileAtIndex( |
- profile_info_cache_->GetIndexOfProfileWithPath(profile_2_path_), |
- new_profile_2_name); |
+ profile_2_entry->SetName(new_profile_2_name); |
RunPendingTasks(); |
EXPECT_FALSE(ProfileShortcutExistsAtDefaultPath(profile_2_name_)); |
ValidateProfileShortcut(FROM_HERE, new_profile_2_name, profile_2_path_); |
@@ -747,7 +749,7 @@ TEST_F(ProfileShortcutManagerTest, |
// Delete a profile and verify that only the system-level shortcut still |
// exists. |
- profile_info_cache_->DeleteProfileFromCache(profile_1_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_1_path_); |
RunPendingTasks(); |
EXPECT_TRUE(base::PathExists(system_level_shortcut_path)); |
@@ -776,7 +778,7 @@ TEST_F(ProfileShortcutManagerTest, |
// Delete the profile that has a shortcut, which will exercise the non-profile |
// shortcut creation path in |DeleteDesktopShortcuts()|, which is |
// not covered by the |DeleteSecondToLastProfileWithSystemLevelShortcut| test. |
- profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_2_path_); |
RunPendingTasks(); |
// Verify that only the system-level shortcut still exists. |
@@ -828,7 +830,7 @@ TEST_F(ProfileShortcutManagerTest, UnbadgeProfileIconOnDeletion) { |
// Deleting the default profile will unbadge the new profile's icon and should |
// result in an icon that is identical to the unbadged default profile icon. |
- profile_info_cache_->DeleteProfileFromCache(profile_1_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_1_path_); |
RunPendingTasks(); |
std::string unbadged_icon_2; |
@@ -842,8 +844,6 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) { |
profiles::internal::GetProfileIconPath(profile_1_path_); |
const base::FilePath icon_path_2 = |
profiles::internal::GetProfileIconPath(profile_2_path_); |
- const size_t profile_index_1 = |
- profile_info_cache_->GetIndexOfProfileWithPath(profile_1_path_); |
std::string badged_icon_1; |
EXPECT_TRUE(base::ReadFileToString(icon_path_1, &badged_icon_1)); |
@@ -853,8 +853,11 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) { |
// Profile 1 and 2 are created with the same icon. |
EXPECT_EQ(badged_icon_1, badged_icon_2); |
+ ProfileAttributesEntry* entry; |
+ ASSERT_TRUE(profile_attributes_storage_->GetProfileAttributesWithPath( |
+ profile_1_path_, &entry)); |
// Change profile 1's icon. |
- profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); |
+ entry->SetAvatarIconIndex(1); |
RunPendingTasks(); |
std::string new_badged_icon_1; |
@@ -862,7 +865,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) { |
EXPECT_NE(new_badged_icon_1, badged_icon_1); |
// Ensure the new icon is not the unbadged icon. |
- profile_info_cache_->DeleteProfileFromCache(profile_2_path_); |
+ profile_attributes_storage_->RemoveProfile(profile_2_path_); |
RunPendingTasks(); |
std::string unbadged_icon_1; |
@@ -870,7 +873,7 @@ TEST_F(ProfileShortcutManagerTest, ProfileIconOnAvatarChange) { |
EXPECT_NE(unbadged_icon_1, new_badged_icon_1); |
// Ensure the icon doesn't change on avatar change without 2 profiles. |
- profile_info_cache_->SetAvatarIconOfProfileAtIndex(profile_index_1, 1); |
+ entry->SetAvatarIconIndex(1); |
RunPendingTasks(); |
std::string unbadged_icon_1_a; |