1 // Copyright 2019 The PDFium Authors 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "testing/xfa_test_environment.h" 6 7 #include "core/fxge/cfx_fontmgr.h" 8 #include "core/fxge/cfx_gemodule.h" 9 #include "core/fxge/systemfontinfo_iface.h" 10 #include "third_party/base/check.h" 11 #include "xfa/fgas/font/cfgas_gemodule.h" 12 13 namespace { 14 15 XFATestEnvironment* g_env = nullptr; 16 17 } // namespace 18 XFATestEnvironment()19XFATestEnvironment::XFATestEnvironment() { 20 DCHECK(!g_env); 21 g_env = this; 22 } 23 ~XFATestEnvironment()24XFATestEnvironment::~XFATestEnvironment() { 25 DCHECK(g_env); 26 g_env = nullptr; 27 } 28 SetUp()29void XFATestEnvironment::SetUp() { 30 CFX_GEModule::Get()->GetFontMgr()->GetBuiltinMapper()->SetSystemFontInfo( 31 CFX_GEModule::Get()->GetPlatform()->CreateDefaultSystemFontInfo()); 32 33 // The font loading that takes place in CFGAS_GEModule::Create() is slow, 34 // but we do it only once per binary execution, not once per test. 35 CFGAS_GEModule::Create(); 36 } 37 TearDown()38void XFATestEnvironment::TearDown() { 39 CFGAS_GEModule::Destroy(); 40 } 41