/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace ::com::sun::star::uno; using namespace com::sun::star; /* Implementation of Macros test */ class SwLayoutTest : public test::BootstrapFixture, public unotest::MacrosTest { public: SwLayoutTest(); void createFileURL(const OUString& aFileBase, const OUString& aFileExtension, OUString& rFilePath); virtual void setUp(); virtual void tearDown(); void test(); CPPUNIT_TEST_SUITE(SwLayoutTest); #if !defined(MACOSX) && !defined(WNT) CPPUNIT_TEST(test); #endif CPPUNIT_TEST_SUITE_END(); private: uno::Reference m_xWriterComponent; OUString m_aBaseString; }; void SwLayoutTest::createFileURL(const OUString& aFileBase, const OUString& aFileExtension, OUString& rFilePath) { OUString aSep("/"); OUStringBuffer aBuffer( getSrcRootURL() ); aBuffer.append(m_aBaseString).append(aSep).append(aFileExtension); aBuffer.append(aSep).append(aFileBase).append(aFileExtension); rFilePath = aBuffer.makeStringAndClear(); } void SwLayoutTest::test() { OUString aFilePath; OUString aFileBase("test."); OUString aExtension("odt"); createFileURL(aFileBase, aExtension, aFilePath); uno::Reference< lang::XComponent > xComponent = loadFromDesktop(aFilePath, "com.sun.star.text.TextDocument"); CPPUNIT_ASSERT(xComponent.is()); } SwLayoutTest::SwLayoutTest() : m_aBaseString("/sw/qa/core/data") { } void SwLayoutTest::setUp() { test::BootstrapFixture::setUp(); // This is a bit of a fudge, we do this to ensure that SwGlobals::ensure, // which is a private symbol to us, gets called m_xWriterComponent = getMultiServiceFactory()->createInstance(OUString( "com.sun.star.comp.Writer.TextDocument")); CPPUNIT_ASSERT_MESSAGE("no calc component!", m_xWriterComponent.is()); mxDesktop = com::sun::star::frame::Desktop::create( comphelper::getComponentContext(getMultiServiceFactory()) ); } void SwLayoutTest::tearDown() { uno::Reference< lang::XComponent >( m_xWriterComponent, UNO_QUERY_THROW )->dispose(); test::BootstrapFixture::tearDown(); } CPPUNIT_TEST_SUITE_REGISTRATION(SwLayoutTest); CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */