diff options
Diffstat (limited to 'fpdfsdk/fpdf_view_embeddertest.cpp')
-rw-r--r-- | fpdfsdk/fpdf_view_embeddertest.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fpdfsdk/fpdf_view_embeddertest.cpp b/fpdfsdk/fpdf_view_embeddertest.cpp index 7cc5478808..cef5e9a0d4 100644 --- a/fpdfsdk/fpdf_view_embeddertest.cpp +++ b/fpdfsdk/fpdf_view_embeddertest.cpp @@ -7,6 +7,8 @@ #include <memory> #include <string> +#include "core/fpdfapi/parser/cpdf_document.h" +#include "fpdfsdk/cpdfsdk_helpers.h" #include "fpdfsdk/fpdf_view_c_api_test.h" #include "public/cpp/fpdf_scopers.h" #include "public/fpdfview.h" @@ -589,6 +591,40 @@ TEST_F(FPDFViewEmbeddertest, FPDF_RenderPageBitmapWithMatrix) { UnloadPage(page); } +TEST_F(FPDFViewEmbeddertest, FPDF_GetPageSizeByIndex) { + EXPECT_TRUE(OpenDocument("rectangles.pdf")); + CPDF_Document* pDoc = CPDFDocumentFromFPDFDocument(document()); + + double width = 0; + double height = 0; + + // Page -1 doesn't exist. + EXPECT_FALSE(FPDF_GetPageSizeByIndex(document(), -1, &width, &height)); + + // Page 1 doesn't exist. + EXPECT_FALSE(FPDF_GetPageSizeByIndex(document(), 1, &width, &height)); + + // Page 0 exists. + EXPECT_TRUE(FPDF_GetPageSizeByIndex(document(), 0, &width, &height)); + EXPECT_EQ(200.0, width); + EXPECT_EQ(300.0, height); + +#ifdef PDF_ENABLE_XFA + // TODO(tsepez): XFA must obtain this size without parsing. + EXPECT_EQ(1u, pDoc->GetParsedPageCountForTesting()); +#else // PDF_ENABLE_XFA + EXPECT_EQ(0u, pDoc->GetParsedPageCountForTesting()); +#endif // PDF_ENABLE_XFA + + // Double-check against values from when page is actually parsed. + FPDF_PAGE page = LoadPage(0); + ASSERT_TRUE(page); + EXPECT_EQ(width, FPDF_GetPageWidth(page)); + EXPECT_EQ(height, FPDF_GetPageHeight(page)); + EXPECT_EQ(1u, pDoc->GetParsedPageCountForTesting()); + UnloadPage(page); +} + class UnSupRecordDelegate : public EmbedderTest::Delegate { public: UnSupRecordDelegate() : type_(-1) {} |