OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/fonts/Font.h" | 5 #include "platform/fonts/Font.h" |
6 | 6 |
7 #include "platform/graphics/paint/PaintFlags.h" | 7 #include "platform/graphics/paint/PaintFlags.h" |
8 #include "platform/testing/FontTestHelpers.h" | 8 #include "platform/testing/FontTestHelpers.h" |
9 #include "platform/testing/UnitTestHelpers.h" | 9 #include "platform/testing/UnitTestHelpers.h" |
10 #include "platform/text/TextRun.h" | 10 #include "platform/text/TextRun.h" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
13 using blink::testing::createTestFont; | 13 using blink::testing::createTestFont; |
14 | 14 |
15 namespace blink { | 15 namespace blink { |
16 | 16 |
17 static inline String fontPath(String relativePath) { | |
18 return testing::blinkRootDir() + "/Source/platform/testing/data/" + | |
19 relativePath; | |
20 } | |
21 | |
22 TEST(FontTest, TextIntercepts) { | 17 TEST(FontTest, TextIntercepts) { |
23 Font font = createTestFont("Ahem", fontPath("Ahem.woff"), 16); | 18 Font font = |
| 19 createTestFont("Ahem", testing::platformTestDataPath("Ahem.woff"), 16); |
24 // A sequence of LATIN CAPITAL LETTER E WITH ACUTE and LATIN SMALL LETTER P | 20 // A sequence of LATIN CAPITAL LETTER E WITH ACUTE and LATIN SMALL LETTER P |
25 // characters. E ACUTES are squares above the baseline in Ahem, while p's | 21 // characters. E ACUTES are squares above the baseline in Ahem, while p's |
26 // are rectangles below the baseline. | 22 // are rectangles below the baseline. |
27 UChar ahemAboveBelowBaselineString[] = {0xc9, 0x70, 0xc9, 0x70, 0xc9, | 23 UChar ahemAboveBelowBaselineString[] = {0xc9, 0x70, 0xc9, 0x70, 0xc9, |
28 0x70, 0xc9, 0x70, 0xc9}; | 24 0x70, 0xc9, 0x70, 0xc9}; |
29 TextRun ahemAboveBelowBaseline(ahemAboveBelowBaselineString, 9); | 25 TextRun ahemAboveBelowBaseline(ahemAboveBelowBaselineString, 9); |
30 TextRunPaintInfo textRunPaintInfo(ahemAboveBelowBaseline); | 26 TextRunPaintInfo textRunPaintInfo(ahemAboveBelowBaseline); |
31 PaintFlags defaultPaint; | 27 PaintFlags defaultPaint; |
32 float deviceScaleFactor = 1; | 28 float deviceScaleFactor = 1; |
33 | 29 |
(...skipping 11 matching lines...) Expand all Loading... |
45 // 5 intercept ranges for the above baseline E ACUTE glyphs | 41 // 5 intercept ranges for the above baseline E ACUTE glyphs |
46 font.getTextIntercepts(textRunPaintInfo, deviceScaleFactor, defaultPaint, | 42 font.getTextIntercepts(textRunPaintInfo, deviceScaleFactor, defaultPaint, |
47 aboveBaselineBounds, textIntercepts); | 43 aboveBaselineBounds, textIntercepts); |
48 EXPECT_EQ(textIntercepts.size(), 5u); | 44 EXPECT_EQ(textIntercepts.size(), 5u); |
49 for (auto textIntercept : textIntercepts) { | 45 for (auto textIntercept : textIntercepts) { |
50 EXPECT_GT(textIntercept.m_end, textIntercept.m_begin); | 46 EXPECT_GT(textIntercept.m_end, textIntercept.m_begin); |
51 } | 47 } |
52 } | 48 } |
53 | 49 |
54 } // namespace blink | 50 } // namespace blink |
OLD | NEW |