| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 index2 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_2")); | 327 index2 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_2")); |
| 328 | 328 |
| 329 // Since there is a GAIA name, we use that as a display name. | 329 // Since there is a GAIA name, we use that as a display name. |
| 330 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(index1).empty()); | 330 EXPECT_TRUE(GetCache()->GetGAIANameOfProfileAtIndex(index1).empty()); |
| 331 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(index2)); | 331 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(index2)); |
| 332 EXPECT_EQ(gaia_name, GetCache()->GetNameOfProfileAtIndex(index2)); | 332 EXPECT_EQ(gaia_name, GetCache()->GetNameOfProfileAtIndex(index2)); |
| 333 | 333 |
| 334 // Don't use GAIA name as profile name. This re-sorts the cache. | 334 // Don't use GAIA name as profile name. This re-sorts the cache. |
| 335 base::string16 custom_name(ASCIIToUTF16("Custom name")); | 335 base::string16 custom_name(ASCIIToUTF16("Custom name")); |
| 336 GetCache()->SetNameOfProfileAtIndex(index2, custom_name); | 336 GetCache()->SetNameOfProfileAtIndex(index2, custom_name); |
| 337 GetCache()->SetProfileIsUsingDefaultNameAtIndex(index2, false); |
| 338 |
| 337 index1 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_1")); | 339 index1 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_1")); |
| 338 index2 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_2")); | 340 index2 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_2")); |
| 339 | 341 |
| 340 EXPECT_EQ(custom_name, GetCache()->GetNameOfProfileAtIndex(index2)); | 342 EXPECT_EQ(custom_name, GetCache()->GetNameOfProfileAtIndex(index2)); |
| 341 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(index2)); | 343 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(index2)); |
| 342 } | 344 } |
| 343 | 345 |
| 344 TEST_F(ProfileInfoCacheTest, GAIAPicture) { | 346 TEST_F(ProfileInfoCacheTest, GAIAPicture) { |
| 345 const int kDefaultAvatarIndex = 0; | 347 const int kDefaultAvatarIndex = 0; |
| 346 const int kOtherAvatarIndex = 1; | 348 const int kOtherAvatarIndex = 1; |
| (...skipping 28 matching lines...) Expand all Loading... |
| 375 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); | 377 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); |
| 376 EXPECT_TRUE(gfx::test::IsEqual( | 378 EXPECT_TRUE(gfx::test::IsEqual( |
| 377 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1))); | 379 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1))); |
| 378 // Since we're still using the default avatar, the GAIA image should be | 380 // Since we're still using the default avatar, the GAIA image should be |
| 379 // preferred over the generic avatar image. | 381 // preferred over the generic avatar image. |
| 380 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1)); | 382 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1)); |
| 381 EXPECT_TRUE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1)); | 383 EXPECT_TRUE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1)); |
| 382 EXPECT_TRUE(gfx::test::IsEqual( | 384 EXPECT_TRUE(gfx::test::IsEqual( |
| 383 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); | 385 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
| 384 | 386 |
| 385 // Set another avatar. This should make it preferred over the GAIA image. | 387 // Set a non-default avatar. This should be preferred over the GAIA image. |
| 386 GetCache()->SetAvatarIconOfProfileAtIndex(1, kOtherAvatarIndex); | 388 GetCache()->SetAvatarIconOfProfileAtIndex(1, kOtherAvatarIndex); |
| 389 GetCache()->SetProfileIsUsingDefaultAvatarAtIndex(1, false); |
| 387 EXPECT_FALSE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1)); | 390 EXPECT_FALSE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1)); |
| 388 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1)); | 391 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1)); |
| 389 int other_avatar_id = | 392 int other_avatar_id = |
| 390 profiles::GetDefaultAvatarIconResourceIDAtIndex(kOtherAvatarIndex); | 393 profiles::GetDefaultAvatarIconResourceIDAtIndex(kOtherAvatarIndex); |
| 391 const gfx::Image& other_avatar_image( | 394 const gfx::Image& other_avatar_image( |
| 392 ResourceBundle::GetSharedInstance().GetImageNamed(other_avatar_id)); | 395 ResourceBundle::GetSharedInstance().GetImageNamed(other_avatar_id)); |
| 393 EXPECT_TRUE(gfx::test::IsEqual( | 396 EXPECT_TRUE(gfx::test::IsEqual( |
| 394 other_avatar_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); | 397 other_avatar_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); |
| 395 | 398 |
| 396 // Explicitly setting the GAIA picture should make it preferred again. | 399 // Explicitly setting the GAIA picture should make it preferred again. |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 | 584 |
| 582 // Clean up. | 585 // Clean up. |
| 583 base::FilePath icon_path = | 586 base::FilePath icon_path = |
| 584 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex); | 587 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex); |
| 585 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name)); | 588 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name)); |
| 586 EXPECT_TRUE(base::PathExists(icon_path)); | 589 EXPECT_TRUE(base::PathExists(icon_path)); |
| 587 EXPECT_TRUE(base::DeleteFile(icon_path, true)); | 590 EXPECT_TRUE(base::DeleteFile(icon_path, true)); |
| 588 EXPECT_FALSE(base::PathExists(icon_path)); | 591 EXPECT_FALSE(base::PathExists(icon_path)); |
| 589 } | 592 } |
| 590 #endif | 593 #endif |
| OLD | NEW |