include/test/unoapi_test.hxx |    2 ++
 sc/qa/unit/scshapetest.cxx   |    4 ++++
 sc/qa/unit/uicalc/uicalc.cxx |    4 ++++
 sd/qa/filter/eppt/eppt.cxx   |    2 --
 test/source/unoapi_test.cxx  |   29 ++++++++++++++++++++++++++++-
 xmloff/qa/unit/draw.cxx      |   16 ++--------------
 xmloff/qa/unit/style.cxx     |    6 ------
 xmloff/qa/unit/text.cxx      |   13 +------------
 8 files changed, 41 insertions(+), 35 deletions(-)

New commits:
commit ff97d047393c955af2f3173a9c7e2534a059a058
Author:     Xisco Fauli <[email protected]>
AuthorDate: Tue Oct 25 10:18:11 2022 +0200
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Oct 25 11:24:43 2022 +0200

    UnoApiTest: use validate when saving files
    
    Change-Id: I0f04fae8b4ff922f5e14ae413cd63cc92a66077e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141797
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/include/test/unoapi_test.hxx b/include/test/unoapi_test.hxx
index d38453432f54..8c19a56333a9 100644
--- a/include/test/unoapi_test.hxx
+++ b/include/test/unoapi_test.hxx
@@ -43,6 +43,8 @@ protected:
     // reference to document component that we are testing
     css::uno::Reference<css::lang::XComponent> mxComponent;
 
+    bool mbSkipValidation; // if you set this flag for a new test I'm going to 
haunt you!
+
 private:
     OUString m_aBaseString;
 };
diff --git a/sc/qa/unit/scshapetest.cxx b/sc/qa/unit/scshapetest.cxx
index d597ac10b3fc..e641822beca1 100644
--- a/sc/qa/unit/scshapetest.cxx
+++ b/sc/qa/unit/scshapetest.cxx
@@ -1038,6 +1038,10 @@ void ScShapeTest::testTdf115655_HideDetail()
     pViewShell->GetViewData().GetDispatcher().Execute(SID_OUTLINE_HIDE);
     CPPUNIT_ASSERT_MESSAGE("Collapse: Image should not be visible", 
!pObj->IsVisible());
 
+    // FIXME: validation fails with
+    // Error: unexpected attribute "drawooo:display"
+    mbSkipValidation = true;
+
     // Save and reload
     saveAndReload("calc8");
     CPPUNIT_ASSERT(mxComponent);
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 1131f30463f0..27e28175bc23 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -995,6 +995,10 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf144244)
 
     CPPUNIT_ASSERT_EQUAL(OUString("x"), pDoc->GetString(ScAddress(0, 0, 0)));
 
+    // FIXME: validation fails with
+    // Error: unexpected attribute "drawooo:display"
+    mbSkipValidation = true;
+
     // Without the fix in place, this test would have crashed
     saveAndReload("calc8");
     pModelObj = dynamic_cast<ScModelObj*>(mxComponent.get());
diff --git a/sd/qa/filter/eppt/eppt.cxx b/sd/qa/filter/eppt/eppt.cxx
index 38ba795dce2d..9b853b058044 100644
--- a/sd/qa/filter/eppt/eppt.cxx
+++ b/sd/qa/filter/eppt/eppt.cxx
@@ -81,7 +81,6 @@ CPPUNIT_TEST_FIXTURE(Test, testThemeExport)
 
     // When exporting to PPTX:
     utl::TempFileNamed aTempFile = save("Impress Office Open XML");
-    validate(aTempFile.GetFileName(), test::OOXML);
 
     // Then verify that this color is not lost:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"ppt/theme/theme1.xml");
@@ -101,7 +100,6 @@ CPPUNIT_TEST_FIXTURE(Test, testLoopingFromAnimation)
 
     // When exporting that to PPTX:
     utl::TempFileNamed aTempFile = save("Impress Office Open XML");
-    validate(aTempFile.GetFileName(), test::OOXML);
 
     // Then make sure that the "infinite" repeat count is written:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"ppt/slides/slide1.xml");
diff --git a/test/source/unoapi_test.cxx b/test/source/unoapi_test.cxx
index 0cc8bf0e33cc..395a10db1c37 100644
--- a/test/source/unoapi_test.cxx
+++ b/test/source/unoapi_test.cxx
@@ -22,7 +22,8 @@ using namespace css;
 using namespace css::uno;
 
 UnoApiTest::UnoApiTest(OUString path)
-    : m_aBaseString(std::move(path))
+    : mbSkipValidation(false)
+    , m_aBaseString(std::move(path))
 {
 }
 
