11cb0ef41Sopenharmony_ci#include "node_test_fixture.h" 21cb0ef41Sopenharmony_ci#include "cppgc/platform.h" 31cb0ef41Sopenharmony_ci 41cb0ef41Sopenharmony_ciArrayBufferUniquePtr NodeZeroIsolateTestFixture::allocator{nullptr, nullptr}; 51cb0ef41Sopenharmony_ciuv_loop_t NodeZeroIsolateTestFixture::current_loop; 61cb0ef41Sopenharmony_ciNodePlatformUniquePtr NodeZeroIsolateTestFixture::platform; 71cb0ef41Sopenharmony_ciTracingAgentUniquePtr NodeZeroIsolateTestFixture::tracing_agent; 81cb0ef41Sopenharmony_cibool NodeZeroIsolateTestFixture::node_initialized = false; 91cb0ef41Sopenharmony_civ8::Isolate* NodeTestFixture::isolate_ = nullptr; 101cb0ef41Sopenharmony_cinode::IsolateData* EnvironmentTestFixture::isolate_data_ = nullptr; 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_civoid NodeTestEnvironment::SetUp() { 131cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::tracing_agent = 141cb0ef41Sopenharmony_ci std::make_unique<node::tracing::Agent>(); 151cb0ef41Sopenharmony_ci node::tracing::TraceEventHelper::SetAgent( 161cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::tracing_agent.get()); 171cb0ef41Sopenharmony_ci node::tracing::TracingController* tracing_controller = 181cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::tracing_agent->GetTracingController(); 191cb0ef41Sopenharmony_ci static constexpr int kV8ThreadPoolSize = 4; 201cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::platform.reset( 211cb0ef41Sopenharmony_ci new node::NodePlatform(kV8ThreadPoolSize, tracing_controller)); 221cb0ef41Sopenharmony_ci v8::V8::InitializePlatform(NodeZeroIsolateTestFixture::platform.get()); 231cb0ef41Sopenharmony_ci#ifdef V8_SANDBOX 241cb0ef41Sopenharmony_ci ASSERT_TRUE(v8::V8::InitializeSandbox()); 251cb0ef41Sopenharmony_ci#endif 261cb0ef41Sopenharmony_ci cppgc::InitializeProcess( 271cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::platform->GetPageAllocator()); 281cb0ef41Sopenharmony_ci v8::V8::Initialize(); 291cb0ef41Sopenharmony_ci} 301cb0ef41Sopenharmony_ci 311cb0ef41Sopenharmony_civoid NodeTestEnvironment::TearDown() { 321cb0ef41Sopenharmony_ci v8::V8::Dispose(); 331cb0ef41Sopenharmony_ci v8::V8::DisposePlatform(); 341cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::platform->Shutdown(); 351cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::platform.reset(nullptr); 361cb0ef41Sopenharmony_ci NodeZeroIsolateTestFixture::tracing_agent.reset(nullptr); 371cb0ef41Sopenharmony_ci} 381cb0ef41Sopenharmony_ci 391cb0ef41Sopenharmony_ci::testing::Environment* const node_env = 401cb0ef41Sopenharmony_ci::testing::AddGlobalTestEnvironment(new NodeTestEnvironment()); 41