Kaydet (Commit) 9f874d41 authored tarafından Michael Stahl's avatar Michael Stahl

sc: fix temp file leak in ScHTMLExportTest

Change-Id: Iab385ce8b24dd24985ec9b2d0c9d2a4e603d0fd0
üst c0b1d1bf
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
#include <unotools/mediadescriptor.hxx> #include <unotools/mediadescriptor.hxx>
#include <unotools/ucbstreamhelper.hxx> #include <unotools/ucbstreamhelper.hxx>
#include <unotools/localfilehelper.hxx>
#include <unotest/macros_test.hxx> #include <unotest/macros_test.hxx>
#include <sfx2/docfilt.hxx> #include <sfx2/docfilt.hxx>
#include <sfx2/docfile.hxx> #include <sfx2/docfile.hxx>
...@@ -33,7 +34,6 @@ using namespace utl; ...@@ -33,7 +34,6 @@ using namespace utl;
class ScHTMLExportTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools, public HtmlTestTools class ScHTMLExportTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools, public HtmlTestTools
{ {
Reference<XComponent> mxComponent; Reference<XComponent> mxComponent;
TempFile maTempFile;
OUString maFilterOptions; OUString maFilterOptions;
void load(const char* pDir, const char* pName) void load(const char* pDir, const char* pName)
...@@ -45,8 +45,6 @@ class ScHTMLExportTest : public test::BootstrapFixture, public unotest::MacrosTe ...@@ -45,8 +45,6 @@ class ScHTMLExportTest : public test::BootstrapFixture, public unotest::MacrosTe
void save(const OUString& aFilterName, TempFile& rTempFile) void save(const OUString& aFilterName, TempFile& rTempFile)
{ {
rTempFile.EnableKillingFile();
Reference<XStorable> xStorable(mxComponent, UNO_QUERY); Reference<XStorable> xStorable(mxComponent, UNO_QUERY);
MediaDescriptor aMediaDescriptor; MediaDescriptor aMediaDescriptor;
aMediaDescriptor["FilterName"] <<= aFilterName; aMediaDescriptor["FilterName"] <<= aFilterName;
...@@ -75,11 +73,16 @@ public: ...@@ -75,11 +73,16 @@ public:
void testHtmlSkipImage() void testHtmlSkipImage()
{ {
// need a temp dir, because there's an image exported too
TempFile aTempDir(0, true);
OUString const url(aTempDir.GetURL());
TempFile aTempFile(&url, false);
htmlDocPtr pDoc; htmlDocPtr pDoc;
load("/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods"); load("/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods");
save("HTML (StarCalc)", maTempFile); save("HTML (StarCalc)", aTempFile);
pDoc = parseHtml(maTempFile); pDoc = parseHtml(aTempFile);
CPPUNIT_ASSERT (pDoc); CPPUNIT_ASSERT (pDoc);
assertXPath(pDoc, "/html/body", 1); assertXPath(pDoc, "/html/body", 1);
...@@ -87,12 +90,14 @@ public: ...@@ -87,12 +90,14 @@ public:
load("/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods"); load("/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods");
maFilterOptions = OUString("SkipImages"); maFilterOptions = OUString("SkipImages");
save("HTML (StarCalc)", maTempFile); save("HTML (StarCalc)", aTempFile);
pDoc = parseHtml(maTempFile); pDoc = parseHtml(aTempFile);
CPPUNIT_ASSERT (pDoc); CPPUNIT_ASSERT (pDoc);
assertXPath(pDoc, "/html/body", 1); assertXPath(pDoc, "/html/body", 1);
assertXPath(pDoc, "/html/body/table/tr/td/img", 0); assertXPath(pDoc, "/html/body/table/tr/td/img", 0);
utl::removeTree(aTempDir.GetURL());
} }
CPPUNIT_TEST_SUITE(ScHTMLExportTest); CPPUNIT_TEST_SUITE(ScHTMLExportTest);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment