LCOV - code coverage report
Current view: top level - sd/qa/unit - filters-test.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 32 32 100.0 %
Date: 2014-04-11 Functions: 13 14 92.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  */
       9             : 
      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>
      17             : 
      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>
      23             : 
      24             : #include <svx/svdtext.hxx>
      25             : #include <svx/svdotext.hxx>
      26             : 
      27             : #include "drawdoc.hxx"
      28             : #include "../source/ui/inc/DrawDocShell.hxx"
      29             : 
      30             : #include <osl/process.h>
      31             : #include <osl/thread.h>
      32             : 
      33             : using namespace ::com::sun::star;
      34             : 
      35             : /// Test loading of files to assure they do not crash on load.
      36           2 : class SdFiltersTest
      37             :     : public test::FiltersTest
      38             :     , public test::BootstrapFixture
      39             : {
      40             : public:
      41             :     SdFiltersTest();
      42             : 
      43             :     virtual bool load( const OUString &rFilter,
      44             :         const OUString &rURL, const OUString &rUserData,
      45             :         unsigned int nFilterFlags, unsigned int nClipboardID,
      46             :         unsigned int nFilterVersion) SAL_OVERRIDE;
      47             : 
      48             :     virtual void setUp() SAL_OVERRIDE;
      49             :     virtual void tearDown() SAL_OVERRIDE;
      50             : 
      51             :     // Ensure CVEs remain unbroken
      52             :     void testCVEs();
      53             : 
      54           2 :     CPPUNIT_TEST_SUITE(SdFiltersTest);
      55           1 :     CPPUNIT_TEST(testCVEs);
      56           2 :     CPPUNIT_TEST_SUITE_END();
      57             : 
      58             : private:
      59             :     uno::Reference<uno::XInterface> m_xDrawComponent;
      60             : };
      61             : 
      62           8 : bool SdFiltersTest::load(const OUString &rFilter, const OUString &rURL,
      63             :     const OUString &rUserData, unsigned int nFilterFlags, unsigned int nClipboardID,
      64             :     unsigned int nFilterVersion)
      65             : {
      66             :     SfxFilter aFilter(
      67             :         rFilter,
      68             :         OUString(), nFilterFlags, nClipboardID, OUString(), 0, OUString(),
      69           8 :         rUserData, OUString() );
      70           8 :     aFilter.SetVersion(nFilterVersion);
      71             : 
      72          16 :     ::sd::DrawDocShellRef xDocShRef = new ::sd::DrawDocShell();
      73           8 :     SfxMedium* pSrcMed = new SfxMedium(rURL, STREAM_STD_READ);
      74           8 :     pSrcMed->SetFilter(&aFilter);
      75           8 :     bool bLoaded = xDocShRef->DoLoad(pSrcMed);
      76           8 :     xDocShRef->DoClose();
      77          16 :     return bLoaded;
      78             : }
      79             : 
      80           1 : void SdFiltersTest::testCVEs()
      81             : {
      82             : #ifndef DISABLE_CVE_TESTS
      83             :     testDir(OUString("MS PowerPoint 97"),
      84             :             getURLFromSrc("/sd/qa/unit/data/ppt/"),
      85           1 :             OUString("sdfilt"));
      86             : 
      87             :     testDir(OUString("impress8"),
      88             :             getURLFromSrc("/sd/qa/unit/data/odp/"),
      89           1 :             OUString("sdfilt"));
      90             : 
      91             :     testDir(OUString("draw8"),
      92             :             getURLFromSrc("/sd/qa/unit/data/odg/"),
      93           1 :             OUString("sdfilt"));
      94             : #endif
      95           1 : }
      96             : 
      97           1 : SdFiltersTest::SdFiltersTest()
      98             : {
      99           1 : }
     100             : 
     101           1 : void SdFiltersTest::setUp()
     102             : {
     103           1 :     test::BootstrapFixture::setUp();
     104             : 
     105             :     // This is a bit of a fudge, we do this to ensure that ScGlobals::ensure,
     106             :     // which is a private symbol to us, gets called
     107           2 :     m_xDrawComponent =
     108           3 :         getMultiServiceFactory()->createInstance("com.sun.star.comp.Draw.PresentationDocument");
     109           1 :     CPPUNIT_ASSERT_MESSAGE("no impress component!", m_xDrawComponent.is());
     110           1 : }
     111             : 
     112           1 : void SdFiltersTest::tearDown()
     113             : {
     114           1 :     uno::Reference< lang::XComponent >( m_xDrawComponent, uno::UNO_QUERY_THROW )->dispose();
     115           1 :     test::BootstrapFixture::tearDown();
     116           1 : }
     117             : 
     118           1 : CPPUNIT_TEST_SUITE_REGISTRATION(SdFiltersTest);
     119             : 
     120           4 : CPPUNIT_PLUGIN_IMPLEMENT();
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10