[Libreoffice-commits] .: sal/qa
Jan Holesovsky
kendy at kemper.freedesktop.org
Mon Feb 14 02:12:21 PST 2011
sal/qa/osl/file/osl_File.cxx | 57 +++++++++++++++++++++++++++++++++----------
1 file changed, 45 insertions(+), 12 deletions(-)
New commits:
commit 3465ce32271c2f5214fb50c924f5971b688a409b
Author: Jan Holesovsky <kendy at suse.cz>
Date: Mon Feb 14 11:11:24 2011 +0100
unittest: Allow concurrent run of the osl_File.cxx tests.
diff --git a/sal/qa/osl/file/osl_File.cxx b/sal/qa/osl/file/osl_File.cxx
index b0755e2..d90230f 100644
--- a/sal/qa/osl/file/osl_File.cxx
+++ b/sal/qa/osl/file/osl_File.cxx
@@ -6009,22 +6009,55 @@ namespace osl_Directory
//########################################
OUString get_test_path()
{
- OUString tmp;
- FileBase::RC rc = FileBase::getTempDirURL(tmp);
+ static OUString test_path;
+ if (test_path.isEmpty())
+ {
+ OUString tmp;
+ FileBase::RC rc = FileBase::getTempDirURL(tmp);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "Getting the location of TMP dir failed",
+ rc == FileBase::E_None
+ );
+
+ OUString system_path;
+ rc = FileBase::getSystemPathFromFileURL(tmp, system_path);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "Cannot convert the TMP dir to system path",
+ rc == FileBase::E_None
+ );
- CPPUNIT_ASSERT_MESSAGE
- (
- "Test path creation failed",
- rc == FileBase::E_None
- );
+ OString tmp_x(rtl::OUStringToOString(system_path, RTL_TEXTENCODING_UTF8 ));
+ if (tmp_x.lastIndexOf('/') != (tmp_x.getLength() - 1))
+ tmp_x += rtl::OString('/');
- OUStringBuffer b(tmp);
- if (tmp.lastIndexOf('/') != (tmp.getLength() - 1))
- b.appendAscii("/");
+#ifndef WNT
+ // FIXME would be nice to create unique dir even on Windows
+ tmp_x += rtl::OString("XXXXXX");
+ char *out = mkdtemp(const_cast<char*>(tmp_x.getStr()));
- b.appendAscii(TEST_PATH_POSTFIX);
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "mkdtemp call failed",
+ out != NULL
+ );
+
+ tmp_x += rtl::OString('/');
+#endif
+ tmp_x += rtl::OString(TEST_PATH_POSTFIX);
- return b.makeStringAndClear();
+ rc = FileBase::getFileURLFromSystemPath(rtl::OStringToOUString(tmp_x, RTL_TEXTENCODING_UTF8), test_path);
+
+ CPPUNIT_ASSERT_MESSAGE
+ (
+ "Cannot convert the system path back to an URL",
+ rc == FileBase::E_None
+ );
+ }
+ return test_path;
}
//########################################
More information about the Libreoffice-commits
mailing list