bump product version to 5.0.4.1
[LibreOffice.git] / sw / qa / core / layout-test.cxx
blob7539713c70b930bc4dea8d94dec497a1ec01b229
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/macros_test.hxx>
12 #include <test/bootstrapfixture.hxx>
13 #include <rtl/strbuf.hxx>
14 #include <osl/file.hxx>
16 #include <com/sun/star/frame/Desktop.hpp>
18 #include <com/sun/star/lang/XComponent.hpp>
19 #include <com/sun/star/frame/XComponentLoader.hpp>
20 #include <com/sun/star/document/MacroExecMode.hpp>
22 #include <sfx2/app.hxx>
23 #include <sfx2/docfilt.hxx>
24 #include <sfx2/docfile.hxx>
25 #include <sfx2/sfxmodelfactory.hxx>
26 #include <svl/intitem.hxx>
28 using namespace ::com::sun::star::uno;
29 using namespace com::sun::star;
31 /* Implementation of Macros test */
33 class SwLayoutTest : public test::BootstrapFixture, public unotest::MacrosTest
35 public:
36 SwLayoutTest();
38 void createFileURL(const OUString& aFileBase, const OUString& aFileExtension, OUString& rFilePath);
40 virtual void setUp();
41 virtual void tearDown();
43 void test();
45 CPPUNIT_TEST_SUITE(SwLayoutTest);
46 #if !defined(MACOSX) && !defined(WNT)
47 CPPUNIT_TEST(test);
48 #endif
49 CPPUNIT_TEST_SUITE_END();
51 private:
52 uno::Reference<uno::XInterface> m_xWriterComponent;
53 OUString m_aBaseString;
56 void SwLayoutTest::createFileURL(const OUString& aFileBase, const OUString& aFileExtension, OUString& rFilePath)
58 OUString aSep("/");
59 OUStringBuffer aBuffer( getSrcRootURL() );
60 aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension);
61 aBuffer.append(aSep).append(aFileBase).append(aFileExtension);
62 rFilePath = aBuffer.makeStringAndClear();
65 void SwLayoutTest::test()
67 OUString aFilePath;
68 OUString aFileBase("test.");
69 OUString aExtension("odt");
70 createFileURL(aFileBase, aExtension, aFilePath);
71 uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFilePath, "com.sun.star.text.TextDocument");
72 CPPUNIT_ASSERT(xComponent.is());
75 SwLayoutTest::SwLayoutTest()
76 : m_aBaseString("/sw/qa/core/data")
80 void SwLayoutTest::setUp()
82 test::BootstrapFixture::setUp();
84 // This is a bit of a fudge, we do this to ensure that SwGlobals::ensure,
85 // which is a private symbol to us, gets called
86 m_xWriterComponent =
87 getMultiServiceFactory()->createInstance(OUString(
88 "com.sun.star.comp.Writer.TextDocument"));
89 CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xWriterComponent.is());
90 mxDesktop = com::sun::star::frame::Desktop::create( comphelper::getComponentContext(getMultiServiceFactory()) );
93 void SwLayoutTest::tearDown()
95 uno::Reference< lang::XComponent >( m_xWriterComponent, UNO_QUERY_THROW )->dispose();
96 test::BootstrapFixture::tearDown();
99 CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutTest);
101 CPPUNIT_PLUGIN_IMPLEMENT();
103 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */