summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorsb <sb@openoffice.org>2011-02-25 11:32:55 +0100
committersb <sb@openoffice.org>2011-02-25 11:32:55 +0100
commite2cb37ffec3734ab7894af5cf52a97639630cedd (patch)
tree152412d54eee30c51a6455fd9d435ef1cd457ff0 /test
parent322ffc5c4534e935c86a1814ee55268e7a9a5c4b (diff)
debuglevels: #i117073# added cppunittester --protector support; added unoexceptionprotector and use it in installationtest.mk; reverted changes to smoketest.cxx obsoleted by these additions
Diffstat (limited to 'test')
-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
5 files changed, 160 insertions, 8 deletions
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;
+}