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_util.h" | 5 #include "chrome/browser/profiles/profile_info_util.h" |
6 | 6 |
7 #include "grit/generated_resources.h" | 7 #include "grit/generated_resources.h" |
8 #include "grit/theme_resources.h" | 8 #include "grit/theme_resources.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/base/resource/resource_bundle.h" | 10 #include "ui/base/resource/resource_bundle.h" |
11 #include "ui/gfx/image/image_unittest_util.h" | 11 #include "ui/gfx/image/image_unittest_util.h" |
12 | 12 |
13 namespace { | 13 namespace { |
14 | 14 |
15 TEST(ProfileInfoUtilTest, MenuIcon) { | 15 TEST(ProfileInfoUtilTest, MenuIcon) { |
16 // Test that an avatar icon isn't changed. | 16 // Test that an avatar icon isn't changed. |
17 const gfx::Image& profile_image( | 17 const gfx::Image& profile_image( |
18 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0)); | 18 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0)); |
19 gfx::Image result = profiles::GetAvatarIconForMenu(profile_image, false); | 19 gfx::Image result = profiles::GetAvatarIconForMenu(profile_image, false); |
20 EXPECT_FALSE(gfx::test::IsEmpty(result)); | 20 EXPECT_FALSE(gfx::test::IsEmpty(result)); |
21 EXPECT_TRUE(gfx::test::IsEqual(profile_image, result)); | 21 EXPECT_TRUE(gfx::test::IsEqual(profile_image, result)); |
22 | 22 |
23 // Test that a GAIA picture is changed. | 23 // Test that a GAIA picture is changed. |
24 gfx::Image gaia_picture(gfx::test::CreateImage()); | 24 gfx::Image gaia_picture(gfx::test::CreateImage()); |
25 gfx::Image result2 = profiles::GetAvatarIconForMenu(gaia_picture, true); | 25 gfx::Image result2 = profiles::GetAvatarIconForMenu(gaia_picture, true); |
26 EXPECT_FALSE(gfx::test::IsEmpty(result2)); | 26 EXPECT_FALSE(gfx::test::IsEmpty(result2)); |
27 EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2)); | 27 EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2)); |
28 } | 28 } |
29 | 29 |
| 30 TEST(ProfileInfoUtilTest, WebUIIcon) { |
| 31 // Test that an avatar icon isn't changed. |
| 32 const gfx::Image& profile_image( |
| 33 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0)); |
| 34 gfx::Image result = profiles::GetAvatarIconForWebUI(profile_image, false); |
| 35 EXPECT_FALSE(gfx::test::IsEmpty(result)); |
| 36 EXPECT_TRUE(gfx::test::IsEqual(profile_image, result)); |
| 37 |
| 38 // Test that a GAIA picture is changed. |
| 39 gfx::Image gaia_picture(gfx::test::CreateImage()); |
| 40 gfx::Image result2 = profiles::GetAvatarIconForWebUI(gaia_picture, true); |
| 41 EXPECT_FALSE(gfx::test::IsEmpty(result2)); |
| 42 EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2)); |
| 43 } |
| 44 |
30 TEST(ProfileInfoUtilTest, TitleBarIcon) { | 45 TEST(ProfileInfoUtilTest, TitleBarIcon) { |
31 // Test that an avatar icon isn't changed. | 46 // Test that an avatar icon isn't changed. |
32 const gfx::Image& profile_image( | 47 const gfx::Image& profile_image( |
33 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0)); | 48 ResourceBundle::GetSharedInstance().GetImageNamed(IDR_PROFILE_AVATAR_0)); |
34 gfx::Image result = profiles::GetAvatarIconForTitleBar( | 49 gfx::Image result = profiles::GetAvatarIconForTitleBar( |
35 profile_image, false, 100, 40); | 50 profile_image, false, 100, 40); |
36 EXPECT_FALSE(gfx::test::IsEmpty(result)); | 51 EXPECT_FALSE(gfx::test::IsEmpty(result)); |
37 EXPECT_TRUE(gfx::test::IsEqual(profile_image, result)); | 52 EXPECT_TRUE(gfx::test::IsEqual(profile_image, result)); |
38 | 53 |
39 // Test that a GAIA picture is changed. | 54 // Test that a GAIA picture is changed. |
40 gfx::Image gaia_picture(gfx::test::CreateImage()); | 55 gfx::Image gaia_picture(gfx::test::CreateImage()); |
41 gfx::Image result2 = profiles::GetAvatarIconForTitleBar( | 56 gfx::Image result2 = profiles::GetAvatarIconForTitleBar( |
42 gaia_picture, true, 100, 40); | 57 gaia_picture, true, 100, 40); |
43 EXPECT_FALSE(gfx::test::IsEmpty(result2)); | 58 EXPECT_FALSE(gfx::test::IsEmpty(result2)); |
44 EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2)); | 59 EXPECT_FALSE(gfx::test::IsEqual(gaia_picture, result2)); |
45 } | 60 } |
46 | 61 |
47 } // namespace | 62 } // namespace |
OLD | NEW |