Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
cpdf_parser_embeddertest.cpp
Go to the documentation of this file.
1// Copyright 2015 The PDFium Authors
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_text.h"
6#include "testing/embedder_test.h"
7#include "testing/gtest/include/gtest/gtest.h"
8
10
12 // Test a dictionary with hex string instead of correct content.
13 // Verify that the defective pdf shouldn't be opened correctly.
14 EXPECT_FALSE(OpenDocument("bug_454695.pdf"));
15}
16
18 // Test colorspace object with malformed dictionary.
19 ASSERT_TRUE(OpenDocument("bug_481363.pdf"));
20 FPDF_PAGE page = LoadPage(0);
21 EXPECT_TRUE(page);
22 UnloadPage(page);
23}
24
26 // Test self referencing /Pages object.
27 ASSERT_TRUE(OpenDocument("bug_544880.pdf"));
28 // Shouldn't crash. We don't check the return value here because we get the
29 // the count from the "/Count 1" in the testcase (at the time of writing)
30 // rather than the actual count (0).
31 (void)GetPageCount();
32}
33
35 EXPECT_FALSE(OpenDocument("bug_325_a.pdf"));
36}
37
39 EXPECT_FALSE(OpenDocument("bug_325_b.pdf"));
40}
41
43 // Test the case that cross reference entries, which are well formed,
44 // but do not match with the objects.
45 ASSERT_TRUE(OpenDocument("bug_602650.pdf"));
46 FPDF_PAGE page = LoadPage(0);
47 EXPECT_TRUE(page);
48 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
49 EXPECT_TRUE(text_page);
50 // The page should not be blank.
51 EXPECT_LT(0, FPDFText_CountChars(text_page));
52
53 FPDFText_ClosePage(text_page);
54 UnloadPage(page);
55}
56
58 ASSERT_TRUE(OpenDocument("bug_757705.pdf"));
59}
60
62 ASSERT_TRUE(OpenDocumentLinearized("feature_linearized_loading.pdf"));
63 // To check that main cross ref table is loaded correctly,will be enough to
64 // check that the second page was correctly loaded. Because it is contains
65 // crossrefs for second page.
66 EXPECT_EQ(2, GetPageCount());
67 FPDF_PAGE page = LoadPage(1);
68 EXPECT_TRUE(page);
69 FPDF_TEXTPAGE text_page = FPDFText_LoadPage(page);
70 EXPECT_TRUE(text_page);
71 // The page should not be blank.
72 EXPECT_LT(0, FPDFText_CountChars(text_page));
73 FPDFText_ClosePage(text_page);
74 UnloadPage(page);
75}
76
78 ASSERT_TRUE(OpenDocument("bug_828049.pdf"));
79 FPDF_PAGE page = LoadPage(0);
80 EXPECT_TRUE(page);
81 UnloadPage(page);
82}
83
84// crbug.com/1191313
86 ASSERT_TRUE(OpenDocument("bad_dict_keys.pdf"));
87}
TEST_F(CPDFParserEmbedderTest, LoadErrorBug454695)
FPDF_EXPORT int FPDF_CALLCONV FPDFText_CountChars(FPDF_TEXTPAGE text_page)
Definition fpdf_text.cpp:59
FPDF_EXPORT FPDF_TEXTPAGE FPDF_CALLCONV FPDFText_LoadPage(FPDF_PAGE page)
Definition fpdf_text.cpp:40
FPDF_EXPORT void FPDF_CALLCONV FPDFText_ClosePage(FPDF_TEXTPAGE text_page)
Definition fpdf_text.cpp:53