| 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 "config.h" | 5 #include "config.h" |
| 6 | 6 |
| 7 #include "platform/fonts/FontCache.h" | 7 #include "platform/fonts/FontCache.h" |
| 8 #include "platform/fonts/GlyphBuffer.h" | 8 #include "platform/fonts/GlyphBuffer.h" |
| 9 #include "platform/fonts/shaping/CachingWordShapeIterator.h" | 9 #include "platform/fonts/shaping/CachingWordShapeIterator.h" |
| 10 #include <gtest/gtest.h> | 10 #include <gtest/gtest.h> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 unsigned startIndex = 0; | 40 unsigned startIndex = 0; |
| 41 unsigned numGlyphs = 0; | 41 unsigned numGlyphs = 0; |
| 42 hb_script_t script = HB_SCRIPT_INVALID; | 42 hb_script_t script = HB_SCRIPT_INVALID; |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 TEST_F(CachingWordShaperTest, LatinLeftToRightByWord) | 45 TEST_F(CachingWordShaperTest, LatinLeftToRightByWord) |
| 46 { | 46 { |
| 47 TextRun textRun(reinterpret_cast<const LChar*>("ABC DEF."), 8); | 47 TextRun textRun(reinterpret_cast<const LChar*>("ABC DEF."), 8); |
| 48 | 48 |
| 49 RefPtr<ShapeResult> result; | 49 RefPtr<ShapeResult> result; |
| 50 CachingWordShapeIterator iterator(cache, textRun, font, fallbackFonts); | 50 CachingWordShapeIterator iterator(cache, textRun, font); |
| 51 ASSERT_TRUE(iterator.next(&result)); | 51 ASSERT_TRUE(iterator.next(&result)); |
| 52 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); | 52 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 53 EXPECT_EQ(0u, startIndex); | 53 EXPECT_EQ(0u, startIndex); |
| 54 EXPECT_EQ(3u, numGlyphs); | 54 EXPECT_EQ(3u, numGlyphs); |
| 55 EXPECT_EQ(HB_SCRIPT_LATIN, script); | 55 EXPECT_EQ(HB_SCRIPT_LATIN, script); |
| 56 | 56 |
| 57 ASSERT_TRUE(iterator.next(&result)); | 57 ASSERT_TRUE(iterator.next(&result)); |
| 58 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); | 58 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 59 EXPECT_EQ(0u, startIndex); | 59 EXPECT_EQ(0u, startIndex); |
| 60 EXPECT_EQ(1u, numGlyphs); | 60 EXPECT_EQ(1u, numGlyphs); |
| 61 EXPECT_EQ(HB_SCRIPT_COMMON, script); | 61 EXPECT_EQ(HB_SCRIPT_COMMON, script); |
| 62 | 62 |
| 63 ASSERT_TRUE(iterator.next(&result)); | 63 ASSERT_TRUE(iterator.next(&result)); |
| 64 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); | 64 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 65 EXPECT_EQ(0u, startIndex); | 65 EXPECT_EQ(0u, startIndex); |
| 66 EXPECT_EQ(4u, numGlyphs); | 66 EXPECT_EQ(4u, numGlyphs); |
| 67 EXPECT_EQ(HB_SCRIPT_LATIN, script); | 67 EXPECT_EQ(HB_SCRIPT_LATIN, script); |
| 68 | 68 |
| 69 ASSERT_FALSE(iterator.next(&result)); | 69 ASSERT_FALSE(iterator.next(&result)); |
| 70 } | 70 } |
| 71 | 71 |
| 72 TEST_F(CachingWordShaperTest, CommonAccentLeftToRightByWord) | 72 TEST_F(CachingWordShaperTest, CommonAccentLeftToRightByWord) |
| 73 { | 73 { |
| 74 const UChar str[] = { 0x2F, 0x301, 0x2E, 0x20, 0x2E, 0x0 }; | 74 const UChar str[] = { 0x2F, 0x301, 0x2E, 0x20, 0x2E, 0x0 }; |
| 75 TextRun textRun(str, 5); | 75 TextRun textRun(str, 5); |
| 76 | 76 |
| 77 unsigned offset = 0; | 77 unsigned offset = 0; |
| 78 RefPtr<ShapeResult> result; | 78 RefPtr<ShapeResult> result; |
| 79 CachingWordShapeIterator iterator(cache, textRun, font, fallbackFonts); | 79 CachingWordShapeIterator iterator(cache, textRun, font); |
| 80 ASSERT_TRUE(iterator.next(&result)); | 80 ASSERT_TRUE(iterator.next(&result)); |
| 81 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); | 81 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 82 EXPECT_EQ(0u, offset + startIndex); | 82 EXPECT_EQ(0u, offset + startIndex); |
| 83 EXPECT_EQ(3u, numGlyphs); | 83 EXPECT_EQ(3u, numGlyphs); |
| 84 EXPECT_EQ(HB_SCRIPT_COMMON, script); | 84 EXPECT_EQ(HB_SCRIPT_COMMON, script); |
| 85 offset += result->numCharacters(); | 85 offset += result->numCharacters(); |
| 86 | 86 |
| 87 ASSERT_TRUE(iterator.next(&result)); | 87 ASSERT_TRUE(iterator.next(&result)); |
| 88 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); | 88 ASSERT_TRUE(result->runInfoForTesting(0, startIndex, numGlyphs, script)); |
| 89 EXPECT_EQ(3u, offset + startIndex); | 89 EXPECT_EQ(3u, offset + startIndex); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 GlyphBuffer glyphBuffer; | 171 GlyphBuffer glyphBuffer; |
| 172 shaper.fillGlyphBuffer(font, textRun, fallbackFonts, &glyphBuffer, 0, 8); | 172 shaper.fillGlyphBuffer(font, textRun, fallbackFonts, &glyphBuffer, 0, 8); |
| 173 | 173 |
| 174 FloatPoint point; | 174 FloatPoint point; |
| 175 int height = 16; | 175 int height = 16; |
| 176 shaper.selectionRect(font, textRun, point, height, 0, 8); | 176 shaper.selectionRect(font, textRun, point, height, 0, 8); |
| 177 } | 177 } |
| 178 | 178 |
| 179 | 179 |
| 180 } // namespace blink | 180 } // namespace blink |
| OLD | NEW |