Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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 : */
9 :
10 : #include "sdmodeltestbase.hxx"
11 :
12 : #include <test/htmltesttools.hxx>
13 : #include <test/xmltesttools.hxx>
14 :
15 : using namespace css;
16 :
17 3 : class SdHTMLFilterTest : public SdModelTestBase, public XmlTestTools, public HtmlTestTools
18 : {
19 : private:
20 1 : htmlDocPtr exportAndParseHtml(sd::DrawDocShellRef& xDocShRef)
21 : {
22 1 : FileFormat* pFormat = getFormat(HTML);
23 1 : OUString aExt = "." + OUString::createFromAscii(pFormat->pName);
24 2 : utl::TempFile aTempFile(OUString(), true, &aExt);
25 1 : aTempFile.EnableKillingFile();
26 1 : exportTo(xDocShRef, pFormat, aTempFile);
27 2 : return parseHtml(aTempFile);
28 : }
29 :
30 : public:
31 :
32 1 : void testHTMLExport()
33 : {
34 1 : sd::DrawDocShellRef xDocShRef = loadURL(getURLFromSrc("/sd/qa/unit/data/HtmlExportTestDocument.odp"), ODP);
35 1 : htmlDocPtr htmlDoc = exportAndParseHtml(xDocShRef);
36 :
37 1 : assertXPath(htmlDoc, "/html", 1);
38 1 : assertXPath(htmlDoc, "/html/body", 1);
39 1 : assertXPath(htmlDoc, "/html/body/h1", 4);
40 1 : assertXPath(htmlDoc, "/html/body/table", 1);
41 1 : assertXPath(htmlDoc, "/html/body/table/tr", 5);
42 1 : assertXPath(htmlDoc, "/html/body/ul", 1);
43 1 : assertXPath(htmlDoc, "/html/body/ul/li", 2);
44 :
45 1 : assertXPath(htmlDoc, "/html/head/meta[1]", "content", "text/html; charset=utf-8");
46 1 : assertXPath(htmlDoc, "/html/head/meta[2]", "name", "generator");
47 1 : assertXPath(htmlDoc, "/html/head/meta[3]", "name", "created");
48 1 : assertXPath(htmlDoc, "/html/head/meta[3]", "content", "2014-04-09T17:05:41.987922038");
49 1 : }
50 :
51 2 : CPPUNIT_TEST_SUITE(SdHTMLFilterTest);
52 1 : CPPUNIT_TEST(testHTMLExport);
53 5 : CPPUNIT_TEST_SUITE_END();
54 : };
55 :
56 1 : CPPUNIT_TEST_SUITE_REGISTRATION(SdHTMLFilterTest);
57 :
58 4 : CPPUNIT_PLUGIN_IMPLEMENT();
59 :
60 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|