bump product version to 5.0.4.1
[LibreOffice.git] / sd / qa / unit / filters-test.cxx
blob0115d5986c2e14706353464c6ffb5d8cb5617c7a
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 <sal/config.h>
11 #include <unotest/filters-test.hxx>
12 #include <test/bootstrapfixture.hxx>
13 #include <rtl/strbuf.hxx>
14 #include <osl/file.hxx>
15 #include <com/sun/star/lang/XComponent.hpp>
16 #include <com/sun/star/document/XFilter.hpp>
18 #include <sfx2/app.hxx>
19 #include <sfx2/docfilt.hxx>
20 #include <sfx2/docfile.hxx>
21 #include <sfx2/sfxmodelfactory.hxx>
22 #include <svl/stritem.hxx>
24 #include <svx/svdtext.hxx>
25 #include <svx/svdotext.hxx>
27 #include "drawdoc.hxx"
28 #include "../source/ui/inc/DrawDocShell.hxx"
30 #include <osl/process.h>
31 #include <osl/thread.h>
33 using namespace ::com::sun::star;
35 /// Test loading of files to assure they do not crash on load.
36 class SdFiltersTest
37 : public test::FiltersTest
38 , public test::BootstrapFixture
40 public:
41 SdFiltersTest();
43 virtual bool load( const OUString &rFilter,
44 const OUString &rURL, const OUString &rUserData,
45 SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
46 unsigned int nFilterVersion) SAL_OVERRIDE;
48 virtual void setUp() SAL_OVERRIDE;
49 virtual void tearDown() SAL_OVERRIDE;
51 // Ensure CVEs remain unbroken
52 void testCVEs();
54 CPPUNIT_TEST_SUITE(SdFiltersTest);
55 CPPUNIT_TEST(testCVEs);
56 CPPUNIT_TEST_SUITE_END();
58 private:
59 uno::Reference<uno::XInterface> m_xDrawComponent;
62 bool SdFiltersTest::load(const OUString &rFilter, const OUString &rURL,
63 const OUString &rUserData, SfxFilterFlags nFilterFlags, SotClipboardFormatId nClipboardID,
64 unsigned int nFilterVersion)
66 SfxFilter aFilter(
67 rFilter,
68 OUString(), nFilterFlags, nClipboardID, OUString(), 0, OUString(),
69 rUserData, OUString() );
70 aFilter.SetVersion(nFilterVersion);
72 ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
73 SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
74 pSrcMed->SetFilter(&aFilter);
75 bool bLoaded = xDocShRef->DoLoad(pSrcMed);
76 xDocShRef->DoClose();
77 return bLoaded;
80 void SdFiltersTest::testCVEs()
82 #ifndef DISABLE_CVE_TESTS
83 testDir(OUString("MS PowerPoint 97"),
84 getURLFromSrc("/sd/qa/unit/data/ppt/"),
85 OUString("sdfilt"));
87 testDir(OUString("Impress Office Open XML"),
88 getURLFromSrc("/sd/qa/unit/data/pptx/"),
89 OUString(""), (SfxFilterFlags::IMPORT | SfxFilterFlags::ALIEN | SfxFilterFlags::STARONEFILTER));
91 testDir(OUString("impress8"),
92 getURLFromSrc("/sd/qa/unit/data/odp/"),
93 OUString("sdfilt"));
95 testDir(OUString("draw8"),
96 getURLFromSrc("/sd/qa/unit/data/odg/"),
97 OUString("sdfilt"));
99 testDir(OUString("CGM - Computer Graphics Metafile"),
100 getURLFromSrc("/sd/qa/unit/data/cgm/"),
101 OUString("icg"));
102 #endif
105 SdFiltersTest::SdFiltersTest()
109 void SdFiltersTest::setUp()
111 test::BootstrapFixture::setUp();
113 // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
114 // which is a private symbol to us, gets called
115 m_xDrawComponent =
116 getMultiServiceFactory()->createInstance("com.sun.star.comp.Draw.PresentationDocument");
117 CPPUNIT_ASSERT_MESSAGE("no impress component!", m_xDrawComponent.is());
120 void SdFiltersTest::tearDown()
122 uno::Reference< lang::XComponent >( m_xDrawComponent, uno::UNO_QUERY_THROW )->dispose();
123 test::BootstrapFixture::tearDown();
126 CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
128 CPPUNIT_PLUGIN_IMPLEMENT();
130 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */