android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / qa / extras / pdf / HybridPdfTest.cxx
blobfda2b409fbaaf3bc23f64010b6110621cd4dcd5d
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <swmodeltestbase.hxx>
11 #include <docsh.hxx>
12 #include <unotxdoc.hxx>
14 class HybridPdfTest : public SwModelTestBase
16 public:
17 HybridPdfTest()
18 : SwModelTestBase("/sw/qa/extras/pdf/data/")
22 void testNoHybridDataInPDF();
23 void testHybridWithAdditionalStreams();
24 void testHybridWithAdditionalStreamsAndAttachedFile();
26 CPPUNIT_TEST_SUITE(HybridPdfTest);
27 CPPUNIT_TEST(testNoHybridDataInPDF);
28 CPPUNIT_TEST(testHybridWithAdditionalStreams);
29 CPPUNIT_TEST(testHybridWithAdditionalStreamsAndAttachedFile);
30 CPPUNIT_TEST_SUITE_END();
33 void HybridPdfTest::testNoHybridDataInPDF()
35 // Load PDF document without attached ODT document
36 UnoApiXmlTest::load(createFileURL(u"PDFOnly.pdf"), nullptr);
37 CPPUNIT_ASSERT(mxComponent.is());
38 uno::Reference<lang::XServiceInfo> xServiceInfo(mxComponent, uno::UNO_QUERY_THROW);
39 // Draw document is expected in this case - default when importing PDF
40 CPPUNIT_ASSERT(xServiceInfo->supportsService("com.sun.star.drawing.DrawingDocument"));
43 void HybridPdfTest::testHybridWithAdditionalStreams()
45 // Load PDF document with an embedded ODT document
46 // The ODT document is embedded in "/AdditionalStreams" structure that is in the PDF trailer
47 createSwDoc("Hybrid_AdditionalStreamsOnly.pdf");
48 SwDoc* pDoc = getSwDoc();
49 CPPUNIT_ASSERT(pDoc);
51 // We can access the document text in a single paragraph that spans multiple rows
52 // This wouldn't be possible with a PDF, so the opened document has to be ODT
53 CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. \nThat didn't bode well."),
54 getParagraph(1)->getString());
57 void HybridPdfTest::testHybridWithAdditionalStreamsAndAttachedFile()
59 // Load PDF document with an embedded ODT document
60 // The ODT document is embedded in "/AdditionalStreams" structure that is in the PDF trailer
61 // and is included as an attached file conforming to the PDF specs
62 createSwDoc("Hybrid_AdditionalStreamsAndPDFAttachedFile.pdf");
63 SwDoc* pDoc = getSwDoc();
64 CPPUNIT_ASSERT(pDoc);
66 // We can access the document text in a single paragraph that spans multiple rows
67 // This wouldn't be possible with a PDF, so the opened document has to be ODT
68 CPPUNIT_ASSERT_EQUAL(OUString("He heard quiet steps behind him. \nThat didn't bode well."),
69 getParagraph(1)->getString());
72 CPPUNIT_TEST_SUITE_REGISTRATION(HybridPdfTest);
73 CPPUNIT_PLUGIN_IMPLEMENT();
75 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */