1e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// Copyright 2015 PDFium Authors. All rights reserved. 2e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// Use of this source code is governed by a BSD-style license that can be 3e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov// found in the LICENSE file. 4e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 5ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann#include "testing/embedder_test.h" 6e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov#include "testing/gtest/include/gtest/gtest.h" 7e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 8ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmannclass FPDFParserEmbeddertest : public EmbedderTest {}; 9e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 10e6986e1e8d4a57987f47c215490cb080a65ee29aSvet GanovTEST_F(FPDFParserEmbeddertest, LoadError_454695) { 11ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann // Test a dictionary with hex string instead of correct content. 12ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann // Verify that the defective pdf shouldn't be opened correctly. 13ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann EXPECT_FALSE(OpenDocument("bug_454695.pdf")); 14e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov} 15e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov 16e6986e1e8d4a57987f47c215490cb080a65ee29aSvet GanovTEST_F(FPDFParserEmbeddertest, Bug_481363) { 17e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov // Test colorspace object with malformed dictionary. 18ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann EXPECT_TRUE(OpenDocument("bug_481363.pdf")); 19e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov FPDF_PAGE page = LoadPage(0); 20e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov EXPECT_NE(nullptr, page); 21e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov UnloadPage(page); 22e6986e1e8d4a57987f47c215490cb080a65ee29aSvet Ganov} 23ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 24ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. MoltmannTEST_F(FPDFParserEmbeddertest, Bug_544880) { 25ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann // Test self referencing /Pages object. 26ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann EXPECT_TRUE(OpenDocument("bug_544880.pdf")); 27ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann // Shouldn't crash. We don't check the return value here because we get the 28ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann // the count from the "/Count 1" in the testcase (at the time of writing) 29ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann // rather than the actual count (0). 30ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann (void)GetPageCount(); 31ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann} 32ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 33ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. MoltmannTEST_F(FPDFParserEmbeddertest, Feature_Linearized_Loading) { 34ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann EXPECT_TRUE(OpenDocument("feature_linearized_loading.pdf", true)); 35ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann} 36ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann 37ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. MoltmannTEST_F(FPDFParserEmbeddertest, Bug_325) { 38ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann EXPECT_FALSE(OpenDocument("bug_325_a.pdf")); 39ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann EXPECT_FALSE(OpenDocument("bug_325_b.pdf")); 40ac3d58cff7c80b0ef56bf55130d91da17cbaa3c4Philip P. Moltmann} 41