sw_ooxmlexport13: Add test for b2dd08c6af
Change-Id: I0cae335f075b785de907c4aa8ec47c9ca086cd12 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197436 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
@@ -74,6 +74,11 @@ protected:
|
||||
* Useful for checking relative order of elements.
|
||||
*/
|
||||
int getXPathPosition(const xmlDocUniquePtr& pXmlDoc, const char* pXPath, const char* pChildName);
|
||||
/**
|
||||
* Get the position of the attribute named rName of the parent node specified by pXPath.
|
||||
* Useful for checking relative order of elements.
|
||||
*/
|
||||
int getXPathAttributePosition(const xmlDocUniquePtr& pXmlDoc, const char* pXPath, const char* pAttributeName);
|
||||
/**
|
||||
* Get the number of the nodes returned by the pXPath.
|
||||
*/
|
||||
|
||||
@@ -756,6 +756,21 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf169802_hidden_shape)
|
||||
// Layout mustn't contain fly portion, without the fix it would contain several
|
||||
int nFlyNodes = countXPathNodes(pDump, "//*[contains(@type, 'PortionType::Fly')]");
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE("No fly portion nodes must exist in the layout", 0, nFlyNodes);
|
||||
|
||||
save(TestFilter::DOCX);
|
||||
|
||||
xmlDocUniquePtr pXmlDoc = parseExport(u"word/document.xml"_ustr);
|
||||
const char* const sPath("/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor");
|
||||
CPPUNIT_ASSERT_EQUAL(0, getXPathAttributePosition(pXmlDoc, sPath, "distT"));
|
||||
CPPUNIT_ASSERT_EQUAL(1, getXPathAttributePosition(pXmlDoc, sPath, "distB"));
|
||||
CPPUNIT_ASSERT_EQUAL(2, getXPathAttributePosition(pXmlDoc, sPath, "distL"));
|
||||
CPPUNIT_ASSERT_EQUAL(3, getXPathAttributePosition(pXmlDoc, sPath, "distR"));
|
||||
CPPUNIT_ASSERT_EQUAL(4, getXPathAttributePosition(pXmlDoc, sPath, "simplePos"));
|
||||
CPPUNIT_ASSERT_EQUAL(5, getXPathAttributePosition(pXmlDoc, sPath, "relativeHeight"));
|
||||
CPPUNIT_ASSERT_EQUAL(6, getXPathAttributePosition(pXmlDoc, sPath, "behindDoc"));
|
||||
CPPUNIT_ASSERT_EQUAL(7, getXPathAttributePosition(pXmlDoc, sPath, "locked"));
|
||||
CPPUNIT_ASSERT_EQUAL(8, getXPathAttributePosition(pXmlDoc, sPath, "layoutInCell"));
|
||||
CPPUNIT_ASSERT_EQUAL(9, getXPathAttributePosition(pXmlDoc, sPath, "allowOverlap"));
|
||||
}
|
||||
|
||||
DECLARE_OOXMLEXPORT_TEST(testTdf124594, "tdf124594.docx")
|
||||
|
||||
@@ -334,6 +334,34 @@ int XmlTestTools::getXPathPosition(const xmlDocUniquePtr& pXmlDoc, const char* p
|
||||
return nRet;
|
||||
}
|
||||
|
||||
int XmlTestTools::getXPathAttributePosition(const xmlDocUniquePtr& pXmlDoc, const char* pXPath, const char* pAttributeName)
|
||||
{
|
||||
xmlXPathObjectPtr pXmlObj = getXPathNode(pXmlDoc, pXPath);
|
||||
xmlNodeSetPtr pXmlNodes = pXmlObj->nodesetval;
|
||||
CPPUNIT_ASSERT(pXmlNodes);
|
||||
CPPUNIT_ASSERT_EQUAL_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + pXPath + "' number of nodes is incorrect").getStr(),
|
||||
1,
|
||||
xmlXPathNodeSetGetLength(pXmlNodes));
|
||||
xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
|
||||
int nRet = 0;
|
||||
bool bFound = false;
|
||||
for (xmlAttrPtr pAttribute = pXmlNode->properties; pAttribute; pAttribute = pAttribute->next)
|
||||
{
|
||||
if (oconvert(pAttribute->name) == pAttributeName)
|
||||
{
|
||||
bFound = true;
|
||||
break;
|
||||
}
|
||||
++nRet;
|
||||
}
|
||||
xmlXPathFreeObject(pXmlObj);
|
||||
CPPUNIT_ASSERT_MESSAGE(OString(OString::Concat("In <") + pXmlDoc->name + ">, XPath '" + pXPath
|
||||
+ "' attribute '" + pAttributeName + "' not found")
|
||||
.getStr(),
|
||||
bFound);
|
||||
return nRet;
|
||||
}
|
||||
|
||||
void XmlTestTools::assertXPathNodeName(const xmlDocUniquePtr& pXmlDoc, const char* pXPath,
|
||||
std::string_view rExpectedName)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user