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

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

Issue 2182213004: Use ChildThreadImpl::thread_safe_sender in font proxy if available (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unittests Created 4 years, 4 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
(...skipping 30 matching lines...) Expand all
41 } 41 }
42 42
43 class DWriteFontProxyUnitTest : public testing::Test { 43 class DWriteFontProxyUnitTest : public testing::Test {
44 public: 44 public:
45 DWriteFontProxyUnitTest() { 45 DWriteFontProxyUnitTest() {
46 if (!factory) 46 if (!factory)
47 return; 47 return;
48 fake_collection_ = new FakeFontCollection(); 48 fake_collection_ = new FakeFontCollection();
49 SetupFonts(fake_collection_.get()); 49 SetupFonts(fake_collection_.get());
50 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( 50 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(
51 &collection_, factory.Get(), fake_collection_->GetTrackingSender()); 51 &collection_, factory.Get(),
52 base::Bind(&FakeFontCollection::GetTrackingSender, fake_collection_));
52 } 53 }
53 54
54 ~DWriteFontProxyUnitTest() override { 55 ~DWriteFontProxyUnitTest() override {
55 if (collection_) 56 if (collection_)
56 collection_->Unregister(); 57 collection_->Unregister();
57 } 58 }
58 59
59 static void SetupFonts(FakeFontCollection* fonts) { 60 static void SetupFonts(FakeFontCollection* fonts) {
60 fonts->AddFont(L"Aardvark") 61 fonts->AddFont(L"Aardvark")
61 .AddFamilyName(L"en-us", L"Aardvark") 62 .AddFamilyName(L"en-us", L"Aardvark")
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 scoped_refptr<FakeFontCollection> fonts = new FakeFontCollection(); 378 scoped_refptr<FakeFontCollection> fonts = new FakeFontCollection();
378 FakeFont& arial = fonts->AddFont(L"Arial").AddFamilyName(L"en-us", L"Arial"); 379 FakeFont& arial = fonts->AddFont(L"Arial").AddFamilyName(L"en-us", L"Arial");
379 for (auto& path : arial_font_files) { 380 for (auto& path : arial_font_files) {
380 base::File file(base::FilePath(path), base::File::FLAG_OPEN | 381 base::File file(base::FilePath(path), base::File::FLAG_OPEN |
381 base::File::FLAG_READ | 382 base::File::FLAG_READ |
382 base::File::FLAG_EXCLUSIVE_WRITE); 383 base::File::FLAG_EXCLUSIVE_WRITE);
383 arial.AddFileHandle(IPC::TakePlatformFileForTransit(std::move(file))); 384 arial.AddFileHandle(IPC::TakePlatformFileForTransit(std::move(file)));
384 } 385 }
385 mswr::ComPtr<DWriteFontCollectionProxy> collection; 386 mswr::ComPtr<DWriteFontCollectionProxy> collection;
386 mswr::MakeAndInitialize<DWriteFontCollectionProxy>( 387 mswr::MakeAndInitialize<DWriteFontCollectionProxy>(
387 &collection, factory.Get(), fonts->GetTrackingSender()); 388 &collection, factory.Get(),
389 base::Bind(&FakeFontCollection::GetTrackingSender, fonts));
388 390
389 // Check that we can get the font family and match a font. 391 // Check that we can get the font family and match a font.
390 UINT32 index = UINT_MAX; 392 UINT32 index = UINT_MAX;
391 BOOL exists = FALSE; 393 BOOL exists = FALSE;
392 collection->FindFamilyName(L"Arial", &index, &exists); 394 collection->FindFamilyName(L"Arial", &index, &exists);
393 mswr::ComPtr<IDWriteFontFamily> family; 395 mswr::ComPtr<IDWriteFontFamily> family;
394 collection->GetFontFamily(index, &family); 396 collection->GetFontFamily(index, &family);
395 397
396 mswr::ComPtr<IDWriteFont> font; 398 mswr::ComPtr<IDWriteFont> font;
397 HRESULT hr = family->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL, 399 HRESULT hr = family->GetFirstMatchingFont(DWRITE_FONT_WEIGHT_NORMAL,
398 DWRITE_FONT_STRETCH_NORMAL, 400 DWRITE_FONT_STRETCH_NORMAL,
399 DWRITE_FONT_STYLE_NORMAL, &font); 401 DWRITE_FONT_STYLE_NORMAL, &font);
400 402
401 EXPECT_TRUE(SUCCEEDED(hr)); 403 EXPECT_TRUE(SUCCEEDED(hr));
402 EXPECT_NE(nullptr, font.Get()); 404 EXPECT_NE(nullptr, font.Get());
403 405
404 mswr::ComPtr<IDWriteFontFace> font_face; 406 mswr::ComPtr<IDWriteFontFace> font_face;
405 hr = font->CreateFontFace(&font_face); 407 hr = font->CreateFontFace(&font_face);
406 EXPECT_TRUE(SUCCEEDED(hr)); 408 EXPECT_TRUE(SUCCEEDED(hr));
407 } 409 }
408 410
409 } // namespace 411 } // namespace
410 412
411 } // namespace content 413 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698