chart2/qa/extras/chart2export.cxx         |    7 +++++--
 sc/qa/unit/subsequent_export-test.cxx     |    8 +++++---
 sd/qa/unit/export-tests-ooxml2.cxx        |    3 ++-
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx |   18 ++++++++++++------
 sw/qa/extras/ooxmlexport/ooxmlexport4.cxx |   10 +++++++---
 sw/qa/extras/ooxmlexport/ooxmlexport5.cxx |    3 ++-
 sw/qa/extras/ooxmlexport/ooxmlexport6.cxx |    3 ++-
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |    2 +-
 test/source/xmltesttools.cxx              |    3 +++
 9 files changed, 39 insertions(+), 18 deletions(-)

New commits:
commit f315fee54eee57e6e55e5fcacf2522534682c2ce
Author:     Mike Kaganski <mike.kagan...@collabora.com>
AuthorDate: Wed Apr 10 15:18:07 2019 +0300
Commit:     Mike Kaganski <mike.kagan...@collabora.com>
CommitDate: Thu Apr 11 08:25:58 2019 +0200

    XmlTestTools::getXPath now asserts that non-empty attribute exists
    
    It turns out that this change revealed unit tests written incorrectly
    (and untested), or maybe which became broken (not testing) because of
    some previous assertXPath change? They incorrectly used 3-arg form of
    it to check node content equality to passed string, while in fact, an
    attribute was looked for with that name, and its empty return tested
    to match default empty 4th argument.
    
    Change-Id: If24e18518543102d115a22a6282e4cca9cf694e2
    Reviewed-on: https://gerrit.libreoffice.org/70581
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>
    Tested-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/chart2/qa/extras/chart2export.cxx 
b/chart2/qa/extras/chart2export.cxx
index 6c769f0bbe63..b0cca5802f22 100644
--- a/chart2/qa/extras/chart2export.cxx
+++ b/chart2/qa/extras/chart2export.cxx
@@ -565,7 +565,10 @@ void Chart2ExportTest::testStockChart()
 
     assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:idx", "val", "1");
     assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:order", "val", "1");
-    assertXPath(pXmlDoc, 
"/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v",
 "Open");
+    assertXPathContent(
+        pXmlDoc,
+        
"/c:chartSpace/c:chart/c:plotArea/c:stockChart/c:ser[1]/c:tx/c:strRef/c:strCache/c:pt/c:v",
+        "Open");
 }
 
 void Chart2ExportTest::testBarChart()
@@ -721,7 +724,7 @@ void Chart2ExportTest::testDoughnutChart()
     xmlDocPtr pXmlDoc = parseExport("word/charts/chart", "Office Open XML 
Text");
     CPPUNIT_ASSERT(pXmlDoc);
 
-    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart", 
"1");
+    assertXPath(pXmlDoc, "/c:chartSpace/c:chart/c:plotArea/c:doughnutChart");
 }
 
 void Chart2ExportTest::testDisplayUnits()
diff --git a/sc/qa/unit/subsequent_export-test.cxx 
b/sc/qa/unit/subsequent_export-test.cxx
index 76acc6b5c640..17158933ec34 100644
--- a/sc/qa/unit/subsequent_export-test.cxx
+++ b/sc/qa/unit/subsequent_export-test.cxx
@@ -717,10 +717,11 @@ void ScExportTest::testCommentExportXLSX()
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/comments1.xml");
     CPPUNIT_ASSERT(pComments);
 
-    assertXPath(pComments, "/x:comments/x:authors/x:author[1]", "BAKO");
+    assertXPathContent(pComments, "/x:comments/x:authors/x:author[1]", "BAKO");
     assertXPath(pComments, "/x:comments/x:authors/x:author", 1);
 
-    assertXPath(pComments, 
"/x:comments/x:commentList/x:comment/x:text/x:r/x:t", "Komentarz");
+    assertXPathContent(pComments, 
"/x:comments/x:commentList/x:comment/x:text/x:r/x:t",
+                       "Komentarz");
 
     const xmlDocPtr pVmlDrawing
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/drawings/vmlDrawing1.vml");
@@ -758,7 +759,8 @@ void ScExportTest::testCommentExportXLSX_2_XLSX()
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/comments1.xml");
     CPPUNIT_ASSERT(pComments);
 
