| OLD | NEW |
| 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 "chrome/browser/profiles/profile_info_cache_unittest.h" | 5 #include "chrome/browser/profiles/profile_info_cache_unittest.h" |
| 6 | 6 |
| 7 #include <stddef.h> |
| 8 #include <stdint.h> |
| 9 |
| 7 #include <vector> | 10 #include <vector> |
| 8 | 11 |
| 9 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 10 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
| 14 #include "base/macros.h" |
| 11 #include "base/prefs/testing_pref_service.h" | 15 #include "base/prefs/testing_pref_service.h" |
| 12 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
| 14 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "build/build_config.h" |
| 15 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 16 #include "chrome/browser/profiles/profile_avatar_downloader.h" | 21 #include "chrome/browser/profiles/profile_avatar_downloader.h" |
| 17 #include "chrome/browser/profiles/profile_avatar_icon_util.h" | 22 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 18 #include "chrome/browser/profiles/profile_info_cache.h" | 23 #include "chrome/browser/profiles/profile_info_cache.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 24 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/common/chrome_paths.h" | 25 #include "chrome/common/chrome_paths.h" |
| 21 #include "chrome/common/chrome_switches.h" | 26 #include "chrome/common/chrome_switches.h" |
| 22 #include "chrome/common/pref_names.h" | 27 #include "chrome/common/pref_names.h" |
| 23 #include "chrome/test/base/testing_browser_process.h" | 28 #include "chrome/test/base/testing_browser_process.h" |
| 24 #include "components/signin/core/common/profile_management_switches.h" | 29 #include "components/signin/core/common/profile_management_switches.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 } | 123 } |
| 119 | 124 |
| 120 void ProfileInfoCacheTest::ResetCache() { | 125 void ProfileInfoCacheTest::ResetCache() { |
| 121 testing_profile_manager_.DeleteProfileInfoCache(); | 126 testing_profile_manager_.DeleteProfileInfoCache(); |
| 122 } | 127 } |
| 123 | 128 |
| 124 TEST_F(ProfileInfoCacheTest, AddProfiles) { | 129 TEST_F(ProfileInfoCacheTest, AddProfiles) { |
| 125 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); | 130 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); |
| 126 | 131 |
| 127 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 132 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| 128 for (uint32 i = 0; i < 4; ++i) { | 133 for (uint32_t i = 0; i < 4; ++i) { |
| 129 base::FilePath profile_path = | 134 base::FilePath profile_path = |
| 130 GetProfilePath(base::StringPrintf("path_%ud", i)); | 135 GetProfilePath(base::StringPrintf("path_%ud", i)); |
| 131 base::string16 profile_name = | 136 base::string16 profile_name = |
| 132 ASCIIToUTF16(base::StringPrintf("name_%ud", i)); | 137 ASCIIToUTF16(base::StringPrintf("name_%ud", i)); |
| 133 const SkBitmap* icon = rb.GetImageNamed( | 138 const SkBitmap* icon = rb.GetImageNamed( |
| 134 profiles::GetDefaultAvatarIconResourceIDAtIndex( | 139 profiles::GetDefaultAvatarIconResourceIDAtIndex( |
| 135 i)).ToSkBitmap(); | 140 i)).ToSkBitmap(); |
| 136 std::string supervised_user_id = i == 3 ? "TEST_ID" : ""; | 141 std::string supervised_user_id = i == 3 ? "TEST_ID" : ""; |
| 137 | 142 |
| 138 GetCache()->AddProfileToCache(profile_path, profile_name, std::string(), | 143 GetCache()->AddProfileToCache(profile_path, profile_name, std::string(), |
| (...skipping 12 matching lines...) Expand all Loading... |
| 151 EXPECT_EQ(i == 3, GetCache()->ProfileIsSupervisedAtIndex(i)); | 156 EXPECT_EQ(i == 3, GetCache()->ProfileIsSupervisedAtIndex(i)); |
| 152 EXPECT_EQ(i == 3, GetCache()->IsOmittedProfileAtIndex(i)); | 157 EXPECT_EQ(i == 3, GetCache()->IsOmittedProfileAtIndex(i)); |
| 153 EXPECT_EQ(supervised_user_id, | 158 EXPECT_EQ(supervised_user_id, |
| 154 GetCache()->GetSupervisedUserIdOfProfileAtIndex(i)); | 159 GetCache()->GetSupervisedUserIdOfProfileAtIndex(i)); |
| 155 } | 160 } |
| 156 | 161 |
| 157 // Reset the cache and test the it reloads correctly. | 162 // Reset the cache and test the it reloads correctly. |
| 158 ResetCache(); | 163 ResetCache(); |
| 159 | 164 |
| 160 EXPECT_EQ(4u, GetCache()->GetNumberOfProfiles()); | 165 EXPECT_EQ(4u, GetCache()->GetNumberOfProfiles()); |
| 161 for (uint32 i = 0; i < 4; ++i) { | 166 for (uint32_t i = 0; i < 4; ++i) { |
| 162 base::FilePath profile_path = | 167 base::FilePath profile_path = |
| 163 GetProfilePath(base::StringPrintf("path_%ud", i)); | 168 GetProfilePath(base::StringPrintf("path_%ud", i)); |
| 164 EXPECT_EQ(i, GetCache()->GetIndexOfProfileWithPath(profile_path)); | 169 EXPECT_EQ(i, GetCache()->GetIndexOfProfileWithPath(profile_path)); |
| 165 base::string16 profile_name = | 170 base::string16 profile_name = |
| 166 ASCIIToUTF16(base::StringPrintf("name_%ud", i)); | 171 ASCIIToUTF16(base::StringPrintf("name_%ud", i)); |
| 167 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); | 172 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); |
| 168 EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i)); | 173 EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i)); |
| 169 EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i)); | 174 EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i)); |
| 170 base::string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i)); | 175 base::string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i)); |
| 171 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i)); | 176 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i)); |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 718 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( | 723 EXPECT_EQ(name_1, GetCache()->GetNameOfProfileAtIndex( |
| 719 GetCache()->GetIndexOfProfileWithPath(path_1))); | 724 GetCache()->GetIndexOfProfileWithPath(path_1))); |
| 720 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( | 725 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex( |
| 721 GetCache()->GetIndexOfProfileWithPath(path_2))); | 726 GetCache()->GetIndexOfProfileWithPath(path_2))); |
| 722 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( | 727 EXPECT_EQ(name_3, GetCache()->GetNameOfProfileAtIndex( |
| 723 GetCache()->GetIndexOfProfileWithPath(path_3))); | 728 GetCache()->GetIndexOfProfileWithPath(path_3))); |
| 724 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( | 729 EXPECT_EQ(name_4, GetCache()->GetNameOfProfileAtIndex( |
| 725 GetCache()->GetIndexOfProfileWithPath(path_4))); | 730 GetCache()->GetIndexOfProfileWithPath(path_4))); |
| 726 } | 731 } |
| 727 #endif | 732 #endif |
| OLD | NEW |