Version 6.4.0.0.beta1, tag libreoffice-6.4.0.0.beta1
[LibreOffice.git] / sd / qa / unit / HtmlExportTest.cxx
blob343461f493bd28810bde163fd6e3a73b8f1ae96c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include "sdmodeltestbase.hxx"
12 #include <test/htmltesttools.hxx>
13 #include <test/xmltesttools.hxx>
15 using namespace css;
17 class SdHTMLFilterTest : public SdModelTestBase, public XmlTestTools, public HtmlTestTools
19 private:
20 htmlDocPtr exportAndParseHtml(sd::DrawDocShellRef const & xDocShRef)
22 FileFormat* pFormat = getFormat(HTML);
23 OUString aExt = "." + OUString::createFromAscii(pFormat->pName);
24 utl::TempFile aTempFile(OUString(), true, &aExt);
25 aTempFile.EnableKillingFile();
26 exportTo(xDocShRef.get(), pFormat, aTempFile);
27 return parseHtml(aTempFile);
30 public:
32 void testHTMLExport()
34 sd::DrawDocShellRef xDocShRef = loadURL(m_directories.getURLFromSrc("/sd/qa/unit/data/HtmlExportTestDocument.odp"), ODP);
35 htmlDocPtr htmlDoc = exportAndParseHtml(xDocShRef);
37 assertXPath(htmlDoc, "/html", 1);
38 assertXPath(htmlDoc, "/html/body", 1);
39 assertXPath(htmlDoc, "/html/body/h1", 4);
40 assertXPath(htmlDoc, "/html/body/table", 1);
41 assertXPath(htmlDoc, "/html/body/table/tr", 5);
42 assertXPath(htmlDoc, "/html/body/ul", 1);
43 assertXPath(htmlDoc, "/html/body/ul/li", 2);
45 assertXPath(htmlDoc, "/html/head/meta[1]", "content", "text/html; charset=utf-8");
46 assertXPath(htmlDoc, "/html/head/meta[2]", "name", "generator");
47 assertXPath(htmlDoc, "/html/head/meta[3]", "name", "created");
48 assertXPath(htmlDoc, "/html/head/meta[3]", "content", "2014-04-09T17:05:41.987922038");
51 CPPUNIT_TEST_SUITE(SdHTMLFilterTest);
52 CPPUNIT_TEST(testHTMLExport);
53 CPPUNIT_TEST_SUITE_END();
56 CPPUNIT_TEST_SUITE_REGISTRATION(SdHTMLFilterTest);
58 CPPUNIT_PLUGIN_IMPLEMENT();
60 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */