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

Side by Side Diff: chrome/browser/profiles/profile_info_cache_unittest.cc

Issue 8587023: Add GAIA info to profile info cache (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unit test Created 9 years, 1 month 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // 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 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.h" 5 #include "chrome/browser/profiles/profile_info_cache.h"
6 6
7 #include "base/stringprintf.h" 7 #include "base/stringprintf.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
11 #include "chrome/common/chrome_notification_types.h"
11 #include "chrome/test/base/testing_browser_process.h" 12 #include "chrome/test/base/testing_browser_process.h"
12 #include "chrome/test/base/testing_pref_service.h" 13 #include "chrome/test/base/testing_pref_service.h"
13 #include "chrome/test/base/testing_profile_manager.h" 14 #include "chrome/test/base/testing_profile_manager.h"
15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/public/browser/notification_observer.h"
17 #include "content/public/browser/notification_registrar.h"
18 #include "content/test/test_browser_thread.h"
14 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
15 #include "third_party/skia/include/core/SkBitmap.h" 20 #include "third_party/skia/include/core/SkBitmap.h"
16 #include "ui/base/resource/resource_bundle.h" 21 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/image/image.h" 22 #include "ui/gfx/image/image.h"
18 23
24 using content::BrowserThread;
25
19 namespace { 26 namespace {
20 27
28 bool IsEqual(const gfx::Image& image1,
29 const gfx::Image& image2) {
30 const SkBitmap& bmp1 = *image1.ToSkBitmap();
31 const SkBitmap& bmp2 = *image2.ToSkBitmap();
32
33 if (bmp1.width() != bmp2.width() ||
34 bmp1.height() != bmp2.height() ||
35 bmp1.config() != SkBitmap::kARGB_8888_Config ||
36 bmp2.config() != SkBitmap::kARGB_8888_Config) {
37 return false;
38 }
39
40 SkAutoLockPixels lock1(bmp1);
41 SkAutoLockPixels lock2(bmp2);
42 if (!bmp1.getPixels() || !bmp2.getPixels())
43 return false;
44
45 for (int y = 0; y < bmp1.height(); ++y) {
46 for (int x = 0; x < bmp1.width(); ++x) {
47 if (*bmp1.getAddr32(x,y) != *bmp2.getAddr32(x,y))
48 return false;
49 }
50 }
51
52 return true;
53 }
54
55 gfx::Image CreateTestImage() {
56 SkBitmap bitmap;
57 bitmap.setConfig(SkBitmap::kARGB_8888_Config, 100, 50);
58 bitmap.allocPixels();
59 bitmap.eraseRGB(0xff, 0, 0);
60 return gfx::Image(new SkBitmap(bitmap));
61 }
62
21 class ProfileInfoCacheUnittests : public testing::Test { 63 class ProfileInfoCacheUnittests : public testing::Test {
22 protected: 64 protected:
23 ProfileInfoCacheUnittests() 65 ProfileInfoCacheUnittests()
24 : testing_profile_manager_( 66 : testing_profile_manager_(
25 static_cast<TestingBrowserProcess*>(g_browser_process)) { 67 static_cast<TestingBrowserProcess*>(g_browser_process)),
68 ui_thread_(BrowserThread::UI, &message_loop_),
69 file_thread_(BrowserThread::FILE) {
26 } 70 }
27 71
28 virtual void SetUp() OVERRIDE { 72 virtual void SetUp() OVERRIDE {
29 ASSERT_TRUE(testing_profile_manager_.SetUp()); 73 ASSERT_TRUE(testing_profile_manager_.SetUp());
74 file_thread_.Start();
30 } 75 }
31 76
32 ProfileInfoCache* GetCache() { 77 ProfileInfoCache* GetCache() {
33 return testing_profile_manager_.profile_info_cache(); 78 return testing_profile_manager_.profile_info_cache();
34 } 79 }
35 80
36 const FilePath& GetUserDataDir() { 81 const FilePath& GetUserDataDir() {
37 return testing_profile_manager_.profile_manager()->user_data_dir(); 82 return testing_profile_manager_.profile_manager()->user_data_dir();
38 } 83 }
39 84
40 FilePath StringToFilePath(std::string string_path) { 85 FilePath StringToFilePath(std::string string_path) {
41 #if defined(OS_POSIX) 86 #if defined(OS_POSIX)
42 return FilePath(string_path); 87 return FilePath(string_path);
43 #elif defined(OS_WIN) 88 #elif defined(OS_WIN)
44 return FilePath(ASCIIToWide(string_path)); 89 return FilePath(ASCIIToWide(string_path));
45 #endif 90 #endif
46 } 91 }
47 92
93 void ResetCache() {
94 testing_profile_manager_.DeleteProfileInfoCache();
95 }
96
48 private: 97 private:
98 MessageLoopForUI message_loop_;
49 TestingProfileManager testing_profile_manager_; 99 TestingProfileManager testing_profile_manager_;
100 content::TestBrowserThread ui_thread_;
101 content::TestBrowserThread file_thread_;
50 }; 102 };
51 103
52 TEST_F(ProfileInfoCacheUnittests, AddProfiles) { 104 TEST_F(ProfileInfoCacheUnittests, AddProfiles) {
53 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); 105 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
54 106
55 for (uint32 i = 0; i < 4; ++i) { 107 for (uint32 i = 0; i < 4; ++i) {
56 std::string base_name = StringPrintf("path_%ud", i); 108 std::string base_name = StringPrintf("path_%ud", i);
57 FilePath profile_path = 109 FilePath profile_path =
58 GetUserDataDir().Append(StringToFilePath(base_name)); 110 GetUserDataDir().Append(StringToFilePath(base_name));
59 string16 profile_name = ASCIIToUTF16(StringPrintf("name_%ud", i)); 111 string16 profile_name = ASCIIToUTF16(StringPrintf("name_%ud", i));
60 const SkBitmap& icon = ResourceBundle::GetSharedInstance().GetImageNamed( 112 const SkBitmap& icon = ResourceBundle::GetSharedInstance().GetImageNamed(
61 ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(i)); 113 ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(i));
62 114
63 GetCache()->AddProfileToCache(profile_path, profile_name, string16(), 0); 115 GetCache()->AddProfileToCache(profile_path, profile_name, string16(), i);
116 GetCache()->SetBackgroundStatusOfProfileAtIndex(i, true);
117 string16 gaia_name = ASCIIToUTF16(StringPrintf("gaia_%ud", i));
118 GetCache()->SetGAIANameOfProfileAtIndex(i, gaia_name);
64 119
65 EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles()); 120 EXPECT_EQ(i + 1, GetCache()->GetNumberOfProfiles());
66 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i)); 121 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
67 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i)); 122 EXPECT_EQ(profile_path, GetCache()->GetPathOfProfileAtIndex(i));
68 const SkBitmap& actual_icon = GetCache()->GetAvatarIconOfProfileAtIndex(i); 123 const SkBitmap& actual_icon = GetCache()->GetAvatarIconOfProfileAtIndex(i);
69 EXPECT_EQ(icon.width(), actual_icon.width()); 124 EXPECT_EQ(icon.width(), actual_icon.width());
70 EXPECT_EQ(icon.height(), actual_icon.height()); 125 EXPECT_EQ(icon.height(), actual_icon.height());
71 } 126 }
127
128 // Reset the cache and test the it reloads correctly.
129 ResetCache();
130
131 EXPECT_EQ(4u, GetCache()->GetNumberOfProfiles());
132 for (uint32 i = 0; i < 4; ++i) {
133 std::string base_name = StringPrintf("path_%ud", i);
134 FilePath profile_path =
135 GetUserDataDir().Append(StringToFilePath(base_name));
136 EXPECT_EQ(i, GetCache()->GetIndexOfProfileWithPath(profile_path));
137 string16 profile_name = ASCIIToUTF16(StringPrintf("name_%ud", i));
138 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(i));
139 EXPECT_EQ(i, GetCache()->GetAvatarIconIndexOfProfileAtIndex(i));
140 EXPECT_EQ(true, GetCache()->GetBackgroundStatusOfProfileAtIndex(i));
141 string16 gaia_name = ASCIIToUTF16(StringPrintf("gaia_%ud", i));
142 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(i));
143 }
72 } 144 }
73 145
74 TEST_F(ProfileInfoCacheUnittests, DeleteProfile) { 146 TEST_F(ProfileInfoCacheUnittests, DeleteProfile) {
75 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles()); 147 EXPECT_EQ(0u, GetCache()->GetNumberOfProfiles());
76 148
77 FilePath path_1 = GetUserDataDir().Append(StringToFilePath("path_1")); 149 FilePath path_1 = GetUserDataDir().Append(StringToFilePath("path_1"));
78 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), string16(), 150 GetCache()->AddProfileToCache(path_1, ASCIIToUTF16("name_1"), string16(),
79 0); 151 0);
80 EXPECT_EQ(1u, GetCache()->GetNumberOfProfiles()); 152 EXPECT_EQ(1u, GetCache()->GetNumberOfProfiles());
81 153
(...skipping 25 matching lines...) Expand all
107 GetCache()->SetUserNameOfProfileAtIndex(1, new_user_name); 179 GetCache()->SetUserNameOfProfileAtIndex(1, new_user_name);
108 EXPECT_EQ(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(1)); 180 EXPECT_EQ(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(1));
109 EXPECT_NE(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(0)); 181 EXPECT_NE(new_user_name, GetCache()->GetUserNameOfProfileAtIndex(0));
110 182
111 size_t new_icon_index = 3; 183 size_t new_icon_index = 3;
112 GetCache()->SetAvatarIconOfProfileAtIndex(1, new_icon_index); 184 GetCache()->SetAvatarIconOfProfileAtIndex(1, new_icon_index);
113 // Not much to test. 185 // Not much to test.
114 GetCache()->GetAvatarIconOfProfileAtIndex(1); 186 GetCache()->GetAvatarIconOfProfileAtIndex(1);
115 } 187 }
116 188
189 TEST_F(ProfileInfoCacheUnittests, Sort) {
190 string16 name_a = ASCIIToUTF16("apple");
191 GetCache()->AddProfileToCache(GetUserDataDir().Append(
192 StringToFilePath("path_a")), name_a, string16(), 0);
193
194 string16 name_c = ASCIIToUTF16("cat");
195 GetCache()->AddProfileToCache(GetUserDataDir().Append(
196 StringToFilePath("path_c")), name_c, string16(), 0);
197
198 // Sanity check the initial order.
199 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0));
200 EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(1));
201
202 // Add a new profile (start with a capital to test case insensitive sorting.
203 string16 name_b = ASCIIToUTF16("Banana");
204 GetCache()->AddProfileToCache(GetUserDataDir().Append(
205 StringToFilePath("path_b")), name_b, string16(), 0);
206
207 // Verify the new order.
208 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(0));
209 EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(1));
210 EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(2));
211
212 // Change the name of an existing profile.
213 name_a = UTF8ToUTF16("dog");
214 GetCache()->SetNameOfProfileAtIndex(0, name_a);
215
216 // Verify the new order.
217 EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(0));
218 EXPECT_EQ(name_c, GetCache()->GetNameOfProfileAtIndex(1));
219 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(2));
220
221 // Delete a profile.
222 GetCache()->DeleteProfileFromCache(GetUserDataDir().Append(
223 StringToFilePath("path_c")));
224
225 // Verify the new order.
226 EXPECT_EQ(name_b, GetCache()->GetNameOfProfileAtIndex(0));
227 EXPECT_EQ(name_a, GetCache()->GetNameOfProfileAtIndex(1));
228 }
229
117 TEST_F(ProfileInfoCacheUnittests, BackgroundModeStatus) { 230 TEST_F(ProfileInfoCacheUnittests, BackgroundModeStatus) {
118 GetCache()->AddProfileToCache( 231 GetCache()->AddProfileToCache(
119 GetUserDataDir().Append(StringToFilePath("path_1")), 232 GetUserDataDir().Append(StringToFilePath("path_1")),
120 ASCIIToUTF16("name_1"), string16(), 0); 233 ASCIIToUTF16("name_1"), string16(), 0);
121 GetCache()->AddProfileToCache( 234 GetCache()->AddProfileToCache(
122 GetUserDataDir().Append(StringToFilePath("path_2")), 235 GetUserDataDir().Append(StringToFilePath("path_2")),
123 ASCIIToUTF16("name_2"), string16(), 0); 236 ASCIIToUTF16("name_2"), string16(), 0);
124 237
125 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); 238 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
126 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); 239 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
127 240
128 GetCache()->SetBackgroundStatusOfProfileAtIndex(1, true); 241 GetCache()->SetBackgroundStatusOfProfileAtIndex(1, true);
129 242
130 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); 243 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
131 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); 244 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
132 245
133 GetCache()->SetBackgroundStatusOfProfileAtIndex(0, true); 246 GetCache()->SetBackgroundStatusOfProfileAtIndex(0, true);
134 247
135 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); 248 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
136 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); 249 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
137 250
138 GetCache()->SetBackgroundStatusOfProfileAtIndex(1, false); 251 GetCache()->SetBackgroundStatusOfProfileAtIndex(1, false);
139 252
140 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0)); 253 EXPECT_TRUE(GetCache()->GetBackgroundStatusOfProfileAtIndex(0));
141 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1)); 254 EXPECT_FALSE(GetCache()->GetBackgroundStatusOfProfileAtIndex(1));
142 } 255 }
143 256
257 TEST_F(ProfileInfoCacheUnittests, HasMigrated) {
258 GetCache()->AddProfileToCache(
259 GetUserDataDir().Append(StringToFilePath("path_1")),
260 ASCIIToUTF16("name_1"), string16(), 0);
261 GetCache()->AddProfileToCache(
262 GetUserDataDir().Append(StringToFilePath("path_2")),
263 ASCIIToUTF16("name_2"), string16(), 0);
264
265 // Sanity check.
266 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
267 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
268
269 // Set migrated state for 2nd profile.
270 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, true);
271 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
272 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
273
274 // Set migrated state for 1st profile.
275 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(0, true);
276 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
277 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
278
279 // Unset migrated state for 2nd profile.
280 GetCache()->SetHasMigratedToGAIAInfoOfProfileAtIndex(1, false);
281 EXPECT_TRUE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(0));
282 EXPECT_FALSE(GetCache()->GetHasMigratedToGAIAInfoOfProfileAtIndex(1));
283 }
284
285 TEST_F(ProfileInfoCacheUnittests, GAIAName) {
286 GetCache()->AddProfileToCache(
287 GetUserDataDir().Append(StringToFilePath("path_1")),
288 ASCIIToUTF16("name_1"), string16(), 0);
289 string16 profile_name(ASCIIToUTF16("profile name 2"));
290 GetCache()->AddProfileToCache(
291 GetUserDataDir().Append(StringToFilePath("path_2")),
292 profile_name, string16(), 0);
293
294 // Sanity check.
295 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty());
296 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(1).empty());
297 EXPECT_FALSE(GetCache()->IsUsingGAIANameOfProfileAtIndex(0));
298 EXPECT_FALSE(GetCache()->IsUsingGAIANameOfProfileAtIndex(1));
299
300 // Set GAIA name.
301 string16 gaia_name(ASCIIToUTF16("Pat Smith"));
302 GetCache()->SetGAIANameOfProfileAtIndex(1, gaia_name);
303 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(0).empty());
304 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1));
305 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(1));
306
307 // Use GAIA name as profile name.
308 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(1, true);
309
310 EXPECT_EQ(gaia_name, GetCache()->GetNameOfProfileAtIndex(1));
311 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1));
312
313 // Don't use GAIA name as profile name.
314 GetCache()->SetIsUsingGAIANameOfProfileAtIndex(1, false);
315 EXPECT_EQ(profile_name, GetCache()->GetNameOfProfileAtIndex(1));
316 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(1));
317 }
318
319 TEST_F(ProfileInfoCacheUnittests, GAIAPicture) {
320 GetCache()->AddProfileToCache(
321 GetUserDataDir().Append(StringToFilePath("path_1")),
322 ASCIIToUTF16("name_1"), string16(), 0);
323 GetCache()->AddProfileToCache(
324 GetUserDataDir().Append(StringToFilePath("path_2")),
325 ASCIIToUTF16("name_2"), string16(), 0);
326
327 // Sanity check.
328 EXPECT_TRUE(
329 GetCache()->GetGAIAPictureOfProfileAtIndex(0).ToSkBitmap()->isNull());
330 EXPECT_TRUE(
331 GetCache()->GetGAIAPictureOfProfileAtIndex(1).ToSkBitmap()->isNull());
332 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(0));
333 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1));
334
335 // The profile icon should be the default one.
336 int id = ProfileInfoCache::GetDefaultAvatarIconResourceIDAtIndex(0);
337 const gfx::Image& profile_image(
338 ResourceBundle::GetSharedInstance().GetImageNamed(id));
339 EXPECT_TRUE(IsEqual(
340 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
341
342 // Set GAIA picture.
343 gfx::Image gaia_image(CreateTestImage());
344 GetCache()->SetGAIAPictureOfProfileAtIndex(1, gaia_image);
345 EXPECT_TRUE(
346 GetCache()->GetGAIAPictureOfProfileAtIndex(0).ToSkBitmap()->isNull());
347 EXPECT_TRUE(IsEqual(
348 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
349 EXPECT_TRUE(IsEqual(
350 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
351
352 // Use GAIA picture as profile picture.
353 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, true);
354 EXPECT_TRUE(IsEqual(
355 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
356 EXPECT_TRUE(IsEqual(
357 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
358
359 // Don't use GAIA picture as profile picture.
360 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, false);
361 EXPECT_TRUE(IsEqual(
362 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
363 EXPECT_TRUE(IsEqual(
364 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
365 }
366
367 TEST_F(ProfileInfoCacheUnittests, PersistGAIAPicture) {
368 GetCache()->AddProfileToCache(
369 GetUserDataDir().Append(StringToFilePath("path_1")),
370 ASCIIToUTF16("name_1"), string16(), 0);
371 gfx::Image gaia_image(CreateTestImage());
372
373 ui_test_utils::WindowedNotificationObserver save_observer(
374 chrome::NOTIFICATION_PROFILE_CACHE_PICTURE_SAVED,
375 content::NotificationService::AllSources());
376 GetCache()->SetGAIAPictureOfProfileAtIndex(0, gaia_image);
377 EXPECT_TRUE(IsEqual(
378 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(0)));
379
380 // Wait for the file to be written to disk then reset the cache.
381 save_observer.Wait();
382 ResetCache();
383
384 // Try to get the GAIA picture. This should return NULL until the read from
385 // disk is done.
386 ui_test_utils::WindowedNotificationObserver read_observer(
387 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED,
388 content::NotificationService::AllSources());
389 EXPECT_TRUE(
390 GetCache()->GetGAIAPictureOfProfileAtIndex(0).ToSkBitmap()->isNull());
391 read_observer.Wait();
392 EXPECT_TRUE(IsEqual(
393 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(0)));
394 }
395
144 } // namespace 396 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698