LibreOffice Module test (master) 1
xmltesttools.hxx
Go to the documentation of this file.
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#ifndef INCLUDED_TEST_XMLTESTTOOLS_HXX
11#define INCLUDED_TEST_XMLTESTTOOLS_HXX
12
13#include <sal/config.h>
14#include <test/testdllapi.hxx>
15
16#include <libxml/xmlwriter.h>
17#include <libxml/tree.h>
18#include <libxml/xpath.h>
19#include <libxml/xpathInternals.h>
20#include <libxml/parserInternals.h>
21
22#include <rtl/string.hxx>
23#include <rtl/ustring.hxx>
24#include <unotools/tempfile.hxx>
25#include <vcl/mtfxmldump.hxx>
26#include <test/xmldocptr.hxx>
27
28#include <cppunit/TestAssert.h>
29
30#include <string_view>
31#include <vector>
32
34{
35public:
37 static xmlDocUniquePtr parseXmlStream(SvStream* pStream);
38
39 static xmlDocUniquePtr dumpAndParse(MetafileXmlDump& rDumper, const GDIMetaFile& rGDIMetaFile);
40
41protected:
43 virtual ~XmlTestTools();
44
45 static xmlDocUniquePtr parseXml(utl::TempFileNamed const & aTempFile);
46
47 virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx);
48
49 // Caller must call xmlXPathFreeObject:
50 xmlXPathObjectPtr getXPathNode(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath);
54 OUString getXPath(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute);
58 OUString getXPathContent(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath);
63 int getXPathPosition(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, std::string_view rChildName);
67 int countXPathNodes(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath);
72 void assertXPath(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute,
73 const OUString& rExpectedValue);
74 void assertXPathAttrs(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath,
75 const std::vector<std::pair<OString, OUString>>& aPairVector);
80 void assertXPath(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, int nNumberOfNodes = 1);
84 void assertXPathContent(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OUString& rContent);
88 void assertXPathNSDef(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, std::u16string_view rNSPrefix,
89 std::u16string_view rNSHref);
94 void assertXPathChildren(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, int nNumberOfChildNodes);
98 void assertXPathNoAttribute(const xmlDocUniquePtr& pXmlDoc, const OString& rXPath, const OString& rAttribute);
99
100 static void registerODFNamespaces(xmlXPathContextPtr& pXmlXpathCtx);
101 static void registerOOXMLNamespaces(xmlXPathContextPtr& pXmlXpathCtx);
102};
103
104#endif
105
106/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define OOO_DLLPUBLIC_TEST
Definition: testdllapi.hxx:28
std::unique_ptr< xmlDoc, xmlDocDeleter > xmlDocUniquePtr
Definition: xmldocptr.hxx:18