diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2018-03-01 13:31:22 +0100 |
---|---|---|
committer | Christian Lohmaier <lohmaier+LibreOffice@googlemail.com> | 2018-03-14 18:20:28 +0100 |
commit | 102292b1039462ad236730fb24baf232c1452c14 (patch) | |
tree | bd29827deec472f5215c5adfd3f86e4622d3c2cc | |
parent | tdf#115142 Revert "slideshow: clip shapes in secondary screen window" (diff) | |
download | core-102292b1039462ad236730fb24baf232c1452c14.tar.gz core-102292b1039462ad236730fb24baf232c1452c14.zip |
test: add assertXPathNSDef()
Partial backport of Miklos' master commit
f8da775795052ad2eb879970c115d2e2a2fe8c81
without the EPUB changes.
Change-Id: Ic9dd105249a59200dba03bb30eda350a95aff263
Reviewed-on: https://gerrit.libreoffice.org/50582
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
(cherry picked from commit 15cf7d30d475271b394ead3bb2458c1dc791a97c)
Reviewed-on: https://gerrit.libreoffice.org/51288
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Reviewed-by: Eike Rathke <erack@redhat.com>
Tested-by: Eike Rathke <erack@redhat.com>
Reviewed-by: Christian Lohmaier <lohmaier+LibreOffice@googlemail.com>
-rw-r--r-- | include/test/xmltesttools.hxx | 5 | ||||
-rw-r--r-- | test/source/xmltesttools.cxx | 27 |
2 files changed, 32 insertions, 0 deletions
diff --git a/include/test/xmltesttools.hxx b/include/test/xmltesttools.hxx index 80f95b321a50..42025f9c9ce2 100644 --- a/include/test/xmltesttools.hxx +++ b/include/test/xmltesttools.hxx @@ -76,6 +76,11 @@ protected: */ void assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rContent); /** + * Assert that rXPath exists and it has an rNSPrefix=rNSHref namespace definition. + */ + void assertXPathNSDef(xmlDocPtr pXmlDoc, const OString& rXPath, const OUString& rNSPrefix, + const OUString& rNSHref); + /** * 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). */ diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx index 04e90f3cbd7e..94e2cc773e3c 100644 --- a/test/source/xmltesttools.cxx +++ b/test/source/xmltesttools.cxx @@ -122,6 +122,33 @@ void XmlTestTools::assertXPathContent(xmlDocPtr pXmlDoc, const OString& rXPath, CPPUNIT_ASSERT_EQUAL_MESSAGE(OString("In <" + OString(pXmlDoc->name) + ">, XPath contents of child does not match").getStr(), rContent, getXPathContent(pXmlDoc, rXPath)); } +void XmlTestTools::assertXPathNSDef(xmlDocPtr pXmlDoc, const OString& rXPath, + const OUString& rNSPrefix, const OUString& rNSHref) +{ + xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, rXPath); + xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval; + CPPUNIT_ASSERT_MESSAGE( + OString("In <" + OString(pXmlDoc->name) + ">, XPath '" + rXPath + "' not found").getStr(), + xmlXPathNodeSetGetLength(pXmlNodes) > 0); + + xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0]; + bool bFound = false; + for (xmlNsPtr pNamespace = pXmlNode->nsDef; pNamespace; pNamespace = pNamespace->next) + { + if (!pNamespace->prefix) + continue; + + CPPUNIT_ASSERT(pNamespace->href); + if (rNSPrefix == convert(pNamespace->prefix) && rNSHref == convert(pNamespace->href)) + { + bFound = true; + break; + } + } + xmlXPathFreeObject(pXmlObj); + CPPUNIT_ASSERT(bFound); +} + void XmlTestTools::assertXPathChildren(xmlDocPtr pXmlDoc, const OString& rXPath, int nNumberOfChildNodes) { #if LIBXML_VERSION >= 20703 /* xmlChildElementCount is only available in libxml2 >= 2.7.3 */ |