blob: ccbefcff59d7364c29404bb2096b3bfd57d4c9f7 [file] [log] [blame]
[email protected]dee810e2011-06-27 19:43:391// Copyright (c) 2011 The Chromium Authors. All rights reserved.
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]d4f5d1162011-11-30 01:41:525#include "chrome/browser/profiles/profile_info_cache_unittest.h"
[email protected]dee810e2011-06-27 19:43:396
7#include "base/stringprintf.h"
8#include "base/utf_string_conversions.h"
[email protected]583844c2011-08-27 00:38:359#include "chrome/browser/browser_process.h"
[email protected]d4f5d1162011-11-30 01:41:5210#include "chrome/browser/profiles/profile_info_cache.h"
[email protected]6730b1e2011-09-29 05:23:5211#include "chrome/browser/profiles/profile_manager.h"
[email protected]cb114f142011-11-23 20:18:0412#include "chrome/common/chrome_notification_types.h"
[email protected]583844c2011-08-27 00:38:3513#include "chrome/test/base/testing_browser_process.h"
[email protected]8ad3636e2011-08-01 22:31:4014#include "chrome/test/base/testing_pref_service.h"
[email protected]cb114f142011-11-23 20:18:0415#include "chrome/test/base/ui_test_utils.h"
16#include "content/public/browser/notification_observer.h"
17#include "content/public/browser/notification_registrar.h"
[email protected]dee810e2011-06-27 19:43:3918#include "third_party/skia/include/core/SkBitmap.h"
19#include "ui/base/resource/resource_bundle.h"
20#include "ui/gfx/image/image.h"
[email protected]d4f5d1162011-11-30 01:41:5221#include "ui/gfx/image/image_unittest_util.h"
[email protected]dee810e2011-06-27 19:43:3922
[email protected]cb114f142011-11-23 20:18:0423using content::BrowserThread;
24
[email protected]d4f5d1162011-11-30 01:41:5225ProfileInfoCacheTest::ProfileInfoCacheTest()
26 : testing_profile_manager_(
27 static_cast<TestingBrowserProcess*>(g_browser_process)),
28 ui_thread_(BrowserThread::UI, &ui_loop_),
29 file_thread_(BrowserThread::FILE, &ui_loop_) {
30}
31
32ProfileInfoCacheTest::~ProfileInfoCacheTest() {
33}
34
35void ProfileInfoCacheTest::SetUp() {
36 ASSERT_TRUE(testing_profile_manager_.SetUp());
37}
38
[email protected]1302dcf2011-11-30 21:47:0539void ProfileInfoCacheTest::TearDown() {
40 // Drain the UI thread to make sure all tasks are completed. This prevents
41 // memory leaks.
42 ui_loop_.RunAllPending();
43}
44
[email protected]d4f5d1162011-11-30 01:41:5245ProfileInfoCache* ProfileInfoCacheTest::GetCache() {
46 return testing_profile_manager_.profile_info_cache();
47}
48
49FilePath ProfileInfoCacheTest::GetProfilePath(
50 const std::string& base_name) {
51 return testing_profile_manager_.profile_manager()->user_data_dir().
52 AppendASCII(base_name);
53}
54
55void ProfileInfoCacheTest::ResetCache() {
56 testing_profile_manager_.DeleteProfileInfoCache();
57}
58
[email protected]dee810e2011-06-27 19:43:3959namespace {
60
[email protected]d4f5d1162011-11-30 01:41:5261TEST_F(ProfileInfoCacheTest, AddProfiles) {
[email protected]6730b1e2011-09-29 05:23:5262 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
[email protected]dee810e2011-06-27 19:43:3963
64 for (uint32 i = 0; i < 4; ++i) {
[email protected]d4f5d1162011-11-30 01:41:5265 FilePath profile_path = GetProfilePath(StringPrintf("path_%ud", i));
[email protected]dee810e2011-06-27 19:43:3966 string16 profile_name = ASCIIToUTF16(StringPrintf("name_%ud", i));
67 const SkBitmap& icon = ResourceBundle::GetSharedInstance().GetImageNamed(
68 ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(i));
69
[email protected]cb114f142011-11-23 20:18:0470 GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i);
71 GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true);
72 string16 gaia_name = ASCIIToUTF16(StringPrintf("gaia_%ud", i));
73 GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name);
[email protected]dee810e2011-06-27 19:43:3974
[email protected]6730b1e2011-09-29 05:23:5275 EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles());
76 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
77 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i));
78 const SkBitmap& actual_icon = GetCache()->GetAvatarIconOfProfileAtIndex(i);
[email protected]dee810e2011-06-27 19:43:3979 EXPECT_EQ(icon.width(), actual_icon.width());
80 EXPECT_EQ(icon.height(), actual_icon.height());
81 }
[email protected]cb114f142011-11-23 20:18:0482
83 // Reset the cache and test the it reloads correctly.
84 ResetCache();
85
86 EXPECT_EQ(4u, GetCache()->GetNumberOfProfiles());
87 for (uint32 i = 0; i < 4; ++i) {
[email protected]d4f5d1162011-11-30 01:41:5288 FilePath profile_path = GetProfilePath(StringPrintf("path_%ud", i));
[email protected]cb114f142011-11-23 20:18:0489 EXPECT_EQ(i, GetCache()->GetIndexOfProfileWithPath(profile_path));
90 string16 profile_name = ASCIIToUTF16(StringPrintf("name_%ud", i));
91 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
92 EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i));
93 EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i));
94 string16 gaia_name = ASCIIToUTF16(StringPrintf("gaia_%ud", i));
95 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i));
96 }
[email protected]dee810e2011-06-27 19:43:3997}
98
[email protected]d4f5d1162011-11-30 01:41:5299TEST_F(ProfileInfoCacheTest, DeleteProfile) {
[email protected]6730b1e2011-09-29 05:23:52100 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
[email protected]dee810e2011-06-27 19:43:39101
[email protected]d4f5d1162011-11-30 01:41:52102 FilePath path_1 = GetProfilePath("path_1");
[email protected]73cb3722011-10-11 18:12:13103 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), string16(),
[email protected]dee810e2011-06-27 19:43:39104 0);
[email protected]6730b1e2011-09-29 05:23:52105 EXPECT_EQ(1u, GetCache()->GetNumberOfProfiles());
[email protected]dee810e2011-06-27 19:43:39106
[email protected]d4f5d1162011-11-30 01:41:52107 FilePath path_2 = GetProfilePath("path_2");
[email protected]dee810e2011-06-27 19:43:39108 string16 name_2 = ASCIIToUTF16("name_2");
[email protected]73cb3722011-10-11 18:12:13109 GetCache()->AddProfileToCache(path_2, name_2, string16(), 0);
[email protected]6730b1e2011-09-29 05:23:52110 EXPECT_EQ(2u, GetCache()->GetNumberOfProfiles());
[email protected]dee810e2011-06-27 19:43:39111
[email protected]6730b1e2011-09-29 05:23:52112 GetCache()->DeleteProfileFromCache(path_1);
113 EXPECT_EQ(1u, GetCache()->GetNumberOfProfiles());
114 EXPECT_EQ(name_2, GetCache()->GetNameOfProfileAtIndex(0));
[email protected]dee810e2011-06-27 19:43:39115
[email protected]6730b1e2011-09-29 05:23:52116 GetCache()->DeleteProfileFromCache(path_2);
117 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
[email protected]dee810e2011-06-27 19:43:39118}
119
[email protected]d4f5d1162011-11-30 01:41:52120TEST_F(ProfileInfoCacheTest, MutateProfile) {
121 GetCache()->AddProfileToCache(
122 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0);
123 GetCache()->AddProfileToCache(
124 GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0);
[email protected]dee810e2011-06-27 19:43:39125
126 string16 new_name = ASCIIToUTF16("new_name");
[email protected]6730b1e2011-09-29 05:23:52127 GetCache()->SetNameOfProfileAtIndex(1, new_name);
128 EXPECT_EQ(new_name, GetCache()->GetNameOfProfileAtIndex(1));
129 EXPECT_NE(new_name, GetCache()->GetNameOfProfileAtIndex(0));
[email protected]dee810e2011-06-27 19:43:39130
[email protected]e8e78092011-09-29 18:15:38131 string16 new_user_name = ASCIIToUTF16("user_name");
132 GetCache()->SetUserNameOfProfileAtIndex(1, new_user_name);
133 EXPECT_EQ(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(1));
134 EXPECT_NE(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(0));
135
[email protected]dee810e2011-06-27 19:43:39136 size_t new_icon_index = 3;
[email protected]6730b1e2011-09-29 05:23:52137 GetCache()->SetAvatarIconOfProfileAtIndex(1, new_icon_index);
[email protected]dee810e2011-06-27 19:43:39138 // Not much to test.
[email protected]6730b1e2011-09-29 05:23:52139 GetCache()->GetAvatarIconOfProfileAtIndex(1);
[email protected]dee810e2011-06-27 19:43:39140}
141
[email protected]d4f5d1162011-11-30 01:41:52142TEST_F(ProfileInfoCacheTest, Sort) {
[email protected]cb114f142011-11-23 20:18:04143 string16 name_a = ASCIIToUTF16("apple");
[email protected]d4f5d1162011-11-30 01:41:52144 GetCache()->AddProfileToCache(
145 GetProfilePath("path_a"), name_a, string16(), 0);
[email protected]cb114f142011-11-23 20:18:04146
147 string16 name_c = ASCIIToUTF16("cat");
[email protected]d4f5d1162011-11-30 01:41:52148 GetCache()->AddProfileToCache(
149 GetProfilePath("path_c"), name_c, string16(), 0);
[email protected]cb114f142011-11-23 20:18:04150
151 // Sanity check the initial order.
152 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0));
153 EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(1));
154
155 // Add a new profile (start with a capital to test case insensitive sorting.
156 string16 name_b = ASCIIToUTF16("Banana");
[email protected]d4f5d1162011-11-30 01:41:52157 GetCache()->AddProfileToCache(
158 GetProfilePath("path_b"), name_b, string16(), 0);
[email protected]cb114f142011-11-23 20:18:04159
160 // Verify the new order.
161 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0));
162 EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(1));
163 EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(2));
164
165 // Change the name of an existing profile.
166 name_a = UTF8ToUTF16("dog");
167 GetCache()->SetNameOfProfileAtIndex(0, name_a);
168
169 // Verify the new order.
170 EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(0));
171 EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(1));
172 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(2));
173
174 // Delete a profile.
[email protected]d4f5d1162011-11-30 01:41:52175 GetCache()->DeleteProfileFromCache(GetProfilePath("path_c"));
[email protected]cb114f142011-11-23 20:18:04176
177 // Verify the new order.
178 EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(0));
179 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(1));
180}
181
[email protected]d4f5d1162011-11-30 01:41:52182TEST_F(ProfileInfoCacheTest, BackgroundModeStatus) {
[email protected]279170832011-10-12 23:38:03183 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52184 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0);
[email protected]279170832011-10-12 23:38:03185 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52186 GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0);
[email protected]279170832011-10-12 23:38:03187
188 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
189 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
190
191 GetCache()->SetBackgroundStatusOfProfileAtIndex(1, true);
192
193 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
194 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
195
196 GetCache()->SetBackgroundStatusOfProfileAtIndex(0, true);
197
198 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
199 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
200
201 GetCache()->SetBackgroundStatusOfProfileAtIndex(1, false);
202
203 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
204 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
205}
206
[email protected]d4f5d1162011-11-30 01:41:52207TEST_F(ProfileInfoCacheTest, HasMigrated) {
[email protected]cb114f142011-11-23 20:18:04208 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52209 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0);
[email protected]cb114f142011-11-23 20:18:04210 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52211 GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0);
[email protected]cb114f142011-11-23 20:18:04212
213 // Sanity check.
214 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
215 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
216
217 // Set migrated state for 2nd profile.
218 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, true);
219 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
220 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
221
222 // Set migrated state for 1st profile.
223 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(0, true);
224 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
225 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
226
227 // Unset migrated state for 2nd profile.
228 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, false);
229 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
230 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
231}
232
[email protected]d4f5d1162011-11-30 01:41:52233TEST_F(ProfileInfoCacheTest, GAIAName) {
[email protected]cb114f142011-11-23 20:18:04234 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52235 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0);
[email protected]cb114f142011-11-23 20:18:04236 string16 profile_name(ASCIIToUTF16("profile name 2"));
237 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52238 GetProfilePath("path_2"), profile_name, string16(), 0);
[email protected]cb114f142011-11-23 20:18:04239
240 // Sanity check.
241 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty());
242 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(1).empty());
243 EXPECT_FALSE(GetCache()->IsUsingGAIANameOfProfileAtIndex(0));
244 EXPECT_FALSE(GetCache()->IsUsingGAIANameOfProfileAtIndex(1));
245
246 // Set GAIA name.
247 string16 gaia_name(ASCIIToUTF16("Pat Smith"));
248 GetCache()->SetGAIANameOfProfileAtIndex(1, gaia_name);
249 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty());
250 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1));
251 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(1));
252
253 // Use GAIA name as profile name.
254 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(1, true);
255
256 EXPECT_EQ(gaia_name, GetCache()->GetNameOfProfileAtIndex(1));
257 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1));
258
259 // Don't use GAIA name as profile name.
260 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(1, false);
261 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(1));
262 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1));
263}
264
[email protected]d4f5d1162011-11-30 01:41:52265TEST_F(ProfileInfoCacheTest, GAIAPicture) {
[email protected]cb114f142011-11-23 20:18:04266 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52267 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0);
[email protected]cb114f142011-11-23 20:18:04268 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52269 GetProfilePath("path_2"), ASCIIToUTF16("name_2"), string16(), 0);
[email protected]cb114f142011-11-23 20:18:04270
271 // Sanity check.
[email protected]2f3c00f2011-11-30 04:36:22272 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
273 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(1));
[email protected]cb114f142011-11-23 20:18:04274 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(0));
275 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1));
276
277 // The profile icon should be the default one.
278 int id = ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(0);
279 const gfx::Image& profile_image(
280 ResourceBundle::GetSharedInstance().GetImageNamed(id));
[email protected]d4f5d1162011-11-30 01:41:52281 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]cb114f142011-11-23 20:18:04282 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
283
284 // Set GAIA picture.
[email protected]d4f5d1162011-11-30 01:41:52285 gfx::Image gaia_image(gfx::test::CreateImage());
[email protected]2f3c00f2011-11-30 04:36:22286 GetCache()->SetGAIAPictureOfProfileAtIndex(1, &gaia_image);
287 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
[email protected]d4f5d1162011-11-30 01:41:52288 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]2f3c00f2011-11-30 04:36:22289 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
[email protected]d4f5d1162011-11-30 01:41:52290 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]cb114f142011-11-23 20:18:04291 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
292
293 // Use GAIA picture as profile picture.
294 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, true);
[email protected]d4f5d1162011-11-30 01:41:52295 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]2f3c00f2011-11-30 04:36:22296 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
[email protected]d4f5d1162011-11-30 01:41:52297 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]cb114f142011-11-23 20:18:04298 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
299
300 // Don't use GAIA picture as profile picture.
301 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, false);
[email protected]d4f5d1162011-11-30 01:41:52302 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]2f3c00f2011-11-30 04:36:22303 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
[email protected]d4f5d1162011-11-30 01:41:52304 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]cb114f142011-11-23 20:18:04305 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
306}
307
[email protected]754bebc2011-12-01 16:42:16308TEST_F(ProfileInfoCacheTest, PersistGAIAPicture) {
[email protected]cb114f142011-11-23 20:18:04309 GetCache()->AddProfileToCache(
[email protected]d4f5d1162011-11-30 01:41:52310 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), string16(), 0);
311 gfx::Image gaia_image(gfx::test::CreateImage());
[email protected]cb114f142011-11-23 20:18:04312
313 ui_test_utils::WindowedNotificationObserver save_observer(
314 chrome::NOTIFICATION_PROFILE_CACHE_PICTURE_SAVED,
315 content::NotificationService::AllSources());
[email protected]2f3c00f2011-11-30 04:36:22316 GetCache()->SetGAIAPictureOfProfileAtIndex(0, &gaia_image);
[email protected]d4f5d1162011-11-30 01:41:52317 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]2f3c00f2011-11-30 04:36:22318 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(0)));
[email protected]cb114f142011-11-23 20:18:04319
320 // Wait for the file to be written to disk then reset the cache.
321 save_observer.Wait();
322 ResetCache();
323
324 // Try to get the GAIA picture. This should return NULL until the read from
325 // disk is done.
326 ui_test_utils::WindowedNotificationObserver read_observer(
327 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
328 content::NotificationService::AllSources());
[email protected]2f3c00f2011-11-30 04:36:22329 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
[email protected]cb114f142011-11-23 20:18:04330 read_observer.Wait();
[email protected]d4f5d1162011-11-30 01:41:52331 EXPECT_TRUE(gfx::test::IsEqual(
[email protected]2f3c00f2011-11-30 04:36:22332 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(0)));
333}
334
335TEST_F(ProfileInfoCacheTest, EmptyGAIAInfo) {
336 string16 profile_name = ASCIIToUTF16("name_1");
337 int id = ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(0);
338 const gfx::Image& profile_image(
339 ResourceBundle::GetSharedInstance().GetImageNamed(id));
340
341 GetCache()->AddProfileToCache(
342 GetProfilePath("path_1"), profile_name, string16(), 0);
343
344 // Set empty GAIA info.
345 GetCache()->SetGAIANameOfProfileAtIndex(0, string16());
346 GetCache()->SetGAIAPictureOfProfileAtIndex(0, NULL);
347 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(0, true);
348 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(0, true);
349
350 // Verify that the profile name and picture are not empty.
351 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(0));
352 EXPECT_TRUE(gfx::test::IsEqual(
353 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(0)));
[email protected]cb114f142011-11-23 20:18:04354}
355
[email protected]6730b1e2011-09-29 05:23:52356} // namespace