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

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

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

Powered by Google App Engine
This is Rietveld 408576698