| OLD | NEW |
| 1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 2015 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "testing/js_embedder_test.h" | 5 #include "testing/js_embedder_test.h" |
| 6 #include "third_party/base/ptr_util.h" |
| 6 | 7 |
| 7 JSEmbedderTest::JSEmbedderTest() | 8 JSEmbedderTest::JSEmbedderTest() |
| 8 : m_pArrayBufferAllocator(new FXJS_ArrayBufferAllocator), | 9 : m_pArrayBufferAllocator(new FXJS_ArrayBufferAllocator), |
| 9 m_pIsolate(nullptr) {} | 10 m_pIsolate(nullptr) {} |
| 10 | 11 |
| 11 JSEmbedderTest::~JSEmbedderTest() {} | 12 JSEmbedderTest::~JSEmbedderTest() {} |
| 12 | 13 |
| 13 void JSEmbedderTest::SetUp() { | 14 void JSEmbedderTest::SetUp() { |
| 14 v8::Isolate::CreateParams params; | 15 v8::Isolate::CreateParams params; |
| 15 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); | 16 params.array_buffer_allocator = m_pArrayBufferAllocator.get(); |
| 16 m_pIsolate = v8::Isolate::New(params); | 17 m_pIsolate = v8::Isolate::New(params); |
| 17 | 18 |
| 18 EmbedderTest::SetExternalIsolate(m_pIsolate); | 19 EmbedderTest::SetExternalIsolate(m_pIsolate); |
| 19 EmbedderTest::SetUp(); | 20 EmbedderTest::SetUp(); |
| 20 | 21 |
| 21 v8::Isolate::Scope isolate_scope(m_pIsolate); | 22 v8::Isolate::Scope isolate_scope(m_pIsolate); |
| 22 v8::HandleScope handle_scope(m_pIsolate); | 23 v8::HandleScope handle_scope(m_pIsolate); |
| 23 FXJS_PerIsolateData::SetUp(m_pIsolate); | 24 FXJS_PerIsolateData::SetUp(m_pIsolate); |
| 24 m_Engine = WrapUnique(new CFXJS_Engine(m_pIsolate)); | 25 m_Engine = pdfium::MakeUnique<CFXJS_Engine>(m_pIsolate); |
| 25 m_Engine->InitializeEngine(); | 26 m_Engine->InitializeEngine(); |
| 26 } | 27 } |
| 27 | 28 |
| 28 void JSEmbedderTest::TearDown() { | 29 void JSEmbedderTest::TearDown() { |
| 29 m_Engine->ReleaseEngine(); | 30 m_Engine->ReleaseEngine(); |
| 30 m_Engine.reset(); | 31 m_Engine.reset(); |
| 31 EmbedderTest::TearDown(); | 32 EmbedderTest::TearDown(); |
| 32 m_pIsolate->Dispose(); | 33 m_pIsolate->Dispose(); |
| 33 m_pIsolate = nullptr; | 34 m_pIsolate = nullptr; |
| 34 } | 35 } |
| 35 | 36 |
| 36 v8::Isolate* JSEmbedderTest::isolate() { | 37 v8::Isolate* JSEmbedderTest::isolate() { |
| 37 return m_pIsolate; | 38 return m_pIsolate; |
| 38 } | 39 } |
| 39 | 40 |
| 40 v8::Local<v8::Context> JSEmbedderTest::GetV8Context() { | 41 v8::Local<v8::Context> JSEmbedderTest::GetV8Context() { |
| 41 return m_Engine->GetPersistentContext(); | 42 return m_Engine->GetPersistentContext(); |
| 42 } | 43 } |
| OLD | NEW |