@@ -83,6 +84,32 @@ utl::TempFileNamed UnoApiTest::save(const OUString& rFilter)
     mxComponent->dispose();
     mxComponent.clear();
 
+    if (!mbSkipValidation)
+    {
+        if (rFilter == "Office Open XML Text")
+            validate(aTempFile.GetFileName(), test::OOXML);
+        else if (rFilter == "Calc Office Open XML")
+            validate(aTempFile.GetFileName(), test::OOXML);
+        else if (rFilter == "Impress Office Open XML")
+            validate(aTempFile.GetFileName(), test::OOXML);
+        else if (rFilter == "writer8")
+            validate(aTempFile.GetFileName(), test::ODF);
+        else if (rFilter == "calc8")
+            validate(aTempFile.GetFileName(), test::ODF);
+        else if (rFilter == "impress8")
+            validate(aTempFile.GetFileName(), test::ODF);
+        else if (rFilter == "draw8")
+            validate(aTempFile.GetFileName(), test::ODF);
+        else if (rFilter == "OpenDocument Text Flat XML")
+            validate(aTempFile.GetFileName(), test::ODF);
+        else if (rFilter == "MS Word 97")
+            validate(aTempFile.GetFileName(), test::MSBINARY);
+        else if (rFilter == "MS Excel 97")
+            validate(aTempFile.GetFileName(), test::MSBINARY);
+        else if (rFilter == "MS PowerPoint 97")
+            validate(aTempFile.GetFileName(), test::MSBINARY);
+    }
+
     return aTempFile;
 }
 
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx
index 28575f29b12c..b13109900a41 100644
--- a/xmloff/qa/unit/draw.cxx
+++ b/xmloff/qa/unit/draw.cxx
@@ -71,9 +71,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTextBoxLoss)
 {
     // Load a document that has a shape with a textbox in it. Save it to ODF 
and reload.
     loadFromURL(u"textbox-loss.docx");
-    utl::TempFileNamed aTempFile = save("impress8");
-    validate(aTempFile.GetFileName(), test::ODF);
-    mxComponent = loadFromDesktop(aTempFile.GetURL());
+    saveAndReload("impress8");
 
     // Make sure that the shape is still a textbox.
     uno::Reference<drawing::XDrawPageSupplier> xDrawPageSupplier(mxComponent, 
uno::UNO_QUERY);
@@ -94,7 +92,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, 
testTdf141301_Extrusion_Angle)
 
     // Prepare use of XPath
     utl::TempFileNamed aTempFile = save("draw8");
-    validate(aTempFile.GetFileName(), test::ODF);
     uno::Reference<packages::zip::XZipFileAccess2> xNameAccess
         = packages::zip::ZipFileAccess::createWithURL(mxComponentContext, 
aTempFile.GetURL());
     uno::Reference<io::XInputStream> 
xInputStream(xNameAccess->getByName("content.xml"),
@@ -126,7 +123,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport)
 
     // Export to ODP:
     utl::TempFileNamed aTempFile = save("impress8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Check if the 12 colors are written in the XML:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"styles.xml");
@@ -167,7 +163,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testVideoSnapshot)
 
     // Execute ODP export:
     utl::TempFileNamed aTempFile = save("impress8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
     xmlDocUniquePtr pXmlDoc = parseXmlStream(pStream.get());
@@ -210,7 +205,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testReferToTheme)
     // Given a document that refers to a theme color:
     loadFromURL(u"refer-to-theme.odp");
     utl::TempFileNamed aTempFile = save("impress8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Make sure the export result has the theme reference:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -322,7 +316,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, 
testExtrusionMetalTypeExtended)
 
     // Test, that new attribute is written with loext namespace. Adapt when 
attribute is added to ODF.
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // assert XML.
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -347,7 +340,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, 
testExtrusionMetalTypeStrict)
     const SvtSaveOptions::ODFDefaultVersion 
nCurrentODFVersion(GetODFDefaultVersion());
     SetODFDefaultVersion(SvtSaveOptions::ODFVER_013);
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // assert XML.
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -387,7 +379,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, 
testExtrusionSpecularityExtended)
     // Test, that attribute is written in draw namespace with value 100% and 
in loext namespace with
     // value 122.0703125%.
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // assert XML.
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -412,7 +403,6 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, 
testExtrusionSpecularity)
     const SvtSaveOptions::ODFDefaultVersion 
nCurrentODFVersion(GetODFDefaultVersion());
     SetODFDefaultVersion(SvtSaveOptions::ODFVER_013);
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     SetODFDefaultVersion(nCurrentODFVersion);
 }
