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

Side by Side Diff: core/fpdfapi/parser/cpdf_document_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 | « core/fpdfapi/page/fpdf_page_func.cpp ('k') | core/fpdfapi/parser/cpdf_parser.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 "core/fpdfapi/parser/cpdf_document.h" 5 #include "core/fpdfapi/parser/cpdf_document.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "core/fpdfapi/cpdf_modulemgr.h" 10 #include "core/fpdfapi/cpdf_modulemgr.h"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Set up test 101 // Set up test
102 auto allPages = pdfium::MakeUnique<CPDF_Array>(); 102 auto allPages = pdfium::MakeUnique<CPDF_Array>();
103 allPages->AddNew<CPDF_Reference>( 103 allPages->AddNew<CPDF_Reference>(
104 this, AddIndirectObject(CreateNumberedPage(0))->GetObjNum()); 104 this, AddIndirectObject(CreateNumberedPage(0))->GetObjNum());
105 allPages->AddNew<CPDF_Reference>( 105 allPages->AddNew<CPDF_Reference>(
106 this, AddIndirectObject(CreateNumberedPage(1))->GetObjNum()); 106 this, AddIndirectObject(CreateNumberedPage(1))->GetObjNum());
107 // Page without pageNum. 107 // Page without pageNum.
108 allPages->Add(CreateNumberedPage(2)); 108 allPages->Add(CreateNumberedPage(2));
109 CPDF_Dictionary* pagesDict = 109 CPDF_Dictionary* pagesDict =
110 CreatePageTreeNode(std::move(allPages), this, 3); 110 CreatePageTreeNode(std::move(allPages), this, 3);
111 m_pOwnedRootDict.reset(new CPDF_Dictionary()); 111 m_pOwnedRootDict = pdfium::MakeUnique<CPDF_Dictionary>();
112 m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this, 112 m_pOwnedRootDict->SetNewFor<CPDF_Reference>("Pages", this,
113 pagesDict->GetObjNum()); 113 pagesDict->GetObjNum());
114 m_pRootDict = m_pOwnedRootDict.get(); 114 m_pRootDict = m_pOwnedRootDict.get();
115 m_PageList.SetSize(3); 115 m_PageList.SetSize(3);
116 } 116 }
117 117
118 private: 118 private:
119 std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict; 119 std::unique_ptr<CPDF_Dictionary> m_pOwnedRootDict;
120 }; 120 };
121 121
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 const uint32_t obj_num = page_stub->GetObjNum(); 212 const uint32_t obj_num = page_stub->GetObjNum();
213 const int test_page_num = 33; 213 const int test_page_num = 33;
214 214
215 EXPECT_FALSE(document.IsPageLoaded(test_page_num)); 215 EXPECT_FALSE(document.IsPageLoaded(test_page_num));
216 EXPECT_EQ(nullptr, document.GetPage(test_page_num)); 216 EXPECT_EQ(nullptr, document.GetPage(test_page_num));
217 217
218 document.SetPageObjNum(test_page_num, obj_num); 218 document.SetPageObjNum(test_page_num, obj_num);
219 EXPECT_TRUE(document.IsPageLoaded(test_page_num)); 219 EXPECT_TRUE(document.IsPageLoaded(test_page_num));
220 EXPECT_EQ(page_stub, document.GetPage(test_page_num)); 220 EXPECT_EQ(page_stub, document.GetPage(test_page_num));
221 } 221 }
OLDNEW
« no previous file with comments | « core/fpdfapi/page/fpdf_page_func.cpp ('k') | core/fpdfapi/parser/cpdf_parser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698