Index: testing/embedder_test.cpp |
diff --git a/testing/embedder_test.cpp b/testing/embedder_test.cpp |
index b47495556687ab15920298228be21b3ca41f0122..669e16e20435bfef2555eacaffb9d256803a5e5d 100644 |
--- a/testing/embedder_test.cpp |
+++ b/testing/embedder_test.cpp |
@@ -11,6 +11,7 @@ |
#include <utility> |
#include <vector> |
+#include "../public/fpdf_dataavail.h" |
#include "../public/fpdf_text.h" |
#include "../public/fpdfview.h" |
#include "test_support.h" |
@@ -91,7 +92,8 @@ void EmbedderTest::TearDown() { |
free(file_contents_); |
} |
-bool EmbedderTest::OpenDocument(const std::string& filename) { |
+bool EmbedderTest::OpenDocument(const std::string& filename, |
+ bool must_linearize) { |
file_contents_ = GetFileContents(filename.c_str(), &file_length_); |
if (!file_contents_) |
return false; |
@@ -108,18 +110,40 @@ 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_)) |
- document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); |
- else |
+ if (FPDFAvail_IsLinearized(avail_) == PDF_LINEARIZED || must_linearize) { |
Tom Sepez
2015/10/29 16:20:17
Actually, we want to test if FPDFAvail_IsLinearize
jun_fang
2015/10/30 06:02:43
Acknowledged.
|
document_ = FPDFAvail_GetDocument(avail_, nullptr); |
- |
- if (!document_) |
- return false; |
+ if (!document_) { |
+ return false; |
+ } |
+ int32_t nRet = PDF_DATA_NOTAVAIL; |
+ while (nRet == PDF_DATA_NOTAVAIL) { |
+ nRet = FPDFAvail_IsDocAvail(avail_, &hints_); |
+ } |
+ if (nRet == PDF_DATA_ERROR) { |
+ return false; |
+ } |
+ if (FPDFAvail_IsFormAvail(avail_, &hints_) == PDF_FORM_NOTAVAIL) { |
+ return false; |
+ } |
+ int page_count = FPDF_GetPageCount(document_); |
+ for (int i = 0; i < page_count; ++i) { |
+ nRet = PDF_DATA_NOTAVAIL; |
+ while (nRet == PDF_DATA_NOTAVAIL) { |
+ nRet = FPDFAvail_IsPageAvail(avail_, i, &hints_); |
+ } |
+ if (nRet == PDF_DATA_ERROR) { |
+ return false; |
+ } |
+ } |
+ } else { |
+ document_ = FPDF_LoadCustomDocument(&file_access_, nullptr); |
Tom Sepez
2015/10/29 16:20:17
However, if we came here, and must_linearize was s
jun_fang
2015/10/30 06:02:43
Acknowledged.
|
+ 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)); |