office-gobmx/cppuhelper/test/testimplhelper.cxx

587 lines
21 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2000-09-18 09:29:57 -05:00
/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
2000-09-18 09:29:57 -05:00
*
* Copyright 2000, 2010 Oracle and/or its affiliates.
2000-09-18 09:29:57 -05:00
*
* OpenOffice.org - a multi-platform office productivity suite
2000-09-18 09:29:57 -05:00
*
* This file is part of OpenOffice.org.
2000-09-18 09:29:57 -05:00
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
2000-09-18 09:29:57 -05:00
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
2000-09-18 09:29:57 -05:00
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
2000-09-18 09:29:57 -05:00
*
************************************************************************/
#if !defined(OSL_DEBUG_LEVEL) || OSL_DEBUG_LEVEL == 0
# undef OSL_DEBUG_LEVEL
# define OSL_DEBUG_LEVEL 2
#endif
// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_cppuhelper.hxx"
#include <stdio.h>
2001-08-31 03:12:21 -05:00
#include <cppuhelper/implbase1.hxx>
#include <cppuhelper/implbase2.hxx>
#include <cppuhelper/implbase3.hxx>
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/implbase5.hxx>
#include <cppuhelper/implbase6.hxx>
#include <cppuhelper/implbase7.hxx>
#include <cppuhelper/implbase8.hxx>
#include <cppuhelper/implbase9.hxx>
#include <cppuhelper/implbase10.hxx>
#include <cppuhelper/implbase11.hxx>
#include <cppuhelper/implbase12.hxx>
#include <cppuhelper/compbase1.hxx>
#include <cppuhelper/compbase2.hxx>
#include <cppuhelper/compbase3.hxx>
#include <cppuhelper/compbase4.hxx>
#include <cppuhelper/compbase5.hxx>
#include <cppuhelper/compbase6.hxx>
#include <cppuhelper/compbase7.hxx>
#include <cppuhelper/compbase8.hxx>
#include <cppuhelper/compbase9.hxx>
#include <cppuhelper/compbase10.hxx>
#include <cppuhelper/compbase11.hxx>
#include <cppuhelper/compbase12.hxx>
2000-09-18 09:29:57 -05:00
#include <osl/diagnose.h>
#include <cppuhelper/servicefactory.hxx>
#include <cppuhelper/implbase4.hxx>
#include <cppuhelper/compbase4.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <test/A.hpp>
#include <test/BA.hpp>
#include <test/CA.hpp>
#include <test/DBA.hpp>
#include <test/E.hpp>
#include <test/FE.hpp>
#include <test/G.hpp>
2001-08-31 03:12:21 -05:00
#include <test/H.hpp>
#include <test/I.hpp>
2000-09-18 09:29:57 -05:00
#include <com/sun/star/lang/IllegalAccessException.hpp>
using namespace test;
using namespace osl;
using namespace cppu;
using namespace com::sun::star;
2000-09-18 09:29:57 -05:00
using namespace com::sun::star::uno;
2011-03-02 14:53:12 -06:00
using ::rtl::OUString;
using ::rtl::OUStringToOString;
using ::rtl::OString;
2000-09-18 09:29:57 -05:00
//==================================================================================================
struct TestImpl : public ImplHelper4< CA, DBA, FE, G >
{
sal_Int32 nRef;
virtual ~TestImpl()
{ OSL_TRACE( "> TestImpl dtor called... <\n" ); }
2001-10-31 09:18:25 -06:00
virtual Any SAL_CALL queryInterface( const Type & rType ) throw(RuntimeException)
2000-09-18 09:29:57 -05:00
{ return ImplHelper4< CA, DBA, FE, G >::queryInterface( rType ); }
2001-10-31 09:18:25 -06:00
virtual void SAL_CALL acquire( ) throw()
2000-09-18 09:29:57 -05:00
{ ++nRef; }
2001-10-31 09:18:25 -06:00
virtual void SAL_CALL release( ) throw()
2000-09-18 09:29:57 -05:00
{ if (! --nRef) delete this; }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
};
//==================================================================================================
struct TestWeakAggImpl : public WeakAggImplHelper4< CA, DBA, FE, G >
{
virtual ~TestWeakAggImpl()
{ OSL_TRACE( "> TestWeakAggImpl dtor called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
};
//==================================================================================================
struct TestWeakImpl : public WeakImplHelper4< CA, DBA, FE, G >
{
TestWeakImpl() {}
2000-09-18 09:29:57 -05:00
virtual ~TestWeakImpl()
{ OSL_TRACE( "> TestWeakImpl dtor called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
protected:
TestWeakImpl(int) {}
TestWeakImpl(int, int) {}
TestWeakImpl(int, int, int) {}
TestWeakImpl(int, int, int, int) {}
TestWeakImpl(int, int, int, int, int) {}
TestWeakImpl(int, int, int, int, int, int, int = 0) {}
2000-09-18 09:29:57 -05:00
};
//==================================================================================================
struct TestWeakComponentImpl : public WeakComponentImplHelper4< CA, DBA, FE, G >
{
Mutex m;
TestWeakComponentImpl()
: WeakComponentImplHelper4< CA, DBA, FE, G >( m )
{}
virtual ~TestWeakComponentImpl()
{ OSL_TRACE( "> TestWeakComponentImpl dtor called... <\n" ); }
void SAL_CALL disposing()
{ OSL_TRACE( "> TestWeakComponentImpl disposing called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
};
//==================================================================================================
struct TestWeakAggComponentImpl : public WeakAggComponentImplHelper4< CA, DBA, FE, G >
{
Mutex m;
TestWeakAggComponentImpl()
: WeakAggComponentImplHelper4< CA, DBA, FE, G >( m )
{}
virtual ~TestWeakAggComponentImpl()
{ OSL_TRACE( "> TestWeakAggComponentImpl dtor called... <\n" ); }
void SAL_CALL disposing()
{ OSL_TRACE( "> TestWeakAggComponentImpl disposing called... <\n" ); }
// A
virtual OUString SAL_CALL a() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("a") ); }
// BA
virtual OUString SAL_CALL ba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ba") ); }
// CA
virtual OUString SAL_CALL ca() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("ca") ); }
// DBA
virtual OUString SAL_CALL dba() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("dba") ); }
// E
virtual OUString SAL_CALL e() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("e") ); }
// FE
virtual OUString SAL_CALL fe() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("fe") ); }
// G
virtual OUString SAL_CALL g() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("g") ); }
};
2001-08-31 03:12:21 -05:00
//==================================================================================================
struct TestImplInh : public ImplInheritanceHelper2< TestWeakImpl, H, I >
{
TestImplInh() {}
explicit TestImplInh(int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1) {}
TestImplInh(int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2) {}
TestImplInh(int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3) {}
TestImplInh(int, int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4) {}
TestImplInh(int, int, int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5) {}
TestImplInh(int, int, int, int, int, int):
ImplInheritanceHelper2< TestWeakImpl, H, I >(1, 2, 3, 4, 5, 6) {}
2001-08-31 03:12:21 -05:00
virtual ~TestImplInh()
{ OSL_TRACE( "> TestWeakImplInh dtor called... <\n" ); }
// H
virtual OUString SAL_CALL h() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("h") ); }
// I
virtual OUString SAL_CALL i() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("i") ); }
};
//==================================================================================================
struct TestAggImplInh : public AggImplInheritanceHelper2< TestWeakAggImpl, H, I >
{
virtual ~TestAggImplInh()
{ OSL_TRACE( "> TestAggImplInh dtor called... <\n" ); }
// H
virtual OUString SAL_CALL h() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("h2") ); }
// I
virtual OUString SAL_CALL i() throw(RuntimeException)
{ return OUString( RTL_CONSTASCII_USTRINGPARAM("i2") ); }
};
static bool isIn( Sequence< Type > const & rTypes, char const * name )
{
OUString str( OUString::createFromAscii( name ) );
Type const * pTypes = rTypes.getConstArray();
for ( sal_Int32 nPos = rTypes.getLength(); nPos--; )
{
if (pTypes[ nPos ].getTypeName().equals( str ))
return true;
}
return false;
}
2000-09-18 09:29:57 -05:00
//==================================================================================================
static void dotest( const Reference< XInterface > & xOriginal )
{
Reference< lang::XTypeProvider > xTP( xOriginal, UNO_QUERY );
Sequence< sal_Int8 > id( xTP->getImplementationId() );
Sequence< Type > types( xTP->getTypes() );
::fprintf( stderr, "> supported types: " );
long n = 0;
for ( ; n < types.getLength(); ++n )
{
OString str( OUStringToOString( types[ n ].getTypeName(), RTL_TEXTENCODING_ASCII_US ) );
::fprintf( stderr, (n < (types.getLength()-1)) ? "%s, " : "%s; type-id=\n", str.getStr() );
}
for ( n = 0; n < 16; ++n )
{
::fprintf( stderr, n < 15 ? "%x " : "%x \n", id[ n ] );
}
2000-09-18 09:29:57 -05:00
Reference< A > xa( xOriginal, UNO_QUERY );
2001-05-08 09:55:51 -05:00
OSL_ENSURE( xa->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### A failed!" );
2000-09-18 09:29:57 -05:00
Reference< BA > xba( xa, UNO_QUERY );
2001-05-08 09:55:51 -05:00
OSL_ENSURE( xba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### BA failed!" );
OSL_ENSURE( xba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### BA failed!" );
2000-09-18 09:29:57 -05:00
Reference< CA > xca( xba, UNO_QUERY );
2001-05-08 09:55:51 -05:00
OSL_ENSURE( xca->ca().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ca") ), "### CA failed!" );
OSL_ENSURE( xca->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### CA failed!" );
2000-09-18 09:29:57 -05:00
Reference< DBA > xdba( xca, UNO_QUERY );
2001-05-08 09:55:51 -05:00
OSL_ENSURE( xdba->dba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("dba") ), "### DBA failed!" );
OSL_ENSURE( xdba->ba().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("ba") ), "### DBA failed!" );
OSL_ENSURE( xdba->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### DBA failed!" );
2000-09-18 09:29:57 -05:00
Reference< E > xe( xdba, UNO_QUERY );
2001-05-08 09:55:51 -05:00
OSL_ENSURE( xe->e().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("e") ), "### E failed!" );
2000-09-18 09:29:57 -05:00
Reference< FE > xfe( xe, UNO_QUERY );
2001-05-08 09:55:51 -05:00
OSL_ENSURE( xfe->fe().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("fe") ), "### FE failed!" );
2000-09-18 09:29:57 -05:00
Reference< G > xg( xfe, UNO_QUERY );
2001-05-08 09:55:51 -05:00
OSL_ENSURE( xg->g().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("g") ), "### G failed!" );
OSL_ENSURE( xg->a().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("a") ), "### G failed!" );
2000-09-18 09:29:57 -05:00
// type provider
Reference< lang::XTypeProvider > xProv( xg, UNO_QUERY );
2000-09-18 09:29:57 -05:00
Sequence< Type > aTypes( xProv->getTypes() );
// CA, DBA, FE, G, XTypeProvider
2001-08-31 03:12:21 -05:00
OSL_ASSERT( isIn( aTypes, "test.CA" ) );
OSL_ASSERT( isIn( aTypes, "test.DBA" ) );
OSL_ASSERT( isIn( aTypes, "test.FE") );
OSL_ASSERT( isIn( aTypes, "test.G") );
OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XTypeProvider") );
2000-09-18 09:29:57 -05:00
2001-08-31 03:12:21 -05:00
Reference< XWeak > xWeak( xg, UNO_QUERY );
if (xWeak.is())
{
OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XWeak") );
}
Reference< lang::XComponent > xComp( xg, UNO_QUERY );
2000-09-18 09:29:57 -05:00
if (xComp.is())
{
2001-08-31 03:12:21 -05:00
OSL_ASSERT( isIn( aTypes, "com.sun.star.lang.XComponent") );
}
Reference< XAggregation > xAgg( xg, UNO_QUERY );
if (xAgg.is())
{
OSL_ASSERT( isIn( aTypes, "com.sun.star.uno.XAggregation") );
2000-09-18 09:29:57 -05:00
}
2001-08-31 03:12:21 -05:00
Reference< H > xH( xg, UNO_QUERY );
if (xH.is())
2000-09-18 09:29:57 -05:00
{
2001-08-31 03:12:21 -05:00
OSL_ASSERT( isIn( aTypes, "test.H") );
}
Reference< I > xI( xg, UNO_QUERY );
if (xI.is())
{
OSL_ASSERT( isIn( aTypes, "test.I") );
2000-09-18 09:29:57 -05:00
}
2001-08-31 03:12:21 -05:00
OSL_ENSURE( xg == xOriginal, "### root!" );
2000-09-18 09:29:57 -05:00
}
void rethrow()
{
throw;
}
void throw_one(
lang::IllegalAccessException exc )
{
try
{
throw exc;
}
catch (...)
{
rethrow();
}
}
2000-09-18 09:29:57 -05:00
//==================================================================================================
void test_ImplHelper( const Reference< lang::XMultiServiceFactory > & /*xSF*/ )
2000-09-18 09:29:57 -05:00
{
Reference< XInterface > xImpl( (lang::XTypeProvider *)new TestImpl() );
Reference< lang::XTypeProvider > xTP1( xImpl, UNO_QUERY );
2000-09-18 09:29:57 -05:00
Reference< XInterface > xWeakImpl( (OWeakObject *)new TestWeakImpl() );
Reference< lang::XTypeProvider > xTP2( xWeakImpl, UNO_QUERY );
2000-09-18 09:29:57 -05:00
Reference< XInterface > xWeakAggImpl( (OWeakObject *)new TestWeakAggImpl() );
Reference< lang::XTypeProvider > xTP3( xWeakAggImpl, UNO_QUERY );
2000-09-18 09:29:57 -05:00
Reference< XInterface > xWeakComponentImpl( (OWeakObject *)new TestWeakComponentImpl() );
Reference< lang::XTypeProvider > xTP4( xWeakComponentImpl, UNO_QUERY );
2000-09-18 09:29:57 -05:00
Reference< XInterface > xWeakAggComponentImpl( (OWeakObject *)new TestWeakAggComponentImpl() );
Reference< lang::XTypeProvider > xTP5( xWeakAggComponentImpl, UNO_QUERY );
//
OSL_ASSERT(
xTP1->getImplementationId() != xTP2->getImplementationId() &&
xTP1->getImplementationId() != xTP3->getImplementationId() &&
xTP1->getImplementationId() != xTP4->getImplementationId() &&
xTP1->getImplementationId() != xTP5->getImplementationId() &&
xTP2->getImplementationId() != xTP3->getImplementationId() &&
xTP2->getImplementationId() != xTP4->getImplementationId() &&
xTP2->getImplementationId() != xTP5->getImplementationId() &&
xTP3->getImplementationId() != xTP4->getImplementationId() &&
xTP3->getImplementationId() != xTP5->getImplementationId() &&
xTP4->getImplementationId() != xTP5->getImplementationId() );
//
2000-09-18 09:29:57 -05:00
dotest( xImpl );
dotest( xWeakImpl );
dotest( xWeakAggImpl );
dotest( xWeakComponentImpl );
dotest( xWeakAggComponentImpl );
2001-08-31 03:12:21 -05:00
xWeakImpl = (OWeakObject *)new TestImplInh();
Reference< lang::XTypeProvider > xTP6( xWeakImpl, UNO_QUERY );
2001-08-31 03:12:21 -05:00
dotest( xWeakImpl );
Reference< H > xH( xWeakImpl, UNO_QUERY );
Reference< I > xI( xH, UNO_QUERY );
OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h") ) );
OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i") ) );
xWeakAggImpl = (OWeakObject *)new TestAggImplInh();
Reference< lang::XTypeProvider > xTP7( xWeakAggImpl, UNO_QUERY );
2001-08-31 03:12:21 -05:00
dotest( xWeakAggImpl );
xH.set( xWeakAggImpl, UNO_QUERY );
xI.set( xH, UNO_QUERY );
OSL_ASSERT( xH->h().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("h2") ) );
OSL_ASSERT( xI->i().equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("i2") ) );
2000-09-18 09:29:57 -05:00
//
OSL_ASSERT(
xTP6->getImplementationId() != xTP1->getImplementationId() &&
xTP6->getImplementationId() != xTP2->getImplementationId() &&
xTP6->getImplementationId() != xTP3->getImplementationId() &&
xTP6->getImplementationId() != xTP4->getImplementationId() &&
xTP6->getImplementationId() != xTP5->getImplementationId() &&
xTP6->getImplementationId() != xTP7->getImplementationId() &&
xTP7->getImplementationId() != xTP1->getImplementationId() &&
xTP7->getImplementationId() != xTP2->getImplementationId() &&
xTP7->getImplementationId() != xTP3->getImplementationId() &&
xTP7->getImplementationId() != xTP4->getImplementationId() &&
xTP7->getImplementationId() != xTP5->getImplementationId() );
//
bool exc_succ = false;
lang::IllegalAccessException exc(
OUString( RTL_CONSTASCII_USTRINGPARAM("testtest") ),
xWeakAggImpl );
// exception helper tests
try
{
throw exc;
}
catch (Exception &)
{
Any a( getCaughtException() );
OSL_ASSERT( a == exc );
try
{
throwException( a );
}
catch (lang::IllegalAccessException & e)
{
OSL_ASSERT( exc.Message == e.Message && exc.Context == e.Context );
try
{
throw_one( exc );
}
catch (Exception &)
{
Any a2( getCaughtException() );
OSL_ASSERT( (a2 == a) && (a2 == exc) );
try
{
throw_one( exc );
}
catch (lang::IllegalAccessException &)
{
Any a3( getCaughtException() );
OSL_ASSERT( (a3 == a) && (a3 == a2) && (a3 == exc) );
exc_succ = true;
}
}
}
}
OSL_ASSERT( exc_succ );
2000-09-18 09:29:57 -05:00
try
{
throwException( makeAny( RuntimeException(
OUString( RTL_CONSTASCII_USTRINGPARAM("runtime exc") ), xImpl ) ) );
}
catch (RuntimeException & rExc)
{
2001-05-08 09:55:51 -05:00
OSL_ENSURE( rExc.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("runtime exc") ) && rExc.Context == xImpl,
2000-09-18 09:29:57 -05:00
"### unexpected exception content!" );
try
{
throwException( makeAny( Exception(
OUString( RTL_CONSTASCII_USTRINGPARAM("exc") ), rExc.Context ) ) );
}
catch (lang::IllegalAccessException &)
2000-09-18 09:29:57 -05:00
{
2001-05-08 09:55:51 -05:00
OSL_ENSURE( sal_False, "### unexpected IllegalAccessException exception caught!" );
2000-09-18 09:29:57 -05:00
}
catch (Exception & rExc2)
2000-09-18 09:29:57 -05:00
{
OSL_ENSURE( rExc2.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("exc") ) && rExc2.Context == xImpl,
2000-09-18 09:29:57 -05:00
"### unexpected exception content!" );
try
{
throwException( makeAny( lang::IllegalAccessException(
OUString( RTL_CONSTASCII_USTRINGPARAM("axxess exc") ), rExc2.Context ) ) );
2000-09-18 09:29:57 -05:00
}
catch (lang::IllegalAccessException & rExc3)
2000-09-18 09:29:57 -05:00
{
OSL_ENSURE( rExc3.Message.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("axxess exc") ) && rExc3.Context == xImpl,
2000-09-18 09:29:57 -05:00
"### unexpected exception content!" );
return;
}
}
}
catch (...)
{
}
2001-05-08 09:55:51 -05:00
OSL_ENSURE( sal_False, "### exception test failed!" );
2000-09-18 09:29:57 -05:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */