blob: 7799bb16e3e9e5d0b7232e977e9e13347b4ff5e4 [file] [log] [blame]
Tom Sepez22818532020-07-22 20:40:56 +00001// Copyright 2019 PDFium Authors. All rights reserved.
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
Tom Sepez22818532020-07-22 20:40:56 +00007#include "core/fxge/cfx_fontmgr.h"
8#include "core/fxge/cfx_gemodule.h"
9#include "core/fxge/systemfontinfo_iface.h"
Tom Sepez0aed4272020-09-08 22:48:08 +000010#include "xfa/fgas/font/cfgas_gemodule.h"
Tom Sepez22818532020-07-22 20:40:56 +000011
12namespace {
13
14XFATestEnvironment* g_env = nullptr;
15
16} // namespace
17
18XFATestEnvironment::XFATestEnvironment() {
19 ASSERT(!g_env);
20 g_env = this;
21}
22
23XFATestEnvironment::~XFATestEnvironment() {
24 ASSERT(g_env);
25 g_env = nullptr;
26}
27
28void XFATestEnvironment::SetUp() {
Tom Sepez22818532020-07-22 20:40:56 +000029 CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(
Tom Sepez9873bf32020-08-24 17:16:36 +000030 CFX_GEModule::Get()->GetPlatform()->CreateDefaultSystemFontInfo());
Tom Sepez22818532020-07-22 20:40:56 +000031
Tom Sepez0aed4272020-09-08 22:48:08 +000032 // The font loading that takes place in CFGAS_GEModule::Create() is slow,
33 // but we do it only once per binary execution, not once per test.
34 CFGAS_GEModule::Create();
Tom Sepez22818532020-07-22 20:40:56 +000035}
36
37void XFATestEnvironment::TearDown() {
Tom Sepez0aed4272020-09-08 22:48:08 +000038 CFGAS_GEModule::Destroy();
Tom Sepez22818532020-07-22 20:40:56 +000039}