summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Francis <dennis.francis@collabora.com>2019-04-27 21:41:59 +0530
committerDennis Francis <dennis.francis@collabora.com>2019-04-27 22:18:01 +0200
commit511737f7e9de5d4d32bc6cfcf481655f5a9ed3f2 (patch)
tree77a6f3aa0cfb43d49752e7a9b0e7f7915865b580
parent734b33b73dbd4bd65265bce2a17ee07cdb3a5042 (diff)
unit-test for tdf#120270
Change-Id: Icaa547ba5ef210ba721661242b2becd9f559f09a Reviewed-on: https://gerrit.libreoffice.org/71428 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
-rw-r--r--sc/qa/unit/ucalc.hxx2
-rw-r--r--sc/qa/unit/ucalc_formula.cxx65
2 files changed, 67 insertions, 0 deletions
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.