LCOV - code coverage report
Current view: top level - unotest/source/cpp - bootstrapfixturebase.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 37 0.0 %
Date: 2014-04-14 Functions: 0 12 0.0 %
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             : 
      10             : #include "sal/config.h"
      11             : 
      12             : #include <unotest/bootstrapfixturebase.hxx>
      13             : #include <osl/file.hxx>
      14             : #include <rtl/strbuf.hxx>
      15             : #include <rtl/bootstrap.hxx>
      16             : #include <cppuhelper/bootstrap.hxx>
      17             : #include <comphelper/processfactory.hxx>
      18             : 
      19             : #include <com/sun/star/lang/Locale.hpp>
      20             : #include <com/sun/star/lang/XComponent.hpp>
      21             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      22             : 
      23             : using namespace ::com::sun::star;
      24             : 
      25             : namespace {
      26             : 
      27           0 : OUString getFileURLFromSystemPath(OUString const & path) {
      28           0 :     OUString url;
      29           0 :     osl::FileBase::RC e = osl::FileBase::getFileURLFromSystemPath(path, url);
      30           0 :     CPPUNIT_ASSERT_EQUAL(osl::FileBase::E_None, e);
      31           0 :     if (!url.endsWith("/")) {
      32           0 :         url += "/";
      33             :     }
      34           0 :     return url;
      35             : }
      36             : 
      37             : }
      38             : 
      39             : // NB. this constructor is called before any tests are run, once for each
      40             : // test function in a rather non-intuitive way. This is why all the 'real'
      41             : // heavy lifting is deferred until setUp. setUp and tearDown are interleaved
      42             : // between the tests as you might expect.
      43           0 : test::BootstrapFixtureBase::BootstrapFixtureBase()
      44             : {
      45             : #ifndef ANDROID
      46           0 :     const char* pSrcRoot = getenv( "SRC_ROOT" );
      47           0 :     CPPUNIT_ASSERT_MESSAGE("SRC_ROOT env variable not set", pSrcRoot != NULL && pSrcRoot[0] != 0);
      48           0 :     const char* pWorkdirRoot = getenv( "WORKDIR_FOR_BUILD" );
      49           0 :     CPPUNIT_ASSERT_MESSAGE("$WORKDIR_FOR_BUILD env variable not set", pWorkdirRoot != NULL && pWorkdirRoot[0] != 0);
      50             : #else
      51             :     const char* pSrcRoot = "/assets";
      52             :     const char* pWorkdirRoot = "/assets";
      53             : #endif
      54           0 :     m_aSrcRootPath = OUString::createFromAscii( pSrcRoot );
      55           0 :     m_aSrcRootURL = getFileURLFromSystemPath(m_aSrcRootPath);
      56             : 
      57           0 :     m_aWorkdirRootPath = OUString::createFromAscii( pWorkdirRoot );
      58           0 :     m_aWorkdirRootURL = getFileURLFromSystemPath(m_aWorkdirRootPath);
      59             : 
      60           0 : }
      61             : 
      62           0 : test::BootstrapFixtureBase::~BootstrapFixtureBase()
      63             : {
      64           0 : }
      65             : 
      66           0 : OUString test::BootstrapFixtureBase::getURLFromSrc( const char *pPath )
      67             : {
      68           0 :     return m_aSrcRootURL + OUString::createFromAscii( pPath );
      69             : }
      70             : 
      71           0 : OUString test::BootstrapFixtureBase::getURLFromSrc( const OUString& rPath )
      72             : {
      73           0 :     return m_aSrcRootURL + rPath;
      74             : }
      75             : 
      76           0 : OUString test::BootstrapFixtureBase::getPathFromSrc( const char *pPath )
      77             : {
      78           0 :     return m_aSrcRootPath + OUString::createFromAscii( pPath );
      79             : }
      80             : 
      81           0 : OUString test::BootstrapFixtureBase::getURLFromWorkdir( const char *pPath )
      82             : {
      83           0 :     return m_aWorkdirRootURL + OUString::createFromAscii( pPath );
      84             : }
      85             : 
      86             : #ifdef _WIN32 // ifdef just to keep it out of unusedcode.easy
      87             : OUString test::BootstrapFixtureBase::getPathFromWorkdir( const char *pPath )
      88             : {
      89             :     return m_aWorkdirRootPath + OUString::createFromAscii( pPath );
      90             : 
      91             : }
      92             : #endif
      93             : 
      94           0 : void test::BootstrapFixtureBase::setUp()
      95             : {
      96             :     // set UserInstallation to user profile dir in test/user-template
      97           0 :     rtl::Bootstrap aDefaultVars;
      98           0 :     OUString sUserInstallURL = m_aWorkdirRootURL + "/unittest";
      99           0 :     aDefaultVars.set(OUString("UserInstallation"), sUserInstallURL);
     100             : 
     101           0 :     m_xContext = comphelper::getProcessComponentContext();
     102           0 :     m_xFactory = m_xContext->getServiceManager();
     103           0 :     m_xSFactory = uno::Reference<lang::XMultiServiceFactory>(m_xFactory, uno::UNO_QUERY_THROW);
     104           0 : }
     105             : 
     106           0 : void test::BootstrapFixtureBase::tearDown()
     107             : {
     108           0 : }
     109             : 
     110             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10