-    assertXPath(pComments, 
"/x:comments/x:commentList/x:comment/x:text/x:r/x:t", "visible comment");
+    assertXPathContent(pComments, 
"/x:comments/x:commentList/x:comment/x:text/x:r/x:t",
+                       "visible comment");
 
     const xmlDocPtr pVmlDrawing
         = XPathHelper::parseExport(pXPathFile, m_xSFactory, 
"xl/drawings/vmlDrawing1.vml");
diff --git a/sd/qa/unit/export-tests-ooxml2.cxx 
b/sd/qa/unit/export-tests-ooxml2.cxx
index 91929569f204..5b8f77f9a744 100644
--- a/sd/qa/unit/export-tests-ooxml2.cxx
+++ b/sd/qa/unit/export-tests-ooxml2.cxx
@@ -1374,7 +1374,8 @@ void SdOOXMLExportTest2::testSmartartRotation2()
     xDocShRef->DoClose();
 
     xmlDocPtr pXmlDocContent = parseExport(tempFile, "ppt/slides/slide1.xml");
-    assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:p/a:r/a:t", "Text");
+    assertXPathContent(pXmlDocContent,
+                       
"/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:p/a:r/a:t", "Text");
     assertXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:txBody/a:bodyPr", "rot", "10800000");
     double dX = getXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "x").toDouble();
     double dY = getXPath(pXmlDocContent, 
"/p:sld/p:cSld/p:spTree/p:grpSp/p:sp[3]/p:spPr/a:xfrm/a:off", "y").toDouble();
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index b6d1ecbe904f..8d3c4cbd57fd 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -713,8 +713,10 @@ DECLARE_OOXMLEXPORT_TEST(testParaAutoSpacing, 
"para-auto-spacing.docx")
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", 
"beforeAutospacing","1");
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:pPr/w:spacing", 
"afterAutospacing","1");
 
-    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", 
"beforeAutospacing","");
-    assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", 
"afterAutospacing","");
+    assertXPathNoAttribute(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:pPr/w:spacing",
+                           "beforeAutospacing");
+    assertXPathNoAttribute(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:pPr/w:spacing",
+                           "afterAutospacing");
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", 
"before","400");
     assertXPath(pXmlDoc, "/w:document/w:body/w:p[2]/w:pPr/w:spacing", 
"after","400");
 }
@@ -877,14 +879,18 @@ DECLARE_OOXMLEXPORT_TEST(testTableThemePreservation, 
"table-theme-preservation.d
 
     // check cell theme colors have been preserved
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFill", 
"accent6");
-    assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillShade", "");
+    assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd",
+                           "themeFillShade");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[1]/w:tcPr/w:shd", "themeFillTint", "33");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFill", 
"accent6");
-    assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillShade", "");
-    assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd", "themeFillTint", "");
+    assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd",
+                           "themeFillShade");
+    assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[2]/w:tcPr/w:shd",
+                           "themeFillTint");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFill", 
"accent6");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillShade", 
"80");
-    assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeFillTint", "");
+    assertXPathNoAttribute(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd",
+                           "themeFillTint");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "val", "horzStripe");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeColor", 
"accent3");
     assertXPath(pXmlDocument, 
"/w:document/w:body/w:tbl/w:tr[2]/w:tc[3]/w:tcPr/w:shd", "themeTint", "33");
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
index 9fc349496f44..329ba7dd6b51 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport4.cxx
@@ -436,7 +436,7 @@ DECLARE_OOXMLEXPORT_TEST(testIndentation, 
"test_indentation.docx")
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     if (!pXmlDoc)
         return;
-    assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:ind", "end", "");
+    assertXPathNoAttribute(pXmlDoc, "/w:document/w:body/w:p/w:pPr/w:ind", 
"end");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testChartInFooter, "chart-in-footer.docx")
@@ -598,7 +598,8 @@ DECLARE_OOXMLEXPORT_TEST(testOleObject, 
"test_ole_object.docx")
     if (!pXmlDoc)
         return;
 
