From f15023d34037068147f6afe83a187b2fb515351b Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Fri, 16 Mar 2012 20:06:59 +0100 Subject: do not let a unittest create temp files in the current directory --- sdext/source/pdfimport/test/tests.cxx | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'sdext/source') diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx index d3fa3e748b31..b73da1ddb133 100644 --- a/sdext/source/pdfimport/test/tests.cxx +++ b/sdext/source/pdfimport/test/tests.cxx @@ -596,15 +596,14 @@ namespace pdfi::PDFIRawAdaptor aAdaptor( impl_getComponentContext() ); aAdaptor.setTreeVisitorFactory( createDrawTreeVisitorFactory() ); - ::rtl::OUString aURL, aAbsURL, aBaseURL; - osl_getFileURLFromSystemPath( (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pdfi_unittest_draw.xml"))).pData, - &aURL.pData ); - osl_getProcessWorkingDir(&aBaseURL.pData); - osl_getAbsoluteFileURL(aBaseURL.pData,aURL.pData,&aAbsURL.pData); + ::rtl::OUString tempFileURL; + CPPUNIT_ASSERT( osl::File::createTempFile( NULL, NULL, &tempFileURL ) == osl::File::E_None ); + osl::File::remove( tempFileURL ); // FIXME the below apparently fails silently if the file already exists CPPUNIT_ASSERT_MESSAGE("Exporting to ODF", aAdaptor.odfConvert( getURLFromSrc("/sdext/source/pdfimport/test/testinput.pdf"), - new OutputWrap(aAbsURL), + new OutputWrap(tempFileURL), NULL )); + osl::File::remove( tempFileURL ); } void testOdfWriterExport() @@ -612,15 +611,14 @@ namespace pdfi::PDFIRawAdaptor aAdaptor( impl_getComponentContext() ); aAdaptor.setTreeVisitorFactory( createWriterTreeVisitorFactory() ); - ::rtl::OUString aURL, aAbsURL, aBaseURL; - osl_getFileURLFromSystemPath( (rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("pdfi_unittest_writer.xml"))).pData, - &aURL.pData ); - osl_getProcessWorkingDir(&aBaseURL.pData); - osl_getAbsoluteFileURL(aBaseURL.pData,aURL.pData,&aAbsURL.pData); + ::rtl::OUString tempFileURL; + CPPUNIT_ASSERT( osl::File::createTempFile( NULL, NULL, &tempFileURL ) == osl::File::E_None ); + osl::File::remove( tempFileURL ); // FIXME the below apparently fails silently if the file already exists CPPUNIT_ASSERT_MESSAGE("Exporting to ODF", aAdaptor.odfConvert( getURLFromSrc("/sdext/source/pdfimport/test/testinput.pdf"), - new OutputWrap(aAbsURL), + new OutputWrap(tempFileURL), NULL )); + osl::File::remove( tempFileURL ); } CPPUNIT_TEST_SUITE(PDFITest); -- cgit