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

Dennis Francis (via logerrit) logerrit at kemper.freedesktop.org
Sat Apr 27 20:19:36 UTC 2019


 sc/qa/unit/ucalc.hxx         |    2 +
 sc/qa/unit/ucalc_formula.cxx |   65 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+)

New commits:
commit 511737f7e9de5d4d32bc6cfcf481655f5a9ed3f2
Author:     Dennis Francis <dennis.francis at collabora.com>
AuthorDate: Sat Apr 27 21:41:59 2019 +0530
Commit:     Dennis Francis <dennis.francis at collabora.com>
CommitDate: Sat Apr 27 22:18:01 2019 +0200

    unit-test for tdf#120270
    
    Change-Id: Icaa547ba5ef210ba721661242b2becd9f559f09a
    Reviewed-on: https://gerrit.libreoffice.org/71428
    Tested-by: Jenkins
    Reviewed-by: Dennis Francis <dennis.francis at collabora.com>

diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 90fc183d08fd..3bc864734874 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -161,6 +161,7 @@ public:
     void testFormulaRefUpdateMoveUndo2();
     void testFormulaRefUpdateMoveUndo3NonShared();
     void testFormulaRefUpdateMoveUndo3Shared();
+    void testFormulaRefUpdateMoveUndoDependents();
     void testFormulaRefUpdateMoveToSheet();
     void testFormulaRefUpdateDeleteContent();
     void testFormulaRefUpdateDeleteAndShiftLeft();
@@ -599,6 +600,7 @@ public:
     CPPUNIT_TEST(testFormulaRefUpdateMoveUndo2);
     CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3NonShared);
     CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3Shared);
+    CPPUNIT_TEST(testFormulaRefUpdateMoveUndoDependents);
     CPPUNIT_TEST(testFormulaRefUpdateMoveToSheet);
     CPPUNIT_TEST(testFormulaRefUpdateDeleteContent);
     CPPUNIT_TEST(testFormulaRefUpdateDeleteAndShiftLeft);
diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx
index 1248692f5a50..ebc65177b301 100644
--- a/sc/qa/unit/ucalc_formula.cxx
+++ b/sc/qa/unit/ucalc_formula.cxx
@@ -2806,6 +2806,71 @@ void Test::testFormulaRefUpdateMoveUndo3Shared()
     m_pDoc->DeleteTab(0);
 }
 
+void Test::testFormulaRefUpdateMoveUndoDependents()
+{
+    m_pDoc->InsertTab(0, "Test");
+
+    sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.
+    std::vector<std::vector<const char*>> aData = {
+        { "1"           },
+        { "22"          },
+        { "3"           },
+        { "4"           },
+        { "5"           },
+        { "=SUM(C1:C5)" },
+        { "=C6"         },
+    };
+
+    ScRange aOutRange = insertRangeData(m_pDoc, ScAddress(2,0,0), aData);
+
+    std::vector<std::vector<const char*>> aCheckInitial = {
+        { "1"   },
+        { "22"  },
+        { "3"   },
+        { "4"   },
+        { "5"   },
+        { "35"  },
+        { "35"  },
+    };
+
+    bool bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "initial data");
+    CPPUNIT_ASSERT(bGood);
+
+    // Drag C2 into D2.
+    ScDocFunc& rFunc = getDocShell().GetDocFunc();
+    bool bMoved = rFunc.MoveBlock(ScRange(2, 1, 0, 2, 1, 0), ScAddress(3, 1, 0), true, true, false, true);
+    CPPUNIT_ASSERT(bMoved);
+
+    std::vector<std::vector<const char*>> aCheckAfter = {
+        { "1"     },
+        { nullptr },
+        { "3"     },
+        { "4"     },
+        { "5"     },
+        { "13"    },
+        { "13"    },
+    };
+
+    bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "C2 moved to D2");
+    CPPUNIT_ASSERT(bGood);
+
+    // Undo the move.
+    SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+    CPPUNIT_ASSERT(pUndoMgr);
+    pUndoMgr->Undo();
+
+    bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "after undo");
+    CPPUNIT_ASSERT(bGood);
+
+    // Redo and check.
+    pUndoMgr->Redo();
+
+    bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "after redo");
+    CPPUNIT_ASSERT(bGood);
+
+    m_pDoc->DeleteTab(0);
+}
+
 void Test::testFormulaRefUpdateMoveToSheet()
 {
     sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on.


More information about the Libreoffice-commits mailing list