summaryrefslogtreecommitdiff
path: root/sw/qa/extras
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2012-08-28 11:46:00 +0200
committerMiklos Vajna <vmiklos@suse.cz>2012-08-28 11:54:37 +0200
commitea4b668d4aea664d4d7fb27ff0d3b001581ff779 (patch)
tree533630360efdf062a5367f583d3c65e84db551ab /sw/qa/extras
parent5d1d4c940ad47ec3dacdf40d82b40836c99e02c3 (diff)
SwModelTestBase: support extracting node contents from a layout dump
This way tests like "there is a textbox containing foo on the 3rd page" are possible. Also, make sure the XPath expression always matches a single node. Change-Id: Iac82b389e1910db2257240a3764ec3c7ebaa5a02
Diffstat (limited to 'sw/qa/extras')
-rw-r--r--sw/qa/extras/swmodeltestbase.hxx15
1 files changed, 12 insertions, 3 deletions
diff --git a/sw/qa/extras/swmodeltestbase.hxx b/sw/qa/extras/swmodeltestbase.hxx
index 11669fb834b7..6ebd99cd4e33 100644
--- a/sw/qa/extras/swmodeltestbase.hxx
+++ b/sw/qa/extras/swmodeltestbase.hxx
@@ -125,8 +125,12 @@ protected:
return xStyleFamily;
}
- /// Extract a value from the layout dump using an XPath expression and an attribute name.
- rtl::OUString parseDump(rtl::OString aXPath, rtl::OString aAttribute)
+ /**
+ * Extract a value from the layout dump using an XPath expression and an attribute name.
+ *
+ * If the attribute is omitted, the text of the node is returned.
+ */
+ rtl::OUString parseDump(rtl::OString aXPath, rtl::OString aAttribute = OString())
{
if (!mpXmlBuffer)
dumpLayout();
@@ -136,8 +140,13 @@ protected:
xmlXPathContextPtr pXmlXpathCtx = xmlXPathNewContext(pXmlDoc);
xmlXPathObjectPtr pXmlXpathObj = xmlXPathEvalExpression(BAD_CAST(aXPath.getStr()), pXmlXpathCtx);
xmlNodeSetPtr pXmlNodes = pXmlXpathObj->nodesetval;
+ CPPUNIT_ASSERT_EQUAL(1, xmlXPathNodeSetGetLength(pXmlNodes));
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
- rtl::OUString aRet = rtl::OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr())));
+ rtl::OUString aRet;
+ if (aAttribute.getLength())
+ aRet = rtl::OUString::createFromAscii((const char*)xmlGetProp(pXmlNode, BAD_CAST(aAttribute.getStr())));
+ else
+ aRet = rtl::OUString::createFromAscii((const char*)XML_GET_CONTENT(pXmlNode));
xmlFreeDoc(pXmlDoc);