diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-03 13:55:06 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-03 17:33:42 +0100 |
commit | 6f77eda1f4de7f2835a32dd597442a29fe59291c (patch) | |
tree | 61f440eccf04d5575c774681bba0994a1ae49a05 /sc | |
parent | 1cfa0f49922aa49597bac341393c8f38309a3bae (diff) |
CppunitTest_sc_html_export_test: inherit from UnoApiXmlTest
Change-Id: Iee06f883704484bf62bf1d9988580d72ba40db22
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142232
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/CppunitTest_sc_html_export_test.mk | 1 | ||||
-rw-r--r-- | sc/qa/extras/htmlexporttest.cxx | 63 |
2 files changed, 10 insertions, 54 deletions
diff --git a/sc/CppunitTest_sc_html_export_test.mk b/sc/CppunitTest_sc_html_export_test.mk index 16596fb3ef89..dae834614229 100644 --- a/sc/CppunitTest_sc_html_export_test.mk +++ b/sc/CppunitTest_sc_html_export_test.mk @@ -40,6 +40,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sc_html_export_test, \ scqahelper \ sfx \ sot \ + subsequenttest \ svl \ svt \ svx \ diff --git a/sc/qa/extras/htmlexporttest.cxx b/sc/qa/extras/htmlexporttest.cxx index a94a34ba24d5..f7dc9c115f74 100644 --- a/sc/qa/extras/htmlexporttest.cxx +++ b/sc/qa/extras/htmlexporttest.cxx @@ -15,81 +15,36 @@ #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/lang/XComponent.hpp> -#include <test/bootstrapfixture.hxx> #include <test/htmltesttools.hxx> -#include <test/xmltesttools.hxx> +#include <test/unoapixml_test.hxx> #include <comphelper/processfactory.hxx> -#include <unotools/mediadescriptor.hxx> -#include <unotest/macros_test.hxx> using namespace css::uno; using namespace css::lang; using namespace css::frame; using namespace utl; -class ScHTMLExportTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools, public HtmlTestTools +class ScHTMLExportTest : public UnoApiXmlTest, public HtmlTestTools { - Reference<XComponent> mxComponent; - OUString maFilterOptions; - - void load(std::u16string_view pDir, const char* pName) - { - if (mxComponent.is()) - mxComponent->dispose(); - mxComponent = loadFromDesktop(m_directories.getURLFromSrc(pDir) + OUString::createFromAscii(pName), "com.sun.star.comp.Calc.SpreadsheetDocument"); - } - - void save(const OUString& aFilterName, TempFileNamed const & rTempFile) - { - Reference<XStorable> xStorable(mxComponent, UNO_QUERY); - MediaDescriptor aMediaDescriptor; - aMediaDescriptor["FilterName"] <<= aFilterName; - if (!maFilterOptions.isEmpty()) - aMediaDescriptor["FilterOptions"] <<= maFilterOptions; - xStorable->storeToURL(rTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList()); - } - public: ScHTMLExportTest() + : UnoApiXmlTest("/sc/qa/extras/testdocuments/") {} - virtual void setUp() override - { - test::BootstrapFixture::setUp(); - mxDesktop.set(css::frame::Desktop::create(comphelper::getComponentContext(getMultiServiceFactory()))); - } - - virtual void tearDown() override - { - if (mxComponent.is()) - mxComponent->dispose(); - - test::BootstrapFixture::tearDown(); - } - void testHtmlSkipImage() { - // need a temp dir, because there's an image exported too - TempFileNamed aTempDir(nullptr, true); - aTempDir.EnableKillingFile(); - OUString const url(aTempDir.GetURL()); - TempFileNamed aTempFile(&url, false); - - htmlDocUniquePtr pDoc; - - load(u"/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods"); - save("HTML (StarCalc)", aTempFile); - pDoc = parseHtml(aTempFile); + loadFromURL(u"BaseForHTMLExport.ods"); + utl::TempFileNamed aTempFile = save("HTML (StarCalc)"); + htmlDocUniquePtr pDoc = parseHtml(aTempFile); CPPUNIT_ASSERT (pDoc); assertXPath(pDoc, "/html/body", 1); assertXPath(pDoc, "/html/body/table/tr/td/img", 1); - load(u"/sc/qa/extras/testdocuments/", "BaseForHTMLExport.ods"); - maFilterOptions = "SkipImages"; - save("HTML (StarCalc)", aTempFile); + setFilterOptions("SkipImages"); + utl::TempFileNamed aTempFile2 = save("HTML (StarCalc)"); - pDoc = parseHtml(aTempFile); + pDoc = parseHtml(aTempFile2); CPPUNIT_ASSERT (pDoc); assertXPath(pDoc, "/html/body", 1); assertXPath(pDoc, "/html/body/table/tr/td/img", 0); |