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

Unified Diff: content/child/dwrite_font_proxy/dwrite_font_proxy_win_unittest.cc

Issue 2153343002: Implement support for loading font files from outside system directory (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test patchset to run try job Created 4 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
Index: content/child/dwrite_font_proxy/dwrite_font_proxy_win_unittest.cc
diff --git a/content/child/dwrite_font_proxy/dwrite_font_proxy_win_unittest.cc b/content/child/dwrite_font_proxy/dwrite_font_proxy_win_unittest.cc
index 88c02eeb003f64e21ef5408df90af2784824c6c6..a226f6ee1b0c30232ddf215e278f3356acb79046 100644
--- a/content/child/dwrite_font_proxy/dwrite_font_proxy_win_unittest.cc
+++ b/content/child/dwrite_font_proxy/dwrite_font_proxy_win_unittest.cc
@@ -373,6 +373,39 @@ TEST_F(DWriteFontProxyUnitTest, GetFontFromFontFaceShouldFindFont) {
EXPECT_EQ(3u, fake_collection_->MessageCount());
}
+TEST_F(DWriteFontProxyUnitTest, TestCustomFontFiles) {
+ scoped_refptr<FakeFontCollection> fonts = new FakeFontCollection();
+ FakeFont& arial = fonts->AddFont(L"Arial").AddFamilyName(L"en-us", L"Arial");
+ for (auto& path : arial_font_files) {
+ base::File file(base::FilePath(path), base::File::FLAG_OPEN |
+ base::File::FLAG_READ |
+ base::File::FLAG_EXCLUSIVE_WRITE);
+ arial.AddFileHandle(PtrToLong(file.TakePlatformFile()));
+ }
+ mswr::ComPtr<DWriteFontCollectionProxy> collection;
+ mswr::MakeAndInitialize<DWriteFontCollectionProxy>(
+ &collection, factory.Get(), fonts->GetTrackingSender());
+
+ // Check that we can get the font family and match a font.
+ UINT32 index = UINT_MAX;
+ BOOL exists = FALSE;
+ collection->FindFamilyName(L"Arial", &index, &exists);
+ mswr::ComPtr<IDWriteFontFamily> family;
+ collection->GetFontFamily(index, &family);
+
+ mswr::ComPtr<IDWriteFont> font;
+ HRESULT hr = family->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL,
+ DWRITE_FONT_STRETCH_NORMAL,
+ DWRITE_FONT_STYLE_NORMAL, &font);
+
+ EXPECT_TRUE(SUCCEEDED(hr));
+ EXPECT_NE(nullptr, font.Get());
+
+ mswr::ComPtr<IDWriteFontFace> font_face;
+ hr = font->CreateFontFace(&font_face);
+ EXPECT_TRUE(SUCCEEDED(hr));
+}
+
} // namespace
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698