From 3e5fac8169987afe652752ca5c7b9350ffabce0d Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Mon, 12 Feb 2018 21:49:04 +0000 Subject: Test if GC'd FXJS objects have their C-side counterparts cleaned up. Small correctness fix in other engine embeddertest. Change-Id: I6c2721921a659eef1b2f155ea1797722d37209d0 Reviewed-on: https://pdfium-review.googlesource.com/26270 Reviewed-by: dsinclair Commit-Queue: Tom Sepez --- fxjs/cfx_v8_unittest.cpp | 40 +++++++++++++--------------------------- 1 file changed, 13 insertions(+), 27 deletions(-) (limited to 'fxjs/cfx_v8_unittest.cpp') diff --git a/fxjs/cfx_v8_unittest.cpp b/fxjs/cfx_v8_unittest.cpp index db7da961e8..879d90462d 100644 --- a/fxjs/cfx_v8_unittest.cpp +++ b/fxjs/cfx_v8_unittest.cpp @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "fxjs/cfx_v8.h" +#include "fxjs/cfx_v8_unittest.h" #include @@ -10,37 +10,23 @@ #include "testing/test_support.h" #include "third_party/base/ptr_util.h" -namespace { - -struct V8IsolateDeleter { - inline void operator()(v8::Isolate* ptr) const { ptr->Dispose(); } -}; - -} // namespace - -class FXV8UnitTest : public ::testing::Test { - public: - FXV8UnitTest() = default; - ~FXV8UnitTest() override = default; +void FXV8UnitTest::V8IsolateDeleter::operator()(v8::Isolate* ptr) const { + ptr->Dispose(); +} - void SetUp() override { - array_buffer_allocator_ = pdfium::MakeUnique(); +FXV8UnitTest::FXV8UnitTest() = default; - v8::Isolate::CreateParams params; - params.array_buffer_allocator = array_buffer_allocator_.get(); - isolate_.reset(v8::Isolate::New(params)); +FXV8UnitTest::~FXV8UnitTest() = default; - cfx_v8_ = pdfium::MakeUnique(isolate_.get()); - } +void FXV8UnitTest::SetUp() { + array_buffer_allocator_ = pdfium::MakeUnique(); - v8::Isolate* isolate() const { return isolate_.get(); } - CFX_V8* cfx_v8() const { return cfx_v8_.get(); } + v8::Isolate::CreateParams params; + params.array_buffer_allocator = array_buffer_allocator_.get(); + isolate_.reset(v8::Isolate::New(params)); - protected: - std::unique_ptr array_buffer_allocator_; - std::unique_ptr isolate_; - std::unique_ptr cfx_v8_; -}; + cfx_v8_ = pdfium::MakeUnique(isolate_.get()); +} TEST_F(FXV8UnitTest, EmptyLocal) { v8::Isolate::Scope isolate_scope(isolate()); -- cgit v1.2.3