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

Side by Side Diff: content/child/dwrite_font_proxy/dwrite_font_proxy_win_unittest.cc

Issue 2111373002: Reland of Link to DirectWrite directly, instead of calling LoadLibrary (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h" 5 #include "content/child/dwrite_font_proxy/dwrite_font_proxy_win.h"
6 6
7 #include <dwrite.h> 7 #include <dwrite.h>
8 #include <shlobj.h> 8 #include <shlobj.h>
9 #include <wrl.h> 9 #include <wrl.h>
10 10
11 #include <memory> 11 #include <memory>
12 12
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "content/common/dwrite_font_proxy_messages.h" 14 #include "content/common/dwrite_font_proxy_messages.h"
15 #include "content/common/view_messages.h" 15 #include "content/common/view_messages.h"
16 #include "content/test/dwrite_font_fake_sender_win.h" 16 #include "content/test/dwrite_font_fake_sender_win.h"
17 #include "ipc/ipc_message_macros.h" 17 #include "ipc/ipc_message_macros.h"
18 #include "ipc/ipc_sender.h" 18 #include "ipc/ipc_sender.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 20
21 namespace mswr = Microsoft::WRL; 21 namespace mswr = Microsoft::WRL;
22 22
23 namespace content { 23 namespace content {
24 24
25 namespace { 25 namespace {
26 26
27 void CreateDWriteFactory(IUnknown** factory) {
28 using DWriteCreateFactoryProc = decltype(DWriteCreateFactory)*;
29 HMODULE dwrite_dll = LoadLibraryW(L"dwrite.dll");
30 if (!dwrite_dll)
31 return;
32
33 DWriteCreateFactoryProc dwrite_create_factory_proc =
34 reinterpret_cast<DWriteCreateFactoryProc>(
35 GetProcAddress(dwrite_dll, "DWriteCreateFactory"));
36 if (!dwrite_create_factory_proc)
37 return;
38
39 dwrite_create_factory_proc(DWRITE_FACTORY_TYPE_SHARED,
40 __uuidof(IDWriteFactory), factory);
41 }
42
43 class DWriteFontProxyUnitTest : public testing::Test { 27 class DWriteFontProxyUnitTest : public testing::Test {
44 public: 28 public:
45 DWriteFontProxyUnitTest() { 29 DWriteFontProxyUnitTest() {
46 if (!factory)
47 return;
48 fake_collection_ = new FakeFontCollection(); 30 fake_collection_ = new FakeFontCollection();
49 SetupFonts(fake_collection_.get()); 31 SetupFonts(fake_collection_.get());
50 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( 32 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(
51 &collection_, factory.Get(), fake_collection_->GetTrackingSender()); 33 &collection_, factory.Get(), fake_collection_->GetTrackingSender());
52 } 34 }
53 35
54 ~DWriteFontProxyUnitTest() override { 36 ~DWriteFontProxyUnitTest() override {
55 if (collection_) 37 if (collection_)
56 collection_->Unregister(); 38 collection_->Unregister();
57 } 39 }
58 40
59 static void SetupFonts(FakeFontCollection* fonts) { 41 static void SetupFonts(FakeFontCollection* fonts) {
60 fonts->AddFont(L"Aardvark") 42 fonts->AddFont(L"Aardvark")
61 .AddFamilyName(L"en-us", L"Aardvark") 43 .AddFamilyName(L"en-us", L"Aardvark")
62 .AddFamilyName(L"de-de", L"Erdferkel") 44 .AddFamilyName(L"de-de", L"Erdferkel")
63 .AddFilePath(L"X:\\Nonexistent\\Folder\\Aardvark.ttf"); 45 .AddFilePath(L"X:\\Nonexistent\\Folder\\Aardvark.ttf");
64 FakeFont& arial = 46 FakeFont& arial =
65 fonts->AddFont(L"Arial").AddFamilyName(L"en-us", L"Arial"); 47 fonts->AddFont(L"Arial").AddFamilyName(L"en-us", L"Arial");
66 for (auto& path : arial_font_files) 48 for (auto& path : arial_font_files)
67 arial.AddFilePath(path); 49 arial.AddFilePath(path);
68 fonts->AddFont(L"Times New Roman") 50 fonts->AddFont(L"Times New Roman")
69 .AddFamilyName(L"en-us", L"Times New Roman") 51 .AddFamilyName(L"en-us", L"Times New Roman")
70 .AddFilePath(L"X:\\Nonexistent\\Folder\\Times.ttf"); 52 .AddFilePath(L"X:\\Nonexistent\\Folder\\Times.ttf");
71 } 53 }
72 54
73 static void SetUpTestCase() { 55 static void SetUpTestCase() {
74 CreateDWriteFactory(&factory); 56 DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
57 &factory);
75 58
76 std::vector<base::char16> font_path; 59 std::vector<base::char16> font_path;
77 font_path.resize(MAX_PATH); 60 font_path.resize(MAX_PATH);
78 SHGetSpecialFolderPath(nullptr /* hwndOwner - reserved */, font_path.data(), 61 SHGetSpecialFolderPath(nullptr /* hwndOwner - reserved */, font_path.data(),
79 CSIDL_FONTS, FALSE /* fCreate*/); 62 CSIDL_FONTS, FALSE /* fCreate*/);
80 base::string16 arial; 63 base::string16 arial;
81 arial.append(font_path.data()).append(L"\\arial.ttf"); 64 arial.append(font_path.data()).append(L"\\arial.ttf");
82 base::string16 arialbd; 65 base::string16 arialbd;
83 arialbd.append(font_path.data()).append(L"\\arialbd.ttf"); 66 arialbd.append(font_path.data()).append(L"\\arialbd.ttf");
84 arial_font_files.push_back(arial); 67 arial_font_files.push_back(arial);
85 arial_font_files.push_back(arialbd); 68 arial_font_files.push_back(arialbd);
86 } 69 }
87 70
88 protected: 71 protected:
89 scoped_refptr<FakeFontCollection> fake_collection_; 72 scoped_refptr<FakeFontCollection> fake_collection_;
90 mswr::ComPtr<DWriteFontCollectionProxy> collection_; 73 mswr::ComPtr<DWriteFontCollectionProxy> collection_;
91 74
92 static std::vector<base::string16> arial_font_files; 75 static std::vector<base::string16> arial_font_files;
93 static mswr::ComPtr<IDWriteFactory> factory; 76 static mswr::ComPtr<IDWriteFactory> factory;
94 }; 77 };
95 std::vector<base::string16> DWriteFontProxyUnitTest::arial_font_files; 78 std::vector<base::string16> DWriteFontProxyUnitTest::arial_font_files;
96 mswr::ComPtr<IDWriteFactory> DWriteFontProxyUnitTest::factory; 79 mswr::ComPtr<IDWriteFactory> DWriteFontProxyUnitTest::factory;
97 80
98 TEST_F(DWriteFontProxyUnitTest, GetFontFamilyCount) { 81 TEST_F(DWriteFontProxyUnitTest, GetFontFamilyCount) {
99 if (!factory)
100 return;
101
102 UINT32 family_count = collection_->GetFontFamilyCount(); 82 UINT32 family_count = collection_->GetFontFamilyCount();
103 83
104 EXPECT_EQ(3u, family_count); 84 EXPECT_EQ(3u, family_count);
105 ASSERT_EQ(1u, fake_collection_->MessageCount()); 85 ASSERT_EQ(1u, fake_collection_->MessageCount());
106 EXPECT_EQ(DWriteFontProxyMsg_GetFamilyCount::ID, 86 EXPECT_EQ(DWriteFontProxyMsg_GetFamilyCount::ID,
107 fake_collection_->GetMessage(0)->type()); 87 fake_collection_->GetMessage(0)->type());
108 88
109 // Calling again should not cause another message to be sent. 89 // Calling again should not cause another message to be sent.
110 family_count = collection_->GetFontFamilyCount(); 90 family_count = collection_->GetFontFamilyCount();
111 EXPECT_EQ(3u, family_count); 91 EXPECT_EQ(3u, family_count);
112 ASSERT_EQ(1u, fake_collection_->MessageCount()); 92 ASSERT_EQ(1u, fake_collection_->MessageCount());
113 } 93 }
114 94
115 TEST_F(DWriteFontProxyUnitTest, FindFamilyNameShouldFindFamily) { 95 TEST_F(DWriteFontProxyUnitTest, FindFamilyNameShouldFindFamily) {
116 HRESULT hr; 96 HRESULT hr;
117 if (!factory)
118 return;
119 97
120 UINT32 index = UINT_MAX; 98 UINT32 index = UINT_MAX;
121 BOOL exists = FALSE; 99 BOOL exists = FALSE;
122 hr = collection_->FindFamilyName(L"Arial", &index, &exists); 100 hr = collection_->FindFamilyName(L"Arial", &index, &exists);
123 101
124 EXPECT_EQ(S_OK, hr); 102 EXPECT_EQ(S_OK, hr);
125 EXPECT_EQ(1u, index); 103 EXPECT_EQ(1u, index);
126 EXPECT_TRUE(exists); 104 EXPECT_TRUE(exists);
127 ASSERT_EQ(2u, fake_collection_->MessageCount()); 105 ASSERT_EQ(2u, fake_collection_->MessageCount());
128 EXPECT_EQ(DWriteFontProxyMsg_FindFamily::ID, 106 EXPECT_EQ(DWriteFontProxyMsg_FindFamily::ID,
129 fake_collection_->GetMessage(0)->type()); 107 fake_collection_->GetMessage(0)->type());
130 EXPECT_EQ(DWriteFontProxyMsg_GetFamilyCount::ID, 108 EXPECT_EQ(DWriteFontProxyMsg_GetFamilyCount::ID,
131 fake_collection_->GetMessage(1)->type()); 109 fake_collection_->GetMessage(1)->type());
132 } 110 }
133 111
134 TEST_F(DWriteFontProxyUnitTest, FindFamilyNameShouldReturnUINTMAXWhenNotFound) { 112 TEST_F(DWriteFontProxyUnitTest, FindFamilyNameShouldReturnUINTMAXWhenNotFound) {
135 HRESULT hr; 113 HRESULT hr;
136 if (!factory)
137 return;
138 114
139 UINT32 index = UINT_MAX; 115 UINT32 index = UINT_MAX;
140 BOOL exists = FALSE; 116 BOOL exists = FALSE;
141 hr = collection_->FindFamilyName(L"Not a font", &index, &exists); 117 hr = collection_->FindFamilyName(L"Not a font", &index, &exists);
142 118
143 EXPECT_EQ(S_OK, hr); 119 EXPECT_EQ(S_OK, hr);
144 EXPECT_EQ(UINT32_MAX, index); 120 EXPECT_EQ(UINT32_MAX, index);
145 EXPECT_FALSE(exists); 121 EXPECT_FALSE(exists);
146 ASSERT_EQ(1u, fake_collection_->MessageCount()); 122 ASSERT_EQ(1u, fake_collection_->MessageCount());
147 EXPECT_EQ(DWriteFontProxyMsg_FindFamily::ID, 123 EXPECT_EQ(DWriteFontProxyMsg_FindFamily::ID,
148 fake_collection_->GetMessage(0)->type()); 124 fake_collection_->GetMessage(0)->type());
149 } 125 }
150 126
151 TEST_F(DWriteFontProxyUnitTest, FindFamilyNameShouldNotSendDuplicateIPC) { 127 TEST_F(DWriteFontProxyUnitTest, FindFamilyNameShouldNotSendDuplicateIPC) {
152 HRESULT hr; 128 HRESULT hr;
153 if (!factory)
154 return;
155 129
156 UINT32 index = UINT_MAX; 130 UINT32 index = UINT_MAX;
157 BOOL exists = FALSE; 131 BOOL exists = FALSE;
158 hr = collection_->FindFamilyName(L"Arial", &index, &exists); 132 hr = collection_->FindFamilyName(L"Arial", &index, &exists);
159 ASSERT_EQ(S_OK, hr); 133 ASSERT_EQ(S_OK, hr);
160 ASSERT_EQ(2u, fake_collection_->MessageCount()); 134 ASSERT_EQ(2u, fake_collection_->MessageCount());
161 135
162 hr = collection_->FindFamilyName(L"Arial", &index, &exists); 136 hr = collection_->FindFamilyName(L"Arial", &index, &exists);
163 137
164 EXPECT_EQ(S_OK, hr); 138 EXPECT_EQ(S_OK, hr);
165 EXPECT_EQ(2u, fake_collection_->MessageCount()); 139 EXPECT_EQ(2u, fake_collection_->MessageCount());
166 } 140 }
167 141
168 TEST_F(DWriteFontProxyUnitTest, GetFontFamilyShouldCreateFamily) { 142 TEST_F(DWriteFontProxyUnitTest, GetFontFamilyShouldCreateFamily) {
169 HRESULT hr; 143 HRESULT hr;
170 if (!factory)
171 return;
172 144
173 UINT32 index = UINT_MAX; 145 UINT32 index = UINT_MAX;
174 BOOL exists = FALSE; 146 BOOL exists = FALSE;
175 hr = collection_->FindFamilyName(L"Arial", &index, &exists); 147 hr = collection_->FindFamilyName(L"Arial", &index, &exists);
176 ASSERT_EQ(2u, fake_collection_->MessageCount()); 148 ASSERT_EQ(2u, fake_collection_->MessageCount());
177 149
178 mswr::ComPtr<IDWriteFontFamily> family; 150 mswr::ComPtr<IDWriteFontFamily> family;
179 hr = collection_->GetFontFamily(2, &family); 151 hr = collection_->GetFontFamily(2, &family);
180 152
181 EXPECT_EQ(S_OK, hr); 153 EXPECT_EQ(S_OK, hr);
(...skipping 25 matching lines...) Expand all
207 base::string16 actual_value; 179 base::string16 actual_value;
208 string_length++; 180 string_length++;
209 actual_value.resize(string_length); 181 actual_value.resize(string_length);
210 strings->GetString(locale_index, const_cast<WCHAR*>(actual_value.data()), 182 strings->GetString(locale_index, const_cast<WCHAR*>(actual_value.data()),
211 string_length); 183 string_length);
212 EXPECT_STREQ(expected_value.c_str(), actual_value.c_str()); 184 EXPECT_STREQ(expected_value.c_str(), actual_value.c_str());
213 } 185 }
214 186
215 TEST_F(DWriteFontProxyUnitTest, GetFamilyNames) { 187 TEST_F(DWriteFontProxyUnitTest, GetFamilyNames) {
216 HRESULT hr; 188 HRESULT hr;
217 if (!factory)
218 return;
219 189
220 UINT32 index = UINT_MAX; 190 UINT32 index = UINT_MAX;
221 BOOL exists = FALSE; 191 BOOL exists = FALSE;
222 hr = collection_->FindFamilyName(L"Aardvark", &index, &exists); 192 hr = collection_->FindFamilyName(L"Aardvark", &index, &exists);
223 ASSERT_EQ(2u, fake_collection_->MessageCount()); 193 ASSERT_EQ(2u, fake_collection_->MessageCount());
224 194
225 mswr::ComPtr<IDWriteFontFamily> family; 195 mswr::ComPtr<IDWriteFontFamily> family;
226 hr = collection_->GetFontFamily(index, &family); 196 hr = collection_->GetFontFamily(index, &family);
227 EXPECT_EQ(S_OK, hr); 197 EXPECT_EQ(S_OK, hr);
228 EXPECT_EQ(2u, fake_collection_->MessageCount()); 198 EXPECT_EQ(2u, fake_collection_->MessageCount());
(...skipping 17 matching lines...) Expand all
246 216
247 base::string16 unused; 217 base::string16 unused;
248 unused.resize(25); 218 unused.resize(25);
249 hr = names->GetLocaleName(15234, const_cast<WCHAR*>(unused.data()), 219 hr = names->GetLocaleName(15234, const_cast<WCHAR*>(unused.data()),
250 unused.size() - 1); 220 unused.size() - 1);
251 EXPECT_FALSE(SUCCEEDED(hr)); 221 EXPECT_FALSE(SUCCEEDED(hr));
252 } 222 }
253 223
254 TEST_F(DWriteFontProxyUnitTest, GetFontCollection) { 224 TEST_F(DWriteFontProxyUnitTest, GetFontCollection) {
255 HRESULT hr; 225 HRESULT hr;
256 if (!factory)
257 return;
258 226
259 UINT32 index = UINT_MAX; 227 UINT32 index = UINT_MAX;
260 BOOL exists = FALSE; 228 BOOL exists = FALSE;
261 hr = collection_->FindFamilyName(L"Arial", &index, &exists); 229 hr = collection_->FindFamilyName(L"Arial", &index, &exists);
262 ASSERT_EQ(2u, fake_collection_->MessageCount()); 230 ASSERT_EQ(2u, fake_collection_->MessageCount());
263 231
264 mswr::ComPtr<IDWriteFontFamily> family; 232 mswr::ComPtr<IDWriteFontFamily> family;
265 hr = collection_->GetFontFamily(2, &family); 233 hr = collection_->GetFontFamily(2, &family);
266 EXPECT_EQ(S_OK, hr); 234 EXPECT_EQ(S_OK, hr);
267 EXPECT_EQ(2u, fake_collection_->MessageCount()); 235 EXPECT_EQ(2u, fake_collection_->MessageCount());
268 236
269 mswr::ComPtr<IDWriteFontCollection> returned_collection; 237 mswr::ComPtr<IDWriteFontCollection> returned_collection;
270 hr = family->GetFontCollection(&returned_collection); 238 hr = family->GetFontCollection(&returned_collection);
271 EXPECT_EQ(S_OK, hr); 239 EXPECT_EQ(S_OK, hr);
272 EXPECT_EQ(2u, fake_collection_->MessageCount()); 240 EXPECT_EQ(2u, fake_collection_->MessageCount());
273 EXPECT_EQ(collection_.Get(), returned_collection.Get()); 241 EXPECT_EQ(collection_.Get(), returned_collection.Get());
274 } 242 }
275 243
276 TEST_F(DWriteFontProxyUnitTest, GetFamilyNamesShouldNotIPCAfterLoadingFamily) { 244 TEST_F(DWriteFontProxyUnitTest, GetFamilyNamesShouldNotIPCAfterLoadingFamily) {
277 HRESULT hr; 245 HRESULT hr;
278 if (!factory)
279 return;
280 246
281 UINT32 index = UINT_MAX; 247 UINT32 index = UINT_MAX;
282 BOOL exists = FALSE; 248 BOOL exists = FALSE;
283 collection_->FindFamilyName(L"Arial", &index, &exists); 249 collection_->FindFamilyName(L"Arial", &index, &exists);
284 mswr::ComPtr<IDWriteFontFamily> family; 250 mswr::ComPtr<IDWriteFontFamily> family;
285 collection_->GetFontFamily(index, &family); 251 collection_->GetFontFamily(index, &family);
286 family->GetFontCount(); 252 family->GetFontCount();
287 EXPECT_EQ(3u, fake_collection_->MessageCount()); 253 EXPECT_EQ(3u, fake_collection_->MessageCount());
288 254
289 mswr::ComPtr<IDWriteLocalizedStrings> names; 255 mswr::ComPtr<IDWriteLocalizedStrings> names;
290 hr = family->GetFamilyNames(&names); 256 hr = family->GetFamilyNames(&names);
291 EXPECT_EQ(S_OK, hr); 257 EXPECT_EQ(S_OK, hr);
292 EXPECT_EQ(3u, fake_collection_->MessageCount()); 258 EXPECT_EQ(3u, fake_collection_->MessageCount());
293 } 259 }
294 260
295 TEST_F(DWriteFontProxyUnitTest, 261 TEST_F(DWriteFontProxyUnitTest,
296 GetFontFamilyShouldNotCreateFamilyWhenIndexIsInvalid) { 262 GetFontFamilyShouldNotCreateFamilyWhenIndexIsInvalid) {
297 HRESULT hr; 263 HRESULT hr;
298 if (!factory)
299 return;
300 264
301 UINT32 index = UINT_MAX; 265 UINT32 index = UINT_MAX;
302 BOOL exists = FALSE; 266 BOOL exists = FALSE;
303 hr = collection_->FindFamilyName(L"Arial", &index, &exists); 267 hr = collection_->FindFamilyName(L"Arial", &index, &exists);
304 ASSERT_EQ(2u, fake_collection_->MessageCount()); 268 ASSERT_EQ(2u, fake_collection_->MessageCount());
305 269
306 mswr::ComPtr<IDWriteFontFamily> family; 270 mswr::ComPtr<IDWriteFontFamily> family;
307 hr = collection_->GetFontFamily(1654, &family); 271 hr = collection_->GetFontFamily(1654, &family);
308 272
309 EXPECT_FALSE(SUCCEEDED(hr)); 273 EXPECT_FALSE(SUCCEEDED(hr));
310 EXPECT_EQ(2u, fake_collection_->MessageCount()); 274 EXPECT_EQ(2u, fake_collection_->MessageCount());
311 } 275 }
312 276
313 TEST_F(DWriteFontProxyUnitTest, LoadingFontFamily) { 277 TEST_F(DWriteFontProxyUnitTest, LoadingFontFamily) {
314 HRESULT hr; 278 HRESULT hr;
315 if (!factory)
316 return;
317 279
318 UINT32 index = UINT_MAX; 280 UINT32 index = UINT_MAX;
319 BOOL exists = FALSE; 281 BOOL exists = FALSE;
320 collection_->FindFamilyName(L"Arial", &index, &exists); 282 collection_->FindFamilyName(L"Arial", &index, &exists);
321 mswr::ComPtr<IDWriteFontFamily> family; 283 mswr::ComPtr<IDWriteFontFamily> family;
322 collection_->GetFontFamily(index, &family); 284 collection_->GetFontFamily(index, &family);
323 ASSERT_EQ(2u, fake_collection_->MessageCount()); 285 ASSERT_EQ(2u, fake_collection_->MessageCount());
324 286
325 UINT32 font_count = family->GetFontCount(); 287 UINT32 font_count = family->GetFontCount();
326 EXPECT_LT(0u, font_count); 288 EXPECT_LT(0u, font_count);
(...skipping 14 matching lines...) Expand all
341 hr = family->GetMatchingFonts(DWRITE_FONT_WEIGHT_NORMAL, 303 hr = family->GetMatchingFonts(DWRITE_FONT_WEIGHT_NORMAL,
342 DWRITE_FONT_STRETCH_NORMAL, 304 DWRITE_FONT_STRETCH_NORMAL,
343 DWRITE_FONT_STYLE_NORMAL, &matching_fonts); 305 DWRITE_FONT_STYLE_NORMAL, &matching_fonts);
344 EXPECT_EQ(S_OK, hr); 306 EXPECT_EQ(S_OK, hr);
345 EXPECT_EQ(3u, fake_collection_->MessageCount()); 307 EXPECT_EQ(3u, fake_collection_->MessageCount());
346 EXPECT_NE(nullptr, matching_fonts.Get()); 308 EXPECT_NE(nullptr, matching_fonts.Get());
347 } 309 }
348 310
349 TEST_F(DWriteFontProxyUnitTest, GetFontFromFontFaceShouldFindFont) { 311 TEST_F(DWriteFontProxyUnitTest, GetFontFromFontFaceShouldFindFont) {
350 HRESULT hr; 312 HRESULT hr;
351 if (!factory)
352 return;
353 313
354 UINT32 index = UINT_MAX; 314 UINT32 index = UINT_MAX;
355 BOOL exists = FALSE; 315 BOOL exists = FALSE;
356 collection_->FindFamilyName(L"Arial", &index, &exists); 316 collection_->FindFamilyName(L"Arial", &index, &exists);
357 mswr::ComPtr<IDWriteFontFamily> family; 317 mswr::ComPtr<IDWriteFontFamily> family;
358 collection_->GetFontFamily(index, &family); 318 collection_->GetFontFamily(index, &family);
359 319
360 mswr::ComPtr<IDWriteFont> font; 320 mswr::ComPtr<IDWriteFont> font;
361 family->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL, 321 family->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL,
362 DWRITE_FONT_STRETCH_NORMAL, 322 DWRITE_FONT_STRETCH_NORMAL,
363 DWRITE_FONT_STYLE_NORMAL, &font); 323 DWRITE_FONT_STYLE_NORMAL, &font);
364 324
365 mswr::ComPtr<IDWriteFontFace> font_face; 325 mswr::ComPtr<IDWriteFontFace> font_face;
366 hr = font->CreateFontFace(&font_face); 326 hr = font->CreateFontFace(&font_face);
367 ASSERT_TRUE(SUCCEEDED(hr)); 327 ASSERT_TRUE(SUCCEEDED(hr));
368 ASSERT_EQ(3u, fake_collection_->MessageCount()); 328 ASSERT_EQ(3u, fake_collection_->MessageCount());
369 329
370 mswr::ComPtr<IDWriteFont> found_font; 330 mswr::ComPtr<IDWriteFont> found_font;
371 collection_->GetFontFromFontFace(font_face.Get(), &found_font); 331 collection_->GetFontFromFontFace(font_face.Get(), &found_font);
372 EXPECT_NE(nullptr, found_font.Get()); 332 EXPECT_NE(nullptr, found_font.Get());
373 EXPECT_EQ(3u, fake_collection_->MessageCount()); 333 EXPECT_EQ(3u, fake_collection_->MessageCount());
374 } 334 }
375 335
376 } // namespace 336 } // namespace
377 337
378 } // namespace content 338 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698