update credits
[LibreOffice.git] / sw / qa / core / layout-test.cxx
blobcb4ba716075602b50590704d3509d21875f771ff
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());
76 SwLayoutTest::SwLayoutTest()
77 : m_aBaseString("/sw/qa/core/data")
81 void SwLayoutTest::setUp()
83 test::BootstrapFixture::setUp();
85 // This is a bit of a fudge, we do this to ensure that SwGlobals::ensure,
86 // which is a private symbol to us, gets called
87 m_xWriterComponent =
88 getMultiServiceFactory()->createInstance(OUString(
89 "com.sun.star.comp.Writer.TextDocument"));
90 CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xWriterComponent.is());
91 mxDesktop = com::sun::star::frame::Desktop::create( comphelper::getComponentContext(getMultiServiceFactory()) );
94 void SwLayoutTest::tearDown()
96 uno::Reference< lang::XComponent >( m_xWriterComponent, UNO_QUERY_THROW )->dispose();
97 test::BootstrapFixture::tearDown();
100 CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutTest);
102 CPPUNIT_PLUGIN_IMPLEMENT();
104 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */