blob: 07afb93cb0040c1bb17b7d81602634b056ca4c89 [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
7#include <memory>
8#include <utility>
9
10#include "core/fxge/cfx_fontmgr.h"
11#include "core/fxge/cfx_gemodule.h"
12#include "core/fxge/systemfontinfo_iface.h"
Tom Sepez0aed4272020-09-08 22:48:08 +000013#include "xfa/fgas/font/cfgas_gemodule.h"
Tom Sepez22818532020-07-22 20:40:56 +000014
15namespace {
16
17XFATestEnvironment* g_env = nullptr;
18
19} // namespace
20
21XFATestEnvironment::XFATestEnvironment() {
22 ASSERT(!g_env);
23 g_env = this;
24}
25
26XFATestEnvironment::~XFATestEnvironment() {
27 ASSERT(g_env);
28 g_env = nullptr;
29}
30
31void XFATestEnvironment::SetUp() {
Tom Sepez22818532020-07-22 20:40:56 +000032 CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(
Tom Sepez9873bf32020-08-24 17:16:36 +000033 CFX_GEModule::Get()->GetPlatform()->CreateDefaultSystemFontInfo());
Tom Sepez22818532020-07-22 20:40:56 +000034
Tom Sepez0aed4272020-09-08 22:48:08 +000035 // The font loading that takes place in CFGAS_GEModule::Create() is slow,
36 // but we do it only once per binary execution, not once per test.
37 CFGAS_GEModule::Create();
Tom Sepez22818532020-07-22 20:40:56 +000038}
39
40void XFATestEnvironment::TearDown() {
Tom Sepez0aed4272020-09-08 22:48:08 +000041 CFGAS_GEModule::Destroy();
Tom Sepez22818532020-07-22 20:40:56 +000042}