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 "ui/gfx/platform_font_win.h" | 5 #include "ui/gfx/platform_font_win.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 #include "ui/gfx/font.h" | 10 #include "ui/gfx/font.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 // Test that deriving from the new font has the expected result. | 62 // Test that deriving from the new font has the expected result. |
63 Font rederived_font = derived_font.Derive(1, 0); | 63 Font rederived_font = derived_font.Derive(1, 0); |
64 expected_font = Font(derived_font.GetFontName(), | 64 expected_font = Font(derived_font.GetFontName(), |
65 derived_font.GetFontSize() + 1); | 65 derived_font.GetFontSize() + 1); |
66 EXPECT_EQ(expected_font.GetFontName(), rederived_font.GetFontName()); | 66 EXPECT_EQ(expected_font.GetFontName(), rederived_font.GetFontName()); |
67 EXPECT_EQ(expected_font.GetFontSize(), rederived_font.GetFontSize()); | 67 EXPECT_EQ(expected_font.GetFontSize(), rederived_font.GetFontSize()); |
68 EXPECT_EQ(expected_font.GetHeight(), rederived_font.GetHeight()); | 68 EXPECT_EQ(expected_font.GetHeight(), rederived_font.GetHeight()); |
69 } | 69 } |
70 } | 70 } |
71 | 71 |
| 72 TEST(PlatformFontWinTest, DeriveFontWithHeight_Consistency) { |
| 73 gfx::Font arial_12("Arial", 12); |
| 74 ASSERT_GT(16, arial_12.GetHeight()); |
| 75 gfx::Font derived_1 = static_cast<PlatformFontWin*>( |
| 76 arial_12.platform_font())->DeriveFontWithHeight(16, 0); |
| 77 |
| 78 gfx::Font arial_15("Arial", 15); |
| 79 ASSERT_LT(16, arial_15.GetHeight()); |
| 80 gfx::Font derived_2 = static_cast<PlatformFontWin*>( |
| 81 arial_15.platform_font())->DeriveFontWithHeight(16, 0); |
| 82 |
| 83 EXPECT_EQ(derived_1.GetFontSize(), derived_2.GetFontSize()); |
| 84 EXPECT_EQ(16, derived_1.GetHeight()); |
| 85 EXPECT_EQ(16, derived_2.GetHeight()); |
| 86 } |
| 87 |
72 // Callback function used by DeriveFontWithHeight_MinSize() below. | 88 // Callback function used by DeriveFontWithHeight_MinSize() below. |
73 static int GetMinFontSize() { | 89 static int GetMinFontSize() { |
74 return 10; | 90 return 10; |
75 } | 91 } |
76 | 92 |
77 TEST(PlatformFontWinTest, DeriveFontWithHeight_MinSize) { | 93 TEST(PlatformFontWinTest, DeriveFontWithHeight_MinSize) { |
78 PlatformFontWin::GetMinimumFontSizeCallback old_callback = | 94 PlatformFontWin::GetMinimumFontSizeCallback old_callback = |
79 PlatformFontWin::get_minimum_font_size_callback; | 95 PlatformFontWin::get_minimum_font_size_callback; |
80 PlatformFontWin::get_minimum_font_size_callback = &GetMinFontSize; | 96 PlatformFontWin::get_minimum_font_size_callback = &GetMinFontSize; |
81 | 97 |
(...skipping 13 matching lines...) Expand all Loading... |
95 TEST(PlatformFontWinTest, DeriveFontWithHeight_TooSmall) { | 111 TEST(PlatformFontWinTest, DeriveFontWithHeight_TooSmall) { |
96 const Font base_font; | 112 const Font base_font; |
97 PlatformFontWin* platform_font = | 113 PlatformFontWin* platform_font = |
98 static_cast<PlatformFontWin*>(base_font.platform_font()); | 114 static_cast<PlatformFontWin*>(base_font.platform_font()); |
99 | 115 |
100 const Font derived_font = platform_font->DeriveFontWithHeight(1, 0); | 116 const Font derived_font = platform_font->DeriveFontWithHeight(1, 0); |
101 EXPECT_GT(derived_font.GetHeight(), 1); | 117 EXPECT_GT(derived_font.GetHeight(), 1); |
102 } | 118 } |
103 | 119 |
104 } // namespace gfx | 120 } // namespace gfx |
OLD | NEW |