Tom Sepez | eaf9d21 | 2020-07-22 16:24:00 +0000 | [diff] [blame] | 1 | // 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 Sepez | f5397f0 | 2020-07-23 21:22:40 +0000 | [diff] [blame] | 5 | #include "testing/fxgc_unittest.h" |
Tom Sepez | eaf9d21 | 2020-07-22 16:24:00 +0000 | [diff] [blame] | 6 | |
| 7 | #include "fxjs/gc/heap.h" |
| 8 | #include "testing/gtest/include/gtest/gtest.h" |
| 9 | #include "testing/v8_test_environment.h" |
| 10 | |
| 11 | FXGCUnitTest::FXGCUnitTest() = default; |
| 12 | |
| 13 | FXGCUnitTest::~FXGCUnitTest() = default; |
| 14 | |
| 15 | void FXGCUnitTest::SetUp() { |
| 16 | FXV8UnitTest::SetUp(); |
Tom Sepez | 5b2e586 | 2020-09-23 22:03:45 +0000 | [diff] [blame] | 17 | auto* env = V8TestEnvironment::GetInstance(); |
| 18 | FXGC_Initialize(env->platform(), env->isolate()); |
Tom Sepez | eaf9d21 | 2020-07-22 16:24:00 +0000 | [diff] [blame] | 19 | heap_ = FXGC_CreateHeap(); |
| 20 | ASSERT_TRUE(heap_); |
| 21 | } |
| 22 | |
| 23 | void FXGCUnitTest::TearDown() { |
Tom Sepez | 5b2e586 | 2020-09-23 22:03:45 +0000 | [diff] [blame] | 24 | FXGC_ForceGarbageCollection(heap_.get()); |
| 25 | auto* env = V8TestEnvironment::GetInstance(); |
| 26 | while (v8::platform::PumpMessageLoop(env->platform(), env->isolate())) |
| 27 | continue; |
| 28 | |
Tom Sepez | eaf9d21 | 2020-07-22 16:24:00 +0000 | [diff] [blame] | 29 | heap_.reset(); |
| 30 | FXGC_Release(); |
| 31 | FXV8UnitTest::TearDown(); |
| 32 | } |