tdf#145640: sc_uicalc: Add unittest
Change-Id: Iba1723704b3fafdd52e32ae0f5f2cc986ba2ba16
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125245
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
diff --git a/sc/qa/unit/uicalc/data/tdf145640.ods b/sc/qa/unit/uicalc/data/tdf145640.ods
new file mode 100644
index 0000000..34b5017
--- /dev/null
+++ b/sc/qa/unit/uicalc/data/tdf145640.ods
Binary files differ
diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx
index a06dd66..72b1c6e 100644
--- a/sc/qa/unit/uicalc/uicalc.cxx
+++ b/sc/qa/unit/uicalc/uicalc.cxx
@@ -355,6 +355,42 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf100582)
pMod->SetInputOptions(aInputOption);
}
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf145640)
{
ScModelObj* pModelObj = createDoc("tdf145640.ods");
ScDocument* pDoc = pModelObj->GetDocument();
CPPUNIT_ASSERT(pDoc);
// Enable sorting with update reference
ScModule* pMod = SC_MOD();
ScInputOptions aInputOption = pMod->GetInputOptions();
bool bOldStatus = aInputOption.GetSortRefUpdate();
aInputOption.SetSortRefUpdate(true);
pMod->SetInputOptions(aInputOption);
goToCell("A2:F17");
dispatchCommand(mxComponent, ".uno:SortDescending", {});
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A15:B15:C15:D15:E15:F15)"), pDoc->GetFormula(6, 3, 0));
// Without the fix in place, this test would have failed with
// - Expected: 10
// - Actual : 0
CPPUNIT_ASSERT_EQUAL(10.0, pDoc->GetValue(ScAddress(6, 3, 0)));
dispatchCommand(mxComponent, ".uno:Undo", {});
Scheduler::ProcessEventsToIdle();
CPPUNIT_ASSERT_EQUAL(OUString("=SUM(A4:B4:C4:D4:E4:F4)"), pDoc->GetFormula(6, 3, 0));
CPPUNIT_ASSERT_EQUAL(10.0, pDoc->GetValue(ScAddress(6, 3, 0)));
// Restore previous status
aInputOption.SetSortRefUpdate(bOldStatus);
pMod->SetInputOptions(aInputOption);
}
CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf97215)
{
ScModelObj* pModelObj = createDoc("tdf97215.ods");