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

Side by Side Diff: testing/embedder_test.cpp

Issue 2005653002: Distinguish between user and owner passwords. (Closed) Base URL: https://pdfium.googlesource.com/pdfium@master
Patch Set: rebase Created 4 years, 7 months 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 | « testing/embedder_test.h ('k') | testing/resources/encrypted.pdf » ('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 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/embedder_test.h" 5 #include "testing/embedder_test.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 8
9 #include <list> 9 #include <list>
10 #include <string> 10 #include <string>
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 bool EmbedderTest::CreateEmptyDocument() { 104 bool EmbedderTest::CreateEmptyDocument() {
105 document_ = FPDF_CreateNewDocument(); 105 document_ = FPDF_CreateNewDocument();
106 if (!document_) 106 if (!document_)
107 return false; 107 return false;
108 108
109 SetupFormFillEnvironment(); 109 SetupFormFillEnvironment();
110 return true; 110 return true;
111 } 111 }
112 112
113 bool EmbedderTest::OpenDocument(const std::string& filename, 113 bool EmbedderTest::OpenDocument(const std::string& filename,
114 const char* password,
114 bool must_linearize) { 115 bool must_linearize) {
115 std::string file_path; 116 std::string file_path;
116 if (!PathService::GetTestFilePath(filename, &file_path)) 117 if (!PathService::GetTestFilePath(filename, &file_path))
117 return false; 118 return false;
118 file_contents_ = GetFileContents(file_path.c_str(), &file_length_); 119 file_contents_ = GetFileContents(file_path.c_str(), &file_length_);
119 if (!file_contents_) 120 if (!file_contents_)
120 return false; 121 return false;
121 122
122 loader_ = new TestLoader(file_contents_.get(), file_length_); 123 loader_ = new TestLoader(file_contents_.get(), file_length_);
123 file_access_.m_FileLen = static_cast<unsigned long>(file_length_); 124 file_access_.m_FileLen = static_cast<unsigned long>(file_length_);
124 file_access_.m_GetBlock = TestLoader::GetBlock; 125 file_access_.m_GetBlock = TestLoader::GetBlock;
125 file_access_.m_Param = loader_; 126 file_access_.m_Param = loader_;
126 127
127 file_avail_.version = 1; 128 file_avail_.version = 1;
128 file_avail_.IsDataAvail = Is_Data_Avail; 129 file_avail_.IsDataAvail = Is_Data_Avail;
129 130
130 hints_.version = 1; 131 hints_.version = 1;
131 hints_.AddSegment = Add_Segment; 132 hints_.AddSegment = Add_Segment;
132 133
133 avail_ = FPDFAvail_Create(&file_avail_, &file_access_); 134 avail_ = FPDFAvail_Create(&file_avail_, &file_access_);
134 135
135 if (FPDFAvail_IsLinearized(avail_) == PDF_LINEARIZED) { 136 if (FPDFAvail_IsLinearized(avail_) == PDF_LINEARIZED) {
136 document_ = FPDFAvail_GetDocument(avail_, nullptr); 137 document_ = FPDFAvail_GetDocument(avail_, password);
137 if (!document_) { 138 if (!document_) {
138 return false; 139 return false;
139 } 140 }
140 int32_t nRet = PDF_DATA_NOTAVAIL; 141 int32_t nRet = PDF_DATA_NOTAVAIL;
141 while (nRet == PDF_DATA_NOTAVAIL) { 142 while (nRet == PDF_DATA_NOTAVAIL) {
142 nRet = FPDFAvail_IsDocAvail(avail_, &hints_); 143 nRet = FPDFAvail_IsDocAvail(avail_, &hints_);
143 } 144 }
144 if (nRet == PDF_DATA_ERROR) { 145 if (nRet == PDF_DATA_ERROR) {
145 return false; 146 return false;
146 } 147 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 } 317 }
317 318
318 // Can't use gtest-provided main since we need to stash the path to the 319 // Can't use gtest-provided main since we need to stash the path to the
319 // executable in order to find the external V8 binary data files. 320 // executable in order to find the external V8 binary data files.
320 int main(int argc, char** argv) { 321 int main(int argc, char** argv) {
321 g_exe_path_ = argv[0]; 322 g_exe_path_ = argv[0];
322 testing::InitGoogleTest(&argc, argv); 323 testing::InitGoogleTest(&argc, argv);
323 testing::InitGoogleMock(&argc, argv); 324 testing::InitGoogleMock(&argc, argv);
324 return RUN_ALL_TESTS(); 325 return RUN_ALL_TESTS();
325 } 326 }
OLDNEW
« no previous file with comments | « testing/embedder_test.h ('k') | testing/resources/encrypted.pdf » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698