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