From a79acaf274dfe03d008e9fcd3fb8ded6c1724935 Mon Sep 17 00:00:00 2001 From: Xisco Fauli Date: Wed, 16 Oct 2024 16:38:19 +0200 Subject: [PATCH] sw: reduce usage of DECLARE_SW_ROUNDTRIP_TEST Change-Id: Ib2884a766ff891aa768530e62cb2825402b84d03 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/175026 Tested-by: Jenkins Reviewed-by: Xisco Fauli --- sw/qa/extras/odfexport/odfexport.cxx | 20 +++++++++-- .../extras/ooxmlexport/ooxml_ThemeExport.cxx | 17 ++++------ sw/qa/extras/ooxmlexport/ooxmlencryption.cxx | 33 ++++++++++++++----- sw/qa/extras/ooxmlexport/ooxmlexport9.cxx | 9 ++++- 4 files changed, 57 insertions(+), 22 deletions(-) diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx index 853f1ccdc2a9..70bea5e1b890 100644 --- a/sw/qa/extras/odfexport/odfexport.cxx +++ b/sw/qa/extras/odfexport/odfexport.cxx @@ -493,14 +493,30 @@ CPPUNIT_TEST_FIXTURE(Test, testFramebackgrounds) assertXPath(pXmlDoc, "//style:style[@style:parent-style-name='Frame' and @style:family='graphic']/style:graphic-properties[@draw:fill='bitmap' and @fo:background-color='transparent' and @draw:opacity-name='Transparency_20_1']/style:background-image[@style:repeat='stretch' and @draw:opacity='43%']", 1); } -DECLARE_SW_ROUNDTRIP_TEST(testSHA1Correct, "sha1_correct.odt", "1012345678901234567890123456789012345678901234567890", Test) +CPPUNIT_TEST_FIXTURE(Test, testSHA1Correct) { // tdf#114939 this has both an affected password as well as content.xml + const char* const sPass = "1012345678901234567890123456789012345678901234567890"; + createSwDoc("sha1_correct.odt", sPass); + + CPPUNIT_ASSERT_EQUAL(1, getPages()); + getParagraph(1, u"012"_ustr); + + saveAndReload(mpFilter, sPass); + CPPUNIT_ASSERT_EQUAL(1, getPages()); getParagraph(1, u"012"_ustr); } -DECLARE_SW_ROUNDTRIP_TEST(testSHA1Wrong, "sha1_wrong.odt", "1012345678901234567890123456789012345678901234567890", Test) +CPPUNIT_TEST_FIXTURE(Test, testSHA1Wrong) { // tdf#114939 this has both an affected password as well as content.xml + const char* const sPass = "1012345678901234567890123456789012345678901234567890"; + createSwDoc("sha1_wrong.odt", sPass); + + CPPUNIT_ASSERT_EQUAL(1, getPages()); + getParagraph(1, u"012"_ustr); + + saveAndReload(mpFilter, sPass); + CPPUNIT_ASSERT_EQUAL(1, getPages()); getParagraph(1, u"012"_ustr); } diff --git a/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx b/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx index 9dcacd435518..da76f6a1c112 100644 --- a/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxml_ThemeExport.cxx @@ -21,8 +21,8 @@ public: } }; -DECLARE_SW_ROUNDTRIP_TEST(testThemePortionLevelCharColor_ODF, - "Test_ThemePortionLevel_CharColor.fodt", nullptr, Test) +DECLARE_OOXMLEXPORT_TEST(testThemePortionLevelCharColor_ODF, + "Test_ThemePortionLevel_CharColor.fodt") { auto xParagraph = getParagraph(1); CPPUNIT_ASSERT(xParagraph.is()); @@ -36,8 +36,8 @@ DECLARE_SW_ROUNDTRIP_TEST(testThemePortionLevelCharColor_ODF, CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms[0].mnValue); } -DECLARE_SW_ROUNDTRIP_TEST(testThemePortionLevelCharColor_DOCX, - "Test_ThemePortionLevel_CharColor.docx", nullptr, Test) +DECLARE_OOXMLEXPORT_TEST(testThemePortionLevelCharColor_DOCX, + "Test_ThemePortionLevel_CharColor.docx") { auto xParagraph = getParagraph(1); CPPUNIT_ASSERT(xParagraph.is()); @@ -51,8 +51,7 @@ DECLARE_SW_ROUNDTRIP_TEST(testThemePortionLevelCharColor_DOCX, CPPUNIT_ASSERT_EQUAL(sal_Int16(4000), rTransforms[0].mnValue); } -DECLARE_SW_ROUNDTRIP_TEST(testThemePortionBorderColor_DOCX, "Test_ThemeBorderColor.docx", nullptr, - Test) +DECLARE_OOXMLEXPORT_TEST(testThemePortionBorderColor_DOCX, "Test_ThemeBorderColor.docx") { auto xParagraph = getParagraph(1); CPPUNIT_ASSERT(xParagraph.is()); @@ -81,8 +80,7 @@ DECLARE_SW_ROUNDTRIP_TEST(testThemePortionBorderColor_DOCX, "Test_ThemeBorderCol CPPUNIT_ASSERT(isPropertyVoid(xParagraph, u"RightBorderComplexColor"_ustr)); } -DECLARE_SW_ROUNDTRIP_TEST(testCharUnderlineTheme_DOCX, "Test_CharUnderlineThemeColor.docx", nullptr, - Test) +DECLARE_OOXMLEXPORT_TEST(testCharUnderlineTheme_DOCX, "Test_CharUnderlineThemeColor.docx") { auto xParagraph = getParagraph(1); CPPUNIT_ASSERT(xParagraph.is()); @@ -97,8 +95,7 @@ DECLARE_SW_ROUNDTRIP_TEST(testCharUnderlineTheme_DOCX, "Test_CharUnderlineThemeC CPPUNIT_ASSERT_EQUAL(sal_Int16(2509), rTransforms[0].mnValue); } -DECLARE_SW_ROUNDTRIP_TEST(testParaBackgroundTheme_DOCX, "Test_ThemeTextParaBackgroundColor.docx", - nullptr, Test) +DECLARE_OOXMLEXPORT_TEST(testParaBackgroundTheme_DOCX, "Test_ThemeTextParaBackgroundColor.docx") { { auto xParagraph = getParagraph(1); diff --git a/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx b/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx index a4280d0cf84a..7e329f7759da 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlencryption.cxx @@ -19,32 +19,47 @@ public: } }; -DECLARE_SW_ROUNDTRIP_TEST(testPasswordMSO2007, "Encrypted_MSO2007_abc.docx", "abc", Test) +CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2007) { + const char* const sPass = "abc"; + createSwDoc("Encrypted_MSO2007_abc.docx", sPass); // Standard encryption format, AES 128, SHA1 uno::Reference xParagraph(getParagraph(1)); - CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, xParagraph->getString()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString()); + saveAndReload(mpFilter, sPass); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString()); } -DECLARE_SW_ROUNDTRIP_TEST(testPasswordMSO2010, "Encrypted_MSO2010_abc.docx", "abc", Test) +CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2010) { + const char* const sPass = "abc"; + createSwDoc("Encrypted_MSO2010_abc.docx", sPass); // Agile encryption format, AES 128, CBC, SHA1 - uno::Reference xParagraph(getParagraph(1)); - CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, xParagraph->getString()); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString()); + saveAndReload(mpFilter, sPass); + CPPUNIT_ASSERT_EQUAL(u"abc"_ustr, getParagraph(1)->getString()); } -DECLARE_SW_ROUNDTRIP_TEST(testPasswordMSO2013, "Encrypted_MSO2013_abc.docx", "abc", Test) +CPPUNIT_TEST_FIXTURE(Test, testPasswordMSO2013) { + const char* const sPass = "abc"; + createSwDoc("Encrypted_MSO2013_abc.docx", sPass); // Agile encryption format, AES 256, CBC, SHA512 uno::Reference xParagraph(getParagraph(1)); - CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, xParagraph->getString()); + CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString()); + saveAndReload(mpFilter, sPass); + CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString()); } -DECLARE_SW_ROUNDTRIP_TEST(testPasswordLOStandard, "Encrypted_LO_Standard_abc.docx", "abc", Test) +CPPUNIT_TEST_FIXTURE(Test, testPasswordLOStandard) { + const char* const sPass = "abc"; + createSwDoc("Encrypted_LO_Standard_abc.docx", sPass); // Standard encryption format, AES 128, SHA1 uno::Reference xParagraph(getParagraph(1)); - CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, xParagraph->getString()); + CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString()); + saveAndReload(mpFilter, sPass); + CPPUNIT_ASSERT_EQUAL(u"ABC"_ustr, getParagraph(1)->getString()); } CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx index ad48595f8b6f..efce589aadb9 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport9.cxx @@ -113,12 +113,19 @@ CPPUNIT_TEST_FIXTURE(DocmTest, testDocmSave) u"application/vnd.ms-word.document.macroEnabled.main+xml"); } -DECLARE_SW_ROUNDTRIP_TEST(testBadDocm, "bad.docm", nullptr, DocmTest) +CPPUNIT_TEST_FIXTURE(DocmTest, testBadDocm) { + createSwDoc("bad.docm"); SwXTextDocument* pTextDoc = dynamic_cast(mxComponent.get()); CPPUNIT_ASSERT(pTextDoc); // This was 'MS Word 2007 XML', broken docm files were not recognized. CPPUNIT_ASSERT_EQUAL(u"MS Word 2007 XML VBA"_ustr, pTextDoc->GetDocShell()->GetMedium()->GetFilter()->GetName()); + + saveAndReload(mpFilter); + pTextDoc = dynamic_cast(mxComponent.get()); + CPPUNIT_ASSERT(pTextDoc); + // This was 'MS Word 2007 XML', broken docm files were not recognized. + CPPUNIT_ASSERT_EQUAL(u"MS Word 2007 XML VBA"_ustr, pTextDoc->GetDocShell()->GetMedium()->GetFilter()->GetName()); } CPPUNIT_TEST_FIXTURE(Test, testTdf109063)