diff options
author | ckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-08 20:10:40 +0000 |
---|---|---|
committer | ckocagil@chromium.org <ckocagil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-08 20:10:40 +0000 |
commit | 9838033635e529074695e63480597a43c2780acd (patch) | |
tree | 8f7961080301f13c96c0bb9e5f3835b4b9d5f8c7 /ui/gfx/render_text_unittest.cc | |
parent | 4a55a71954376e456599041857f4c847ca003829 (diff) | |
download | chromium_src-9838033635e529074695e63480597a43c2780acd.zip chromium_src-9838033635e529074695e63480597a43c2780acd.tar.gz chromium_src-9838033635e529074695e63480597a43c2780acd.tar.bz2 |
Fix the Char to Glyph mapping logic in RenderTextHarfBuzz
BUG=321868
R=msw@chromium.org
NOTRY=true
Review URL: https://codereview.chromium.org/300623003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275754 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx/render_text_unittest.cc')
-rw-r--r-- | ui/gfx/render_text_unittest.cc | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc index 02dfeb2..6859a50 100644 --- a/ui/gfx/render_text_unittest.cc +++ b/ui/gfx/render_text_unittest.cc @@ -14,6 +14,7 @@ #include "testing/gtest/include/gtest/gtest.h" #include "ui/gfx/break_list.h" #include "ui/gfx/canvas.h" +#include "ui/gfx/render_text_harfbuzz.h" #if defined(OS_WIN) #include "base/win/windows_version.h" @@ -1924,4 +1925,56 @@ TEST_F(RenderTextTest, Win_BreakRunsByUnicodeBlocks) { } #endif // defined(OS_WIN) +TEST_F(RenderTextTest, HarfBuzz_CharToGlyph) { + struct { + uint32 glyph_to_char[4]; + size_t char_to_glyph_expected[4]; + Range char_range_to_glyph_range_expected[4]; + bool is_rtl; + } cases[] = { + { // From string "A B C D" to glyphs "a b c d". + { 0, 1, 2, 3 }, + { 0, 1, 2, 3 }, + { Range(0, 1), Range(1, 2), Range(2, 3), Range(3, 4) }, + false + }, + { // From string "A B C D" to glyphs "d b c a". + { 3, 2, 1, 0 }, + { 3, 2, 1, 0 }, + { Range(3, 4), Range(2, 3), Range(1, 2), Range(0, 1) }, + true + }, + { // From string "A B C D" to glyphs "ab c c d". + { 0, 2, 2, 3 }, + { 0, 0, 1, 3 }, + { Range(0, 1), Range(0, 1), Range(1, 3), Range(3, 4) }, + false + }, + { // From string "A B C D" to glyphs "d c c ba". + { 3, 2, 2, 0 }, + { 3, 3, 1, 0 }, + { Range(3, 4), Range(3, 4), Range(1, 3), Range(0, 1) }, + true + }, + }; + + internal::TextRunHarfBuzz run; + run.range = Range(0, 4); + run.glyph_count = 4; + run.glyph_to_char.reset(new uint32[4]); + + for (size_t i = 0; i < ARRAYSIZE_UNSAFE(cases); ++i) { + std::copy(cases[i].glyph_to_char, cases[i].glyph_to_char + 4, + run.glyph_to_char.get()); + run.is_rtl = cases[i].is_rtl; + for (size_t j = 0; j < 4; ++j) { + SCOPED_TRACE(base::StringPrintf("Case %" PRIuS ", char %" PRIuS, i, j)); + EXPECT_EQ(cases[i].char_to_glyph_expected[j], run.CharToGlyph(j)); + EXPECT_EQ(cases[i].char_range_to_glyph_range_expected[j], + run.CharRangeToGlyphRange(Range(j, j + 1))); + } + } + +} + } // namespace gfx |