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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 435583003: RenderTextHarfBuzz: Check CreateSkiaTypeface return value against NULL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nits Created 6 years, 5 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
« no previous file with comments | « 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 c2b8975ec76b95237fc67c6ed201369297acd3be..751942ea78ea4e12b84bcbceaf4756f6d2b12faf 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -2262,4 +2262,33 @@ TEST_F(RenderTextTest, HarfBuzz_GlyphBounds) {
}
}
+// Ensure that shaping with a non-existent font does not cause a crash.
+TEST_F(RenderTextTest, HarfBuzz_NonExistentFont) {
+ RenderTextHarfBuzz render_text;
+ render_text.SetText(ASCIIToUTF16("test"));
+ render_text.EnsureLayout();
+ ASSERT_EQ(1U, render_text.runs_.size());
+ internal::TextRunHarfBuzz* run = render_text.runs_[0];
+ render_text.ShapeRunWithFont(run, "TheFontThatDoesntExist");
+}
+
+// Ensure an empty run returns sane values to queries.
+TEST_F(RenderTextTest, HarfBuzz_EmptyRun) {
+ internal::TextRunHarfBuzz run;
+ const base::string16 kString = ASCIIToUTF16("abcdefgh");
+ scoped_ptr<base::i18n::BreakIterator> iter(new base::i18n::BreakIterator(
+ kString, base::i18n::BreakIterator::BREAK_CHARACTER));
+ ASSERT_TRUE(iter->Init());
+
+ 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));
+ Range chars;
+ Range glyphs;
+ run.GetClusterAt(4, &chars, &glyphs);
+ EXPECT_EQ(Range(3, 8), chars);
+ EXPECT_EQ(Range(0, 0), glyphs);
+}
+
} // namespace gfx
« no previous file with comments | « ui/gfx/render_text_harfbuzz.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698