Index: testing/embedder_test.cpp |
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp |
index eb16bc70f9cbd2f07d80b48abfc06423629875a2..a6a36f9dd1c1e30f16c49034878d57d35cf6f55e 100644 |
--- a/testing/embedder_test.cpp |
+++ b/testing/embedder_test.cpp |
@@ -14,8 +14,8 @@ |
#include <utility> |
#include <vector> |
+#include "../public/fpdf_dataavail.h" |
#include "../public/fpdf_text.h" |
-#include "../public/fpdfview.h" |
#include "testing/gmock/include/gmock/gmock.h" |
#include "v8/include/libplatform/libplatform.h" |
#include "v8/include/v8.h" |
@@ -200,16 +200,24 @@ bool EmbedderTest::OpenDocument(const std::string& filename) { |
hints_.AddSegment = Add_Segment; |
avail_ = FPDFAvail_Create(&file_avail_, &file_access_); |
- (void)FPDFAvail_IsDocAvail(avail_, &hints_); |
- |
- if (!FPDFAvail_IsLinearized(avail_)) { |
+ if (FPDFAvail_IsLinearized(avail_) != PDF_FILE_LINEARIZED) { |
document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); |
} else { |
document_ = FPDFAvail_GetDocument(avail_, nullptr); |
+ while (!FPDFAvail_IsDocAvail(avail_, &hints_)) |
+ continue; |
+ if (FPDFAvail_IsFormAvail(avail_, &hints_) == PDF_FORM_NOTAVAIL) { |
+ return false; |
+ } |
+ int page_count = FPDF_GetPageCount(document_); |
+ for (int i = 0; i < page_count; ++i) { |
+ while (!FPDFAvail_IsPageAvail(avail_, i, &hints_)) |
+ continue; |
+ } |
} |
- |
+ if (!document_) |
+ return false; |
(void)FPDF_GetDocPermissions(document_); |
- (void)FPDFAvail_IsFormAvail(avail_, &hints_); |
IPDF_JSPLATFORM* platform = static_cast<IPDF_JSPLATFORM*>(this); |
memset(platform, 0, sizeof(IPDF_JSPLATFORM)); |
@@ -347,4 +355,4 @@ int main(int argc, char** argv) { |
testing::InitGoogleTest(&argc, argv); |
testing::InitGoogleMock(&argc, argv); |
return RUN_ALL_TESTS(); |
-} |
+} |