Index: ui/gfx/render_text_unittest.cc |
diff --git a/ui/gfx/render_text_unittest.cc b/ui/gfx/render_text_unittest.cc |
index 542939ea3081369af9a50fdf080f3490eaa7d3d8..477596420f5d162e1fd1a576fec2064319257258 100644 |
--- a/ui/gfx/render_text_unittest.cc |
+++ b/ui/gfx/render_text_unittest.cc |
@@ -19,6 +19,7 @@ |
#include "ui/gfx/canvas.h" |
#include "ui/gfx/color_utils.h" |
#include "ui/gfx/font.h" |
+#include "ui/gfx/font_fallback.h" |
#include "ui/gfx/range/range.h" |
#include "ui/gfx/range/range_f.h" |
#include "ui/gfx/render_text_harfbuzz.h" |
@@ -2569,6 +2570,36 @@ TEST_F(RenderTextTest, HarfBuzz_UniscribeFallback) { |
} |
#endif // defined(OS_WIN) |
+// Ensure that the fallback fonts offered by gfx::GetFallbackFontFamilies() are |
+// tried. Note this test assumes the font "Arial" doesn't provide a unicode |
+// glyph for a particular character, and that there exists a system fallback |
+// font which does. |
+#if defined(OS_WIN) || defined(OS_MACOSX) |
+TEST_F(RenderTextTest, HarfBuzz_UnicodeFallback) { |
+ RenderTextHarfBuzz render_text; |
+ render_text.SetFontList(FontList("Arial, 12px")); |
+ |
+ // Korean character "han". |
+ render_text.SetText(WideToUTF16(L"\xd55c")); |
+ render_text.EnsureLayout(); |
+ internal::TextRunList* run_list = render_text.GetRunList(); |
+ ASSERT_EQ(1U, run_list->size()); |
+ EXPECT_EQ(0U, run_list->runs()[0]->CountMissingGlyphs()); |
+} |
+#endif // defined(OS_WIN) || defined(OS_MACOSX) |
+ |
+// A targeted test for GetFallbackFontFamilies on Mac. It uses a system API that |
+// only became publicly available in the 10.8 SDK. This test is to ensure it |
+// behaves sensibly on all supported OS versions. |
+#if defined(OS_MACOSX) |
+TEST_F(RenderTextTest, HarfBuzz_GetFallbackFontFamilies) { |
+ std::vector<std::string> fallback_families = GetFallbackFontFamilies("Arial"); |
Alexei Svitkine (slow)
2015/03/04 16:23:02
Sounds like this should be in font_fallback_mac_un
tapted
2015/03/04 23:44:35
Done.
|
+ // If there is only one fallback, it means the only fallback is the font |
+ // itself. |
+ EXPECT_LT(1u, fallback_families.size()); |
+} |
+#endif // defined(OS_MACOSX) |
+ |
// Ensure that the width reported by RenderText is sufficient for drawing. Draws |
// to a canvas and checks whether any pixel beyond the width is colored. |
TEST_F(RenderTextTest, TextDoesntClip) { |