94a51094a87f35a4f86e49647a6882beb787ca55
[pdfium.git] / fpdfsdk / src / fpdfview_embeddertest.cpp
1 // Copyright 2015 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "../../testing/embedder_test.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7
8 class FPDFViewEmbeddertest : public EmbedderTest {
9 };
10
11 TEST_F(FPDFViewEmbeddertest, Document) {
12   EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf"));
13   EXPECT_EQ(1, GetPageCount());
14   EXPECT_EQ(0, GetFirstPageNum());
15
16   int version;
17   EXPECT_TRUE(FPDF_GetFileVersion(document(), &version));
18   EXPECT_EQ(14, version);
19
20   EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document()));
21   EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
22 }
23
24 TEST_F(FPDFViewEmbeddertest, Page) {
25   EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf"));
26   FPDF_FORMHANDLE form_handle = SetFormFillEnvironment();
27   FPDF_PAGE page = LoadPage(0, form_handle);
28   EXPECT_NE(nullptr, page);
29   EXPECT_EQ(612.0, FPDF_GetPageWidth(page));
30   EXPECT_EQ(792.0, FPDF_GetPageHeight(page));
31   UnloadPage(page, form_handle);
32   EXPECT_EQ(nullptr, LoadPage(1, form_handle));
33   ClearFormFillEnvironment(form_handle);
34 }
35
36 TEST_F(FPDFViewEmbeddertest, ViewerRef) {
37   EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf"));
38   EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document()));
39   EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document()));
40   EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));
41 }
42