[email protected] | ca59107 | 2012-03-27 01:54:44 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 5 | #include "chrome/browser/profiles/profile_info_cache_unittest.h" |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 6 | |
[email protected] | 04748180 | 2013-09-16 22:26:38 | [diff] [blame^] | 7 | #include <vector> |
| 8 | |
[email protected] | e5ba874f | 2013-02-14 17:20:19 | [diff] [blame] | 9 | #include "base/prefs/testing_pref_service.h" |
[email protected] | 76fb05c | 2013-06-11 04:38:05 | [diff] [blame] | 10 | #include "base/strings/stringprintf.h" |
[email protected] | e309f31 | 2013-06-07 21:50:08 | [diff] [blame] | 11 | #include "base/strings/utf_string_conversions.h" |
[email protected] | 583844c | 2011-08-27 00:38:35 | [diff] [blame] | 12 | #include "chrome/browser/browser_process.h" |
[email protected] | 25ff086 | 2013-07-12 00:59:03 | [diff] [blame] | 13 | #include "chrome/browser/chrome_notification_types.h" |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 14 | #include "chrome/browser/prefs/pref_service_syncable.h" |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 15 | #include "chrome/browser/profiles/profile_info_cache.h" |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 16 | #include "chrome/browser/profiles/profile_manager.h" |
[email protected] | 583844c | 2011-08-27 00:38:35 | [diff] [blame] | 17 | #include "chrome/test/base/testing_browser_process.h" |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 18 | #include "content/public/browser/notification_observer.h" |
| 19 | #include "content/public/browser/notification_registrar.h" |
[email protected] | c0b03090 | 2011-12-19 16:21:05 | [diff] [blame] | 20 | #include "content/public/browser/notification_service.h" |
[email protected] | a7fe911 | 2012-07-20 02:34:45 | [diff] [blame] | 21 | #include "content/public/test/test_utils.h" |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 22 | #include "third_party/skia/include/core/SkBitmap.h" |
| 23 | #include "ui/base/resource/resource_bundle.h" |
| 24 | #include "ui/gfx/image/image.h" |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 25 | #include "ui/gfx/image/image_unittest_util.h" |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 26 | |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 27 | using content::BrowserThread; |
| 28 | |
[email protected] | 6a46066 | 2011-12-22 22:05:16 | [diff] [blame] | 29 | ProfileNameVerifierObserver::ProfileNameVerifierObserver( |
| 30 | TestingProfileManager* testing_profile_manager) |
| 31 | : testing_profile_manager_(testing_profile_manager) { |
| 32 | DCHECK(testing_profile_manager_); |
[email protected] | 590e189b | 2011-12-13 22:07:03 | [diff] [blame] | 33 | } |
| 34 | |
| 35 | ProfileNameVerifierObserver::~ProfileNameVerifierObserver() { |
| 36 | } |
| 37 | |
| 38 | void ProfileNameVerifierObserver::OnProfileAdded( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 39 | const base::FilePath& profile_path) { |
[email protected] | 6a46066 | 2011-12-22 22:05:16 | [diff] [blame] | 40 | string16 profile_name = GetCache()->GetNameOfProfileAtIndex( |
| 41 | GetCache()->GetIndexOfProfileWithPath(profile_path)); |
[email protected] | 590e189b | 2011-12-13 22:07:03 | [diff] [blame] | 42 | EXPECT_TRUE(profile_names_.find(profile_name) == profile_names_.end()); |
| 43 | profile_names_.insert(profile_name); |
| 44 | } |
| 45 | |
[email protected] | 7b0af15 | 2011-12-16 17:02:06 | [diff] [blame] | 46 | void ProfileNameVerifierObserver::OnProfileWillBeRemoved( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 47 | const base::FilePath& profile_path) { |
[email protected] | 6a46066 | 2011-12-22 22:05:16 | [diff] [blame] | 48 | string16 profile_name = GetCache()->GetNameOfProfileAtIndex( |
| 49 | GetCache()->GetIndexOfProfileWithPath(profile_path)); |
[email protected] | 590e189b | 2011-12-13 22:07:03 | [diff] [blame] | 50 | EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end()); |
| 51 | profile_names_.erase(profile_name); |
| 52 | } |
| 53 | |
[email protected] | 7b0af15 | 2011-12-16 17:02:06 | [diff] [blame] | 54 | void ProfileNameVerifierObserver::OnProfileWasRemoved( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 55 | const base::FilePath& profile_path, |
[email protected] | 7b0af15 | 2011-12-16 17:02:06 | [diff] [blame] | 56 | const string16& profile_name) { |
| 57 | EXPECT_TRUE(profile_names_.find(profile_name) == profile_names_.end()); |
| 58 | } |
| 59 | |
[email protected] | 590e189b | 2011-12-13 22:07:03 | [diff] [blame] | 60 | void ProfileNameVerifierObserver::OnProfileNameChanged( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 61 | const base::FilePath& profile_path, |
[email protected] | 6a46066 | 2011-12-22 22:05:16 | [diff] [blame] | 62 | const string16& old_profile_name) { |
| 63 | string16 new_profile_name = GetCache()->GetNameOfProfileAtIndex( |
| 64 | GetCache()->GetIndexOfProfileWithPath(profile_path)); |
[email protected] | 590e189b | 2011-12-13 22:07:03 | [diff] [blame] | 65 | EXPECT_TRUE(profile_names_.find(old_profile_name) != profile_names_.end()); |
| 66 | EXPECT_TRUE(profile_names_.find(new_profile_name) == profile_names_.end()); |
| 67 | profile_names_.erase(old_profile_name); |
| 68 | profile_names_.insert(new_profile_name); |
| 69 | } |
| 70 | |
| 71 | void ProfileNameVerifierObserver::OnProfileAvatarChanged( |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 72 | const base::FilePath& profile_path) { |
[email protected] | 6a46066 | 2011-12-22 22:05:16 | [diff] [blame] | 73 | string16 profile_name = GetCache()->GetNameOfProfileAtIndex( |
| 74 | GetCache()->GetIndexOfProfileWithPath(profile_path)); |
[email protected] | 590e189b | 2011-12-13 22:07:03 | [diff] [blame] | 75 | EXPECT_TRUE(profile_names_.find(profile_name) != profile_names_.end()); |
| 76 | } |
| 77 | |
[email protected] | 6a46066 | 2011-12-22 22:05:16 | [diff] [blame] | 78 | ProfileInfoCache* ProfileNameVerifierObserver::GetCache() { |
| 79 | return testing_profile_manager_->profile_info_cache(); |
| 80 | } |
| 81 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 82 | ProfileInfoCacheTest::ProfileInfoCacheTest() |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 83 | : testing_profile_manager_(TestingBrowserProcess::GetGlobal()), |
[email protected] | 6a46066 | 2011-12-22 22:05:16 | [diff] [blame] | 84 | name_observer_(&testing_profile_manager_) { |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 85 | } |
| 86 | |
| 87 | ProfileInfoCacheTest::~ProfileInfoCacheTest() { |
| 88 | } |
| 89 | |
| 90 | void ProfileInfoCacheTest::SetUp() { |
| 91 | ASSERT_TRUE(testing_profile_manager_.SetUp()); |
[email protected] | 590e189b | 2011-12-13 22:07:03 | [diff] [blame] | 92 | testing_profile_manager_.profile_info_cache()->AddObserver(&name_observer_); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 93 | } |
| 94 | |
[email protected] | 1302dcf | 2011-11-30 21:47:05 | [diff] [blame] | 95 | void ProfileInfoCacheTest::TearDown() { |
| 96 | // Drain the UI thread to make sure all tasks are completed. This prevents |
| 97 | // memory leaks. |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 98 | base::RunLoop().RunUntilIdle(); |
[email protected] | 1302dcf | 2011-11-30 21:47:05 | [diff] [blame] | 99 | } |
| 100 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 101 | ProfileInfoCache* ProfileInfoCacheTest::GetCache() { |
| 102 | return testing_profile_manager_.profile_info_cache(); |
| 103 | } |
| 104 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 105 | base::FilePath ProfileInfoCacheTest::GetProfilePath( |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 106 | const std::string& base_name) { |
| 107 | return testing_profile_manager_.profile_manager()->user_data_dir(). |
| 108 | AppendASCII(base_name); |
| 109 | } |
| 110 | |
| 111 | void ProfileInfoCacheTest::ResetCache() { |
| 112 | testing_profile_manager_.DeleteProfileInfoCache(); |
| 113 | } |
| 114 | |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 115 | namespace { |
| 116 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 117 | TEST_F(ProfileInfoCacheTest, AddProfiles) { |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 118 | EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 119 | |
[email protected] | ca59107 | 2012-03-27 01:54:44 | [diff] [blame] | 120 | ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 121 | for (uint32 i = 0; i < 4; ++i) { |
[email protected] | 7d3cbc9 | 2013-03-18 22:33:04 | [diff] [blame] | 122 | base::FilePath profile_path = |
| 123 | GetProfilePath(base::StringPrintf("path_%ud", i)); |
| 124 | string16 profile_name = ASCIIToUTF16(base::StringPrintf("name_%ud", i)); |
[email protected] | ca59107 | 2012-03-27 01:54:44 | [diff] [blame] | 125 | const SkBitmap* icon = rb.GetImageNamed( |
| 126 | ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex( |
| 127 | i)).ToSkBitmap(); |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 128 | std::string managed_user_id = i == 3 ? "TEST_ID" : ""; |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 129 | |
[email protected] | fea25d8 | 2012-12-19 01:19:50 | [diff] [blame] | 130 | GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i, |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 131 | managed_user_id); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 132 | GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true); |
[email protected] | 7d3cbc9 | 2013-03-18 22:33:04 | [diff] [blame] | 133 | string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i)); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 134 | GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 135 | |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 136 | EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles()); |
| 137 | EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); |
| 138 | EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 139 | const SkBitmap* actual_icon = |
| 140 | GetCache()->GetAvatarIconOfProfileAtIndex(i).ToSkBitmap(); |
[email protected] | ca59107 | 2012-03-27 01:54:44 | [diff] [blame] | 141 | EXPECT_EQ(icon->width(), actual_icon->width()); |
| 142 | EXPECT_EQ(icon->height(), actual_icon->height()); |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 143 | EXPECT_EQ(i == 3, GetCache()->ProfileIsManagedAtIndex(i)); |
| 144 | EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i)); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 145 | } |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 146 | |
| 147 | // Reset the cache and test the it reloads correctly. |
| 148 | ResetCache(); |
| 149 | |
| 150 | EXPECT_EQ(4u, GetCache()->GetNumberOfProfiles()); |
| 151 | for (uint32 i = 0; i < 4; ++i) { |
[email protected] | 7d3cbc9 | 2013-03-18 22:33:04 | [diff] [blame] | 152 | base::FilePath profile_path = |
| 153 | GetProfilePath(base::StringPrintf("path_%ud", i)); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 154 | EXPECT_EQ(i, GetCache()->GetIndexOfProfileWithPath(profile_path)); |
[email protected] | 7d3cbc9 | 2013-03-18 22:33:04 | [diff] [blame] | 155 | string16 profile_name = ASCIIToUTF16(base::StringPrintf("name_%ud", i)); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 156 | EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); |
| 157 | EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i)); |
| 158 | EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i)); |
[email protected] | 7d3cbc9 | 2013-03-18 22:33:04 | [diff] [blame] | 159 | string16 gaia_name = ASCIIToUTF16(base::StringPrintf("gaia_%ud", i)); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 160 | EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i)); |
| 161 | } |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 162 | } |
| 163 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 164 | TEST_F(ProfileInfoCacheTest, DeleteProfile) { |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 165 | EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 166 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 167 | base::FilePath path_1 = GetProfilePath("path_1"); |
[email protected] | 73cb372 | 2011-10-11 18:12:13 | [diff] [blame] | 168 | GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), string16(), |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 169 | 0, std::string()); |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 170 | EXPECT_EQ(1u, GetCache()->GetNumberOfProfiles()); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 171 | |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 172 | base::FilePath path_2 = GetProfilePath("path_2"); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 173 | string16 name_2 = ASCIIToUTF16("name_2"); |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 174 | GetCache()->AddProfileToCache(path_2, name_2, string16(), 0, std::string()); |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 175 | EXPECT_EQ(2u, GetCache()->GetNumberOfProfiles()); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 176 | |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 177 | GetCache()->DeleteProfileFromCache(path_1); |
| 178 | EXPECT_EQ(1u, GetCache()->GetNumberOfProfiles()); |
| 179 | EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex(0)); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 180 | |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 181 | GetCache()->DeleteProfileFromCache(path_2); |
| 182 | EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 183 | } |
| 184 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 185 | TEST_F(ProfileInfoCacheTest, MutateProfile) { |
| 186 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 187 | GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
| 188 | string16(), 0, std::string()); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 189 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 190 | GetProfilePath("path_2"), ASCIIToUTF16("name_2"), |
| 191 | string16(), 0, std::string()); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 192 | |
| 193 | string16 new_name = ASCIIToUTF16("new_name"); |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 194 | GetCache()->SetNameOfProfileAtIndex(1, new_name); |
| 195 | EXPECT_EQ(new_name, GetCache()->GetNameOfProfileAtIndex(1)); |
| 196 | EXPECT_NE(new_name, GetCache()->GetNameOfProfileAtIndex(0)); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 197 | |
[email protected] | e8e7809 | 2011-09-29 18:15:38 | [diff] [blame] | 198 | string16 new_user_name = ASCIIToUTF16("user_name"); |
| 199 | GetCache()->SetUserNameOfProfileAtIndex(1, new_user_name); |
| 200 | EXPECT_EQ(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(1)); |
| 201 | EXPECT_NE(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(0)); |
| 202 | |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 203 | size_t new_icon_index = 3; |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 204 | GetCache()->SetAvatarIconOfProfileAtIndex(1, new_icon_index); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 205 | // Not much to test. |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 206 | GetCache()->GetAvatarIconOfProfileAtIndex(1); |
[email protected] | dee810e | 2011-06-27 19:43:39 | [diff] [blame] | 207 | } |
| 208 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 209 | TEST_F(ProfileInfoCacheTest, Sort) { |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 210 | string16 name_a = ASCIIToUTF16("apple"); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 211 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 212 | GetProfilePath("path_a"), name_a, string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 213 | |
| 214 | string16 name_c = ASCIIToUTF16("cat"); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 215 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 216 | GetProfilePath("path_c"), name_c, string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 217 | |
| 218 | // Sanity check the initial order. |
| 219 | EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0)); |
| 220 | EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(1)); |
| 221 | |
| 222 | // Add a new profile (start with a capital to test case insensitive sorting. |
| 223 | string16 name_b = ASCIIToUTF16("Banana"); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 224 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 225 | GetProfilePath("path_b"), name_b, string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 226 | |
| 227 | // Verify the new order. |
| 228 | EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0)); |
| 229 | EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(1)); |
| 230 | EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(2)); |
| 231 | |
| 232 | // Change the name of an existing profile. |
| 233 | name_a = UTF8ToUTF16("dog"); |
| 234 | GetCache()->SetNameOfProfileAtIndex(0, name_a); |
| 235 | |
| 236 | // Verify the new order. |
| 237 | EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(0)); |
| 238 | EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(1)); |
| 239 | EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(2)); |
| 240 | |
| 241 | // Delete a profile. |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 242 | GetCache()->DeleteProfileFromCache(GetProfilePath("path_c")); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 243 | |
| 244 | // Verify the new order. |
| 245 | EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(0)); |
| 246 | EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(1)); |
| 247 | } |
| 248 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 249 | TEST_F(ProfileInfoCacheTest, BackgroundModeStatus) { |
[email protected] | 27917083 | 2011-10-12 23:38:03 | [diff] [blame] | 250 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 251 | GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
| 252 | string16(), 0, std::string()); |
[email protected] | 27917083 | 2011-10-12 23:38:03 | [diff] [blame] | 253 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 254 | GetProfilePath("path_2"), ASCIIToUTF16("name_2"), |
| 255 | string16(), 0, std::string()); |
[email protected] | 27917083 | 2011-10-12 23:38:03 | [diff] [blame] | 256 | |
| 257 | EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); |
| 258 | EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); |
| 259 | |
| 260 | GetCache()->SetBackgroundStatusOfProfileAtIndex(1, true); |
| 261 | |
| 262 | EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); |
| 263 | EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); |
| 264 | |
| 265 | GetCache()->SetBackgroundStatusOfProfileAtIndex(0, true); |
| 266 | |
| 267 | EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); |
| 268 | EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); |
| 269 | |
| 270 | GetCache()->SetBackgroundStatusOfProfileAtIndex(1, false); |
| 271 | |
| 272 | EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); |
| 273 | EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); |
| 274 | } |
| 275 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 276 | TEST_F(ProfileInfoCacheTest, HasMigrated) { |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 277 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 278 | GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
| 279 | string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 280 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 281 | GetProfilePath("path_2"), ASCIIToUTF16("name_2"), |
| 282 | string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 283 | |
| 284 | // Sanity check. |
| 285 | EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); |
| 286 | EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); |
| 287 | |
| 288 | // Set migrated state for 2nd profile. |
| 289 | GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, true); |
| 290 | EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); |
| 291 | EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); |
| 292 | |
| 293 | // Set migrated state for 1st profile. |
| 294 | GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(0, true); |
| 295 | EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); |
| 296 | EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); |
| 297 | |
| 298 | // Unset migrated state for 2nd profile. |
| 299 | GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, false); |
| 300 | EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0)); |
| 301 | EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1)); |
| 302 | } |
| 303 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 304 | TEST_F(ProfileInfoCacheTest, GAIAName) { |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 305 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 306 | GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
| 307 | string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 308 | string16 profile_name(ASCIIToUTF16("profile name 2")); |
| 309 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 310 | GetProfilePath("path_2"), profile_name, string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 311 | |
| 312 | // Sanity check. |
| 313 | EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty()); |
| 314 | EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(1).empty()); |
| 315 | EXPECT_FALSE(GetCache()->IsUsingGAIANameOfProfileAtIndex(0)); |
| 316 | EXPECT_FALSE(GetCache()->IsUsingGAIANameOfProfileAtIndex(1)); |
| 317 | |
| 318 | // Set GAIA name. |
| 319 | string16 gaia_name(ASCIIToUTF16("Pat Smith")); |
| 320 | GetCache()->SetGAIANameOfProfileAtIndex(1, gaia_name); |
| 321 | EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty()); |
| 322 | EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1)); |
| 323 | EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(1)); |
| 324 | |
| 325 | // Use GAIA name as profile name. |
| 326 | GetCache()->SetIsUsingGAIANameOfProfileAtIndex(1, true); |
| 327 | |
| 328 | EXPECT_EQ(gaia_name, GetCache()->GetNameOfProfileAtIndex(1)); |
| 329 | EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1)); |
| 330 | |
| 331 | // Don't use GAIA name as profile name. |
| 332 | GetCache()->SetIsUsingGAIANameOfProfileAtIndex(1, false); |
| 333 | EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(1)); |
| 334 | EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1)); |
| 335 | } |
| 336 | |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 337 | TEST_F(ProfileInfoCacheTest, GAIAPicture) { |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 338 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 339 | GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
| 340 | string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 341 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 342 | GetProfilePath("path_2"), ASCIIToUTF16("name_2"), |
| 343 | string16(), 0, std::string()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 344 | |
| 345 | // Sanity check. |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 346 | EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); |
| 347 | EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(1)); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 348 | EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(0)); |
| 349 | EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1)); |
| 350 | |
| 351 | // The profile icon should be the default one. |
| 352 | int id = ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(0); |
| 353 | const gfx::Image& profile_image( |
| 354 | ResourceBundle::GetSharedInstance().GetImageNamed(id)); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 355 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 356 | profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
| 357 | |
| 358 | // Set GAIA picture. |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 359 | gfx::Image gaia_image(gfx::test::CreateImage()); |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 360 | GetCache()->SetGAIAPictureOfProfileAtIndex(1, &gaia_image); |
| 361 | EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 362 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 363 | gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1))); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 364 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 365 | profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
| 366 | |
| 367 | // Use GAIA picture as profile picture. |
| 368 | GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, true); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 369 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 370 | gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1))); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 371 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 372 | gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
| 373 | |
| 374 | // Don't use GAIA picture as profile picture. |
| 375 | GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, false); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 376 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 377 | gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1))); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 378 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 379 | profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
| 380 | } |
| 381 | |
[email protected] | 754bebc | 2011-12-01 16:42:16 | [diff] [blame] | 382 | TEST_F(ProfileInfoCacheTest, PersistGAIAPicture) { |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 383 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 384 | GetProfilePath("path_1"), ASCIIToUTF16("name_1"), |
| 385 | string16(), 0, std::string()); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 386 | gfx::Image gaia_image(gfx::test::CreateImage()); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 387 | |
[email protected] | a7fe911 | 2012-07-20 02:34:45 | [diff] [blame] | 388 | content::WindowedNotificationObserver save_observer( |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 389 | chrome::NOTIFICATION_PROFILE_CACHE_PICTURE_SAVED, |
| 390 | content::NotificationService::AllSources()); |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 391 | GetCache()->SetGAIAPictureOfProfileAtIndex(0, &gaia_image); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 392 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 393 | gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(0))); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 394 | |
| 395 | // Wait for the file to be written to disk then reset the cache. |
| 396 | save_observer.Wait(); |
| 397 | ResetCache(); |
| 398 | |
| 399 | // Try to get the GAIA picture. This should return NULL until the read from |
| 400 | // disk is done. |
[email protected] | a7fe911 | 2012-07-20 02:34:45 | [diff] [blame] | 401 | content::WindowedNotificationObserver read_observer( |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 402 | chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
| 403 | content::NotificationService::AllSources()); |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 404 | EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 405 | read_observer.Wait(); |
[email protected] | d4f5d116 | 2011-11-30 01:41:52 | [diff] [blame] | 406 | EXPECT_TRUE(gfx::test::IsEqual( |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 407 | gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(0))); |
| 408 | } |
| 409 | |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 410 | TEST_F(ProfileInfoCacheTest, SetManagedUserId) { |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 411 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 412 | GetProfilePath("test"), ASCIIToUTF16("Test"), |
| 413 | string16(), 0, std::string()); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 414 | EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0)); |
| 415 | |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 416 | GetCache()->SetManagedUserIdOfProfileAtIndex(0, "TEST_ID"); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 417 | EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0)); |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 418 | EXPECT_EQ("TEST_ID", GetCache()->GetManagedUserIdOfProfileAtIndex(0)); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 419 | |
| 420 | ResetCache(); |
| 421 | EXPECT_TRUE(GetCache()->ProfileIsManagedAtIndex(0)); |
| 422 | |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 423 | GetCache()->SetManagedUserIdOfProfileAtIndex(0, std::string()); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 424 | EXPECT_FALSE(GetCache()->ProfileIsManagedAtIndex(0)); |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 425 | EXPECT_EQ("", GetCache()->GetManagedUserIdOfProfileAtIndex(0)); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 426 | } |
| 427 | |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 428 | TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) { |
| 429 | string16 profile_name = ASCIIToUTF16("name_1"); |
| 430 | int id = ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(0); |
| 431 | const gfx::Image& profile_image( |
| 432 | ResourceBundle::GetSharedInstance().GetImageNamed(id)); |
| 433 | |
| 434 | GetCache()->AddProfileToCache( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 435 | GetProfilePath("path_1"), profile_name, string16(), 0, std::string()); |
[email protected] | 2f3c00f | 2011-11-30 04:36:22 | [diff] [blame] | 436 | |
| 437 | // Set empty GAIA info. |
| 438 | GetCache()->SetGAIANameOfProfileAtIndex(0, string16()); |
| 439 | GetCache()->SetGAIAPictureOfProfileAtIndex(0, NULL); |
| 440 | GetCache()->SetIsUsingGAIANameOfProfileAtIndex(0, true); |
| 441 | GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(0, true); |
| 442 | |
| 443 | // Verify that the profile name and picture are not empty. |
| 444 | EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(0)); |
| 445 | EXPECT_TRUE(gfx::test::IsEqual( |
| 446 | profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0))); |
[email protected] | cb114f14 | 2011-11-23 20:18:04 | [diff] [blame] | 447 | } |
| 448 | |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 449 | TEST_F(ProfileInfoCacheTest, CreateManagedTestingProfile) { |
| 450 | testing_profile_manager_.CreateTestingProfile("default"); |
| 451 | string16 managed_user_name = ASCIIToUTF16("Supervised User"); |
| 452 | testing_profile_manager_.CreateTestingProfile( |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 453 | "test1", scoped_ptr<PrefServiceSyncable>(), |
| 454 | managed_user_name, 0, "TEST_ID"); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 455 | for (size_t i = 0; i < GetCache()->GetNumberOfProfiles(); i++) { |
| 456 | bool is_managed = |
| 457 | GetCache()->GetNameOfProfileAtIndex(i) == managed_user_name; |
| 458 | EXPECT_EQ(is_managed, GetCache()->ProfileIsManagedAtIndex(i)); |
[email protected] | a6e01b4 | 2013-08-05 14:13:13 | [diff] [blame] | 459 | std::string managed_user_id = is_managed ? "TEST_ID" : ""; |
| 460 | EXPECT_EQ(managed_user_id, GetCache()->GetManagedUserIdOfProfileAtIndex(i)); |
[email protected] | 0aa018a | 2013-07-31 15:08:54 | [diff] [blame] | 461 | } |
| 462 | } |
| 463 | |
[email protected] | 04748180 | 2013-09-16 22:26:38 | [diff] [blame^] | 464 | TEST_F(ProfileInfoCacheTest, AddStubProfile) { |
| 465 | EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); |
| 466 | |
| 467 | // Add some profiles with and without a '.' in their paths. |
| 468 | const struct { |
| 469 | const char* profile_path; |
| 470 | const char* profile_name; |
| 471 | } kTestCases[] = { |
| 472 | { "path.test0", "name_0" }, |
| 473 | { "path_test1", "name_1" }, |
| 474 | { "path.test2", "name_2" }, |
| 475 | { "path_test3", "name_3" }, |
| 476 | }; |
| 477 | |
| 478 | for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
| 479 | base::FilePath profile_path = GetProfilePath(kTestCases[i].profile_path); |
| 480 | string16 profile_name = ASCIIToUTF16(kTestCases[i].profile_name); |
| 481 | |
| 482 | GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i, |
| 483 | ""); |
| 484 | |
| 485 | EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); |
| 486 | EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); |
| 487 | } |
| 488 | |
| 489 | ASSERT_EQ(4U, GetCache()->GetNumberOfProfiles()); |
| 490 | |
| 491 | // Check that the profiles can be extracted from the local state. |
| 492 | std::vector<string16> names = ProfileInfoCache::GetProfileNames(); |
| 493 | for (size_t i = 0; i < 4; i++) |
| 494 | ASSERT_FALSE(names[i].empty()); |
| 495 | } |
| 496 | |
[email protected] | 6730b1e | 2011-09-29 05:23:52 | [diff] [blame] | 497 | } // namespace |