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

Unified Diff: ui/gfx/render_text_unittest.cc

Issue 2734333005: RenderTextMac: Fix crash when passed an invalid font. (Closed)
Patch Set: Created 3 years, 9 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_mac.mm ('K') | « ui/gfx/render_text_mac.mm ('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 a5656060bebbd45d4076046fc5bf9fbc43b397b9..84daa1492b5ec9760424c402642ec88094b21f33 100644
--- a/ui/gfx/render_text_unittest.cc
+++ b/ui/gfx/render_text_unittest.cc
@@ -4349,6 +4349,22 @@ TEST_P(RenderTextHarfBuzzTest, GetSubstringBoundsMultiline) {
EXPECT_EQ(expected_total_bounds, GetSelectionBoundsUnion());
}
+// Tests that RenderText doesn't crash even if it's passed an invalid font.
+TEST_P(RenderTextTest, InvalidFont) {
+// TODO(crbug.com/) This crashes with RenderTextHarfBuzz on Mac.
+#if defined(OS_MACOSX)
+ if (GetParam() == RENDER_TEXT_HARFBUZZ)
+ return;
+#endif
+ const std::string font_name = "invalid_font";
+ const int kFontSize = 13;
+ RenderText* render_text = GetRenderText();
+ render_text->SetFontList(FontList(Font(font_name, kFontSize)));
+ render_text->SetText(ASCIIToUTF16("hello"));
+
+ DrawVisualText();
+}
+
// Prefix for test instantiations intentionally left blank since each test
// fixture class has a single parameterization.
#if defined(OS_MACOSX)
« ui/gfx/render_text_mac.mm ('K') | « ui/gfx/render_text_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698