Kaydet (Commit) e2cb37ff authored tarafından sb's avatar sb

debuglevels: #i117073# added cppunittester --protector support; added…

debuglevels: #i117073# added cppunittester --protector support; added unoexceptionprotector and use it in installationtest.mk; reverted changes to smoketest.cxx obsoleted by these additions
üst 322ffc5c
......@@ -48,7 +48,6 @@
#include "com/sun/star/uno/Sequence.hxx"
#include "com/sun/star/util/URL.hpp"
#include <preextstl.h>
#include "cppuhelper/exc_hlp.hxx"
#include "cppuhelper/implbase1.hxx"
#include "cppunit/TestAssert.h"
#include "cppunit/TestFixture.h"
......@@ -57,7 +56,6 @@
#include <postextstl.h>
#include "osl/conditn.hxx"
#include "osl/diagnose.h"
#include "rtl/strbuf.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "test/gettestargument.hxx"
......@@ -132,46 +130,23 @@ public:
private:
CPPUNIT_TEST_SUITE(Test);
CPPUNIT_TEST(runSmoketestDoc);
CPPUNIT_TEST(test);
CPPUNIT_TEST_SUITE_END();
void runSmoketestDoc();
::rtl::OString getFailMessage( sal_Char const * i_context, css::uno::Any const & i_exception );
void test();
test::OfficeConnection connection_;
};
::rtl::OString Test::getFailMessage( sal_Char const * i_context, css::uno::Any const & i_exception )
{
::rtl::OStringBuffer failMessage;
failMessage.append( i_context );
failMessage.append( ": caught a " );
failMessage.append( ::rtl::OUStringToOString( i_exception.getValueTypeName(), RTL_TEXTENCODING_ASCII_US ) );
return failMessage.makeStringAndClear();
}
void Test::setUp() {
try {
connection_.setUp();
}
catch( css::uno::Exception const & ) {
CPPUNIT_FAIL( getFailMessage( "setting up the connection failed", ::cppu::getCaughtException() ).getStr() );
}
connection_.setUp();
}
void Test::tearDown() {
try {
connection_.tearDown();
}
catch( css::uno::Exception const & ) {
CPPUNIT_FAIL( getFailMessage( "tearing down the connection failed", ::cppu::getCaughtException() ).getStr() );
}
connection_.tearDown();
}
void Test::runSmoketestDoc() {
try
{
void Test::test() {
rtl::OUString doc;
CPPUNIT_ASSERT(
test::getTestArgument(
......@@ -220,10 +195,6 @@ void Test::runSmoketestDoc() {
result.condition.wait();
CPPUNIT_ASSERT(result.success);
CPPUNIT_ASSERT_EQUAL(rtl::OUString(), result.result);
}
catch( css::uno::Exception const & ) {
CPPUNIT_FAIL( getFailMessage( "executing the smoketest macro", ::cppu::getCaughtException() ).getStr() );
}
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
......
te test : BOOST:boost cppu cppuhelper CPPUNIT:cppunit javaunohelper offuh ridljar sal solenv unoil NULL
te test : BOOST:boost cppu cppuhelper CPPUNIT:cppunit javaunohelper offuh ridljar sal solenv stlport unoil NULL
te test\inc nmake - all inc NULL
te test\source\cpp nmake - all source_cpp inc NULL
te test\source\cpp\unoexceptionprotector nmake - all source_cpp_unoexceptionprotector inc NULL
te test\source\java\org\openoffice\test nmake - all source_java NULL
te test\source\java\org\openoffice\test\tools nmake - all source_java_tools NULL
mkdir: %_DEST%\inc%_EXT%\test
mkdir: %_DEST%\inc%_EXT%\test\detail
..\%__SRC%\bin\test.dll %_DEST%\bin%_EXT%\test.dll
..\%__SRC%\bin\unoexceptionprotector.dll %_DEST%\bin%_EXT%\unoexceptionprotector.dll
..\%__SRC%\lib\itest.lib %_DEST%\lib%_EXT%\itest.lib
..\%__SRC%\lib\libtest.dylib %_DEST%\lib%_EXT%\libtest.dylib
..\%__SRC%\lib\libtest.so %_DEST%\lib%_EXT%\libtest.so
..\%__SRC%\lib\unoexceptionprotector.dylib %_DEST%\lib%_EXT%\unoexceptionprotector.dylib
..\%__SRC%\lib\unoexceptionprotector.so %_DEST%\lib%_EXT%\unoexceptionprotector.so
..\inc\test\detail\testdllapi.hxx %_DEST%\inc%_EXT%\test\detail\testdllapi.hxx
..\inc\test\gettestargument.hxx %_DEST%\inc%_EXT%\test\gettestargument.hxx
..\inc\test\officeconnection.hxx %_DEST%\inc%_EXT%\test\officeconnection.hxx
......
......@@ -33,14 +33,11 @@ VISIBILITY_HIDDEN = TRUE
.INCLUDE: settings.mk
CDEFS += -DOOO_DLLIMPLEMENTATION_TEST
CFLAGSCXX += $(CPPUNIT_CFLAGS)
#building with stlport, but cppunit was not built with stlport
.IF "$(USE_SYSTEM_STL)"!="YES"
.IF "$(SYSTEM_CPPUNIT)"=="YES"
CFLAGSCXX+=-DADAPT_EXT_STL
.ENDIF
.ENDIF
CFLAGSCXX += $(CPPUNIT_CFLAGS)
.IF "$(USE_SYSTEM_STL)" != "YES" && "$(SYSTEM_CPPUNIT)" == "YES"
CFLAGSCXX += -DADAPT_EXT_STL
.END
SLOFILES = \
$(SLO)/getargument.obj \
......
#*************************************************************************
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# Copyright 2000, 2010 Oracle and/or its affiliates.
#
# OpenOffice.org - a multi-platform office productivity suite
#
# This file is part of OpenOffice.org.
#
# 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.
#
# 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).
#
# 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.
#***********************************************************************/
PRJ = ../../..
PRJNAME = test
TARGET = unoexceptionprotector
ENABLE_EXCEPTIONS = TRUE
VISIBILITY_HIDDEN = TRUE
.INCLUDE: settings.mk
DLLPRE =
CFLAGSCXX += $(CPPUNIT_CFLAGS)
.IF "$(USE_SYSTEM_STL)" != "YES" && "$(SYSTEM_CPPUNIT)" == "YES"
CFLAGSCXX += -DADAPT_EXT_STL
.END
SLOFILES = $(SLO)/unoexceptionprotector.obj
SHL1IMPLIB = i$(SHL1TARGET)
SHL1OBJS = $(SLOFILES)
SHL1RPATH = NONE
SHL1STDLIBS = \
$(CPPUHELPERLIB) \
$(CPPULIB) \
$(CPPUNITLIB) \
$(SALLIB)
SHL1TARGET = unoexceptionprotector
SHL1USE_EXPORTS = name
DEF1NAME = $(SHL1TARGET)
.INCLUDE: target.mk
/*************************************************************************
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2000, 2011 Oracle and/or its affiliates.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* This file is part of OpenOffice.org.
*
* 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.
*
* 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).
*
* 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.
************************************************************************/
#include "sal/config.h"
#include <limits>
#include <string>
#include "boost/noncopyable.hpp"
#include "com/sun/star/uno/Any.hxx"
#include "com/sun/star/uno/Exception.hpp"
#include "cppuhelper/exc_hlp.hxx"
#include "osl/thread.h"
#include "rtl/string.hxx"
#include "rtl/ustring.h"
#include "rtl/ustring.hxx"
#include "sal/types.h"
#include "preextstl.h"
#include "cppunit/Message.h"
#include "cppunit/Protector.h"
#include "postextstl.h"
namespace {
namespace css = com::sun::star;
// Best effort conversion:
std::string convert(rtl::OUString const & s16) {
rtl::OString s8(rtl::OUStringToOString(s16, osl_getThreadTextEncoding()));
return std::string(
s8.getStr(),
(s8.getLength() > std::numeric_limits< std::string::size_type >::max()
? std::numeric_limits< std::string::size_type >::max()
: static_cast< std::string::size_type >(s8.getLength())));
}
class Prot: public CppUnit::Protector, private boost::noncopyable {
public:
Prot() {}
virtual ~Prot() {}
virtual bool protect(
CppUnit::Functor const & functor,
CppUnit::ProtectorContext const & context);
};
bool Prot::protect(
CppUnit::Functor const & functor, CppUnit::ProtectorContext const & context)
{
try {
return functor();
} catch (css::uno::Exception & e) {
css::uno::Any a(cppu::getCaughtException());
reportError(
context,
CppUnit::Message(
convert(
rtl::OUString(
RTL_CONSTASCII_USTRINGPARAM(
"uncaught exception of type "))
+ a.getValueTypeName()),
convert(e.Message)));
}
}
}
extern "C" SAL_DLLPUBLIC_EXPORT CppUnit::Protector * SAL_CALL
unoexceptionprotector() {
return new Prot;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment