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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 EXPECT_EQ(Font::BOLD, derived_font.GetStyle()); | 60 EXPECT_EQ(Font::BOLD, derived_font.GetStyle()); |
61 | 61 |
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 | |
71 const Font bigger_font(base_font.GetFontName(), base_font.GetFontSize() + 10); | |
Alexei Svitkine (slow)
2014/05/09 21:21:00
Oops, I see you already added a test.
Can you mak
Tomasz Moniuszko
2014/05/29 10:46:40
Done.
| |
72 PlatformFontWin* bigger_platform_font = | |
73 static_cast<PlatformFontWin*>(bigger_font.platform_font()); | |
74 | |
75 int requested_height = (base_font.GetHeight() + bigger_font.GetHeight()) / 2; | |
Alexei Svitkine (slow)
2014/05/09 21:21:00
Is it possible to do something more straight forwa
Tomasz Moniuszko
2014/05/29 10:46:40
Done.
| |
76 ASSERT_GT(requested_height, base_font.GetHeight()); | |
77 ASSERT_LT(requested_height, bigger_font.GetHeight()); | |
78 | |
79 Font derived_font_1 = | |
80 platform_font->DeriveFontWithHeight(requested_height, 0); | |
81 Font derived_font_2 = | |
82 bigger_platform_font->DeriveFontWithHeight(requested_height, 0); | |
83 | |
84 // Derived fonts should be the same height for both higher and lower base | |
85 // fonts. | |
86 EXPECT_EQ(derived_font_1.GetHeight(), derived_font_2.GetHeight()); | |
70 } | 87 } |
71 | 88 |
72 // Callback function used by DeriveFontWithHeight_MinSize() below. | 89 // Callback function used by DeriveFontWithHeight_MinSize() below. |
73 static int GetMinFontSize() { | 90 static int GetMinFontSize() { |
74 return 10; | 91 return 10; |
75 } | 92 } |
76 | 93 |
77 TEST(PlatformFontWinTest, DeriveFontWithHeight_MinSize) { | 94 TEST(PlatformFontWinTest, DeriveFontWithHeight_MinSize) { |
78 PlatformFontWin::GetMinimumFontSizeCallback old_callback = | 95 PlatformFontWin::GetMinimumFontSizeCallback old_callback = |
79 PlatformFontWin::get_minimum_font_size_callback; | 96 PlatformFontWin::get_minimum_font_size_callback; |
(...skipping 15 matching lines...) Expand all Loading... | |
95 TEST(PlatformFontWinTest, DeriveFontWithHeight_TooSmall) { | 112 TEST(PlatformFontWinTest, DeriveFontWithHeight_TooSmall) { |
96 const Font base_font; | 113 const Font base_font; |
97 PlatformFontWin* platform_font = | 114 PlatformFontWin* platform_font = |
98 static_cast<PlatformFontWin*>(base_font.platform_font()); | 115 static_cast<PlatformFontWin*>(base_font.platform_font()); |
99 | 116 |
100 const Font derived_font = platform_font->DeriveFontWithHeight(1, 0); | 117 const Font derived_font = platform_font->DeriveFontWithHeight(1, 0); |
101 EXPECT_GT(derived_font.GetHeight(), 1); | 118 EXPECT_GT(derived_font.GetHeight(), 1); |
102 } | 119 } |
103 | 120 |
104 } // namespace gfx | 121 } // namespace gfx |
OLD | NEW |