Home | History | Annotate | Download | only in profiles
      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
      3 // found in the LICENSE file.
      4 
      5 #include "chrome/browser/profiles/profile_info_util.h"
      6 
      7 #include "grit/generated_resources.h"
      8 #include "grit/theme_resources.h"
      9 #include "testing/gtest/include/gtest/gtest.h"
     10 #include "ui/base/resource/resource_bundle.h"
     11 #include "ui/gfx/image/image_unittest_util.h"
     12 
     13 namespace {
     14 
     15 TEST(ProfileInfoUtilTest, SizedMenuIcon) {
     16   // Test that an avatar icon isn't changed.
     17   const gfx::Image& profile_image(
     18       ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0));
     19   gfx::Image result =
     20       profiles::GetSizedAvatarIconWithBorder(profile_image, false, 50, 50);
     21   EXPECT_FALSE(gfx::test::IsEmpty(result));
     22   EXPECT_TRUE(gfx::test::IsEqual(profile_image, result));
     23 
     24   // Test that a GAIA picture is changed.
     25   gfx::Image gaia_picture(gfx::test::CreateImage());
     26   gfx::Image result2 =
     27       profiles::GetSizedAvatarIconWithBorder(gaia_picture, true, 50, 50);
     28   EXPECT_FALSE(gfx::test::IsEmpty(result2));
     29   EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2));
     30 }
     31 
     32 TEST(ProfileInfoUtilTest, MenuIcon) {
     33   // Test that an avatar icon isn't changed.
     34   const gfx::Image& profile_image(
     35       ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0));
     36   gfx::Image result = profiles::GetAvatarIconForMenu(profile_image, false);
     37   EXPECT_FALSE(gfx::test::IsEmpty(result));
     38   EXPECT_TRUE(gfx::test::IsEqual(profile_image, result));
     39 
     40   // Test that a GAIA picture is changed.
     41   gfx::Image gaia_picture(gfx::test::CreateImage());
     42   gfx::Image result2 = profiles::GetAvatarIconForMenu(gaia_picture, true);
     43   EXPECT_FALSE(gfx::test::IsEmpty(result2));
     44   EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2));
     45 }
     46 
     47 TEST(ProfileInfoUtilTest, WebUIIcon) {
     48   // Test that an avatar icon isn't changed.
     49   const gfx::Image& profile_image(
     50       ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0));
     51   gfx::Image result = profiles::GetAvatarIconForWebUI(profile_image, false);
     52   EXPECT_FALSE(gfx::test::IsEmpty(result));
     53   EXPECT_TRUE(gfx::test::IsEqual(profile_image, result));
     54 
     55   // Test that a GAIA picture is changed.
     56   gfx::Image gaia_picture(gfx::test::CreateImage());
     57   gfx::Image result2 = profiles::GetAvatarIconForWebUI(gaia_picture, true);
     58   EXPECT_FALSE(gfx::test::IsEmpty(result2));
     59   EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2));
     60 }
     61 
     62 TEST(ProfileInfoUtilTest, TitleBarIcon) {
     63   // Test that an avatar icon isn't changed.
     64   const gfx::Image& profile_image(
     65       ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0));
     66   gfx::Image result = profiles::GetAvatarIconForTitleBar(
     67       profile_image, false, 100, 40);
     68   EXPECT_FALSE(gfx::test::IsEmpty(result));
     69   EXPECT_TRUE(gfx::test::IsEqual(profile_image, result));
     70 
     71   // Test that a GAIA picture is changed.
     72   gfx::Image gaia_picture(gfx::test::CreateImage());
     73   gfx::Image result2 = profiles::GetAvatarIconForTitleBar(
     74       gaia_picture, true, 100, 40);
     75   EXPECT_FALSE(gfx::test::IsEmpty(result2));
     76   EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2));
     77 }
     78 
     79 }  // namespace
     80