Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(949)

Side by Side Diff: third_party/WebKit/Source/platform/fonts/FontTest.cpp

Issue 2640983002: Rename paint data structures (Closed)
Patch Set: Clean up comments, fix mac build Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/testing/FontTestHelpers.h" 8 #include "platform/testing/FontTestHelpers.h"
8 #include "platform/testing/UnitTestHelpers.h" 9 #include "platform/testing/UnitTestHelpers.h"
9 #include "platform/text/TextRun.h" 10 #include "platform/text/TextRun.h"
10 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
11 12
12 using blink::testing::createTestFont; 13 using blink::testing::createTestFont;
13 14
14 namespace blink { 15 namespace blink {
15 16
16 static inline String fontPath(String relativePath) { 17 static inline String fontPath(String relativePath) {
17 return testing::blinkRootDir() + "/Source/platform/testing/data/" + 18 return testing::blinkRootDir() + "/Source/platform/testing/data/" +
18 relativePath; 19 relativePath;
19 } 20 }
20 21
21 TEST(FontTest, TextIntercepts) { 22 TEST(FontTest, TextIntercepts) {
22 Font font = createTestFont("Ahem", fontPath("Ahem.woff"), 16); 23 Font font = createTestFont("Ahem", fontPath("Ahem.woff"), 16);
23 // A sequence of LATIN CAPITAL LETTER E WITH ACUTE and LATIN SMALL LETTER P 24 // A sequence of LATIN CAPITAL LETTER E WITH ACUTE and LATIN SMALL LETTER P
24 // characters. E ACUTES are squares above the baseline in Ahem, while p's 25 // characters. E ACUTES are squares above the baseline in Ahem, while p's
25 // are rectangles below the baseline. 26 // are rectangles below the baseline.
26 UChar ahemAboveBelowBaselineString[] = {0xc9, 0x70, 0xc9, 0x70, 0xc9, 27 UChar ahemAboveBelowBaselineString[] = {0xc9, 0x70, 0xc9, 0x70, 0xc9,
27 0x70, 0xc9, 0x70, 0xc9}; 28 0x70, 0xc9, 0x70, 0xc9};
28 TextRun ahemAboveBelowBaseline(ahemAboveBelowBaselineString, 9); 29 TextRun ahemAboveBelowBaseline(ahemAboveBelowBaselineString, 9);
29 TextRunPaintInfo textRunPaintInfo(ahemAboveBelowBaseline); 30 TextRunPaintInfo textRunPaintInfo(ahemAboveBelowBaseline);
30 SkPaint defaultPaint; 31 PaintFlags defaultPaint;
31 float deviceScaleFactor = 1; 32 float deviceScaleFactor = 1;
32 33
33 std::tuple<float, float> belowBaselineBounds = std::make_tuple(2, 4); 34 std::tuple<float, float> belowBaselineBounds = std::make_tuple(2, 4);
34 Vector<Font::TextIntercept> textIntercepts; 35 Vector<Font::TextIntercept> textIntercepts;
35 // 4 intercept ranges for below baseline p glyphs in the test string 36 // 4 intercept ranges for below baseline p glyphs in the test string
36 font.getTextIntercepts(textRunPaintInfo, deviceScaleFactor, defaultPaint, 37 font.getTextIntercepts(textRunPaintInfo, deviceScaleFactor, defaultPaint,
37 belowBaselineBounds, textIntercepts); 38 belowBaselineBounds, textIntercepts);
38 EXPECT_EQ(textIntercepts.size(), 4u); 39 EXPECT_EQ(textIntercepts.size(), 4u);
39 for (auto textIntercept : textIntercepts) { 40 for (auto textIntercept : textIntercepts) {
40 EXPECT_GT(textIntercept.m_end, textIntercept.m_begin); 41 EXPECT_GT(textIntercept.m_end, textIntercept.m_begin);
41 } 42 }
42 43
43 std::tuple<float, float> aboveBaselineBounds = std::make_tuple(-4, -2); 44 std::tuple<float, float> aboveBaselineBounds = std::make_tuple(-4, -2);
44 // 5 intercept ranges for the above baseline E ACUTE glyphs 45 // 5 intercept ranges for the above baseline E ACUTE glyphs
45 font.getTextIntercepts(textRunPaintInfo, deviceScaleFactor, defaultPaint, 46 font.getTextIntercepts(textRunPaintInfo, deviceScaleFactor, defaultPaint,
46 aboveBaselineBounds, textIntercepts); 47 aboveBaselineBounds, textIntercepts);
47 EXPECT_EQ(textIntercepts.size(), 5u); 48 EXPECT_EQ(textIntercepts.size(), 5u);
48 for (auto textIntercept : textIntercepts) { 49 for (auto textIntercept : textIntercepts) {
49 EXPECT_GT(textIntercept.m_end, textIntercept.m_begin); 50 EXPECT_GT(textIntercept.m_end, textIntercept.m_begin);
50 } 51 }
51 } 52 }
52 53
53 } // namespace blink 54 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698