OLD | NEW |
1 // Copyright 2015 PDFium Authors. All rights reserved. | 1 // Copyright 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 <limits> | 5 #include <limits> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "../../testing/embedder_test.h" | 8 #include "../../testing/embedder_test.h" |
9 #include "../../fpdfsdk/include/fpdfview.h" | 9 #include "../../fpdfsdk/include/fpdfview.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 class FPDFViewEmbeddertest : public EmbedderTest { | 12 class FPDFViewEmbeddertest : public EmbedderTest { |
13 }; | 13 }; |
14 | 14 |
15 TEST_F(FPDFViewEmbeddertest, Document) { | 15 TEST_F(FPDFViewEmbeddertest, Document) { |
16 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); | 16 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); |
17 EXPECT_EQ(1, GetPageCount()); | 17 EXPECT_EQ(1, GetPageCount()); |
18 EXPECT_EQ(0, GetFirstPageNum()); | 18 EXPECT_EQ(0, GetFirstPageNum()); |
19 | 19 |
20 int version; | 20 int version; |
21 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version)); | 21 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version)); |
22 EXPECT_EQ(14, version); | 22 EXPECT_EQ(14, version); |
23 | 23 |
24 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document())); | 24 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document())); |
25 EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document())); | 25 EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document())); |
26 } | 26 } |
27 | 27 |
28 TEST_F(FPDFViewEmbeddertest, Page) { | 28 TEST_F(FPDFViewEmbeddertest, Page) { |
29 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); | 29 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); |
30 FPDF_FORMHANDLE form_handle = SetFormFillEnvironment(); | 30 FPDF_PAGE page = LoadPage(0); |
31 FPDF_PAGE page = LoadPage(0, form_handle); | |
32 EXPECT_NE(nullptr, page); | 31 EXPECT_NE(nullptr, page); |
33 EXPECT_EQ(612.0, FPDF_GetPageWidth(page)); | 32 EXPECT_EQ(612.0, FPDF_GetPageWidth(page)); |
34 EXPECT_EQ(792.0, FPDF_GetPageHeight(page)); | 33 EXPECT_EQ(792.0, FPDF_GetPageHeight(page)); |
35 UnloadPage(page, form_handle); | 34 UnloadPage(page); |
36 EXPECT_EQ(nullptr, LoadPage(1, form_handle)); | 35 EXPECT_EQ(nullptr, LoadPage(1)); |
37 ClearFormFillEnvironment(form_handle); | |
38 } | 36 } |
39 | 37 |
40 TEST_F(FPDFViewEmbeddertest, ViewerRef) { | 38 TEST_F(FPDFViewEmbeddertest, ViewerRef) { |
41 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); | 39 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); |
42 EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document())); | 40 EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document())); |
43 EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document())); | 41 EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document())); |
44 EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document())); | 42 EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document())); |
45 } | 43 } |
46 | 44 |
47 TEST_F(FPDFViewEmbeddertest, NamedDests) { | 45 TEST_F(FPDFViewEmbeddertest, NamedDests) { |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // No such destination in either Dest NameTree or dictionary. | 174 // No such destination in either Dest NameTree or dictionary. |
177 dest = FPDF_GetNamedDestByName(document(), "Bogus"); | 175 dest = FPDF_GetNamedDestByName(document(), "Bogus"); |
178 EXPECT_EQ(nullptr, dest); | 176 EXPECT_EQ(nullptr, dest); |
179 } | 177 } |
180 | 178 |
181 // The following tests pass if the document opens without crashing. | 179 // The following tests pass if the document opens without crashing. |
182 TEST_F(FPDFViewEmbeddertest, Crashers) { | 180 TEST_F(FPDFViewEmbeddertest, Crashers) { |
183 // XFA branch detects this document as bad. | 181 // XFA branch detects this document as bad. |
184 EXPECT_FALSE(OpenDocument("testing/resources/bug_451830.pdf")); | 182 EXPECT_FALSE(OpenDocument("testing/resources/bug_451830.pdf")); |
185 } | 183 } |
OLD | NEW |