[Libreoffice-commits] core.git: sal/CppunitTest_sal_osl.mk sal/qa unotools/source
Juergen Funk
juergen.funk_ml at cib.de
Fri Dec 22 15:43:26 UTC 2017
sal/CppunitTest_sal_osl.mk | 1 +
sal/qa/osl/file/osl_old_test_file.cxx | 25 +++++++++++++++++++++++++
unotools/source/ucbhelper/tempfile.cxx | 15 ++++++++++-----
3 files changed, 36 insertions(+), 5 deletions(-)
New commits:
commit 26be5f21cebfe9acad088a1086f97eebdb437b7c
Author: Juergen Funk <juergen.funk_ml at cib.de>
Date: Wed Dec 20 13:09:40 2017 +0100
unotools: don't go belly-up if temp dir is wrong or empty
When a wrong temp directory was set (e.g. wrong path in xcu ist set),
you get a assert in the LO-Debug Version, this patch avoid this assertion.
Change-Id: I192f682860ad9cddf907e4b239eff36b4bd6072d
Reviewed-on: https://gerrit.libreoffice.org/46846
Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
Tested-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>
diff --git a/sal/CppunitTest_sal_osl.mk b/sal/CppunitTest_sal_osl.mk
index d96ab2d41483..787dbf96174f 100644
--- a/sal/CppunitTest_sal_osl.mk
+++ b/sal/CppunitTest_sal_osl.mk
@@ -27,6 +27,7 @@ $(eval $(call gb_CppunitTest_add_exception_objects,sal_osl,\
$(eval $(call gb_CppunitTest_use_libraries,sal_osl,\
sal \
+ utl \
))
# the test uses the library created by Module_DLL
diff --git a/sal/qa/osl/file/osl_old_test_file.cxx b/sal/qa/osl/file/osl_old_test_file.cxx
index f093d5fe1bb8..fbbefbb03884 100644
--- a/sal/qa/osl/file/osl_old_test_file.cxx
+++ b/sal/qa/osl/file/osl_old_test_file.cxx
@@ -32,6 +32,9 @@
#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/plugin/TestPlugIn.h>
+#include <unotools/tempfile.hxx>
+
+
namespace osl_test_file
{
@@ -137,8 +140,30 @@ void oldtestfile::test_file_004()
#endif
}
+class TempFileTest : public CppUnit::TestFixture
+{
+
+public:
+ TempFileTest() {}
+
+ void SetTempNameBaseDirectory()
+ { // only testing: of not found the directory
+ OUString path = utl::TempFile::SetTempNameBaseDirectory("file:///not/found/dir");
+
+ CPPUNIT_ASSERT_MESSAGE("SetTempNameBaseDirectory must give a empty string back",
+ path.isEmpty());
+ }
+
+
+ CPPUNIT_TEST_SUITE(TempFileTest);
+ CPPUNIT_TEST(SetTempNameBaseDirectory);
+ CPPUNIT_TEST_SUITE_END();
+};
+
+
} // namespace osl_test_file
CPPUNIT_TEST_SUITE_REGISTRATION( osl_test_file::oldtestfile);
+CPPUNIT_TEST_SUITE_REGISTRATION( osl_test_file::TempFileTest);
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/unotools/source/ucbhelper/tempfile.cxx b/unotools/source/ucbhelper/tempfile.cxx
index eb099a43dca9..47afc2ed82ce 100644
--- a/unotools/source/ucbhelper/tempfile.cxx
+++ b/unotools/source/ucbhelper/tempfile.cxx
@@ -57,13 +57,18 @@ namespace utl
OUString getParentName( const OUString& aFileName )
{
sal_Int32 lastIndex = aFileName.lastIndexOf( '/' );
- OUString aParent = aFileName.copy( 0, lastIndex );
+ OUString aParent;
- if( aParent.endsWith(":") && aParent.getLength() == 6 )
- aParent += "/";
+ if (lastIndex > -1)
+ {
+ aParent = aFileName.copy(0, lastIndex);
+
+ if (aParent.endsWith(":") && aParent.getLength() == 6)
+ aParent += "/";
- if( aParent.equalsIgnoreAsciiCase( "file://" ) )
- aParent = "file:///";
+ if (aParent.equalsIgnoreAsciiCase("file://"))
+ aParent = "file:///";
+ }
return aParent;
}
More information about the Libreoffice-commits
mailing list