| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ui/gfx/render_text.h" | 5 #include "ui/gfx/render_text.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
| (...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2154 base::string16 text = WideToUTF16(cases[i]); | 2154 base::string16 text = WideToUTF16(cases[i]); |
| 2155 render_text.SetText(text); | 2155 render_text.SetText(text); |
| 2156 render_text.EnsureLayout(); | 2156 render_text.EnsureLayout(); |
| 2157 ASSERT_EQ(1U, render_text.runs_.size()); | 2157 ASSERT_EQ(1U, render_text.runs_.size()); |
| 2158 internal::TextRunHarfBuzz* run = render_text.runs_[0]; | 2158 internal::TextRunHarfBuzz* run = render_text.runs_[0]; |
| 2159 | 2159 |
| 2160 base::i18n::BreakIterator* iter = render_text.grapheme_iterator_.get(); | 2160 base::i18n::BreakIterator* iter = render_text.grapheme_iterator_.get(); |
| 2161 auto first_grapheme_bounds = run->GetGraphemeBounds(iter, 0); | 2161 auto first_grapheme_bounds = run->GetGraphemeBounds(iter, 0); |
| 2162 EXPECT_EQ(first_grapheme_bounds, run->GetGraphemeBounds(iter, 1)); | 2162 EXPECT_EQ(first_grapheme_bounds, run->GetGraphemeBounds(iter, 1)); |
| 2163 auto second_grapheme_bounds = run->GetGraphemeBounds(iter, 2); | 2163 auto second_grapheme_bounds = run->GetGraphemeBounds(iter, 2); |
| 2164 EXPECT_EQ(first_grapheme_bounds.second, second_grapheme_bounds.first); | 2164 EXPECT_EQ(first_grapheme_bounds.end(), second_grapheme_bounds.start()); |
| 2165 } | 2165 } |
| 2166 } | 2166 } |
| 2167 | 2167 |
| 2168 // Test the partition of a multi-grapheme cluster into grapheme ranges. | 2168 // Test the partition of a multi-grapheme cluster into grapheme ranges. |
| 2169 TEST_F(RenderTextTest, HarfBuzz_SubglyphGraphemePartition) { | 2169 TEST_F(RenderTextTest, HarfBuzz_SubglyphGraphemePartition) { |
| 2170 struct { | 2170 struct { |
| 2171 uint32 glyph_to_char[2]; | 2171 uint32 glyph_to_char[2]; |
| 2172 Range bounds[4]; | 2172 Range bounds[4]; |
| 2173 bool is_rtl; | 2173 bool is_rtl; |
| 2174 } cases[] = { | 2174 } cases[] = { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2459 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); | 2459 base::StringToLowerASCII(fonts[0].GetActualFontNameForTesting())); |
| 2460 | 2460 |
| 2461 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); | 2461 scoped_ptr<RenderText> render_text(RenderText::CreateInstance()); |
| 2462 render_text->SetDisplayRect(Rect(0, 0, 25, 25)); | 2462 render_text->SetDisplayRect(Rect(0, 0, 25, 25)); |
| 2463 render_text->SetFontList(font_list); | 2463 render_text->SetFontList(font_list); |
| 2464 EXPECT_GT(render_text->GetBaseline(), font_list.GetBaseline()); | 2464 EXPECT_GT(render_text->GetBaseline(), font_list.GetBaseline()); |
| 2465 } | 2465 } |
| 2466 #endif | 2466 #endif |
| 2467 | 2467 |
| 2468 } // namespace gfx | 2468 } // namespace gfx |
| OLD | NEW |