Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(563)

Side by Side Diff: fpdfsdk/src/fpdfview_embeddertest.cpp

Issue 1411403012: Merge to XFA: Add path service to retrieve test data directory at run time so tests can be run from… (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: remove a blank line Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fpdfsdk/src/fpdftext_embeddertest.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "fpdfsdk/src/fpdfview_c_api_test.h"
9 #include "fpdfview_c_api_test.h"
10 #include "public/fpdfview.h" 9 #include "public/fpdfview.h"
10 #include "testing/embedder_test.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 TEST(fpdf, CApiTest) { 13 TEST(fpdf, CApiTest) {
14 EXPECT_TRUE(CheckPDFiumCApi()); 14 EXPECT_TRUE(CheckPDFiumCApi());
15 } 15 }
16 16
17 class FPDFViewEmbeddertest : public EmbedderTest {}; 17 class FPDFViewEmbeddertest : public EmbedderTest {};
18 18
19 TEST_F(FPDFViewEmbeddertest, Document) { 19 TEST_F(FPDFViewEmbeddertest, Document) {
20 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); 20 EXPECT_TRUE(OpenDocument("about_blank.pdf"));
21 EXPECT_EQ(1, GetPageCount()); 21 EXPECT_EQ(1, GetPageCount());
22 EXPECT_EQ(0, GetFirstPageNum()); 22 EXPECT_EQ(0, GetFirstPageNum());
23 23
24 int version; 24 int version;
25 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version)); 25 EXPECT_TRUE(FPDF_GetFileVersion(document(), &version));
26 EXPECT_EQ(14, version); 26 EXPECT_EQ(14, version);
27 27
28 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document())); 28 EXPECT_EQ(0xFFFFFFFF, FPDF_GetDocPermissions(document()));
29 EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document())); 29 EXPECT_EQ(-1, FPDF_GetSecurityHandlerRevision(document()));
30 } 30 }
31 31
32 TEST_F(FPDFViewEmbeddertest, Page) { 32 TEST_F(FPDFViewEmbeddertest, Page) {
33 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); 33 EXPECT_TRUE(OpenDocument("about_blank.pdf"));
34 FPDF_PAGE page = LoadPage(0); 34 FPDF_PAGE page = LoadPage(0);
35 EXPECT_NE(nullptr, page); 35 EXPECT_NE(nullptr, page);
36 EXPECT_EQ(612.0, FPDF_GetPageWidth(page)); 36 EXPECT_EQ(612.0, FPDF_GetPageWidth(page));
37 EXPECT_EQ(792.0, FPDF_GetPageHeight(page)); 37 EXPECT_EQ(792.0, FPDF_GetPageHeight(page));
38 UnloadPage(page); 38 UnloadPage(page);
39 EXPECT_EQ(nullptr, LoadPage(1)); 39 EXPECT_EQ(nullptr, LoadPage(1));
40 } 40 }
41 41
42 TEST_F(FPDFViewEmbeddertest, ViewerRef) { 42 TEST_F(FPDFViewEmbeddertest, ViewerRef) {
43 EXPECT_TRUE(OpenDocument("testing/resources/about_blank.pdf")); 43 EXPECT_TRUE(OpenDocument("about_blank.pdf"));
44 EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document())); 44 EXPECT_TRUE(FPDF_VIEWERREF_GetPrintScaling(document()));
45 EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document())); 45 EXPECT_EQ(1, FPDF_VIEWERREF_GetNumCopies(document()));
46 EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document())); 46 EXPECT_EQ(DuplexUndefined, FPDF_VIEWERREF_GetDuplex(document()));
47 } 47 }
48 48
49 TEST_F(FPDFViewEmbeddertest, NamedDests) { 49 TEST_F(FPDFViewEmbeddertest, NamedDests) {
50 EXPECT_TRUE(OpenDocument("testing/resources/named_dests.pdf")); 50 EXPECT_TRUE(OpenDocument("named_dests.pdf"));
51 long buffer_size; 51 long buffer_size;
52 char fixed_buffer[512]; 52 char fixed_buffer[512];
53 FPDF_DEST dest; 53 FPDF_DEST dest;
54 54
55 // Query the size of the first item. 55 // Query the size of the first item.
56 buffer_size = 2000000; // Absurdly large, check not used for this case. 56 buffer_size = 2000000; // Absurdly large, check not used for this case.
57 dest = FPDF_GetNamedDest(document(), 0, nullptr, &buffer_size); 57 dest = FPDF_GetNamedDest(document(), 0, nullptr, &buffer_size);
58 EXPECT_NE(nullptr, dest); 58 EXPECT_NE(nullptr, dest);
59 EXPECT_EQ(12u, buffer_size); 59 EXPECT_EQ(12u, buffer_size);
60 60
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 EXPECT_EQ(nullptr, dest); 135 EXPECT_EQ(nullptr, dest);
136 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 136 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
137 137
138 buffer_size = sizeof(fixed_buffer); 138 buffer_size = sizeof(fixed_buffer);
139 dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, &buffer_size); 139 dest = FPDF_GetNamedDest(document(), -1, fixed_buffer, &buffer_size);
140 EXPECT_EQ(nullptr, dest); 140 EXPECT_EQ(nullptr, dest);
141 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified. 141 EXPECT_EQ(sizeof(fixed_buffer), buffer_size); // unmodified.
142 } 142 }
143 143
144 TEST_F(FPDFViewEmbeddertest, NamedDestsByName) { 144 TEST_F(FPDFViewEmbeddertest, NamedDestsByName) {
145 EXPECT_TRUE(OpenDocument("testing/resources/named_dests.pdf")); 145 EXPECT_TRUE(OpenDocument("named_dests.pdf"));
146 146
147 // Null pointer returns NULL. 147 // Null pointer returns NULL.
148 FPDF_DEST dest = FPDF_GetNamedDestByName(document(), nullptr); 148 FPDF_DEST dest = FPDF_GetNamedDestByName(document(), nullptr);
149 EXPECT_EQ(nullptr, dest); 149 EXPECT_EQ(nullptr, dest);
150 150
151 // Empty string returns NULL. 151 // Empty string returns NULL.
152 dest = FPDF_GetNamedDestByName(document(), ""); 152 dest = FPDF_GetNamedDestByName(document(), "");
153 EXPECT_EQ(nullptr, dest); 153 EXPECT_EQ(nullptr, dest);
154 154
155 // Item from Dests NameTree. 155 // Item from Dests NameTree.
(...skipping 17 matching lines...) Expand all
173 dest = FPDF_GetNamedDestByName(document(), "WrongType"); 173 dest = FPDF_GetNamedDestByName(document(), "WrongType");
174 EXPECT_EQ(nullptr, dest); 174 EXPECT_EQ(nullptr, dest);
175 175
176 // No such destination in either Dest NameTree or dictionary. 176 // No such destination in either Dest NameTree or dictionary.
177 dest = FPDF_GetNamedDestByName(document(), "Bogus"); 177 dest = FPDF_GetNamedDestByName(document(), "Bogus");
178 EXPECT_EQ(nullptr, dest); 178 EXPECT_EQ(nullptr, dest);
179 } 179 }
180 180
181 // The following tests pass if the document opens without crashing. 181 // The following tests pass if the document opens without crashing.
182 TEST_F(FPDFViewEmbeddertest, Crasher_113) { 182 TEST_F(FPDFViewEmbeddertest, Crasher_113) {
183 EXPECT_TRUE(OpenDocument("testing/resources/bug_113.pdf")); 183 EXPECT_TRUE(OpenDocument("bug_113.pdf"));
184 } 184 }
185 185
186 TEST_F(FPDFViewEmbeddertest, Crasher_451830) { 186 TEST_F(FPDFViewEmbeddertest, Crasher_451830) {
187 // Document is damaged and can't be opened. 187 // Document is damaged and can't be opened.
188 EXPECT_FALSE(OpenDocument("testing/resources/bug_451830.pdf")); 188 EXPECT_FALSE(OpenDocument("bug_451830.pdf"));
189 } 189 }
190 190
191 TEST_F(FPDFViewEmbeddertest, Crasher_452455) { 191 TEST_F(FPDFViewEmbeddertest, Crasher_452455) {
192 EXPECT_TRUE(OpenDocument("testing/resources/bug_452455.pdf")); 192 EXPECT_TRUE(OpenDocument("bug_452455.pdf"));
193 FPDF_PAGE page = LoadPage(0); 193 FPDF_PAGE page = LoadPage(0);
194 EXPECT_NE(nullptr, page); 194 EXPECT_NE(nullptr, page);
195 UnloadPage(page); 195 UnloadPage(page);
196 } 196 }
197 197
198 TEST_F(FPDFViewEmbeddertest, Crasher_454695) { 198 TEST_F(FPDFViewEmbeddertest, Crasher_454695) {
199 // Document is damanged and can't be opened. 199 // Document is damanged and can't be opened.
200 EXPECT_FALSE(OpenDocument("testing/resources/bug_454695.pdf")); 200 EXPECT_FALSE(OpenDocument("bug_454695.pdf"));
201 } 201 }
OLDNEW
« no previous file with comments | « fpdfsdk/src/fpdftext_embeddertest.cpp ('k') | pdfium.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698