2011-09-28 13:48:34 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
|
|
|
/*
|
|
|
|
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License or as specified alternatively below. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* Major Contributor(s):
|
|
|
|
* Copyright (C) 2011 Michael Meeks <michael.meeks@suse.com>
|
|
|
|
* Caolán McNamara <caolanm@redhat.com>
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* For minor contributions see the git repository.
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
|
|
|
|
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
|
|
|
|
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
|
|
|
|
* instead of those above.
|
|
|
|
*/
|
|
|
|
#include <test/bootstrapfixture.hxx>
|
|
|
|
#include <tools/errinf.hxx>
|
|
|
|
#include <rtl/strbuf.hxx>
|
2011-09-29 18:30:06 +02:00
|
|
|
#include <rtl/bootstrap.hxx>
|
2011-09-28 13:48:34 +01:00
|
|
|
#include <cppuhelper/bootstrap.hxx>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/lang/Locale.hpp>
|
|
|
|
#include <com/sun/star/lang/XComponent.hpp>
|
|
|
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
2012-09-14 18:08:57 +02:00
|
|
|
#include <com/sun/star/ucb/XContentProvider.hpp>
|
|
|
|
#include <com/sun/star/ucb/XUniversalContentBroker.hpp>
|
2011-09-28 13:48:34 +01:00
|
|
|
|
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <tools/resmgr.hxx>
|
2013-01-02 22:07:41 +01:00
|
|
|
#include <vcl/graphicfilter.hxx>
|
2011-09-28 13:48:34 +01:00
|
|
|
#include <unotools/syslocaleoptions.hxx>
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
2012-10-04 17:13:24 +02:00
|
|
|
static void aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
|
2011-09-28 13:48:34 +01:00
|
|
|
{
|
2012-08-01 21:35:08 +02:00
|
|
|
OStringBuffer aErr( "Unexpected dialog: " );
|
|
|
|
aErr.append( OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) );
|
2011-09-28 13:48:34 +01:00
|
|
|
aErr.append( " Error: " );
|
2012-08-01 21:35:08 +02:00
|
|
|
aErr.append( OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ) );
|
2011-09-28 13:48:34 +01:00
|
|
|
CPPUNIT_ASSERT_MESSAGE( aErr.getStr(), false);
|
|
|
|
}
|
|
|
|
|
2011-10-05 16:00:44 +01:00
|
|
|
// NB. this constructor is called before any tests are run, once for each
|
|
|
|
// test function in a rather non-intuitive way. This is why all the 'real'
|
|
|
|
// heavy lifting is deferred until setUp. setUp and tearDown are interleaved
|
|
|
|
// between the tests as you might expect.
|
2011-09-30 12:39:08 +01:00
|
|
|
test::BootstrapFixture::BootstrapFixture( bool bAssertOnDialog, bool bNeedUCB )
|
2011-10-05 16:00:44 +01:00
|
|
|
: m_bNeedUCB( bNeedUCB )
|
|
|
|
, m_bAssertOnDialog( bAssertOnDialog )
|
2011-09-28 13:48:34 +01:00
|
|
|
{
|
2012-04-13 11:13:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void test::BootstrapFixture::setUp()
|
|
|
|
{
|
|
|
|
test::BootstrapFixtureBase::setUp();
|
|
|
|
|
2011-10-05 16:00:44 +01:00
|
|
|
// force locale (and resource files loaded) to en-US
|
|
|
|
|
2012-11-17 01:16:00 +01:00
|
|
|
lang::Locale aLocale( "en", "US", "");
|
2011-10-05 16:00:44 +01:00
|
|
|
ResMgr::SetDefaultLocale( aLocale );
|
|
|
|
|
2011-09-28 13:48:34 +01:00
|
|
|
SvtSysLocaleOptions aLocalOptions;
|
2012-11-17 01:16:00 +01:00
|
|
|
OUString aLangISO( "en-US" );
|
2011-09-30 14:57:15 +01:00
|
|
|
aLocalOptions.SetLocaleConfigString( aLangISO );
|
|
|
|
aLocalOptions.SetUILocaleConfigString( aLangISO );
|
2011-09-28 13:48:34 +01:00
|
|
|
|
2012-10-31 09:22:53 +01:00
|
|
|
InitVCL();
|
2012-04-13 11:13:19 +01:00
|
|
|
if (Application::IsHeadlessModeRequested())
|
2011-12-06 20:27:29 +01:00
|
|
|
Application::EnableHeadlessMode(true);
|
2011-09-28 13:48:34 +01:00
|
|
|
|
2011-10-05 16:00:44 +01:00
|
|
|
if( m_bAssertOnDialog )
|
2011-09-28 13:48:34 +01:00
|
|
|
ErrorHandler::RegisterDisplay( aBasicErrorFunc );
|
2012-08-01 10:05:05 +02:00
|
|
|
|
|
|
|
// Make GraphicConverter work, normally done in desktop::Desktop::Main()
|
|
|
|
Application::SetFilterHdl( LINK( this, test::BootstrapFixture, ImplInitFilterHdl ) );
|
2012-09-14 18:08:57 +02:00
|
|
|
|
|
|
|
if (m_bNeedUCB)
|
|
|
|
{
|
|
|
|
// initialise unconfigured UCB:
|
|
|
|
uno::Reference<ucb::XUniversalContentBroker> xUcb(m_xSFactory->createInstance("com.sun.star.ucb.UniversalContentBroker"), uno::UNO_QUERY_THROW);
|
|
|
|
uno::Reference<ucb::XContentProvider> xFileProvider(m_xSFactory->createInstance("com.sun.star.ucb.FileContentProvider"), uno::UNO_QUERY_THROW);
|
|
|
|
xUcb->registerContentProvider(xFileProvider, "file", sal_True);
|
|
|
|
uno::Reference<ucb::XContentProvider> xTdocProvider(m_xSFactory->createInstance("com.sun.star.ucb.TransientDocumentsContentProvider"), uno::UNO_QUERY);
|
|
|
|
if (xTdocProvider.is())
|
|
|
|
{
|
|
|
|
xUcb->registerContentProvider(xTdocProvider, "vnd.sun.star.tdoc", sal_True);
|
|
|
|
}
|
|
|
|
}
|
2011-09-28 13:48:34 +01:00
|
|
|
}
|
|
|
|
|
2011-10-05 16:00:44 +01:00
|
|
|
void test::BootstrapFixture::tearDown()
|
|
|
|
{
|
2011-10-12 15:19:21 +01:00
|
|
|
test::BootstrapFixtureBase::tearDown();
|
2011-10-05 16:00:44 +01:00
|
|
|
}
|
|
|
|
|
2011-09-28 13:48:34 +01:00
|
|
|
test::BootstrapFixture::~BootstrapFixture()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-08-01 10:05:05 +02:00
|
|
|
IMPL_LINK( test::BootstrapFixture, ImplInitFilterHdl, ConvertData*, pData )
|
|
|
|
{
|
|
|
|
return GraphicFilter::GetGraphicFilter().GetFilterCallback().Call( pData );
|
|
|
|
}
|
|
|
|
|
2011-09-28 13:48:34 +01:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|