1 // Copyright 2020 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/fxgc_unittest.h" 6 7 #include "fxjs/gc/heap.h" 8 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/v8_test_environment.h" 10 #include "v8/include/libplatform/libplatform.h" 11 12 FXGCUnitTest::FXGCUnitTest() = default; 13 14 FXGCUnitTest::~FXGCUnitTest() = default; 15 SetUp()16void FXGCUnitTest::SetUp() { 17 ::testing::Test::SetUp(); 18 auto* env = V8TestEnvironment::GetInstance(); 19 FXGC_Initialize(env->platform(), env->isolate()); 20 heap_ = FXGC_CreateHeap(); 21 ASSERT_TRUE(heap_); 22 } 23 TearDown()24void FXGCUnitTest::TearDown() { 25 ForceGCAndPump(); 26 heap_.reset(); 27 FXGC_Release(); 28 ::testing::Test::TearDown(); 29 } 30 ForceGCAndPump()31void FXGCUnitTest::ForceGCAndPump() { 32 FXGC_ForceGarbageCollection(heap_.get()); 33 Pump(); 34 } 35 Pump()36void FXGCUnitTest::Pump() { 37 V8TestEnvironment::PumpPlatformMessageLoop( 38 V8TestEnvironment::GetInstance()->isolate()); 39 } 40