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 <Cocoa/Cocoa.h> | 5 #include <Cocoa/Cocoa.h> |
| 6 #include <stddef.h> |
6 | 7 |
| 8 #include "base/macros.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
8 #include "ui/gfx/font.h" | 10 #include "ui/gfx/font.h" |
9 | 11 |
10 TEST(PlatformFontMacTest, DeriveFont) { | 12 TEST(PlatformFontMacTest, DeriveFont) { |
11 // Use a base font that support all traits. | 13 // Use a base font that support all traits. |
12 gfx::Font base_font("Helvetica", 13); | 14 gfx::Font base_font("Helvetica", 13); |
13 | 15 |
14 // Bold | 16 // Bold |
15 gfx::Font bold_font(base_font.Derive(0, gfx::Font::BOLD)); | 17 gfx::Font bold_font(base_font.Derive(0, gfx::Font::BOLD)); |
16 NSFontTraitMask traits = [[NSFontManager sharedFontManager] | 18 NSFontTraitMask traits = [[NSFontManager sharedFontManager] |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 // (plus baseline). So the height depends on the rounding of the ascender, | 92 // (plus baseline). So the height depends on the rounding of the ascender, |
91 // and can be as much as 1 greater than the simple sum of floats. | 93 // and can be as much as 1 greater than the simple sum of floats. |
92 EXPECT_LE(sum, font.GetHeight()); | 94 EXPECT_LE(sum, font.GetHeight()); |
93 EXPECT_GE(sum + 1, font.GetHeight()); | 95 EXPECT_GE(sum + 1, font.GetHeight()); |
94 | 96 |
95 // Recreate the rounding performed for GetBaseLine(). | 97 // Recreate the rounding performed for GetBaseLine(). |
96 EXPECT_EQ(ceil(ceil(ascender) - descender + leading), font.GetHeight()); | 98 EXPECT_EQ(ceil(ceil(ascender) - descender + leading), font.GetHeight()); |
97 } | 99 } |
98 } | 100 } |
99 } | 101 } |
OLD | NEW |