Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 2379033004: Optimize some code in RenderTextHarfbuzz. (Closed)
Patch Set: . Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« ui/gfx/render_text_harfbuzz.cc ('K') | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/render_text_unittest.cc
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc
index e2b37c105430797eb0f3a97556643534f06f8bf3..724d9b453d875b4249455c3405c1b8b4369df1e0 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -423,10 +423,6 @@ class RenderTextHarfBuzzTest : public RenderTextTest {
return GetRenderTextHarfBuzz()->ShapeRunWithFont(text, font, params, run);
}
- base::i18n::BreakIterator* GetGraphemeIterator() {
- return GetRenderTextHarfBuzz()->GetGraphemeIterator();
- }
-
private:
DISALLOW_COPY_AND_ASSIGN(RenderTextHarfBuzzTest);
};
@@ -3218,10 +3214,9 @@ TEST_P(RenderTextHarfBuzzTest, HarfBuzz_SubglyphGraphemeCases) {
ASSERT_EQ(1U, run_list->size());
internal::TextRunHarfBuzz* run = run_list->runs()[0];
- base::i18n::BreakIterator* iter = GetGraphemeIterator();
- auto first_grapheme_bounds = run->GetGraphemeBounds(iter, 0);
- EXPECT_EQ(first_grapheme_bounds, run->GetGraphemeBounds(iter, 1));
- auto second_grapheme_bounds = run->GetGraphemeBounds(iter, 2);
+ auto first_grapheme_bounds = run->GetGraphemeBounds(render_text, 0);
+ EXPECT_EQ(first_grapheme_bounds, run->GetGraphemeBounds(render_text, 1));
+ auto second_grapheme_bounds = run->GetGraphemeBounds(render_text, 2);
EXPECT_EQ(first_grapheme_bounds.end(), second_grapheme_bounds.start());
}
}
@@ -3262,10 +3257,9 @@ TEST_P(RenderTextHarfBuzzTest, HarfBuzz_SubglyphGraphemePartition) {
run.positions.reset(new SkPoint[4]);
run.width = 20;
+ RenderTextHarfBuzz* render_text = GetRenderTextHarfBuzz();
const base::string16 kString = ASCIIToUTF16("abcd");
msw 2016/09/30 19:10:17 optional nit: inline |render_text->SetText(ASCIITo
Alexei Svitkine (slow) 2016/09/30 19:14:16 Done.
- std::unique_ptr<base::i18n::BreakIterator> iter(new base::i18n::BreakIterator(
- kString, base::i18n::BreakIterator::BREAK_CHARACTER));
- ASSERT_TRUE(iter->Init());
+ render_text->SetText(kString);
for (size_t i = 0; i < arraysize(cases); ++i) {
std::copy(cases[i].glyph_to_char, cases[i].glyph_to_char + 2,
@@ -3277,7 +3271,7 @@ TEST_P(RenderTextHarfBuzzTest, HarfBuzz_SubglyphGraphemePartition) {
for (size_t j = 0; j < 4; ++j) {
SCOPED_TRACE(base::StringPrintf("Case %" PRIuS ", char %" PRIuS, i, j));
EXPECT_EQ(cases[i].bounds[j],
- run.GetGraphemeBounds(iter.get(), j).Round());
+ run.GetGraphemeBounds(render_text, j).Round());
}
}
}
@@ -3406,15 +3400,14 @@ TEST_P(RenderTextHarfBuzzTest, HarfBuzz_NonExistentFont) {
// Ensure an empty run returns sane values to queries.
TEST_P(RenderTextHarfBuzzTest, HarfBuzz_EmptyRun) {
internal::TextRunHarfBuzz run((Font()));
+ RenderTextHarfBuzz* render_text = GetRenderTextHarfBuzz();
const base::string16 kString = ASCIIToUTF16("abcdefgh");
msw 2016/09/30 19:10:17 ditto optional nit: inline |render_text->SetText(A
Alexei Svitkine (slow) 2016/09/30 19:14:16 Done.
- std::unique_ptr<base::i18n::BreakIterator> iter(new base::i18n::BreakIterator(
- kString, base::i18n::BreakIterator::BREAK_CHARACTER));
- ASSERT_TRUE(iter->Init());
+ render_text->SetText(kString);
run.range = Range(3, 8);
run.glyph_count = 0;
EXPECT_EQ(Range(0, 0), run.CharRangeToGlyphRange(Range(4, 5)));
- EXPECT_EQ(Range(0, 0), run.GetGraphemeBounds(iter.get(), 4).Round());
+ EXPECT_EQ(Range(0, 0), run.GetGraphemeBounds(render_text, 4).Round());
Range chars;
Range glyphs;
run.GetClusterAt(4, &chars, &glyphs);
« ui/gfx/render_text_harfbuzz.cc ('K') | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698