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

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

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

Powered by Google App Engine
This is Rietveld 408576698