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

Side by Side Diff: ui/gfx/font_fallback_mac_unittest.cc

Issue 2927953003: Use CTFontCreateForString for RenderTextHarfbuzz on Mac (Closed)
Patch Set: Fix views::Label tests Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « ui/gfx/font_fallback_mac.mm ('k') | ui/gfx/font_fallback_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/font_fallback.h" 5 #include "ui/gfx/font_fallback.h"
6 6
7 #include "base/strings/utf_string_conversions.h"
7 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
8 #include "ui/gfx/font.h" 9 #include "ui/gfx/font.h"
9 10
10 namespace gfx { 11 namespace gfx {
11 12
12 // A targeted test for GetFallbackFonts on Mac. It uses a system API that 13 // A targeted test for GetFallbackFonts on Mac. It uses a system API that
13 // only became publicly available in the 10.8 SDK. This test is to ensure it 14 // only became publicly available in the 10.8 SDK. This test is to ensure it
14 // behaves sensibly on all supported OS versions. 15 // behaves sensibly on all supported OS versions.
15 GTEST_TEST(FontFallbackMacTest, GetFallbackFonts) { 16 TEST(FontFallbackMacTest, GetFallbackFonts) {
16 Font font("Arial", 12); 17 Font font("Arial", 12);
17 std::vector<Font> fallback_fonts = GetFallbackFonts(font); 18 std::vector<Font> fallback_fonts = GetFallbackFonts(font);
18 // If there is only one fallback, it means the only fallback is the font 19 // If there is only one fallback, it means the only fallback is the font
19 // itself. 20 // itself.
20 EXPECT_LT(1u, fallback_fonts.size()); 21 EXPECT_LT(1u, fallback_fonts.size());
21 } 22 }
22 23
24 // Sanity check GetFallbackFont() behavior on Mac. This test makes assumptions
25 // about font properties and availability on specific macOS versions.
26 TEST(FontFallbackMacTest, GetFallbackFont) {
27 Font arial("Helvetica", 12);
28 const base::string16 ascii = base::ASCIIToUTF16("abc");
29 const base::string16 hebrew = base::WideToUTF16(L"\x5d0\x5d1\x5d2");
30 const base::string16 emoji = base::UTF8ToUTF16("😋");
31
32 gfx::Font fallback;
33 EXPECT_FALSE(GetFallbackFont(arial, ascii.data(), ascii.size(), &fallback));
34 EXPECT_TRUE(GetFallbackFont(arial, hebrew.data(), hebrew.size(), &fallback));
35 EXPECT_EQ("Lucida Grande", fallback.GetFontName());
36 EXPECT_TRUE(GetFallbackFont(arial, emoji.data(), emoji.size(), &fallback));
37 EXPECT_EQ("Apple Color Emoji", fallback.GetFontName());
38 }
39
23 } // namespace gfx 40 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_fallback_mac.mm ('k') | ui/gfx/font_fallback_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698