blob: 5b0a4930a589247a4e4f022763c7c4734acb1bee [file] [log] [blame]
Tom Sepezeaf9d212020-07-22 16:24:00 +00001// Copyright 2020 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
Tom Sepezf5397f02020-07-23 21:22:40 +00005#include "testing/fxgc_unittest.h"
Tom Sepezeaf9d212020-07-22 16:24:00 +00006
7#include "fxjs/gc/heap.h"
8#include "testing/gtest/include/gtest/gtest.h"
9#include "testing/v8_test_environment.h"
Lei Zhangdabb2062021-06-07 18:17:25 +000010#include "v8/include/libplatform/libplatform.h"
Tom Sepezeaf9d212020-07-22 16:24:00 +000011
12FXGCUnitTest::FXGCUnitTest() = default;
13
14FXGCUnitTest::~FXGCUnitTest() = default;
15
16void FXGCUnitTest::SetUp() {
17 FXV8UnitTest::SetUp();
Tom Sepez5b2e5862020-09-23 22:03:45 +000018 auto* env = V8TestEnvironment::GetInstance();
19 FXGC_Initialize(env->platform(), env->isolate());
Tom Sepezeaf9d212020-07-22 16:24:00 +000020 heap_ = FXGC_CreateHeap();
21 ASSERT_TRUE(heap_);
22}
23
24void FXGCUnitTest::TearDown() {
Tom Sepez5b2e5862020-09-23 22:03:45 +000025 FXGC_ForceGarbageCollection(heap_.get());
26 auto* env = V8TestEnvironment::GetInstance();
27 while (v8::platform::PumpMessageLoop(env->platform(), env->isolate()))
28 continue;
29
Tom Sepezeaf9d212020-07-22 16:24:00 +000030 heap_.reset();
31 FXGC_Release();
32 FXV8UnitTest::TearDown();
33}