LibreOffice Module test (master) 1
Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
XmlTestTools Class Reference

#include <xmltesttools.hxx>

Inheritance diagram for XmlTestTools:
[legend]

Static Public Member Functions

static xmlDocUniquePtr parseXmlStream (SvStream *pStream)
 Return xmlDocPtr representation of the XML stream read from pStream. More...
 
static xmlDocUniquePtr dumpAndParse (MetafileXmlDump &rDumper, const GDIMetaFile &rGDIMetaFile)
 

Protected Member Functions

 XmlTestTools ()
 
virtual ~XmlTestTools ()
 
virtual void registerNamespaces (xmlXPathContextPtr &pXmlXpathCtx)
 
xmlXPathObjectPtr getXPathNode (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath)
 
OUString getXPath (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, const OString &rAttribute)
 Same as the assertXPath(), but don't assert: return the string instead. More...
 
OUString getXPathContent (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath)
 Same as the assertXPathContent(), but don't assert: return the string instead. More...
 
int getXPathPosition (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, std::string_view rChildName)
 Get the position of the child named rName of the parent node specified by rXPath. More...
 
int countXPathNodes (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath)
 Get the number of the nodes returned by the rXPath. More...
 
void assertXPath (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, const OString &rAttribute, const OUString &rExpectedValue)
 Assert that rXPath exists, returns exactly one node, and the rXPath's attribute's value equals to the rExpected value. More...
 
void assertXPathAttrs (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, const std::vector< std::pair< OString, OUString > > &aPairVector)
 
void assertXPath (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, int nNumberOfNodes=1)
 Assert that rXPath exists, and returns exactly nNumberOfNodes nodes (1 by default). More...
 
void assertXPathContent (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, const OUString &rContent)
 Assert that rXPath exists, and its content equals rContent. More...
 
void assertXPathNSDef (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, std::u16string_view rNSPrefix, std::u16string_view rNSHref)
 Assert that rXPath exists and it has an rNSPrefix=rNSHref namespace definition. More...
 
void assertXPathChildren (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, int nNumberOfChildNodes)
 Assert that rXPath exists, and has exactly nNumberOfChildNodes child nodes. More...
 
void assertXPathNoAttribute (const xmlDocUniquePtr &pXmlDoc, const OString &rXPath, const OString &rAttribute)
 Assert that rXPath exists, has exactly 1 result set nodes and does not have an attribute named rAttribute. More...
 

Static Protected Member Functions

static xmlDocUniquePtr parseXml (utl::TempFileNamed const &aTempFile)
 
static void registerODFNamespaces (xmlXPathContextPtr &pXmlXpathCtx)
 
static void registerOOXMLNamespaces (xmlXPathContextPtr &pXmlXpathCtx)
 

Detailed Description

Definition at line 33 of file xmltesttools.hxx.

Constructor & Destructor Documentation

◆ XmlTestTools()

XmlTestTools::XmlTestTools ( )
protected

Definition at line 39 of file xmltesttools.cxx.

◆ ~XmlTestTools()

XmlTestTools::~XmlTestTools ( )
protectedvirtual

Definition at line 42 of file xmltesttools.cxx.

Member Function Documentation

◆ assertXPath() [1/2]

void XmlTestTools::assertXPath ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
const OString &  rAttribute,
const OUString &  rExpectedValue 
)
protected

Assert that rXPath exists, returns exactly one node, and the rXPath's attribute's value equals to the rExpected value.

Definition at line 167 of file xmltesttools.cxx.

References getXPath().

Referenced by assertXPathAttrs().

◆ assertXPath() [2/2]

void XmlTestTools::assertXPath ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
int  nNumberOfNodes = 1 
)
protected

Assert that rXPath exists, and returns exactly nNumberOfNodes nodes (1 by default).

Also useful for checking that we do not export some node (nNumberOfNodes == 0).

Definition at line 192 of file xmltesttools.cxx.

References countXPathNodes().

◆ assertXPathAttrs()

void XmlTestTools::assertXPathAttrs ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
const std::vector< std::pair< OString, OUString > > &  aPairVector 
)
protected

Definition at line 174 of file xmltesttools.cxx.

References assertXPath().

◆ assertXPathChildren()

void XmlTestTools::assertXPathChildren ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
int  nNumberOfChildNodes 
)
protected

