diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-04 17:31:55 +0100 |
---|---|---|
committer | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-11-08 11:54:22 +0100 |
commit | 248be1fe7d31499fe7e237bb15ec67b55962c1a7 (patch) | |
tree | d2a3693af5d555f5c6cca31b625a9001af21e869 /xmloff | |
parent | 444bf8710d5da7b584fbcb94693e4ed8d2e29297 (diff) |
UnoApiTest: simplify code by using tempfile member
SwModelTestBase does the same. this will help to make
SwModelTestBase inherit from UnoApiTest
Change-Id: If1c824cf92f0e8b70253e4d5fdeddcaa521d4632
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142287
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'xmloff')
-rw-r--r-- | xmloff/qa/unit/draw.cxx | 34 | ||||
-rw-r--r-- | xmloff/qa/unit/style.cxx | 28 | ||||
-rw-r--r-- | xmloff/qa/unit/text.cxx | 56 |
3 files changed, 58 insertions, 60 deletions
diff --git a/xmloff/qa/unit/draw.cxx b/xmloff/qa/unit/draw.cxx index 1f41afbba3ed..e7b2f54d8412 100644 --- a/xmloff/qa/unit/draw.cxx +++ b/xmloff/qa/unit/draw.cxx @@ -89,8 +89,8 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testTdf141301_Extrusion_Angle) loadFromURL(u"tdf141301_Extrusion_Skew.odg"); // Prepare use of XPath - utl::TempFileNamed aTempFile = save("draw8"); - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + save("draw8"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without fix draw:extrusion-skew="50 -135" was not written to file although "50 -135" is not // default in ODF, but only default inside LO. @@ -115,10 +115,10 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testThemeExport) xMasterPage->setPropertyValue("Theme", aTheme); // Export to ODP: - utl::TempFileNamed aTempFile = save("impress8"); + save("impress8"); // Check if the 12 colors are written in the XML: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); // Without the accompanying fix in place, this test would have failed with: // - Expected: 12 // - Actual : 0 @@ -154,9 +154,9 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testVideoSnapshot) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1356), rCrop.Right); // Execute ODP export: - utl::TempFileNamed aTempFile = save("impress8"); + save("impress8"); - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Check that the preview was exported: // Without the accompanying fix in place, this test would have failed with: // - Expected: 1 @@ -195,10 +195,10 @@ 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"); + save("impress8"); // Make sure the export result has the theme reference: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this test would have failed with: // - XPath '//style:style[@style:name='T1']/style:text-properties' no attribute 'theme-color' exist // i.e. only the direct color was written, but not the theme reference. @@ -305,16 +305,16 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeExtended) lcl_assertMetalProperties("from doc", xShape); // Test, that new attribute is written with loext namespace. Adapt when attribute is added to ODF. - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // assert XML. - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPath(pXmlDoc, "//draw:enhanced-geometry", "extrusion-metal", "true"); assertXPath(pXmlDoc, "//draw:enhanced-geometry[@loext:extrusion-metal-type='loext:MetalMSCompatible']"); // reload - mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument"); // verify properties uno::Reference<drawing::XShape> xShapeReload(getShape(0)); lcl_assertMetalProperties("from ODF 1.3 extended", xShapeReload); @@ -328,10 +328,10 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionMetalTypeStrict) // added to ODF. const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_013); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // assert XML. - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPath(pXmlDoc, "//draw:enhanced-geometry", "extrusion-metal", "true"); assertXPath(pXmlDoc, "//draw:enhanced-geometry[@loext:extrusion-metal-type]", 0); @@ -366,16 +366,16 @@ 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"); + save("writer8"); // assert XML. - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPath(pXmlDoc, "//draw:enhanced-geometry[@draw:extrusion-specularity='100%']"); assertXPath(pXmlDoc, "//draw:enhanced-geometry[@loext:extrusion-specularity-loext='122.0703125%']"); // reload and verify, that the loext value is used - mxComponent = loadFromDesktop(aTempFile.GetURL(), "com.sun.star.text.TextDocument"); + mxComponent = loadFromDesktop(maTempFile.GetURL(), "com.sun.star.text.TextDocument"); // verify properties uno::Reference<drawing::XShape> xShapeReload(getShape(0)); lcl_assertSpecularityProperty("from ODF 1.3 extended", xShapeReload); @@ -389,7 +389,7 @@ CPPUNIT_TEST_FIXTURE(XmloffDrawTest, testExtrusionSpecularity) // Save to ODF 1.3 strict and make sure it does not produce a validation error. const SvtSaveOptions::ODFDefaultVersion nCurrentODFVersion(GetODFDefaultVersion()); SetODFDefaultVersion(SvtSaveOptions::ODFVER_013); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); SetODFDefaultVersion(nCurrentODFVersion); } diff --git a/xmloff/qa/unit/style.cxx b/xmloff/qa/unit/style.cxx index a51b55b37818..5cd1edad5069 100644 --- a/xmloff/qa/unit/style.cxx +++ b/xmloff/qa/unit/style.cxx @@ -85,10 +85,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testFontSorting) mxComponent = loadFromDesktop("private:factory/swriter"); // When saving that document to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure <style:font-face> elements are sorted (by style:name="..."): - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); xmlXPathObjectPtr pXPath = getXPathNode(pXmlDoc, "/office:document-content/office:font-face-decls/style:font-face"); xmlNodeSetPtr pXmlNodes = pXPath->nodesetval; @@ -181,10 +181,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); pBatch->commit(); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // With applied fix for tdf150407 still loext:writing-mode="bt-lr" has to be written. - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); assertXPath(pXmlDoc, "/office:document-styles/office:styles/style:style[@style:name='FrameBTLR']/" "style:graphic-properties[@loext:writing-mode]"); @@ -201,11 +201,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testWritingModeBTLR) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); pBatch->commit(); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Without the fix an faulty 'writing-mode="bt-lr"' attribute was written in productive build. // A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); assertXPathNoAttribute(pXmlDoc, "/office:document-styles/office:styles/" "style:style[@style:name='FrameBTLR']/style:graphic-properties", @@ -234,11 +234,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); pBatch->commit(); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // With applied fix for tdf150407 still loext:vertical-rel="page-content-bottom" has to be // written. - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPath( pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" @@ -257,11 +257,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelBottomMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); pBatch->commit(); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Without the fix an faulty 'vertical-rel="page-content-bottom"' attribute was written in // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:automatic-styles/" "style:style[@style:name='gr1']/style:graphic-properties", @@ -290,11 +290,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(3, pBatch); pBatch->commit(); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // With applied fix for tdf150407 still loext:vertical-rel="page-content-top has to be // written. - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPath( pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:name='gr1']/" @@ -313,11 +313,11 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPosRelTopMargin) comphelper::ConfigurationChanges::create()); officecfg::Office::Common::Save::ODF::DefaultVersion::set(10, pBatch); pBatch->commit(); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Without the fix an faulty 'vertical-rel="page-content-top"' attribute was written in // productive build. A debug build fails assertion in SvXMLNamespaceMap::GetQNameByKey(). - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPathNoAttribute(pXmlDoc, "/office:document-content/office:automatic-styles/" "style:style[@style:name='gr1']/style:graphic-properties", diff --git a/xmloff/qa/unit/text.cxx b/xmloff/qa/unit/text.cxx index 64ec2500ad9f..16f830aa43cf 100644 --- a/xmloff/qa/unit/text.cxx +++ b/xmloff/qa/unit/text.cxx @@ -151,10 +151,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testParaStyleListLevel) CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), nNumberingLevel); // Test the export as well: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure we save the style's numbering level: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "styles.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("styles.xml"); // Without the accompanying fix in place, this failed with: // - XPath '/office:document-styles/office:styles/style:style[@style:name='mystyle']' no attribute 'list-level' exist // i.e. a custom NumberingLevel was lost on save. @@ -190,10 +190,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testListId) loadFromURL(u"list-id.fodt"); // When storing that document as ODF: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure that unreferenced xml:id="..." attributes are not written: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this failed with: // - XPath '//text:list' unexpected 'id' attribute // i.e. xml:id="..." was written unconditionally, even when no other list needed it. @@ -217,10 +217,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testClearingBreakExport) xText->insertTextContent(xCursor, xLineBreak, /*bAbsorb=*/false); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this failed with: // - XPath '//text:line-break' number of nodes is incorrect // i.e. the clearing break was lost on export. @@ -285,9 +285,9 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testRelativeWidth) // Body frame width is 16cm. xStyle->setPropertyValue("Width", uno::Any(static_cast<sal_Int32>(20000))); - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this failed with: // - Expected: 3.1492in (8cm) // - Actual : 0.0161in (0.04 cm) @@ -315,10 +315,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testScaleWidthAndHeight) xText->insertTextContent(xCursor, xTextFrame, /*bAbsorb=*/false); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure that we still export a non-zero size: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this failed with: // - Expected: 0.7874in // - Actual : 0in @@ -344,10 +344,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this failed with: // - XPath '//loext:content-control' number of nodes is incorrect // i.e. the content control was lost on export. @@ -406,10 +406,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testCheckboxContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); assertXPath(pXmlDoc, "//loext:content-control", "checkbox", "true"); assertXPath(pXmlDoc, "//loext:content-control", "checked", "true"); assertXPath(pXmlDoc, "//loext:content-control", "checked-state", u"☒"); @@ -492,10 +492,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this failed with: // - Expected: 1 // - Actual : 0 @@ -576,10 +576,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPictureContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'picture' exist assertXPath(pXmlDoc, "//loext:content-control", "picture", "true"); @@ -634,10 +634,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDateContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'date' exist assertXPath(pXmlDoc, "//loext:content-control", "date", "true"); @@ -700,10 +700,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testPlainTextContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'plain-text' exist // i.e. the plain text content control was turned into a rich text one on export. @@ -755,10 +755,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testComboBoxContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this test would have failed with: // - XPath '//loext:content-control' no attribute 'combobox' exist // i.e. the combo box content control was turned into a drop-down one on export. @@ -784,10 +784,10 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testAliasContentControlExport) xText->insertTextContent(xCursor, xContentControl, /*bAbsorb=*/true); // When exporting to ODT: - utl::TempFileNamed aTempFile = save("writer8"); + save("writer8"); // Then make sure the expected markup is used: - xmlDocUniquePtr pXmlDoc = parseExport(aTempFile.GetURL(), "content.xml"); + xmlDocUniquePtr pXmlDoc = parseExport("content.xml"); // Without the accompanying fix in place, this test would have failed with: // - Expression: prop // - XPath '//loext:content-control' no attribute 'alias' exist @@ -866,11 +866,9 @@ CPPUNIT_TEST_FIXTURE(XmloffStyleTest, testDropdownContentControlAutostyleExport) uno::Sequence<beans::PropertyValue> aStoreProps = comphelper::InitPropertySequence({ { "FilterName", uno::Any(OUString("writer8")) }, }); - utl::TempFileNamed aTempFile; - aTempFile.EnableKillingFile(); // Without the accompanying fix in place, this test would have failed, we had duplicated XML // attributes. - xStorable->storeToURL(aTempFile.GetURL(), aStoreProps); + xStorable->storeToURL(maTempFile.GetURL(), aStoreProps); } CPPUNIT_PLUGIN_IMPLEMENT(); |