LCOV - code coverage report
Current view: top level - writerfilter/qa/cppunittests/rtftok - testrtftok.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 24 24 100.0 %
Date: 2014-04-11 Functions: 12 13 92.3 %
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 <unotest/filters-test.hxx>
      11             : #include <test/bootstrapfixture.hxx>
      12             : #include <com/sun/star/document/XFilter.hpp>
      13             : #include <com/sun/star/io/WrongFormatException.hpp>
      14             : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
      15             : 
      16             : #include <osl/file.hxx>
      17             : #include <osl/process.h>
      18             : 
      19             : using namespace ::com::sun::star;
      20             : 
      21             : /**
      22             :  * Unit test invoking the Writer RTF import filter.
      23             :  *
      24             :  * This does only minimal testing, checking if the filter crashes and returns
      25             :  * the expected bool value for given inputs. More fine-grained tests can be
      26             :  * found under sw/qa/extras/rtfimport/.
      27             :  */
      28           3 : class RtfTest
      29             :     : public test::FiltersTest
      30             :     , public test::BootstrapFixture
      31             : {
      32             : public:
      33             : 
      34             :     virtual void setUp() SAL_OVERRIDE;
      35             : 
      36             :     virtual bool load(const OUString&,
      37             :                       const OUString& rURL, const OUString&,
      38             :                       unsigned int, unsigned int, unsigned int) SAL_OVERRIDE;
      39             : 
      40             :     void test();
      41             : 
      42           2 :     CPPUNIT_TEST_SUITE(RtfTest);
      43           1 :     CPPUNIT_TEST(test);
      44           2 :     CPPUNIT_TEST_SUITE_END();
      45             : private:
      46             :     uno::Reference<document::XFilter> m_xFilter;
      47             : };
      48             : 
      49           1 : void RtfTest::setUp()
      50             : {
      51           1 :     test::BootstrapFixture::setUp();
      52             : 
      53           1 :     m_xFilter = uno::Reference< document::XFilter >(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
      54           1 : }
      55             : 
      56          16 : bool RtfTest::load(const OUString&,
      57             :                    const OUString& rURL, const OUString&,
      58             :                    unsigned int, unsigned int, unsigned int)
      59             : {
      60          16 :     uno::Sequence< beans::PropertyValue > aDescriptor(1);
      61          16 :     aDescriptor[0].Name = "URL";
      62          16 :     aDescriptor[0].Value <<= rURL;
      63             :     try
      64             :     {
      65          16 :         return m_xFilter->filter(aDescriptor);
      66             :     }
      67           2 :     catch (const lang::WrappedTargetRuntimeException& rWrapped)
      68             :     {
      69           2 :         io::WrongFormatException e;
      70           2 :         if (rWrapped.TargetException >>= e)
      71             :         {
      72           2 :             return false;
      73             :         }
      74           2 :         throw;
      75          16 :     }
      76             : }
      77             : 
      78           1 : void RtfTest::test()
      79             : {
      80             :     testDir(OUString(),
      81             :             getURLFromSrc("/writerfilter/qa/cppunittests/rtftok/data/"),
      82           1 :             OUString());
      83           1 : }
      84             : 
      85           1 : CPPUNIT_TEST_SUITE_REGISTRATION(RtfTest);
      86             : 
      87           4 : CPPUNIT_PLUGIN_IMPLEMENT();
      88             : 
      89             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10