| OLD | NEW |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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/shaping/CachingWordShaper.h" | 5 #include "platform/fonts/shaping/CachingWordShaper.h" |
| 6 | 6 |
| 7 #include "platform/fonts/CharacterRange.h" | 7 #include "platform/fonts/CharacterRange.h" |
| 8 #include "platform/fonts/FontCache.h" | 8 #include "platform/fonts/FontCache.h" |
| 9 #include "platform/fonts/GlyphBuffer.h" | 9 #include "platform/fonts/GlyphBuffer.h" |
| 10 #include "platform/fonts/shaping/CachingWordShapeIterator.h" | 10 #include "platform/fonts/shaping/CachingWordShapeIterator.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 ASSERT_TRUE(iterator.next(&result)); | 59 ASSERT_TRUE(iterator.next(&result)); |
| 60 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); | 60 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); |
| 61 EXPECT_EQ(0u, startIndex); | 61 EXPECT_EQ(0u, startIndex); |
| 62 EXPECT_EQ(1u, numGlyphs); | 62 EXPECT_EQ(1u, numGlyphs); |
| 63 EXPECT_EQ(HB_SCRIPT_COMMON, script); | 63 EXPECT_EQ(HB_SCRIPT_COMMON, script); |
| 64 | 64 |
| 65 ASSERT_TRUE(iterator.next(&result)); | 65 ASSERT_TRUE(iterator.next(&result)); |
| 66 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); | 66 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); |
| 67 EXPECT_EQ(0u, startIndex); | 67 EXPECT_EQ(0u, startIndex); |
| 68 EXPECT_EQ(4u, numGlyphs); | 68 EXPECT_EQ(3u, numGlyphs); |
| 69 EXPECT_EQ(HB_SCRIPT_LATIN, script); | 69 EXPECT_EQ(HB_SCRIPT_LATIN, script); |
| 70 | 70 |
| 71 ASSERT_TRUE(iterator.next(&result)); |
| 72 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); |
| 73 EXPECT_EQ(0u, startIndex); |
| 74 EXPECT_EQ(1u, numGlyphs); |
| 75 EXPECT_EQ(HB_SCRIPT_COMMON, script); |
| 76 |
| 71 ASSERT_FALSE(iterator.next(&result)); | 77 ASSERT_FALSE(iterator.next(&result)); |
| 72 } | 78 } |
| 73 | 79 |
| 74 TEST_F(CachingWordShaperTest, CommonAccentLeftToRightByWord) | 80 TEST_F(CachingWordShaperTest, CommonAccentLeftToRightByWord) |
| 75 { | 81 { |
| 76 const UChar str[] = { 0x2F, 0x301, 0x2E, 0x20, 0x2E, 0x0 }; | 82 const UChar str[] = { 0x2F, 0x301, 0x2E, 0x20, 0x2E, 0x0 }; |
| 77 TextRun textRun(str, 5); | 83 TextRun textRun(str, 5); |
| 78 | 84 |
| 79 unsigned offset = 0; | 85 unsigned offset = 0; |
| 80 RefPtr<ShapeResult> result; | 86 RefPtr<ShapeResult> result; |
| 81 CachingWordShapeIterator iterator(cache.get(), textRun, &font); | 87 CachingWordShapeIterator iterator(cache.get(), textRun, &font); |
| 82 ASSERT_TRUE(iterator.next(&result)); | 88 ASSERT_TRUE(iterator.next(&result)); |
| 83 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); | 89 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); |
| 84 EXPECT_EQ(0u, offset + startIndex); | 90 EXPECT_EQ(0u, offset + startIndex); |
| 85 EXPECT_EQ(3u, numGlyphs); | 91 EXPECT_EQ(2u, numGlyphs); |
| 86 EXPECT_EQ(HB_SCRIPT_COMMON, script); | 92 EXPECT_EQ(HB_SCRIPT_COMMON, script); |
| 87 offset += result->numCharacters(); | 93 offset += result->numCharacters(); |
| 88 | 94 |
| 95 ASSERT_TRUE(iterator.next(&result)); |
| 96 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); |
| 97 EXPECT_EQ(2u, offset + startIndex); |
| 98 EXPECT_EQ(1u, numGlyphs); |
| 99 EXPECT_EQ(HB_SCRIPT_COMMON, script); |
| 100 offset += result->numCharacters(); |
| 101 |
| 89 ASSERT_TRUE(iterator.next(&result)); | 102 ASSERT_TRUE(iterator.next(&result)); |
| 90 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); | 103 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); |
| 91 EXPECT_EQ(3u, offset + startIndex); | 104 EXPECT_EQ(3u, offset + startIndex); |
| 92 EXPECT_EQ(1u, numGlyphs); | 105 EXPECT_EQ(1u, numGlyphs); |
| 93 EXPECT_EQ(HB_SCRIPT_COMMON, script); | 106 EXPECT_EQ(HB_SCRIPT_COMMON, script); |
| 94 offset += result->numCharacters(); | 107 offset += result->numCharacters(); |
| 95 | 108 |
| 96 ASSERT_TRUE(iterator.next(&result)); | 109 ASSERT_TRUE(iterator.next(&result)); |
| 97 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); | 110 ASSERT_TRUE(testInfo(result)->runInfoForTesting(0, startIndex, numGlyphs, sc
ript)); |
| 98 EXPECT_EQ(4u, offset + startIndex); | 111 EXPECT_EQ(4u, offset + startIndex); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 float periodsAndSpacesWidth = shaper.width(&font, periodsAndSpaces, nullptr,
&periodsAndSpacesGlyphBounds); | 530 float periodsAndSpacesWidth = shaper.width(&font, periodsAndSpaces, nullptr,
&periodsAndSpacesGlyphBounds); |
| 518 | 531 |
| 519 // The total width of periods and spaces should be longer than the width of
periods alone. | 532 // The total width of periods and spaces should be longer than the width of
periods alone. |
| 520 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); | 533 ASSERT_GT(periodsAndSpacesWidth, periodsWidth); |
| 521 | 534 |
| 522 // The glyph bounds of periods and spaces should be longer than the glyph bo
unds of periods alone. | 535 // The glyph bounds of periods and spaces should be longer than the glyph bo
unds of periods alone. |
| 523 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); | 536 ASSERT_GT(periodsAndSpacesGlyphBounds.width(), periodsGlyphBounds.width()); |
| 524 } | 537 } |
| 525 | 538 |
| 526 } // namespace blink | 539 } // namespace blink |
| OLD | NEW |