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_text.h" | 17 #include "../public/fpdf_text.h" |
18 #include "../public/fpdfview.h" | 18 #include "../public/fpdf_dataavail.h" |
Tom Sepez
2015/09/22 19:17:59
nit: alphabetize.
jun_fang
2015/09/23 12:26:59
Acknowledged.
| |
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_) != FSDK_IS_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 (true) { | |
Tom Sepez
2015/09/22 19:17:59
strange spinnng here. do you have to yield or chec
jun_fang
2015/09/23 12:26:59
If the return value is false, that means we need t
Tom Sepez
2015/09/24 18:24:40
So...do we need an IFX_Pause or some such to check
| |
208 if (FPDFAvail_IsDocAvail(avail_, &hints_)) | |
209 break; | |
210 } | |
211 if (FPDFAvail_IsFormAvail(avail_, &hints_) == PDFFORM_NOTAVAIL) { | |
212 return false; | |
213 } | |
214 int page_count = FPDF_GetPageCount(document_); | |
215 for (int i = 0; i < page_count; ++i) { | |
216 while (true) { | |
Tom Sepez
2015/09/22 19:17:59
nit: same here.
jun_fang
2015/09/23 12:26:59
Acknowledged.
| |
217 if (FPDFAvail_IsPageAvail(avail_, i, &hints_)) | |
218 break; | |
219 } | |
220 } | |
209 } | 221 } |
210 | 222 if (!document_) |
223 return false; | |
211 (void)FPDF_GetDocPermissions(document_); | 224 (void)FPDF_GetDocPermissions(document_); |
212 (void)FPDFAvail_IsFormAvail(avail_, &hints_); | |
213 | 225 |
214 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); | 226 IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); |
215 memset(platform, 0, sizeof(IPDF_JSPLATFORM)); | 227 memset(platform, 0, sizeof(IPDF_JSPLATFORM)); |
216 platform->version = 2; | 228 platform->version = 2; |
217 platform->app_alert = AlertTrampoline; | 229 platform->app_alert = AlertTrampoline; |
218 | 230 |
219 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this); | 231 FPDF_FORMFILLINFO* formfillinfo = static_cast<FPDF_FORMFILLINFO*>(this); |
220 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO)); | 232 memset(formfillinfo, 0, sizeof(FPDF_FORMFILLINFO)); |
221 formfillinfo->version = 1; | 233 formfillinfo->version = 1; |
222 formfillinfo->FFI_SetTimer = SetTimerTrampoline; | 234 formfillinfo->FFI_SetTimer = SetTimerTrampoline; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 } | 353 } |
342 | 354 |
343 // Can't use gtest-provided main since we need to stash the path to the | 355 // 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. | 356 // executable in order to find the external V8 binary data files. |
345 int main(int argc, char** argv) { | 357 int main(int argc, char** argv) { |
346 g_exe_path_ = argv[0]; | 358 g_exe_path_ = argv[0]; |
347 testing::InitGoogleTest(&argc, argv); | 359 testing::InitGoogleTest(&argc, argv); |
348 testing::InitGoogleMock(&argc, argv); | 360 testing::InitGoogleMock(&argc, argv); |
349 return RUN_ALL_TESTS(); | 361 return RUN_ALL_TESTS(); |
350 } | 362 } |
OLD | NEW |