diff options
author | Dennis Francis <dennis.francis@collabora.com> | 2019-04-27 22:14:43 +0530 |
---|---|---|
committer | Dennis Francis <dennis.francis@collabora.com> | 2019-04-27 22:19:47 +0200 |
commit | 22f4ad10ff9caef430ede01dc3acfe5fdf512d9b (patch) | |
tree | a1324c5c5ee93f9d95ca0e1620e26303ed5db92b | |
parent | 511737f7e9de5d4d32bc6cfcf481655f5a9ed3f2 (diff) |
unit-test for tdf#124326
Change-Id: Id3416e5631dcd6e427429ac475ac81b2ab70b9e5
Reviewed-on: https://gerrit.libreoffice.org/71429
Tested-by: Jenkins
Reviewed-by: Dennis Francis <dennis.francis@collabora.com>
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 65 |
2 files changed, 67 insertions, 0 deletions
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. |