OLD | NEW |
---|---|
1 // Copyright (c) 2015 PDFium Authors. All rights reserved. | 1 // Copyright (c) 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 "embedder_test.h" | 5 #include "embedder_test.h" |
6 | 6 |
7 #include <limits.h> | 7 #include <limits.h> |
8 #include <stdio.h> | 8 #include <stdio.h> |
9 #include <stdlib.h> | 9 #include <stdlib.h> |
10 #include <string.h> | 10 #include <string.h> |
11 | 11 |
12 #include <list> | 12 #include <list> |
13 #include <string> | 13 #include <string> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "../public/fpdf_dataavail.h" | |
18 #include "../public/fpdf_macro.h" | |
17 #include "../public/fpdf_text.h" | 19 #include "../public/fpdf_text.h" |
18 #include "../public/fpdfview.h" | |
19 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
20 | 21 |
21 #ifdef PDF_ENABLE_V8 | 22 #ifdef PDF_ENABLE_V8 |
22 #include "v8/include/libplatform/libplatform.h" | 23 #include "v8/include/libplatform/libplatform.h" |
23 #include "v8/include/v8.h" | 24 #include "v8/include/v8.h" |
24 #endif // PDF_ENABLE_V8 | 25 #endif // PDF_ENABLE_V8 |
25 | 26 |
26 #ifdef _WIN32 | 27 #ifdef _WIN32 |
27 #define snprintf _snprintf | 28 #define snprintf _snprintf |
28 #define PATH_SEPARATOR '\\' | 29 #define PATH_SEPARATOR '\\' |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
208 file_access_.m_GetBlock = Get_Block; | 209 file_access_.m_GetBlock = Get_Block; |
209 file_access_.m_Param = loader_; | 210 file_access_.m_Param = loader_; |
210 | 211 |
211 file_avail_.version = 1; | 212 file_avail_.version = 1; |
212 file_avail_.IsDataAvail = Is_Data_Avail; | 213 file_avail_.IsDataAvail = Is_Data_Avail; |
213 | 214 |
214 hints_.version = 1; | 215 hints_.version = 1; |
215 hints_.AddSegment = Add_Segment; | 216 hints_.AddSegment = Add_Segment; |
216 | 217 |
217 avail_ = FPDFAvail_Create(&file_avail_, &file_access_); | 218 avail_ = FPDFAvail_Create(&file_avail_, &file_access_); |
218 (void)FPDFAvail_IsDocAvail(avail_, &hints_); | 219 if (FPDFAvail_IsLinearized(avail_) != PDF_LINEARIZED) { |
219 | |
220 if (!FPDFAvail_IsLinearized(avail_)) { | |
221 document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); | 220 document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); |
222 } else { | 221 } else { |
223 document_ = FPDFAvail_GetDocument(avail_, nullptr); | 222 document_ = FPDFAvail_GetDocument(avail_, nullptr); |
223 while (!FPDFAvail_IsDocAvail(avail_, &hints_)) | |
Tom Sepez
2015/10/14 16:57:45
do we need to make this same change in samples/pdf
jun_fang
2015/10/15 10:22:28
Acknowledged.
| |
224 continue; | |
225 if (FPDFAvail_IsFormAvail(avail_, &hints_) == PDF_FORM_NOTAVAIL) { | |
226 return false; | |
227 } | |
228 int page_count = FPDF_GetPageCount(document_); | |
229 for (int i = 0; i < page_count; ++i) { | |
230 while (!FPDFAvail_IsPageAvail(avail_, i, &hints_)) | |
231 continue; | |
232 } | |
224 } | 233 } |
225 | 234 if (!document_) |
235 return false; | |
226 (void)FPDF_GetDocPermissions(document_); | 236 (void)FPDF_GetDocPermissions(document_); |
227 (void)FPDFAvail_IsFormAvail(avail_, &hints_); | |
228 | 237 |
229 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); | 238 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); |
230 memset(platform, 0, sizeof(IPDF_JSPLATFORM)); | 239 memset(platform, 0, sizeof(IPDF_JSPLATFORM)); |
231 platform->version = 2; | 240 platform->version = 2; |
232 platform->app_alert = AlertTrampoline; | 241 platform->app_alert = AlertTrampoline; |
233 | 242 |
234 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this); | 243 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this); |
235 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO)); | 244 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO)); |
236 formfillinfo->version = 1; | 245 formfillinfo->version = 1; |
237 formfillinfo->FFI_SetTimer = SetTimerTrampoline; | 246 formfillinfo->FFI_SetTimer = SetTimerTrampoline; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
356 } | 365 } |
357 | 366 |
358 // Can't use gtest-provided main since we need to stash the path to the | 367 // Can't use gtest-provided main since we need to stash the path to the |
359 // executable in order to find the external V8 binary data files. | 368 // executable in order to find the external V8 binary data files. |
360 int main(int argc, char** argv) { | 369 int main(int argc, char** argv) { |
361 g_exe_path_ = argv[0]; | 370 g_exe_path_ = argv[0]; |
362 testing::InitGoogleTest(&argc, argv); | 371 testing::InitGoogleTest(&argc, argv); |
363 testing::InitGoogleMock(&argc, argv); | 372 testing::InitGoogleMock(&argc, argv); |
364 return RUN_ALL_TESTS(); | 373 return RUN_ALL_TESTS(); |
365 } | 374 } |
OLD | NEW |