[Libreoffice-commits] core.git: sc/qa

Xisco Fauli (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 25 19:10:24 UTC 2020


 sc/qa/unit/uicalc/data/tdf133326.ods |binary
 sc/qa/unit/uicalc/uicalc.cxx         |   57 +++++++++++++++++++++++++++++++++++
 2 files changed, 57 insertions(+)

New commits:
commit 122628e63543e7015547f522cf771f08afc4ea90
Author:     Xisco Fauli <xiscofauli at libreoffice.org>
AuthorDate: Thu Jun 25 16:46:18 2020 +0200
Commit:     Xisco Fauli <xiscofauli at libreoffice.org>
CommitDate: Thu Jun 25 21:09:43 2020 +0200

    tdf#133326: sc: Add unittest
    
    Change-Id: I2436822fa289ae1bf10643cfc5232f4db6df2e29
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97150
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>

diff --git a/sc/qa/unit/uicalc/data/tdf133326.ods b/sc/qa/unit/uicalc/data/tdf133326.ods
new file mode 100644
index 000000000000..102f169bd56e
Binary files /dev/null and b/sc/qa/unit/uicalc/data/tdf133326.ods differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index 46e4b24bf669..84b16529c864 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -12,6 +12,7 @@
 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
 #include <vcl/scheduler.hxx>
 
+#include <comphelper/propertysequence.hxx>
 #include <comphelper/processfactory.hxx>
 #include <com/sun/star/frame/Desktop.hpp>
 #include <document.hxx>
@@ -89,6 +90,62 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf122232)
     checkCurrentCell(2, 6);
 }
 
+CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf133326)
+{
+    ScModelObj* pModelObj = createDoc("tdf133326.ods");
+    ScDocument* pDoc = pModelObj->GetDocument();
+    CPPUNIT_ASSERT(pDoc);
+
+    dispatchCommand(mxComponent, ".uno:SelectAll", {});
+    dispatchCommand(mxComponent, ".uno:Copy", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount());
+
+    uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence(
+        { { "Name", uno::Any(OUString("")) }, { "Index", uno::Any(sal_Int32(2)) } }));
+    dispatchCommand(mxComponent, ".uno:Insert", aArgs);
+
+    OUString aFormula;
+    pDoc->GetFormula(0, 0, 1, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+
+    dispatchCommand(mxComponent, ".uno:Paste", {});
+    Scheduler::ProcessEventsToIdle();
+
+    pDoc->GetFormula(0, 0, 1, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString("=RAND()*1000000"), aFormula);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    pDoc->GetFormula(0, 0, 1, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+
+    dispatchCommand(mxComponent, ".uno:Undo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount());
+
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+    pDoc->GetFormula(0, 0, 1, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString(""), aFormula);
+
+    // Without the fix in place, it would have crashed here
+    dispatchCommand(mxComponent, ".uno:Redo", {});
+    Scheduler::ProcessEventsToIdle();
+
+    pDoc->GetFormula(0, 0, 1, aFormula);
+    CPPUNIT_ASSERT_EQUAL(OUString("=RAND()*1000000"), aFormula);
+    CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(2), pDoc->GetTableCount());
+}
+
 CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf126904)
 {
     ScModelObj* pModelObj = createDoc("tdf126904.ods");


More information about the Libreoffice-commits mailing list