Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions test/cctest/node_test_fixture.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "node_test_fixture.h"

ArrayBufferUniquePtr NodeTestFixture::allocator{nullptr, nullptr};
uv_loop_t NodeTestFixture::current_loop;
std::unique_ptr<node::NodePlatform> NodeTestFixture::platform;
std::unique_ptr<v8::ArrayBuffer::Allocator> NodeTestFixture::allocator;
std::unique_ptr<v8::TracingController> NodeTestFixture::tracing_controller;
v8::Isolate::CreateParams NodeTestFixture::params;
NodePlatformUniquePtr NodeTestFixture::platform;
TracingControllerUniquePtr NodeTestFixture::tracing_controller;
17 changes: 10 additions & 7 deletions test/cctest/node_test_fixture.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,16 @@ struct Argv {
int nr_args_;
};

using ArrayBufferUniquePtr = std::unique_ptr<node::ArrayBufferAllocator,
decltype(&node::FreeArrayBufferAllocator)>;
using TracingControllerUniquePtr = std::unique_ptr<v8::TracingController>;
using NodePlatformUniquePtr = std::unique_ptr<node::NodePlatform>;

class NodeTestFixture : public ::testing::Test {
protected:
static std::unique_ptr<v8::ArrayBuffer::Allocator> allocator;
static std::unique_ptr<v8::TracingController> tracing_controller;
static std::unique_ptr<node::NodePlatform> platform;
static v8::Isolate::CreateParams params;
static ArrayBufferUniquePtr allocator;
static TracingControllerUniquePtr tracing_controller;
static NodePlatformUniquePtr platform;
static uv_loop_t current_loop;
v8::Isolate* isolate_;

Expand All @@ -68,8 +71,6 @@ class NodeTestFixture : public ::testing::Test {
node::tracing::TraceEventHelper::SetTracingController(
tracing_controller.get());
platform.reset(new node::NodePlatform(4, nullptr));
allocator.reset(v8::ArrayBuffer::Allocator::NewDefaultAllocator());
params.array_buffer_allocator = allocator.get();
CHECK_EQ(0, uv_loop_init(&current_loop));
v8::V8::InitializePlatform(platform.get());
v8::V8::Initialize();
Expand All @@ -85,7 +86,9 @@ class NodeTestFixture : public ::testing::Test {
}

virtual void SetUp() {
isolate_ = v8::Isolate::New(params);
allocator = ArrayBufferUniquePtr(node::CreateArrayBufferAllocator(),
&node::FreeArrayBufferAllocator);
isolate_ = NewIsolate(allocator.get());
CHECK_NE(isolate_, nullptr);
}

Expand Down