Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * Version: MPL 1.1 / GPLv3+ / LGPLv3+
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Initial Developer of the Original Code is
16 : * Miklos Vajna <vmiklos@frugalware.org>
17 : * Portions created by the Initial Developer are Copyright (C) 2011 the
18 : * Initial Developer. All Rights Reserved.
19 : *
20 : * Contributor(s):
21 : *
22 : * Alternatively, the contents of this file may be used under the terms of
23 : * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
24 : * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
25 : * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
26 : * instead of those above.
27 : */
28 :
29 : #include <unotest/filters-test.hxx>
30 : #include <test/bootstrapfixture.hxx>
31 : #include <com/sun/star/document/XFilter.hpp>
32 : #include <com/sun/star/io/WrongFormatException.hpp>
33 : #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
34 :
35 : #include <osl/file.hxx>
36 : #include <osl/process.h>
37 :
38 : using namespace ::com::sun::star;
39 :
40 3 : class RtfTest
41 : : public test::FiltersTest
42 : , public test::BootstrapFixture
43 : {
44 : public:
45 :
46 : virtual void setUp();
47 :
48 : virtual bool load(const rtl::OUString &,
49 : const rtl::OUString &rURL, const rtl::OUString &,
50 : unsigned int, unsigned int, unsigned int);
51 :
52 : void test();
53 :
54 2 : CPPUNIT_TEST_SUITE(RtfTest);
55 1 : CPPUNIT_TEST(test);
56 2 : CPPUNIT_TEST_SUITE_END();
57 : private:
58 : uno::Reference<document::XFilter> m_xFilter;
59 : };
60 :
61 1 : void RtfTest::setUp()
62 : {
63 1 : test::BootstrapFixture::setUp();
64 :
65 1 : m_xFilter = uno::Reference< document::XFilter >(m_xSFactory->createInstance("com.sun.star.comp.Writer.RtfFilter"), uno::UNO_QUERY_THROW);
66 1 : }
67 :
68 11 : bool RtfTest::load(const rtl::OUString &,
69 : const rtl::OUString &rURL, const rtl::OUString &,
70 : unsigned int, unsigned int, unsigned int)
71 : {
72 11 : uno::Sequence< beans::PropertyValue > aDescriptor(1);
73 11 : aDescriptor[0].Name = "URL";
74 11 : aDescriptor[0].Value <<= rURL;
75 : try
76 : {
77 11 : return m_xFilter->filter(aDescriptor);
78 : }
79 2 : catch (const lang::WrappedTargetRuntimeException& rWrapped)
80 : {
81 2 : io::WrongFormatException e;
82 2 : if (rWrapped.TargetException >>= e)
83 : {
84 2 : return false;
85 : }
86 2 : throw;
87 11 : }
88 : }
89 :
90 1 : void RtfTest::test()
91 : {
92 : testDir(OUString(),
93 : getURLFromSrc("/writerfilter/qa/cppunittests/rtftok/data/"),
94 1 : OUString());
95 1 : }
96 :
97 1 : CPPUNIT_TEST_SUITE_REGISTRATION(RtfTest);
98 :
99 4 : CPPUNIT_PLUGIN_IMPLEMENT();
100 :
101 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|