sc/qa/unit/subsequent_filters-test.cxx |   75 ++++++++-------------------------
 1 file changed, 19 insertions(+), 56 deletions(-)

New commits:
commit 6220d619b42b18cca7280174daed56aad5c82fce
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri Jan 22 10:56:29 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri Jan 22 13:29:41 2021 +0100

    sc_subsequent_filters: factor out common code
    
    Change-Id: Iaa5ed1b3f68b257ec94731c2873e6016c7988608
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109780
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/qa/unit/subsequent_filters-test.cxx 
b/sc/qa/unit/subsequent_filters-test.cxx
index 6635feb5e10b..3f76ede398be 100644
--- a/sc/qa/unit/subsequent_filters-test.cxx
+++ b/sc/qa/unit/subsequent_filters-test.cxx
@@ -488,6 +488,7 @@ public:
     CPPUNIT_TEST_SUITE_END();
 
 private:
+    void testImportCrash(std::u16string_view rFileName, sal_Int32 nFormat);
     void testPassword_Impl(std::u16string_view rFileNameBase);
 
     uno::Reference<uno::XInterface> m_xCalcComponent;
@@ -1869,6 +1870,17 @@ void ScFiltersTest::testRowIndex1BasedXLSX()
     xDocSh->DoClose();
 }
 
+void ScFiltersTest::testImportCrash(std::u16string_view rFileName, sal_Int32 
nFormat)
+{
+    ScDocShellRef xDocSh =loadDoc(rFileName, nFormat);
+    CPPUNIT_ASSERT_MESSAGE(OString("Failed to load " + 
OUStringToOString(rFileName, RTL_TEXTENCODING_UTF8)).getStr(), xDocSh.is());
+
+    ScDocument& rDoc = xDocSh->GetDocument();
+    rDoc.CalcAll(); // perform hard re-calculation.
+
+    xDocSh->DoClose();
+}
+
 void ScFiltersTest::testPassword_Impl(std::u16string_view aFileNameBase)
 {
     OUString aFileExtension(getFileFormats()[0].pName, 
strlen(getFileFormats()[0].pName), RTL_TEXTENCODING_UTF8 );
@@ -3846,74 +3858,32 @@ void ScFiltersTest::testTdf110440XLSX()
 
 void ScFiltersTest::testTdf122643()
 {
-    // Would crash without the fix on loading
-    ScDocShellRef xDocSh = loadDoc(u"tdf122643.", FORMAT_ODS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll(); // perform hard re-calculation.
-
-    xDocSh->DoClose();
+    testImportCrash(u"tdf122643.", FORMAT_ODS);
 }
 
 void ScFiltersTest::testTdf132278()
 {
-    // Would crash without the fix on loading
-    ScDocShellRef xDocSh = loadDoc(u"tdf132278.", FORMAT_ODS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll(); // perform hard re-calculation.
-
-    xDocSh->DoClose();
+    testImportCrash(u"tdf132278.", FORMAT_ODS);
 }
 
 void ScFiltersTest::testTdf130959()
 {
-    // Would crash without the fix on loading
-    ScDocShellRef xDocSh = loadDoc(u"tdf130959.", FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll(); // perform hard re-calculation.
-
-    xDocSh->DoClose();
+    testImportCrash(u"tdf130959.", FORMAT_XLSX);
 }
 
 void ScFiltersTest::testTdf129410()
 {
-    // Would crash without the fix on loading
-    ScDocShellRef xDocSh = loadDoc(u"tdf129410.", FORMAT_ODS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll(); // perform hard re-calculation.
-
-    xDocSh->DoClose();
+    testImportCrash(u"tdf129410.", FORMAT_ODS);
 }
 
 void ScFiltersTest::testTdf138507()
 {
-    // Would fail to load without the fix
-    ScDocShellRef xDocSh = loadDoc(u"tdf138507.", FORMAT_ODS);
-    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll(); // perform hard re-calculation.
-
-    xDocSh->DoClose();
+    testImportCrash(u"tdf138507.", FORMAT_ODS);
 }
 
 void ScFiltersTest::testTdf131380()
 {
-    ScDocShellRef xDocSh = loadDoc(u"tdf131380.", FORMAT_XLSX);
-    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
-
-    // Would crash without the fix on recalculating
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll(); // perform hard re-calculation.
-
-    xDocSh->DoClose();
+    testImportCrash(u"tdf131380.", FORMAT_XLSX);
 }
 
 void ScFiltersTest::testTdf129681()
@@ -3946,14 +3916,7 @@ void ScFiltersTest::testTdf129681()
 
 void ScFiltersTest::testTdf111974XLSM()
 {
-    // Would crash without the fix on loading
-    ScDocShellRef xDocSh = loadDoc(u"tdf111974.", FORMAT_XLSM);
-    CPPUNIT_ASSERT_MESSAGE("Failed to open doc", xDocSh.is());
-
-    ScDocument& rDoc = xDocSh->GetDocument();
-    rDoc.CalcAll(); // perform hard re-calculation.
-
-    xDocSh->DoClose();
+    testImportCrash(u"tdf111974.", FORMAT_XLSM);
 }
 
 void ScFiltersTest::testBnc762542()
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to