LCOV - code coverage report
Current view: top level - libreoffice/test/source - bootstrapfixture.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 35 42 83.3 %
Date: 2012-12-27 Functions: 8 10 80.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             :  * Version: MPL 1.1 / GPLv3+ / LGPLv3+
       4             :  *
       5             :  * The contents of this file are subject to the Mozilla Public License Version
       6             :  * 1.1 (the "License"); you may not use this file except in compliance with
       7             :  * the License or as specified alternatively below. You may obtain a copy of
       8             :  * the License at http://www.mozilla.org/MPL/
       9             :  *
      10             :  * Software distributed under the License is distributed on an "AS IS" basis,
      11             :  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
      12             :  * for the specific language governing rights and limitations under the
      13             :  * License.
      14             :  *
      15             :  * Major Contributor(s):
      16             :  *   Copyright (C) 2011 Michael Meeks <michael.meeks@suse.com>
      17             :  *   Caolán McNamara <caolanm@redhat.com>
      18             :  *
      19             :  * All Rights Reserved.
      20             :  *
      21             :  * For minor contributions see the git repository.
      22             :  *
      23             :  * Alternatively, the contents of this file may be used under the terms of
      24             :  * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
      25             :  * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
      26             :  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
      27             :  * instead of those above.
      28             :  */
      29             : #include <test/bootstrapfixture.hxx>
      30             : #include <tools/errinf.hxx>
      31             : #include <rtl/strbuf.hxx>
      32             : #include <rtl/bootstrap.hxx>
      33             : #include <cppuhelper/bootstrap.hxx>
      34             : #include <comphelper/processfactory.hxx>
      35             : 
      36             : #include <com/sun/star/lang/Locale.hpp>
      37             : #include <com/sun/star/lang/XComponent.hpp>
      38             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      39             : #include <com/sun/star/ucb/XContentProvider.hpp>
      40             : #include <com/sun/star/ucb/XUniversalContentBroker.hpp>
      41             : 
      42             : #include <vcl/svapp.hxx>
      43             : #include <tools/resmgr.hxx>
      44             : #include <svtools/filter.hxx>
      45             : #include <unotools/syslocaleoptions.hxx>
      46             : 
      47             : using namespace ::com::sun::star;
      48             : 
      49           0 : static void aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
      50             : {
      51           0 :     OStringBuffer aErr( "Unexpected dialog: " );
      52           0 :     aErr.append( OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) );
      53           0 :     aErr.append( " Error: " );
      54           0 :     aErr.append( OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ) );
      55           0 :     CPPUNIT_ASSERT_MESSAGE( aErr.getStr(), false);
      56           0 : }
      57             : 
      58             : // NB. this constructor is called before any tests are run, once for each
      59             : // test function in a rather non-intuitive way. This is why all the 'real'
      60             : // heavy lifting is deferred until setUp. setUp and tearDown are interleaved
      61             : // between the tests as you might expect.
      62         186 : test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB )
      63             :     : m_bNeedUCB( bNeedUCB )
      64         186 :     , m_bAssertOnDialog( bAssertOnDialog )
      65             : {
      66         186 : }
      67             : 
      68         186 : void test::BootstrapFixture::setUp()
      69             : {
      70         186 :     test::BootstrapFixtureBase::setUp();
      71             : 
      72             :     // force locale (and resource files loaded) to en-US
      73             : 
      74         186 :     lang::Locale aLocale( "en", "US", "");
      75         186 :     ResMgr::SetDefaultLocale( aLocale );
      76             : 
      77         186 :     SvtSysLocaleOptions aLocalOptions;
      78         186 :     OUString aLangISO( "en-US" );
      79         186 :     aLocalOptions.SetLocaleConfigString( aLangISO );
      80         186 :     aLocalOptions.SetUILocaleConfigString( aLangISO );
      81             : 
      82         186 :     InitVCL();
      83         186 :     if (Application::IsHeadlessModeRequested())
      84         186 :         Application::EnableHeadlessMode(true);
      85             : 
      86         186 :     if( m_bAssertOnDialog )
      87         183 :         ErrorHandler::RegisterDisplay( aBasicErrorFunc );
      88             : 
      89             :     // Make GraphicConverter work, normally done in desktop::Desktop::Main()
      90         186 :     Application::SetFilterHdl( LINK( this, test::BootstrapFixture, ImplInitFilterHdl ) );
      91             : 
      92         186 :     if (m_bNeedUCB)
      93             :     {
      94             :         // initialise unconfigured UCB:
      95         171 :         uno::Reference<ucb::XUniversalContentBroker> xUcb(m_xSFactory->createInstance("com.sun.star.ucb.UniversalContentBroker"), uno::UNO_QUERY_THROW);
      96         171 :         uno::Reference<ucb::XContentProvider> xFileProvider(m_xSFactory->createInstance("com.sun.star.ucb.FileContentProvider"), uno::UNO_QUERY_THROW);
      97         171 :         xUcb->registerContentProvider(xFileProvider, "file", sal_True);
      98         171 :         uno::Reference<ucb::XContentProvider> xTdocProvider(m_xSFactory->createInstance("com.sun.star.ucb.TransientDocumentsContentProvider"), uno::UNO_QUERY);
      99         171 :         if (xTdocProvider.is())
     100             :         {
     101          73 :             xUcb->registerContentProvider(xTdocProvider, "vnd.sun.star.tdoc", sal_True);
     102         171 :         }
     103         186 :     }
     104         186 : }
     105             : 
     106         186 : void test::BootstrapFixture::tearDown()
     107             : {
     108         186 :     test::BootstrapFixtureBase::tearDown();
     109         186 : }
     110             : 
     111         186 : test::BootstrapFixture::~BootstrapFixture()
     112             : {
     113         186 : }
     114             : 
     115         130 : IMPL_LINK( test::BootstrapFixture, ImplInitFilterHdl, ConvertData*, pData )
     116             : {
     117          65 :     return GraphicFilter::GetGraphicFilter().GetFilterCallback().Call( pData );
     118          96 : }
     119             : 
     120             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10