2020-03-27 10:02:58 +00:00
|
|
|
// Copyright 2020 the V8 project authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#include "test/unittests/heap/cppgc/tests.h"
|
|
|
|
|
2020-04-07 21:35:29 +00:00
|
|
|
#include <memory>
|
|
|
|
|
2020-06-10 07:10:20 +00:00
|
|
|
#include "src/heap/cppgc/object-allocator.h"
|
2020-05-26 14:40:57 +00:00
|
|
|
#include "test/unittests/heap/cppgc/test-platform.h"
|
|
|
|
|
2020-03-27 10:02:58 +00:00
|
|
|
namespace cppgc {
|
2020-05-06 22:14:44 +00:00
|
|
|
namespace internal {
|
2020-03-27 10:02:58 +00:00
|
|
|
namespace testing {
|
|
|
|
|
|
|
|
// static
|
2020-05-28 19:04:43 +00:00
|
|
|
std::shared_ptr<TestPlatform> TestWithPlatform::platform_;
|
2020-03-27 10:02:58 +00:00
|
|
|
|
|
|
|
// static
|
|
|
|
void TestWithPlatform::SetUpTestSuite() {
|
2020-05-26 14:40:57 +00:00
|
|
|
platform_ = std::make_unique<TestPlatform>();
|
2020-05-28 19:04:43 +00:00
|
|
|
cppgc::InitializeProcess(platform_->GetPageAllocator());
|
2020-03-27 10:02:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// static
|
|
|
|
void TestWithPlatform::TearDownTestSuite() {
|
2020-05-28 19:04:43 +00:00
|
|
|
cppgc::ShutdownProcess();
|
2020-05-26 14:40:57 +00:00
|
|
|
platform_.reset();
|
2020-03-27 10:02:58 +00:00
|
|
|
}
|
|
|
|
|
2020-06-10 22:28:41 +00:00
|
|
|
TestWithHeap::TestWithHeap()
|
|
|
|
: heap_(Heap::Create(platform_)),
|
|
|
|
allocation_handle_(heap_->GetAllocationHandle()) {}
|
2020-03-27 10:02:58 +00:00
|
|
|
|
2020-06-10 07:10:20 +00:00
|
|
|
void TestWithHeap::ResetLinearAllocationBuffers() {
|
|
|
|
Heap::From(GetHeap())->object_allocator().ResetLinearAllocationBuffers();
|
|
|
|
}
|
|
|
|
|
2020-04-07 21:35:29 +00:00
|
|
|
TestSupportingAllocationOnly::TestSupportingAllocationOnly()
|
2020-06-15 09:37:43 +00:00
|
|
|
: no_gc_scope_(*internal::Heap::From(GetHeap())) {}
|
2020-03-27 10:02:58 +00:00
|
|
|
|
|
|
|
} // namespace testing
|
2020-05-06 22:14:44 +00:00
|
|
|
} // namespace internal
|
2020-03-27 10:02:58 +00:00
|
|
|
} // namespace cppgc
|