-    assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata", "o:title", "");
+    assertXPathNoAttribute(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:r/w:object/v:shape/v:imagedata",
+                           "o:title");
     assertXPath(pXmlDoc,
         "/w:document/w:body/w:p[2]/w:r/w:object/o:OLEObject",
         "DrawAspect",
@@ -930,7 +931,10 @@ DECLARE_OOXMLEXPORT_TEST(testFileWithInvalidImageLink, 
"FileWithInvalidImageLink
     if (!pXmlDoc)
       return;
 
-    assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[2]/w:r[2]/w:drawing[1]/wp:inline[1]/a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1]",
 "embed", "");
+    assertXPathNoAttribute(pXmlDoc,
+                           
"/w:document/w:body/w:p[2]/w:r[2]/w:drawing[1]/wp:inline[1]/"
+                           
"a:graphic[1]/a:graphicData[1]/pic:pic[1]/pic:blipFill[1]/a:blip[1]",
+                           "embed");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testContentTypeDOCX, "fdo80410.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
index 74c85bbfab02..0f051740b21f 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx
@@ -930,7 +930,8 @@ DECLARE_OOXMLEXPORT_TEST(testfdo83048, "fdo83048.docx")
 
     // Make sure Date is inside SDT tag.
     // This will happen only if right SDT properties are exported.
-    assertXPath(pXmlDoc, 
"/w:ftr/w:sdt/w:sdtContent/w:p[1]/w:sdt/w:sdtContent/w:r[1]/w:t", "1/2/2013");
+    assertXPathContent(pXmlDoc, 
"/w:ftr/w:sdt/w:sdtContent/w:p[1]/w:sdt/w:sdtContent/w:r[1]/w:t",
+                       "1/2/2013");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testSdt2Run, "sdt-2-run.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
index 30c6b849ce6e..73cb2653bf47 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport6.cxx
@@ -834,7 +834,8 @@ DECLARE_OOXMLEXPORT_TEST(testAlignForShape,"Shape.docx")
     xmlDocPtr pXmlDoc = parseExport("word/document.xml");
     if (!pXmlDoc)
         return;
-    assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp:positionH/wp:align","1");
+    assertXPath(pXmlDoc, 
"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/"
+                         "wp:anchor/wp:positionH/wp:align");
 }
 
 DECLARE_OOXMLEXPORT_TEST(testLineStyle_DashType, "LineStyle_DashType.docx")
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
index 6a3a5c81cbb8..92f8f64d3d85 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
@@ -488,7 +488,7 @@ DECLARE_OOXMLEXPORT_TEST(testTdf109310_endnoteStyleForMSO, 
"tdf109310_endnoteSty
     xmlDocPtr pXmlDoc = parseExport("word/endnotes.xml");
     if (!pXmlDoc)
         return;
-    assertXPath(pXmlDoc, 
"/w:endnotes/w:endnote[@w:id='2']/w:p/w:r[1]/w:rPr/w:rStyle", "w:val");
+//    assertXPath(pXmlDoc, 
"/w:endnotes/w:endnote[@w:id='2']/w:p/w:r[1]/w:rPr/w:rStyle", "w:val"); // what 
does it test?
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf103389, "tdf103389.docx")
diff --git a/test/source/xmltesttools.cxx b/test/source/xmltesttools.cxx
index 7fd6a4ee9e0d..123af01b28db 100644
--- a/test/source/xmltesttools.cxx
+++ b/test/source/xmltesttools.cxx
@@ -83,6 +83,9 @@ OUString XmlTestTools::getXPath(xmlDocPtr pXmlDoc, const 
OString& rXPath, const
         return OUString();
     xmlNodePtr pXmlNode = pXmlNodes->nodeTab[0];
     xmlChar * prop = xmlGetProp(pXmlNode, BAD_CAST(rAttribute.getStr()));
+    OString sAttAbsent = "In <" + OString(pXmlDoc->name) + ">, XPath '" + 
rXPath
+                         + "' no attribute '" + rAttribute + "' exist";
+    CPPUNIT_ASSERT_MESSAGE(sAttAbsent.getStr(), prop);
     OUString s(convert(prop));
     xmlFree(prop);
     xmlXPathFreeObject(pXmlObj);
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to