summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-14 15:15:45 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-02-14 20:52:56 -0500
commit1ffec457c86df0906b358ac431ffdb5d1d47de8c (patch)
treeca2d04634655d405864c45a1b84e1f22a04bc158
parentecf22894f522374cbdb8196d3bdef88e2fba7af9 (diff)
fdo#72691: Write unit test for this.
One tricky bit was that in order to reproduce the bug in the unit test, formula cell's bChanged flag needed to be cleared after each update, because that's what happens when you display updated formula on screen. Each time an updated formula cell gets drawn, the UI code clears this flag. That same flag was used to control the code path during interpretation... Change-Id: I2eedea3c9294f4f545422b8611840c81f8c2304f
-rw-r--r--sc/qa/unit/ucalc.cxx28
-rw-r--r--sc/qa/unit/ucalc.hxx3
2 files changed, 31 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index c06f82d93ebe..717631264ee5 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1360,6 +1360,34 @@ void Test::testFormulaDepTracking2()
m_pDoc->DeleteTab(0);
}
+void Test::testFormulaDepTrackingMatrix()
+{
+ m_pDoc->InsertTab(0, "Test");
+
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calculation.
+
+ // Set a numeric value to A1.
+ m_pDoc->SetValue(ScAddress(0,0,0), 11.0);
+
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ m_pDoc->InsertMatrixFormula(1, 0, 1, 0, aMark, "=A1", NULL);
+ CPPUNIT_ASSERT_EQUAL(11.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+ ScFormulaCell* pFC = m_pDoc->GetFormulaCell(ScAddress(1,0,0));
+ CPPUNIT_ASSERT_MESSAGE("Failed to get formula cell.", pFC);
+ pFC->SetChanged(false); // Clear this flag to simulate displaying of formula cell value on screen.
+
+ m_pDoc->SetString(ScAddress(0,0,0), "ABC");
+ CPPUNIT_ASSERT_EQUAL(OUString("ABC"), m_pDoc->GetString(ScAddress(1,0,0)));
+ pFC->SetChanged(false);
+
+ // Put a new value into A1. The formula should update.
+ m_pDoc->SetValue(ScAddress(0,0,0), 13.0);
+ CPPUNIT_ASSERT_EQUAL(13.0, m_pDoc->GetValue(ScAddress(1,0,0)));
+
+ m_pDoc->DeleteTab(0);
+}
+
namespace {
bool broadcasterShifted(const ScDocument& rDoc, const ScAddress& rFrom, const ScAddress& rTo)
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index f94ac91549b2..9f6dc32c6720 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -150,6 +150,8 @@ public:
*/
void testFormulaDepTracking2();
+ void testFormulaDepTrackingMatrix();
+
/**
* More direct test for cell broadcaster management, used to track formula
* dependencies.
@@ -370,6 +372,7 @@ public:
CPPUNIT_TEST(testValueIterator);
CPPUNIT_TEST(testFormulaDepTracking);
CPPUNIT_TEST(testFormulaDepTracking2);
+ CPPUNIT_TEST(testFormulaDepTrackingMatrix);
CPPUNIT_TEST(testCellBroadcaster);
CPPUNIT_TEST(testFuncParam);
CPPUNIT_TEST(testNamedRange);