summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsmoketestoo_native/smoketest.cxx39
-rw-r--r--test/prj/build.lst3
-rw-r--r--test/prj/d.lst3
-rw-r--r--test/source/cpp/makefile.mk11
-rw-r--r--test/source/cpp/unoexceptionprotector/makefile.mk56
-rw-r--r--test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx95
6 files changed, 165 insertions, 42 deletions
diff --git a/smoketestoo_native/smoketest.cxx b/smoketestoo_native/smoketest.cxx
index 002967823e00..a4e532123456 100755
--- a/smoketestoo_native/smoketest.cxx
+++ b/smoketestoo_native/smoketest.cxx
@@ -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);
diff --git a/test/prj/build.lst b/test/prj/build.lst
index 7adea0c0727b..e22199a5c437 100644
--- a/test/prj/build.lst
+++ b/test/prj/build.lst
@@ -1,5 +1,6 @@
-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
diff --git a/test/prj/d.lst b/test/prj/d.lst
index 54da2062a511..18a599fd5849 100644
--- a/test/prj/d.lst
+++ b/test/prj/d.lst
@@ -1,9 +1,12 @@
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
diff --git a/test/source/cpp/makefile.mk b/test/source/cpp/makefile.mk
index 4c90dc678959..2073f1500c07 100644
--- a/test/source/cpp/makefile.mk
+++ b/test/source/cpp/makefile.mk
@@ -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 \
diff --git a/test/source/cpp/unoexceptionprotector/makefile.mk b/test/source/cpp/unoexceptionprotector/makefile.mk
new file mode 100644
index 000000000000..7f62199f46dc
--- /dev/null
+++ b/test/source/cpp/unoexceptionprotector/makefile.mk
@@ -0,0 +1,56 @@
+#*************************************************************************
+# 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
diff --git a/test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx b/test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
new file mode 100644
index 000000000000..28a0462c3ef1
--- /dev/null
+++ b/test/source/cpp/unoexceptionprotector/unoexceptionprotector.cxx
@@ -0,0 +1,95 @@
+/*************************************************************************
+* 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;
+}