[Libreoffice-commits] .: sdext/source

Lubos Lunak llunak at kemper.freedesktop.org
Fri Mar 16 12:10:07 PDT 2012


 sdext/source/pdfimport/test/tests.cxx |   22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

New commits:
commit f15023d34037068147f6afe83a187b2fb515351b
Author: Luboš Luňák <l.lunak at suse.cz>
Date:   Fri Mar 16 20:06:59 2012 +0100

    do not let a unittest create temp files in the current directory

diff --git a/sdext/source/pdfimport/test/tests.cxx b/sdext/source/pdfimport/test/tests.cxx
index d3fa3e7..b73da1d 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);


More information about the Libreoffice-commits mailing list