OLD | NEW |
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" |
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
365 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); | 365 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
366 | 366 |
367 // Don't use GAIA picture as profile picture. | 367 // Don't use GAIA picture as profile picture. |
368 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, false); | 368 GetCache()->SetIsUsingGAIAPictureOfProfileAtIndex(1, false); |
369 EXPECT_TRUE(IsEqual( | 369 EXPECT_TRUE(IsEqual( |
370 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(1))); | 370 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(1))); |
371 EXPECT_TRUE(IsEqual( | 371 EXPECT_TRUE(IsEqual( |
372 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); | 372 profile_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
373 } | 373 } |
374 | 374 |
375 #if defined(USE_AURA) | 375 TEST_F(ProfileInfoCacheUnittests, PersistGAIAPicture) { |
376 #define MAYBE_PersistGAIAPicture DISABLED_PersistGAIAPicture | |
377 #else | |
378 #define MAYBE_PersistGAIAPicture PersistGAIAPicture | |
379 #endif | |
380 | |
381 TEST_F(ProfileInfoCacheUnittests, MAYBE_PersistGAIAPicture) { | |
382 GetCache()->AddProfileToCache( | 376 GetCache()->AddProfileToCache( |
383 GetUserDataDir().Append(StringToFilePath("path_1")), | 377 GetUserDataDir().Append(StringToFilePath("path_1")), |
384 ASCIIToUTF16("name_1"), string16(), 0); | 378 ASCIIToUTF16("name_1"), string16(), 0); |
385 gfx::Image gaia_image(CreateTestImage()); | 379 gfx::Image gaia_image(CreateTestImage()); |
386 | 380 |
387 ui_test_utils::WindowedNotificationObserver save_observer( | 381 ui_test_utils::WindowedNotificationObserver save_observer( |
388 chrome::NOTIFICATION_PROFILE_CACHE_PICTURE_SAVED, | 382 chrome::NOTIFICATION_PROFILE_CACHE_PICTURE_SAVED, |
389 content::NotificationService::AllSources()); | 383 content::NotificationService::AllSources()); |
390 GetCache()->SetGAIAPictureOfProfileAtIndex(0, gaia_image); | 384 GetCache()->SetGAIAPictureOfProfileAtIndex(0, gaia_image); |
391 EXPECT_TRUE(IsEqual( | 385 EXPECT_TRUE(IsEqual( |
392 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(0))); | 386 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(0))); |
393 | 387 |
394 // Wait for the file to be written to disk then reset the cache. | 388 // Wait for the file to be written to disk then reset the cache. |
395 save_observer.Wait(); | 389 save_observer.Wait(); |
396 ResetCache(); | 390 ResetCache(); |
397 | 391 |
398 // Try to get the GAIA picture. This should return NULL until the read from | 392 // Try to get the GAIA picture. This should return NULL until the read from |
399 // disk is done. | 393 // disk is done. |
400 ui_test_utils::WindowedNotificationObserver read_observer( | 394 ui_test_utils::WindowedNotificationObserver read_observer( |
401 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, | 395 chrome::NOTIFICATION_PROFILE_CACHED_INFO_CHANGED, |
402 content::NotificationService::AllSources()); | 396 content::NotificationService::AllSources()); |
403 EXPECT_TRUE( | 397 EXPECT_TRUE( |
404 GetCache()->GetGAIAPictureOfProfileAtIndex(0).ToSkBitmap()->isNull()); | 398 GetCache()->GetGAIAPictureOfProfileAtIndex(0).ToSkBitmap()->isNull()); |
405 read_observer.Wait(); | 399 read_observer.Wait(); |
406 EXPECT_TRUE(IsEqual( | 400 EXPECT_TRUE(IsEqual( |
407 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(0))); | 401 gaia_image, GetCache()->GetGAIAPictureOfProfileAtIndex(0))); |
408 } | 402 } |
409 | 403 |
410 } // namespace | 404 } // namespace |
OLD | NEW |