[Libreoffice-commits] .: sc/qa

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Jan 27 06:57:51 PST 2012


 sc/qa/unit/ucalc.cxx |   31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

New commits:
commit 86ec0c8201d89d472cd8b826c5265eccab62b96e
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Thu Jan 26 23:48:12 2012 -0500

    Unit test for updating formula cells that references into the pivot table.

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index e83f500..a7bfe2c 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -1259,6 +1259,22 @@ ScDPObject* createDPFromRange(
     return createDPFromSourceDesc(pDoc, aSheetDesc, aFields, nFieldCount, bFilterButton);
 }
 
+class AutoCalcSwitch
+{
+    ScDocument* mpDoc;
+    bool mbOldValue;
+public:
+    AutoCalcSwitch(ScDocument* pDoc, bool bAutoCalc) : mpDoc(pDoc), mbOldValue(pDoc->GetAutoCalc())
+    {
+        mpDoc->SetAutoCalc(bAutoCalc);
+    }
+
+    ~AutoCalcSwitch()
+    {
+        mpDoc->SetAutoCalc(mbOldValue);
+    }
+};
+
 }
 
 void Test::testPivotTable()
@@ -1655,6 +1671,15 @@ void Test::testPivotTableFilters()
         CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
     }
 
+    AutoCalcSwitch aACSwitch(m_pDoc, true); // turn on auto calculation.
+
+    ScAddress aFormulaAddr = aOutRange.aEnd;
+    aFormulaAddr.IncRow(2);
+    m_pDoc->SetString(aFormulaAddr.Col(), aFormulaAddr.Row(), aFormulaAddr.Tab(),
+                      rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("=B8")));
+    double fTest = m_pDoc->GetValue(aFormulaAddr);
+    CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 80.0);
+
     // Set current page of 'Group2' to 'A'.
     ScDPSaveData aSaveData(*pDPObj->GetSaveData());
     ScDPSaveDimension* pDim = aSaveData.GetDimensionByName(
@@ -1682,6 +1707,9 @@ void Test::testPivotTableFilters()
         CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
     }
 
+    fTest = m_pDoc->GetValue(aFormulaAddr);
+    CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 40.0);
+
     // Set query filter.
     ScSheetSourceDesc aDesc(*pDPObj->GetSheetDesc());
     ScQueryParam aQueryParam(aDesc.GetQueryParam());
@@ -1711,6 +1739,9 @@ void Test::testPivotTableFilters()
         CPPUNIT_ASSERT_MESSAGE("Table output check failed", bSuccess);
     }
 
+    fTest = m_pDoc->GetValue(aFormulaAddr);
+    CPPUNIT_ASSERT_MESSAGE("Incorrect formula value that references a cell in the pivot table output.", fTest == 20.0);
+
     pDPs->FreeTable(pDPObj);
     CPPUNIT_ASSERT_MESSAGE("There shouldn't be any data pilot table stored with the document.",
                            pDPs->GetCount() == 0);


More information about the Libreoffice-commits mailing list