blob: b62faebd799a40171813c5aadcff5402c44fc669 [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"
13#include "testing/gtest/include/gtest/gtest.h"
Tom Sepezc99362a2020-09-02 23:49:25 +000014#include "third_party/base/logging.h"
Tom Sepez22818532020-07-22 20:40:56 +000015#include "xfa/fgas/font/cfgas_fontmgr.h"
16
17namespace {
18
19XFATestEnvironment* g_env = nullptr;
20
21} // namespace
22
23XFATestEnvironment::XFATestEnvironment() {
24 ASSERT(!g_env);
25 g_env = this;
26}
27
28XFATestEnvironment::~XFATestEnvironment() {
29 ASSERT(g_env);
30 g_env = nullptr;
31}
32
33void XFATestEnvironment::SetUp() {
Tom Sepez9873bf32020-08-24 17:16:36 +000034 // This font loading is slow, but we do it only once per binary
35 // execution, not once per test.
Tom Sepez22818532020-07-22 20:40:56 +000036 CFX_GEModule::Get()->GetFontMgr()->SetSystemFontInfo(
Tom Sepez9873bf32020-08-24 17:16:36 +000037 CFX_GEModule::Get()->GetPlatform()->CreateDefaultSystemFontInfo());
Tom Sepez22818532020-07-22 20:40:56 +000038
Tom Sepezc99362a2020-09-02 23:49:25 +000039 font_mgr_ = std::make_unique<CFGAS_FontMgr>();
40 CHECK(font_mgr_->EnumFonts());
Tom Sepez22818532020-07-22 20:40:56 +000041}
42
43void XFATestEnvironment::TearDown() {
44 font_mgr_.reset();
45}
46
47// static
48CFGAS_FontMgr* XFATestEnvironment::GetGlobalFontManager() {
49 return g_env->font_mgr_.get();
50}