LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/unotest/source/cpp - bootstrapfixturebase.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 31 31 100.0 %
Date: 2013-07-09 Functions: 8 9 88.9 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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             :  */
       9             : #include <unotest/bootstrapfixturebase.hxx>
      10             : #include <rtl/strbuf.hxx>
      11             : #include <rtl/bootstrap.hxx>
      12             : #include <cppuhelper/bootstrap.hxx>
      13             : #include <comphelper/processfactory.hxx>
      14             : 
      15             : #include <com/sun/star/lang/Locale.hpp>
      16             : #include <com/sun/star/lang/XComponent.hpp>
      17             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      18             : 
      19             : using namespace ::com::sun::star;
      20             : 
      21             : // NB. this constructor is called before any tests are run, once for each
      22             : // test function in a rather non-intuitive way. This is why all the 'real'
      23             : // heavy lifting is deferred until setUp. setUp and tearDown are interleaved
      24             : // between the tests as you might expect.
      25         377 : test::BootstrapFixtureBase::BootstrapFixtureBase()
      26         377 :     : m_aSrcRootURL("file://"), m_aSolverRootURL( m_aSrcRootURL )
      27             : {
      28             : #ifndef ANDROID
      29         377 :     const char* pSrcRoot = getenv( "SRC_ROOT" );
      30         377 :     CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != NULL && pSrcRoot[0] != 0);
      31         377 :     const char* pSolverRoot = getenv( "OUTDIR_FOR_BUILD" );
      32         377 :     CPPUNIT_ASSERT_MESSAGE("$OUTDIR_FOR_BUILD env variable not set", pSolverRoot != NULL && pSolverRoot[0] != 0);
      33         377 :     const char* pWorkdirRoot = getenv( "WORKDIR_FOR_BUILD" );
      34         377 :     CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != NULL && pWorkdirRoot[0] != 0);
      35             : #ifdef WNT
      36             :     if (pSrcRoot[1] == ':')
      37             :     {
      38             :         m_aSrcRootURL += "/";
      39             :     }
      40             :     if (pSolverRoot[1] == ':')
      41             :     {
      42             :         m_aSolverRootURL += "/";
      43             :     }
      44             :     if (pWorkdirRoot[1] == ':')
      45             :     {
      46             :         m_aWorkdirRootURL += "/";
      47             :     }
      48             : #endif
      49             : #else
      50             :     const char* pSrcRoot = "/assets";
      51             :     const char* pSolverRoot = "/assets";
      52             :     const char* pWorkdirRoot = "/assets";
      53             : #endif
      54         377 :     m_aSrcRootPath = OUString::createFromAscii( pSrcRoot );
      55         377 :     m_aSrcRootURL += m_aSrcRootPath;
      56             : 
      57         377 :     m_aSolverRootPath = OUString::createFromAscii( pSolverRoot );
      58         377 :     m_aSolverRootURL += m_aSolverRootPath;
      59             : 
      60         377 :     m_aWorkdirRootPath = OUString::createFromAscii( pWorkdirRoot );
      61         377 :     m_aWorkdirRootURL += m_aWorkdirRootPath;
      62             : 
      63         377 : }
      64             : 
      65         377 : test::BootstrapFixtureBase::~BootstrapFixtureBase()
      66             : {
      67         377 : }
      68             : 
      69         348 : OUString test::BootstrapFixtureBase::getURLFromSrc( const char *pPath )
      70             : {
      71         348 :     return m_aSrcRootURL + OUString::createFromAscii( pPath );
      72             : }
      73             : 
      74          26 : OUString test::BootstrapFixtureBase::getPathFromSrc( const char *pPath )
      75             : {
      76          26 :     return m_aSrcRootPath + OUString::createFromAscii( pPath );
      77             : }
      78             : 
      79             : // just temporarily ifdef this out as it's currently unused (callcatcher)
      80             : // if you start using it on linux just remove the ifdef
      81             : #ifndef LINUX
      82             : OUString test::BootstrapFixtureBase::getURLFromWorkdir( const char *pPath )
      83             : {
      84             :     return m_aWorkdirRootURL + OUString::createFromAscii( pPath );
      85             : }
      86             : 
      87             : OUString test::BootstrapFixtureBase::getPathFromWorkdir( const char *pPath )
      88             : {
      89             :     return m_aWorkdirRootPath + OUString::createFromAscii( pPath );
      90             : 
      91             : }
      92             : #endif
      93             : 
      94         377 : void test::BootstrapFixtureBase::setUp()
      95             : {
      96             :     // set UserInstallation to user profile dir in test/user-template
      97         377 :     rtl::Bootstrap aDefaultVars;
      98         754 :     OUString sUserInstallURL = m_aSolverRootURL + OUString("/unittest");
      99         377 :     aDefaultVars.set(OUString("UserInstallation"), sUserInstallURL);
     100             : 
     101         377 :     m_xContext = comphelper::getProcessComponentContext();
     102         377 :     m_xFactory = m_xContext->getServiceManager();
     103         754 :     m_xSFactory = uno::Reference<lang::XMultiServiceFactory>(m_xFactory, uno::UNO_QUERY_THROW);
     104         377 : }
     105             : 
     106         377 : void test::BootstrapFixtureBase::tearDown()
     107             : {
     108         569 : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10