@@ -511,10 +501,8 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, 
testTextRotationPlusPre)
     // draw:text-rotate-angle was written twice, one from TextPreRotateAngle 
and the other from
     // TextRotateAngle.
     // This should already catch the format error, but does not, see tdf#149567
-    utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
     // But reload catches it.
-    mxComponent = loadFromDesktop(aTempFile.GetURL());
+    saveAndReload("writer8");
 }
 CPPUNIT_PLUGIN_IMPLEMENT();
 
diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx
index f2a2bd80e352..016c5d6bb5ed 100644
--- a/xmloff/qa/unit/style.cxx
+++ b/xmloff/qa/unit/style.cxx
@@ -189,7 +189,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR)
         officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
         pBatch->commit();
         utl::TempFileNamed aTempFile = save("writer8");
-        validate(aTempFile.GetFileName(), test::ODF);
 
         // With applied fix for tdf150407 still loext:writing-mode="bt-lr" has 
to be written.
         std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"styles.xml");
@@ -211,7 +210,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR)
         officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch);
         pBatch->commit();
         utl::TempFileNamed aTempFile = save("writer8");
-        validate(aTempFile.GetFileName(), test::ODF);
 
         // Without the fix an faulty 'writing-mode="bt-lr"' attribute was 
written in productive build.
         // A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey().
@@ -246,7 +244,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testPosRelBottomMargin)
         officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
         pBatch->commit();
         utl::TempFileNamed aTempFile = save("writer8");
-        validate(aTempFile.GetFileName(), test::ODF);
 
         // With applied fix for tdf150407 still 
loext:vertical-rel="page-content-bottom" has to be
         // written.
@@ -271,7 +268,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testPosRelBottomMargin)
         officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch);
         pBatch->commit();
         utl::TempFileNamed aTempFile = save("writer8");
-        validate(aTempFile.GetFileName(), test::ODF);
 
         // Without the fix an faulty 'vertical-rel="page-content-bottom"' 
attribute was written in
         // productive build. A debug build fails assertion in 
SvXMLNamespaceMap::GetQNameByKey().
@@ -306,7 +302,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin)
         officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch);
         pBatch->commit();
         utl::TempFileNamed aTempFile = save("writer8");
-        validate(aTempFile.GetFileName(), test::ODF);
 
         // With applied fix for tdf150407 still 
loext:vertical-rel="page-content-top has to be
         // written.
@@ -331,7 +326,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin)
         officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch);
         pBatch->commit();
         utl::TempFileNamed aTempFile = save("writer8");
-        validate(aTempFile.GetFileName(), test::ODF);
 
         // Without the fix an faulty 'vertical-rel="page-content-top"' 
attribute was written in
         // productive build. A debug build fails assertion in 
SvXMLNamespaceMap::GetQNameByKey().
diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx
index 8d8733f4d582..99bb4c1a2910 100644
--- a/xmloff/qa/unit/text.cxx
+++ b/xmloff/qa/unit/text.cxx
@@ -109,11 +109,9 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testBibliographyLocalUrl)
     xText->insertTextContent(xCursor, xContent, /*bAbsorb=*/false);
 
     // When invoking ODT export + import on it:
-    utl::TempFileNamed aTempFile = save("writer8");
+    saveAndReload("writer8");
     // Without the accompanying fix in place, this test would have resulted in 
an assertion failure,
     // as LocalURL was mapped to XML_TOKEN_INVALID.
-    validate(aTempFile.GetFileName(), test::ODF);
-    mxComponent = loadFromDesktop(aTempFile.GetURL());
 
     // Then make sure that LocalURL is preserved:
     xTextDocument.set(mxComponent, uno::UNO_QUERY);
@@ -244,7 +242,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testClearingBreakExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -387,7 +384,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -451,7 +447,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testCheckboxContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -539,7 +534,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testDropdownContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -625,7 +619,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testPictureContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -685,7 +678,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testDateContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -753,7 +745,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testPlainTextContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -810,7 +801,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testComboBoxContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");
@@ -841,7 +831,6 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, 
testAliasContentControlExport)
 
     // When exporting to ODT:
     utl::TempFileNamed aTempFile = save("writer8");
-    validate(aTempFile.GetFileName(), test::ODF);
 
     // Then make sure the expected markup is used:
     std::unique_ptr<SvStream> pStream = parseExportStream(aTempFile, 
"content.xml");

Reply via email to