LCOV - code coverage report
Current view: top level - test/source - bootstrapfixture.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 46 84.8 %
Date: 2012-08-25 Functions: 8 10 80.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 45 120 37.5 %

           Branch data     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 <ucbhelper/contentbroker.hxx>
      35                 :            : #include <comphelper/processfactory.hxx>
      36                 :            : #include <i18npool/mslangid.hxx>
      37                 :            : 
      38                 :            : #include <com/sun/star/lang/Locale.hpp>
      39                 :            : #include <com/sun/star/lang/XComponent.hpp>
      40                 :            : #include <com/sun/star/lang/XMultiServiceFactory.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 String &rErr, const String &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                 :        919 : test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB )
      63                 :            :     : m_bNeedUCB( bNeedUCB )
      64                 :        919 :     , m_bAssertOnDialog( bAssertOnDialog )
      65                 :            : {
      66                 :        919 : }
      67                 :            : 
      68                 :        919 : void test::BootstrapFixture::setUp()
      69                 :            : {
      70         [ +  - ]:        919 :     test::BootstrapFixtureBase::setUp();
      71                 :            : 
      72                 :            :     // force locale (and resource files loaded) to en-US
      73                 :        919 :     const LanguageType eLang=LANGUAGE_ENGLISH_US;
      74                 :            : 
      75                 :        919 :     OUString aLang, aCountry;
      76         [ +  - ]:        919 :     MsLangId::convertLanguageToIsoNames(eLang, aLang, aCountry);
      77                 :        919 :     lang::Locale aLocale(aLang, aCountry, OUString());
      78         [ +  - ]:        919 :     ResMgr::SetDefaultLocale( aLocale );
      79                 :            : 
      80         [ +  + ]:        919 :     if (m_bNeedUCB)
      81                 :            :     {
      82                 :            :         // initialise UCB-Broker
      83         [ +  - ]:        904 :         uno::Sequence<uno::Any> aUcbInitSequence(2);
      84 [ +  - ][ +  - ]:        904 :         aUcbInitSequence[0] <<= OUString("Local");
      85 [ +  - ][ +  - ]:        904 :         aUcbInitSequence[1] <<= OUString("Office");
      86         [ +  - ]:        904 :         bool bInitUcb = ucbhelper::ContentBroker::initialize(m_xSFactory, aUcbInitSequence);
      87 [ +  - ][ +  - ]:        904 :         CPPUNIT_ASSERT_MESSAGE("Should be able to initialize UCB", bInitUcb);
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ +  - ]
      88                 :            : 
      89                 :            :         uno::Reference<ucb::XContentProviderManager> xUcb =
      90 [ +  - ][ +  - ]:        904 :             ucbhelper::ContentBroker::get()->getContentProviderManagerInterface();
      91 [ +  - ][ +  - ]:        904 :         uno::Reference<ucb::XContentProvider> xFileProvider(m_xSFactory->createInstance("com.sun.star.ucb.FileContentProvider"), uno::UNO_QUERY);
                 [ +  - ]
      92 [ +  - ][ +  - ]:        904 :         xUcb->registerContentProvider(xFileProvider, "file", sal_True);
                 [ +  - ]
      93                 :            :     }
      94                 :            : 
      95         [ +  - ]:        919 :     SvtSysLocaleOptions aLocalOptions;
      96         [ +  - ]:        919 :     OUString aLangISO = MsLangId::convertLanguageToIsoString( LANGUAGE_ENGLISH_US );
      97         [ +  - ]:        919 :     aLocalOptions.SetLocaleConfigString( aLangISO );
      98         [ +  - ]:        919 :     aLocalOptions.SetUILocaleConfigString( aLangISO );
      99                 :            : 
     100         [ +  - ]:        919 :     InitVCL(m_xSFactory);
     101 [ +  - ][ +  - ]:        919 :     if (Application::IsHeadlessModeRequested())
     102         [ +  - ]:        919 :         Application::EnableHeadlessMode(true);
     103                 :            : 
     104         [ +  - ]:        919 :     if( m_bAssertOnDialog )
     105         [ +  - ]:        919 :         ErrorHandler::RegisterDisplay( aBasicErrorFunc );
     106                 :            : 
     107                 :            :     // Make GraphicConverter work, normally done in desktop::Desktop::Main()
     108 [ +  - ][ +  - ]:        919 :     Application::SetFilterHdl( LINK( this, test::BootstrapFixture, ImplInitFilterHdl ) );
                 [ +  - ]
     109                 :        919 : }
     110                 :            : 
     111                 :        919 : void test::BootstrapFixture::tearDown()
     112                 :            : {
     113                 :        919 :     ucbhelper::ContentBroker::deinitialize();
     114                 :        919 :     test::BootstrapFixtureBase::tearDown();
     115                 :        919 : }
     116                 :            : 
     117                 :        919 : test::BootstrapFixture::~BootstrapFixture()
     118                 :            : {
     119         [ -  + ]:        919 : }
     120                 :            : 
     121                 :        186 : IMPL_LINK( test::BootstrapFixture, ImplInitFilterHdl, ConvertData*, pData )
     122                 :            : {
     123         [ +  - ]:        186 :     return GraphicFilter::GetGraphicFilter().GetFilterCallback().Call( pData );
     124 [ +  - ][ +  - ]:        315 : }
     125                 :            : 
     126                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10