Convert pdfium::MakeUnique<> to std::make_unique<> in testing
Change-Id: Iab2d2d36bae5e8740119d2dca4cde9b97dd53810
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/69993
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp
index a04e597..650805e 100644
--- a/testing/embedder_test.cpp
+++ b/testing/embedder_test.cpp
@@ -26,7 +26,6 @@
#include "testing/utils/hash.h"
#include "testing/utils/path_service.h"
#include "third_party/base/logging.h"
-#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#ifdef PDF_ENABLE_V8
@@ -55,7 +54,7 @@
} // namespace
EmbedderTest::EmbedderTest()
- : default_delegate_(pdfium::MakeUnique<EmbedderTest::Delegate>()),
+ : default_delegate_(std::make_unique<EmbedderTest::Delegate>()),
delegate_(default_delegate_.get()) {
FPDF_FILEWRITE::version = 1;
FPDF_FILEWRITE::WriteBlock = WriteBlockCallback;
@@ -148,7 +147,7 @@
return false;
EXPECT_TRUE(!loader_);
- loader_ = pdfium::MakeUnique<TestLoader>(
+ loader_ = std::make_unique<TestLoader>(
pdfium::make_span(file_contents_.get(), file_length_));
memset(&file_access_, 0, sizeof(file_access_));
@@ -156,7 +155,7 @@
file_access_.m_GetBlock = TestLoader::GetBlock;
file_access_.m_Param = loader_.get();
- fake_file_access_ = pdfium::MakeUnique<FakeFileAccess>(&file_access_);
+ fake_file_access_ = std::make_unique<FakeFileAccess>(&file_access_);
return OpenDocumentHelper(password, linearize_option, javascript_option,
fake_file_access_.get(), &document_, &avail_,
&form_handle_);
@@ -477,7 +476,7 @@
saved_file_access_.m_Param = &saved_document_file_data_;
saved_fake_file_access_ =
- pdfium::MakeUnique<FakeFileAccess>(&saved_file_access_);
+ std::make_unique<FakeFileAccess>(&saved_file_access_);
EXPECT_TRUE(OpenDocumentHelper(
password, LinearizeOption::kDefaultLinearize,
diff --git a/testing/fake_file_access.cpp b/testing/fake_file_access.cpp
index 723f772..3c236e6 100644
--- a/testing/fake_file_access.cpp
+++ b/testing/fake_file_access.cpp
@@ -10,7 +10,6 @@
#include <vector>
#include "core/fxcrt/fx_system.h"
-#include "third_party/base/ptr_util.h"
namespace {
@@ -76,9 +75,9 @@
FakeFileAccess::FakeFileAccess(FPDF_FILEACCESS* file_access)
: file_access_(file_access),
- file_access_wrapper_(pdfium::MakeUnique<FileAccessWrapper>(this)),
- file_avail_(pdfium::MakeUnique<FileAvailImpl>(this)),
- download_hints_(pdfium::MakeUnique<DownloadHintsImpl>(this)) {
+ file_access_wrapper_(std::make_unique<FileAccessWrapper>(this)),
+ file_avail_(std::make_unique<FileAvailImpl>(this)),
+ download_hints_(std::make_unique<DownloadHintsImpl>(this)) {
ASSERT(file_access_);
}
diff --git a/testing/fuzzers/pdf_bidi_fuzzer.cc b/testing/fuzzers/pdf_bidi_fuzzer.cc
index 614df52..fb6caf6 100644
--- a/testing/fuzzers/pdf_bidi_fuzzer.cc
+++ b/testing/fuzzers/pdf_bidi_fuzzer.cc
@@ -3,20 +3,20 @@
// found in the LICENSE file.
#include <cstdint>
+#include <memory>
#include "core/fxcrt/widestring.h"
#include "core/fxge/cfx_font.h"
#include "core/fxge/fx_font.h"
-#include "third_party/base/ptr_util.h"
#include "xfa/fgas/font/cfgas_fontmgr.h"
#include "xfa/fgas/font/cfgas_gefont.h"
#include "xfa/fgas/layout/cfx_char.h"
#include "xfa/fgas/layout/cfx_rtfbreak.h"
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
- auto fontmgr = pdfium::MakeUnique<CFGAS_FontMgr>();
+ auto fontmgr = std::make_unique<CFGAS_FontMgr>();
- auto font = pdfium::MakeUnique<CFX_Font>();
+ auto font = std::make_unique<CFX_Font>();
font->LoadSubst("Arial", true, 0, FXFONT_FW_NORMAL, 0, 0, 0);
assert(font);
diff --git a/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc b/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc
index b191f76..095af86 100644
--- a/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc
+++ b/testing/fuzzers/pdf_cfgas_stringformatter_fuzzer.cc
@@ -6,8 +6,9 @@
#include <stdint.h>
+#include <memory>
+
#include "core/fxcrt/fx_string.h"
-#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
#include "xfa/fxfa/parser/cxfa_localemgr.h"
@@ -28,7 +29,7 @@
static std::vector<std::unique_ptr<CXFA_LocaleMgr>> mgrs;
if (mgrs.empty()) {
for (const auto* locale : kLocales)
- mgrs.push_back(pdfium::MakeUnique<CXFA_LocaleMgr>(nullptr, locale));
+ mgrs.push_back(std::make_unique<CXFA_LocaleMgr>(nullptr, locale));
}
uint8_t test_selector = data[0] % 10;
@@ -44,7 +45,7 @@
WideString value =
WideString::FromLatin1(ByteStringView(data + pattern_len, value_len));
- auto fmt = pdfium::MakeUnique<CFGAS_StringFormatter>(
+ auto fmt = std::make_unique<CFGAS_StringFormatter>(
mgrs[locale_selector].get(), pattern);
WideString result;
diff --git a/testing/fuzzers/pdf_formcalc_context_fuzzer.cc b/testing/fuzzers/pdf_formcalc_context_fuzzer.cc
index 2ba52d5..eeff9cd 100644
--- a/testing/fuzzers/pdf_formcalc_context_fuzzer.cc
+++ b/testing/fuzzers/pdf_formcalc_context_fuzzer.cc
@@ -4,6 +4,8 @@
#include <stdint.h>
+#include <memory>
+
#include "core/fxcrt/fx_string.h"
#include "fpdfsdk/cpdfsdk_helpers.h"
#include "fpdfsdk/fpdfxfa/cpdfxfa_context.h"
@@ -11,7 +13,6 @@
#include "fxjs/xfa/cfxjse_value.h"
#include "public/fpdf_formfill.h"
#include "testing/fuzzers/pdfium_fuzzer_helper.h"
-#include "third_party/base/ptr_util.h"
#include "v8/include/v8.h"
#include "xfa/fxfa/cxfa_eventparam.h"
@@ -526,7 +527,7 @@
script_context->SetEventParam(¶ms);
ByteStringView data_view(data_, size_);
- auto value = pdfium::MakeUnique<CFXJSE_Value>(script_context->GetIsolate());
+ auto value = std::make_unique<CFXJSE_Value>(script_context->GetIsolate());
script_context->RunScript(CXFA_Script::Type::Formcalc,
WideString::FromUTF8(data_view).AsStringView(),
value.get(), xfa_document->GetRoot());
diff --git a/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc b/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc
index 86703f7..9bd59b2 100644
--- a/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc
+++ b/testing/fuzzers/pdf_scanlinecompositor_fuzzer.cc
@@ -2,11 +2,12 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <memory>
+
#include "core/fxge/cfx_cliprgn.h"
#include "core/fxge/dib/cfx_dibitmap.h"
#include "core/fxge/fx_dib.h"
#include "testing/fuzzers/pdfium_fuzzer_util.h"
-#include "third_party/base/ptr_util.h"
#include "third_party/base/stl_util.h"
namespace {
@@ -53,7 +54,7 @@
std::unique_ptr<CFX_ClipRgn> clip_rgn;
if (is_clip)
- clip_rgn = pdfium::MakeUnique<CFX_ClipRgn>(width, height);
+ clip_rgn = std::make_unique<CFX_ClipRgn>(width, height);
if (src_bitmap->IsAlphaMask()) {
dest_bitmap->CompositeMask(dest_left, dest_top, width, height, src_bitmap,
argb, src_left, src_top, blend_mode,
diff --git a/testing/fuzzers/xfa_codec_fuzzer.h b/testing/fuzzers/xfa_codec_fuzzer.h
index 285259e..275a636 100644
--- a/testing/fuzzers/xfa_codec_fuzzer.h
+++ b/testing/fuzzers/xfa_codec_fuzzer.h
@@ -12,7 +12,6 @@
#include "core/fxcrt/cfx_readonlymemorystream.h"
#include "core/fxcrt/retain_ptr.h"
#include "core/fxge/dib/cfx_dibitmap.h"
-#include "third_party/base/ptr_util.h"
#include "third_party/base/span.h"
// Support up to 64 MB. This prevents trivial OOM when MSAN is on and
@@ -22,7 +21,7 @@
class XFACodecFuzzer {
public:
static int Fuzz(const uint8_t* data, size_t size, FXCODEC_IMAGE_TYPE type) {
- auto decoder = pdfium::MakeUnique<ProgressiveDecoder>();
+ auto decoder = std::make_unique<ProgressiveDecoder>();
auto source = pdfium::MakeRetain<CFX_ReadOnlyMemoryStream>(
pdfium::make_span(data, size));
CFX_DIBAttribute attr;
diff --git a/testing/js_embedder_test.cpp b/testing/js_embedder_test.cpp
index 57e6c4d..9857007 100644
--- a/testing/js_embedder_test.cpp
+++ b/testing/js_embedder_test.cpp
@@ -5,11 +5,9 @@
#include "testing/js_embedder_test.h"
#include "fxjs/cfxjs_engine.h"
-#include "third_party/base/ptr_util.h"
JSEmbedderTest::JSEmbedderTest()
- : m_pArrayBufferAllocator(
- pdfium::MakeUnique<CFX_V8ArrayBufferAllocator>()) {}
+ : m_pArrayBufferAllocator(std::make_unique<CFX_V8ArrayBufferAllocator>()) {}
JSEmbedderTest::~JSEmbedderTest() {}
@@ -24,7 +22,7 @@
v8::Isolate::Scope isolate_scope(isolate());
v8::HandleScope handle_scope(isolate());
FXJS_PerIsolateData::SetUp(isolate());
- m_Engine = pdfium::MakeUnique<CFXJS_Engine>(isolate());
+ m_Engine = std::make_unique<CFXJS_Engine>(isolate());
m_Engine->InitializeEngine();
}
diff --git a/testing/xfa_js_embedder_test.cpp b/testing/xfa_js_embedder_test.cpp
index 2f9cc67..2dd9dc7 100644
--- a/testing/xfa_js_embedder_test.cpp
+++ b/testing/xfa_js_embedder_test.cpp
@@ -11,12 +11,10 @@
#include "fxjs/xfa/cfxjse_engine.h"
#include "fxjs/xfa/cfxjse_value.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/base/ptr_util.h"
#include "xfa/fxfa/cxfa_ffapp.h"
XFAJSEmbedderTest::XFAJSEmbedderTest()
- : array_buffer_allocator_(
- pdfium::MakeUnique<CFX_V8ArrayBufferAllocator>()) {}
+ : array_buffer_allocator_(std::make_unique<CFX_V8ArrayBufferAllocator>()) {}
XFAJSEmbedderTest::~XFAJSEmbedderTest() {}
@@ -91,7 +89,7 @@
}
bool XFAJSEmbedderTest::ExecuteHelper(ByteStringView input) {
- value_ = pdfium::MakeUnique<CFXJSE_Value>(GetIsolate());
+ value_ = std::make_unique<CFXJSE_Value>(GetIsolate());
return script_context_->RunScript(CXFA_Script::Type::Formcalc,
WideString::FromUTF8(input).AsStringView(),
value_.get(), GetXFADocument()->GetRoot());
diff --git a/testing/xfa_unit_test_support.cpp b/testing/xfa_unit_test_support.cpp
index 8cc2d6c..ae7f480 100644
--- a/testing/xfa_unit_test_support.cpp
+++ b/testing/xfa_unit_test_support.cpp
@@ -11,7 +11,6 @@
#include "core/fxge/cfx_gemodule.h"
#include "core/fxge/systemfontinfo_iface.h"
#include "testing/gtest/include/gtest/gtest.h"
-#include "third_party/base/ptr_util.h"
#include "xfa/fgas/font/cfgas_fontmgr.h"
namespace {
@@ -23,7 +22,7 @@
public:
// testing::Environment:
void SetUp() override {
- auto font_mgr = pdfium::MakeUnique<CFGAS_FontMgr>();
+ auto font_mgr = std::make_unique<CFGAS_FontMgr>();
if (font_mgr->EnumFonts())
font_mgr_ = std::move(font_mgr);
}