| 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" |
| 17 #include "../public/fpdf_text.h" | 18 #include "../public/fpdf_text.h" |
| 18 #include "../public/fpdfview.h" | |
| 19 #include "testing/gmock/include/gmock/gmock.h" | 19 #include "testing/gmock/include/gmock/gmock.h" |
| 20 #include "v8/include/libplatform/libplatform.h" | 20 #include "v8/include/libplatform/libplatform.h" |
| 21 #include "v8/include/v8.h" | 21 #include "v8/include/v8.h" |
| 22 | 22 |
| 23 #ifdef _WIN32 | 23 #ifdef _WIN32 |
| 24 #define snprintf _snprintf | 24 #define snprintf _snprintf |
| 25 #define PATH_SEPARATOR '\\' | 25 #define PATH_SEPARATOR '\\' |
| 26 #else | 26 #else |
| 27 #define PATH_SEPARATOR '/' | 27 #define PATH_SEPARATOR '/' |
| 28 #endif | 28 #endif |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 193 file_access_.m_GetBlock = Get_Block; | 193 file_access_.m_GetBlock = Get_Block; |
| 194 file_access_.m_Param = loader_; | 194 file_access_.m_Param = loader_; |
| 195 | 195 |
| 196 file_avail_.version = 1; | 196 file_avail_.version = 1; |
| 197 file_avail_.IsDataAvail = Is_Data_Avail; | 197 file_avail_.IsDataAvail = Is_Data_Avail; |
| 198 | 198 |
| 199 hints_.version = 1; | 199 hints_.version = 1; |
| 200 hints_.AddSegment = Add_Segment; | 200 hints_.AddSegment = Add_Segment; |
| 201 | 201 |
| 202 avail_ = FPDFAvail_Create(&file_avail_, &file_access_); | 202 avail_ = FPDFAvail_Create(&file_avail_, &file_access_); |
| 203 (void)FPDFAvail_IsDocAvail(avail_, &hints_); | 203 if (FPDFAvail_IsLinearized(avail_) != PDF_FILE_LINEARIZED) { |
| 204 | |
| 205 if (!FPDFAvail_IsLinearized(avail_)) { | |
| 206 document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); | 204 document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); |
| 207 } else { | 205 } else { |
| 208 document_ = FPDFAvail_GetDocument(avail_, nullptr); | 206 document_ = FPDFAvail_GetDocument(avail_, nullptr); |
| 207 while (!FPDFAvail_IsDocAvail(avail_, &hints_)) |
| 208 continue; |
| 209 if (FPDFAvail_IsFormAvail(avail_, &hints_) == PDF_FORM_NOTAVAIL) { |
| 210 return false; |
| 211 } |
| 212 int page_count = FPDF_GetPageCount(document_); |
| 213 for (int i = 0; i < page_count; ++i) { |
| 214 while (!FPDFAvail_IsPageAvail(avail_, i, &hints_)) |
| 215 continue; |
| 216 } |
| 209 } | 217 } |
| 210 | 218 if (!document_) |
| 219 return false; |
| 211 (void)FPDF_GetDocPermissions(document_); | 220 (void)FPDF_GetDocPermissions(document_); |
| 212 (void)FPDFAvail_IsFormAvail(avail_, &hints_); | |
| 213 | 221 |
| 214 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); | 222 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); |
| 215 memset(platform, 0, sizeof(IPDF_JSPLATFORM)); | 223 memset(platform, 0, sizeof(IPDF_JSPLATFORM)); |
| 216 platform->version = 2; | 224 platform->version = 2; |
| 217 platform->app_alert = AlertTrampoline; | 225 platform->app_alert = AlertTrampoline; |
| 218 | 226 |
| 219 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this); | 227 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this); |
| 220 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO)); | 228 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO)); |
| 221 formfillinfo->version = 1; | 229 formfillinfo->version = 1; |
| 222 formfillinfo->FFI_SetTimer = SetTimerTrampoline; | 230 formfillinfo->FFI_SetTimer = SetTimerTrampoline; |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return test->delegate_->GetPage(test->m_pFormfillinfo, document, page_index); | 348 return test->delegate_->GetPage(test->m_pFormfillinfo, document, page_index); |
| 341 } | 349 } |
| 342 | 350 |
| 343 // Can't use gtest-provided main since we need to stash the path to the | 351 // Can't use gtest-provided main since we need to stash the path to the |
| 344 // executable in order to find the external V8 binary data files. | 352 // executable in order to find the external V8 binary data files. |
| 345 int main(int argc, char** argv) { | 353 int main(int argc, char** argv) { |
| 346 g_exe_path_ = argv[0]; | 354 g_exe_path_ = argv[0]; |
| 347 testing::InitGoogleTest(&argc, argv); | 355 testing::InitGoogleTest(&argc, argv); |
| 348 testing::InitGoogleMock(&argc, argv); | 356 testing::InitGoogleMock(&argc, argv); |
| 349 return RUN_ALL_TESTS(); | 357 return RUN_ALL_TESTS(); |
| 350 } | 358 } |
| OLD | NEW |