sc/qa/unit/ucalc.hxx | 2 + sc/qa/unit/ucalc_formula.cxx | 65 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+)
New commits: commit 22f4ad10ff9caef430ede01dc3acfe5fdf512d9b Author: Dennis Francis <dennis.fran...@collabora.com> AuthorDate: Sat Apr 27 22:14:43 2019 +0530 Commit: Dennis Francis <dennis.fran...@collabora.com> CommitDate: Sat Apr 27 22:19:47 2019 +0200 unit-test for tdf#124326 Change-Id: Id3416e5631dcd6e427429ac475ac81b2ab70b9e5 Reviewed-on: https://gerrit.libreoffice.org/71429 Tested-by: Jenkins Reviewed-by: Dennis Francis <dennis.fran...@collabora.com> diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 3bc864734874..ba85b9b78042 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -162,6 +162,7 @@ public: void testFormulaRefUpdateMoveUndo3NonShared(); void testFormulaRefUpdateMoveUndo3Shared(); void testFormulaRefUpdateMoveUndoDependents(); + void testFormulaRefUpdateMoveUndo4(); void testFormulaRefUpdateMoveToSheet(); void testFormulaRefUpdateDeleteContent(); void testFormulaRefUpdateDeleteAndShiftLeft(); @@ -601,6 +602,7 @@ public: CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3NonShared); CPPUNIT_TEST(testFormulaRefUpdateMoveUndo3Shared); CPPUNIT_TEST(testFormulaRefUpdateMoveUndoDependents); + CPPUNIT_TEST(testFormulaRefUpdateMoveUndo4); 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 ebc65177b301..8754239bbb2a 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -2871,6 +2871,71 @@ void Test::testFormulaRefUpdateMoveUndoDependents() m_pDoc->DeleteTab(0); } +void Test::testFormulaRefUpdateMoveUndo4() +{ + m_pDoc->InsertTab(0, "Test"); + + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. + std::vector<std::vector<const char*>> aData = { + { "1", nullptr, "=B1", "=A1" }, + { "2", nullptr, "=B2", "=A2" }, + }; + + ScRange aOutRange = insertRangeData(m_pDoc, ScAddress(0,0,0), aData); + + std::vector<std::vector<const char*>> aCheckInitial = { + { "1", nullptr, "0", "1" }, + { "2", nullptr, "0", "2" }, + }; + + bool bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "initial data"); + CPPUNIT_ASSERT(bGood); + + // Drag A1:A2 into B1:B2. + ScDocFunc& rFunc = getDocShell().GetDocFunc(); + bool bMoved = rFunc.MoveBlock(ScRange(0, 0, 0, 0, 1, 0), ScAddress(1, 0, 0), true, true, false, true); + CPPUNIT_ASSERT(bMoved); + + std::vector<std::vector<const char*>> aCheckAfter = { + { nullptr, "1", "1", "1" }, + { nullptr, "2", "2", "2" }, + }; + + bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "A1:A2 moved to B1:B2"); + CPPUNIT_ASSERT(bGood); + + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula"); // C1 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula"); // C2 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "B1", "Wrong formula"); // D1 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "B2", "Wrong formula"); // D2 + + // Undo the move. + SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); + CPPUNIT_ASSERT(pUndoMgr); + pUndoMgr->Undo(); + + bGood = checkOutput(m_pDoc, aOutRange, aCheckInitial, "after undo"); + CPPUNIT_ASSERT(bGood); + + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula"); // C1 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula"); // C2 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "A1", "Wrong formula"); // D1 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "A2", "Wrong formula"); // D2 + + // Redo and check. + pUndoMgr->Redo(); + + bGood = checkOutput(m_pDoc, aOutRange, aCheckAfter, "after redo"); + CPPUNIT_ASSERT(bGood); + + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,0,0), "B1", "Wrong formula"); // C1 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(2,1,0), "B2", "Wrong formula"); // C2 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,0,0), "B1", "Wrong formula"); // D1 + ASSERT_FORMULA_EQUAL(*m_pDoc, ScAddress(3,1,0), "B2", "Wrong formula"); // D2 + + m_pDoc->DeleteTab(0); +} + void Test::testFormulaRefUpdateMoveToSheet() { sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn auto calc on. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits