Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Side by Side Diff: fpdfsdk/fpdfdoc_unittest.cpp

Issue 2571913002: Avoid the ptr.reset(new XXX()) anti-pattern (Closed)
Patch Set: rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/fpdfdoc.cpp ('k') | xfa/fde/cfde_txtedtengine.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 PDFium Authors. All rights reserved. 1 // Copyright 2016 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 "public/fpdf_doc.h" 5 #include "public/fpdf_doc.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "core/fpdfapi/cpdf_modulemgr.h" 10 #include "core/fpdfapi/cpdf_modulemgr.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 }; 58 };
59 59
60 void SetUp() override { 60 void SetUp() override {
61 // We don't need page module or render module, but 61 // We don't need page module or render module, but
62 // initialize them to keep the code sane. 62 // initialize them to keep the code sane.
63 CPDF_ModuleMgr* module_mgr = CPDF_ModuleMgr::Get(); 63 CPDF_ModuleMgr* module_mgr = CPDF_ModuleMgr::Get();
64 module_mgr->InitPageModule(); 64 module_mgr->InitPageModule();
65 65
66 m_pDoc = pdfium::MakeUnique<CPDF_TestPdfDocument>(); 66 m_pDoc = pdfium::MakeUnique<CPDF_TestPdfDocument>();
67 m_pIndirectObjs = m_pDoc->GetHolder(); 67 m_pIndirectObjs = m_pDoc->GetHolder();
68
68 // Setup the root directory. 69 // Setup the root directory.
69 m_pRootObj.reset(new CPDF_Dictionary()); 70 m_pRootObj = pdfium::MakeUnique<CPDF_Dictionary>();
70 m_pDoc->SetRoot(m_pRootObj.get()); 71 m_pDoc->SetRoot(m_pRootObj.get());
71 } 72 }
72 73
73 void TearDown() override { 74 void TearDown() override {
74 m_pRootObj.reset(); 75 m_pRootObj.reset();
75 m_pIndirectObjs = nullptr; 76 m_pIndirectObjs = nullptr;
76 m_pDoc.reset(); 77 m_pDoc.reset();
77 CPDF_ModuleMgr::Destroy(); 78 CPDF_ModuleMgr::Destroy();
78 } 79 }
79 80
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, 265 EXPECT_TRUE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom,
265 &x, &y, &zoom)); 266 &x, &y, &zoom));
266 EXPECT_FALSE(hasX); 267 EXPECT_FALSE(hasX);
267 EXPECT_FALSE(hasY); 268 EXPECT_FALSE(hasY);
268 EXPECT_FALSE(hasZoom); 269 EXPECT_FALSE(hasZoom);
269 270
270 array = pdfium::MakeUnique<CPDF_Array>(); 271 array = pdfium::MakeUnique<CPDF_Array>();
271 EXPECT_FALSE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom, 272 EXPECT_FALSE(FPDFDest_GetLocationInPage(array.get(), &hasX, &hasY, &hasZoom,
272 &x, &y, &zoom)); 273 &x, &y, &zoom));
273 } 274 }
OLDNEW
« no previous file with comments | « fpdfsdk/fpdfdoc.cpp ('k') | xfa/fde/cfde_txtedtengine.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698