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

Side by Side Diff: fpdfsdk/fpdfppo_embeddertest.cpp

Issue 2488403004: Add fpdfppo_embeddertest.cpp. (Closed)
Patch Set: One last suggestion Created 4 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 | « BUILD.gn ('k') | xfa/fgas/localization/fgas_locale.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 "public/fpdf_ppo.h"
6
7 #include "core/fxcrt/fx_basic.h"
8 #include "public/fpdf_edit.h"
9 #include "public/fpdfview.h"
10 #include "testing/embedder_test.h"
11 #include "testing/gtest/include/gtest/gtest.h"
12 #include "testing/test_support.h"
13
14 namespace {
15
16 class FPDFPPOEmbeddertest : public EmbedderTest {};
17
18 } // namespace
19
20 TEST_F(FPDFPPOEmbeddertest, NoViewerPreferences) {
21 EXPECT_TRUE(OpenDocument("hello_world.pdf"));
22
23 FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
24 EXPECT_TRUE(output_doc);
25 EXPECT_FALSE(FPDF_CopyViewerPreferences(output_doc, document()));
26 FPDF_CloseDocument(output_doc);
27 }
28
29 TEST_F(FPDFPPOEmbeddertest, ViewerPreferences) {
30 EXPECT_TRUE(OpenDocument("viewer_ref.pdf"));
31
32 FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
33 EXPECT_TRUE(output_doc);
34 EXPECT_TRUE(FPDF_CopyViewerPreferences(output_doc, document()));
35 FPDF_CloseDocument(output_doc);
36 }
37
38 TEST_F(FPDFPPOEmbeddertest, ImportPages) {
39 EXPECT_TRUE(OpenDocument("viewer_ref.pdf"));
40
41 FPDF_PAGE page = LoadPage(0);
42 EXPECT_TRUE(page);
43
44 FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
45 EXPECT_TRUE(output_doc);
46 EXPECT_TRUE(FPDF_CopyViewerPreferences(output_doc, document()));
47 EXPECT_TRUE(FPDF_ImportPages(output_doc, document(), "1", 0));
48 EXPECT_EQ(1, FPDF_GetPageCount(output_doc));
49 FPDF_CloseDocument(output_doc);
50
51 UnloadPage(page);
52 }
53
54 TEST_F(FPDFPPOEmbeddertest, BadRanges) {
55 EXPECT_TRUE(OpenDocument("viewer_ref.pdf"));
56
57 FPDF_PAGE page = LoadPage(0);
58 EXPECT_TRUE(page);
59
60 FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
61 EXPECT_TRUE(output_doc);
62 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "clams", 0));
63 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "0", 0));
64 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "42", 0));
65 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "1,2", 0));
66 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "1-2", 0));
67 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), ",1", 0));
68 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "1,", 0));
69 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "1-", 0));
70 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "-1", 0));
71 EXPECT_FALSE(FPDF_ImportPages(output_doc, document(), "-,0,,,1-", 0));
72 FPDF_CloseDocument(output_doc);
73
74 UnloadPage(page);
75 }
76
77 TEST_F(FPDFPPOEmbeddertest, GoodRanges) {
78 EXPECT_TRUE(OpenDocument("viewer_ref.pdf"));
79
80 FPDF_PAGE page = LoadPage(0);
81 EXPECT_TRUE(page);
82
83 FPDF_DOCUMENT output_doc = FPDF_CreateNewDocument();
84 EXPECT_TRUE(output_doc);
85 EXPECT_TRUE(FPDF_CopyViewerPreferences(output_doc, document()));
86 EXPECT_TRUE(FPDF_ImportPages(output_doc, document(), "1,1,1,1", 0));
87 EXPECT_TRUE(FPDF_ImportPages(output_doc, document(), "1-1", 0));
88 EXPECT_EQ(5, FPDF_GetPageCount(output_doc));
89 FPDF_CloseDocument(output_doc);
90
91 UnloadPage(page);
92 }
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | xfa/fgas/localization/fgas_locale.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698