diff options
author | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-02-16 10:23:55 +0100 |
---|---|---|
committer | Frank Schoenheit [fs] <frank.schoenheit@oracle.com> | 2011-02-16 10:23:55 +0100 |
commit | e648dff4561470d3aba457ec916437d04fea5c0c (patch) | |
tree | 60768e34527f81bc8285cf7eb3681fb36e1b9b0c /smoketestoo_native/smoketest.cxx | |
parent | 68bcb8d2fa5021af8ba67309eee65dc2028adf63 (diff) |
debuglevels: explicit failure upon catching an UNO exception (which gives a slightly better idea of the failure than what cppunit emits by default)
Diffstat (limited to 'smoketestoo_native/smoketest.cxx')
-rwxr-xr-x | smoketestoo_native/smoketest.cxx | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/smoketestoo_native/smoketest.cxx b/smoketestoo_native/smoketest.cxx index a4e532123456..002967823e00 100755 --- a/smoketestoo_native/smoketest.cxx +++ b/smoketestoo_native/smoketest.cxx @@ -48,6 +48,7 @@ #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" @@ -56,6 +57,7 @@ #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" @@ -130,23 +132,46 @@ public: private: CPPUNIT_TEST_SUITE(Test); - CPPUNIT_TEST(test); + CPPUNIT_TEST(runSmoketestDoc); CPPUNIT_TEST_SUITE_END(); - void test(); + void runSmoketestDoc(); + + ::rtl::OString getFailMessage( sal_Char const * i_context, css::uno::Any const & i_exception ); 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() { - connection_.setUp(); + try { + connection_.setUp(); + } + catch( css::uno::Exception const & ) { + CPPUNIT_FAIL( getFailMessage( "setting up the connection failed", ::cppu::getCaughtException() ).getStr() ); + } } void Test::tearDown() { - connection_.tearDown(); + try { + connection_.tearDown(); + } + catch( css::uno::Exception const & ) { + CPPUNIT_FAIL( getFailMessage( "tearing down the connection failed", ::cppu::getCaughtException() ).getStr() ); + } } -void Test::test() { +void Test::runSmoketestDoc() { + try + { rtl::OUString doc; CPPUNIT_ASSERT( test::getTestArgument( @@ -195,6 +220,10 @@ void Test::test() { 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); |