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

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

Issue 462713002: [Win] Profile desktop shortcuts should use the Gaia avatar if it's in use. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: s/_eq/_ge Created 6 years, 4 months 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
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_shortcut_manager_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 index1 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_1")); 337 index1 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_1"));
338 index2 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_2")); 338 index2 = GetCache()->GetIndexOfProfileWithPath(GetProfilePath("path_2"));
339 339
340 EXPECT_EQ(custom_name, GetCache()->GetNameOfProfileAtIndex(index2)); 340 EXPECT_EQ(custom_name, GetCache()->GetNameOfProfileAtIndex(index2));
341 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(index2)); 341 EXPECT_EQ(gaia_name, GetCache()->GetGAIANameOfProfileAtIndex(index2));
342 } 342 }
343 343
344 TEST_F(ProfileInfoCacheTest, GAIAPicture) { 344 TEST_F(ProfileInfoCacheTest, GAIAPicture) {
345 const int kDefaultAvatarIndex = 0; 345 const int kDefaultAvatarIndex = 0;
346 const int kOtherAvatarIndex = 1; 346 const int kOtherAvatarIndex = 1;
347 const int kGaiaPictureSize = 256; // Standard size of a Gaia account picture.
347 GetCache()->AddProfileToCache( 348 GetCache()->AddProfileToCache(
348 GetProfilePath("path_1"), ASCIIToUTF16("name_1"), 349 GetProfilePath("path_1"), ASCIIToUTF16("name_1"),
349 base::string16(), kDefaultAvatarIndex, std::string()); 350 base::string16(), kDefaultAvatarIndex, std::string());
350 GetCache()->AddProfileToCache( 351 GetCache()->AddProfileToCache(
351 GetProfilePath("path_2"), ASCIIToUTF16("name_2"), 352 GetProfilePath("path_2"), ASCIIToUTF16("name_2"),
352 base::string16(), kDefaultAvatarIndex, std::string()); 353 base::string16(), kDefaultAvatarIndex, std::string());
353 354
354 // Sanity check. 355 // Sanity check.
355 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); 356 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
356 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(1)); 357 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(1));
357 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(0)); 358 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(0));
358 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1)); 359 EXPECT_FALSE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1));
359 360
360 // The profile icon should be the default one. 361 // The profile icon should be the default one.
361 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(0)); 362 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(0));
362 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1)); 363 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1));
363 int default_avatar_id = 364 int default_avatar_id =
364 profiles::GetDefaultAvatarIconResourceIDAtIndex(kDefaultAvatarIndex); 365 profiles::GetDefaultAvatarIconResourceIDAtIndex(kDefaultAvatarIndex);
365 const gfx::Image& default_avatar_image( 366 const gfx::Image& default_avatar_image(
366 ResourceBundle::GetSharedInstance().GetImageNamed(default_avatar_id)); 367 ResourceBundle::GetSharedInstance().GetImageNamed(default_avatar_id));
367 EXPECT_TRUE(gfx::test::IsEqual( 368 EXPECT_TRUE(gfx::test::IsEqual(
368 default_avatar_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); 369 default_avatar_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
369 370
370 // Set GAIA picture. 371 // Set GAIA picture.
371 gfx::Image gaia_image(gfx::test::CreateImage()); 372 gfx::Image gaia_image(gfx::test::CreateImage(
373 kGaiaPictureSize, kGaiaPictureSize));
372 GetCache()->SetGAIAPictureOfProfileAtIndex(1, &gaia_image); 374 GetCache()->SetGAIAPictureOfProfileAtIndex(1, &gaia_image);
373 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0)); 375 EXPECT_EQ(NULL, GetCache()->GetGAIAPictureOfProfileAtIndex(0));
374 EXPECT_TRUE(gfx::test::IsEqual( 376 EXPECT_TRUE(gfx::test::IsEqual(
375 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1))); 377 gaia_image, *GetCache()->GetGAIAPictureOfProfileAtIndex(1)));
376 // Since we're still using the default avatar, the GAIA image should be 378 // Since we're still using the default avatar, the GAIA image should be
377 // preferred over the generic avatar image. 379 // preferred over the generic avatar image.
378 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1)); 380 EXPECT_TRUE(GetCache()->ProfileIsUsingDefaultAvatarAtIndex(1));
379 EXPECT_TRUE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1)); 381 EXPECT_TRUE(GetCache()->IsUsingGAIAPictureOfProfileAtIndex(1));
380 EXPECT_TRUE(gfx::test::IsEqual( 382 EXPECT_TRUE(gfx::test::IsEqual(
381 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1))); 383 gaia_image, GetCache()->GetAvatarIconOfProfileAtIndex(1)));
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 base::RunLoop().RunUntilIdle(); 578 base::RunLoop().RunUntilIdle();
577 579
578 // Clean up. 580 // Clean up.
579 base::FilePath icon_path = 581 base::FilePath icon_path =
580 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex); 582 profiles::GetPathOfHighResAvatarAtIndex(kIconIndex);
581 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name)); 583 EXPECT_NE(std::string::npos, icon_path.MaybeAsASCII().find(file_name));
582 EXPECT_TRUE(base::PathExists(icon_path)); 584 EXPECT_TRUE(base::PathExists(icon_path));
583 EXPECT_TRUE(base::DeleteFile(icon_path, true)); 585 EXPECT_TRUE(base::DeleteFile(icon_path, true));
584 EXPECT_FALSE(base::PathExists(icon_path)); 586 EXPECT_FALSE(base::PathExists(icon_path));
585 } 587 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_shortcut_manager_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698