Assert that rXPath exists, and has exactly nNumberOfChildNodes child nodes.

Useful for checking that we do have a no child nodes to a specific node (nNumberOfChildNodes == 0).

Definition at line 230 of file xmltesttools.cxx.

References getXPathNode().

◆ assertXPathContent()

void XmlTestTools::assertXPathContent ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
const OUString &  rContent 
)
protected

Assert that rXPath exists, and its content equals rContent.

Definition at line 198 of file xmltesttools.cxx.

References getXPathContent().

◆ assertXPathNoAttribute()

void XmlTestTools::assertXPathNoAttribute ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
const OString &  rAttribute 
)
protected

Assert that rXPath exists, has exactly 1 result set nodes and does not have an attribute named rAttribute.

Definition at line 248 of file xmltesttools.cxx.

References getXPathNode().

◆ assertXPathNSDef()

void XmlTestTools::assertXPathNSDef ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
std::u16string_view  rNSPrefix,
std::u16string_view  rNSHref 
)
protected

Assert that rXPath exists and it has an rNSPrefix=rNSHref namespace definition.

Definition at line 203 of file xmltesttools.cxx.

References getXPathNode().

◆ countXPathNodes()

int XmlTestTools::countXPathNodes ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath 
)
protected

Get the number of the nodes returned by the rXPath.

Definition at line 183 of file xmltesttools.cxx.

References getXPathNode(), and n.

Referenced by assertXPath().

◆ dumpAndParse()

xmlDocUniquePtr XmlTestTools::dumpAndParse ( MetafileXmlDump rDumper,
const GDIMetaFile rGDIMetaFile 
)
static

◆ getXPath()

OUString XmlTestTools::getXPath ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
const OString &  rAttribute 
)
protected

Same as the assertXPath(), but don't assert: return the string instead.

Definition at line 89 of file xmltesttools.cxx.

References getXPathNode().

Referenced by assertXPath().

◆ getXPathContent()

OUString XmlTestTools::getXPathContent ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath 
)
protected

Same as the assertXPathContent(), but don't assert: return the string instead.

Definition at line 109 of file xmltesttools.cxx.

References getXPathNode().

Referenced by assertXPathContent().

◆ getXPathNode()

xmlXPathObjectPtr XmlTestTools::getXPathNode ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath 
)
protected

◆ getXPathPosition()

int XmlTestTools::getXPathPosition ( const xmlDocUniquePtr pXmlDoc,
const OString &  rXPath,
std::string_view  rChildName 
)
protected

Get the position of the child named rName of the parent node specified by rXPath.

Useful for checking relative order of elements.

Definition at line 260 of file xmltesttools.cxx.

References getXPathNode().

◆ parseXml()

xmlDocUniquePtr XmlTestTools::parseXml ( utl::TempFileNamed const &  aTempFile)
staticprotected

Definition at line 45 of file xmltesttools.cxx.

References utl::TempFileNamed::GetURL(), and parseXmlStream().

◆ parseXmlStream()

xmlDocUniquePtr XmlTestTools::parseXmlStream ( SvStream pStream)
static

Return xmlDocPtr representation of the XML stream read from pStream.

Definition at line 51 of file xmltesttools.cxx.

References SvStream::ReadBytes(), SvStream::remainingSize(), and SAL_INFO.

Referenced by dumpAndParse(), UnoApiXmlTest::parseExport(), and parseXml().

◆ registerNamespaces()

void XmlTestTools::registerNamespaces ( xmlXPathContextPtr &  pXmlXpathCtx)
protectedvirtual

Definition at line 79 of file xmltesttools.cxx.

References registerODFNamespaces(), and registerOOXMLNamespaces().

Referenced by getXPathNode().

◆ registerODFNamespaces()

void XmlTestTools::registerODFNamespaces ( xmlXPathContextPtr &  pXmlXpathCtx)
staticprotected

Definition at line 287 of file xmltesttools.cxx.

Referenced by registerNamespaces().

◆ registerOOXMLNamespaces()

void XmlTestTools::registerOOXMLNamespaces ( xmlXPathContextPtr &  pXmlXpathCtx)
staticprotected

Definition at line 370 of file xmltesttools.cxx.

Referenced by registerNamespaces().


The documentation for this class was generated from the following files: