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 <xiscofauli@libreoffice.org>
This commit is contained in:
@@ -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;
|
||||
};
|
||||
|
@@ -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);
|
||||
|
@@ -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());
|
||||
|
@@ -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");
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
|
@@ -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();
|
||||
|
||||
|
@@ -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().
|
||||
|
@@ -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");
|
||||
|
Reference in New Issue
Block a user