Updated core
[LibreOffice.git] / writerfilter / qa / cppunittests / rtftok / testrtftok.cxx
blob3342f121f998e4a15a84c5127a03994e463bc83b
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 <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>
16 #include <osl/file.hxx>
17 #include <osl/process.h>
19 using namespace ::com::sun::star;
21 /**
22 * Unit test invoking the Writer RTF import filter.
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/.
28 class RtfTest
29 : public test::FiltersTest
30 , public test::BootstrapFixture
32 public:
34 virtual void setUp();
36 virtual bool load(const OUString &,
37 const OUString &rURL, const OUString &,
38 unsigned int, unsigned int, unsigned int);
40 void test();
42 CPPUNIT_TEST_SUITE(RtfTest);
43 CPPUNIT_TEST(test);
44 CPPUNIT_TEST_SUITE_END();
45 private:
46 uno::Reference<document::XFilter> m_xFilter;
49 void RtfTest::setUp()
51 test::BootstrapFixture::setUp();
53 m_xFilter = uno::Reference< document::XFilter >(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
56 bool RtfTest::load(const OUString &,
57 const OUString &rURL, const OUString &,
58 unsigned int, unsigned int, unsigned int)
60 uno::Sequence< beans::PropertyValue > aDescriptor(1);
61 aDescriptor[0].Name = "URL";
62 aDescriptor[0].Value <<= rURL;
63 try
65 return m_xFilter->filter(aDescriptor);
67 catch (const lang::WrappedTargetRuntimeException& rWrapped)
69 io::WrongFormatException e;
70 if (rWrapped.TargetException >>= e)
72 return false;
74 throw;
78 void RtfTest::test()
80 testDir(OUString(),
81 getURLFromSrc("/writerfilter/qa/cppunittests/rtftok/data/"),
82 OUString());
85 CPPUNIT_TEST_SUITE_REGISTRATION(RtfTest);
87 CPPUNIT_PLUGIN_IMPLEMENT();
89 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */