diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-08 14:42:31 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-08 15:15:19 -0500 |
commit | ac5682aa3013550e3643026c571b5d851b9e7b67 (patch) | |
tree | dbdb37824e4805cddf8f05dcef8fa6be223a6777 | |
parent | 2d04286f258603a7fbb1d63cccaa7f1f81b22075 (diff) |
fdo#74453: Write unit test for this.
Change-Id: Ic8cbc650d6608ff7af5d1d58deeeba409bb81725
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 2 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_sharedformula.cxx | 39 |
2 files changed, 41 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index f59546798bec..053e60709326 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -252,6 +252,7 @@ public: void testSharedFormulasRefUpdateRange(); void testSharedFormulasDeleteRows(); void testSharedFormulasRefUpdateMoveSheets(); + void testSharedFormulasRefUpdateCopySheets(); void testSharedFormulasCopyPaste(); void testSharedFormulaInsertColumn(); void testFormulaPosition(); @@ -414,6 +415,7 @@ public: CPPUNIT_TEST(testSharedFormulasRefUpdateRange); CPPUNIT_TEST(testSharedFormulasDeleteRows); CPPUNIT_TEST(testSharedFormulasRefUpdateMoveSheets); + CPPUNIT_TEST(testSharedFormulasRefUpdateCopySheets); CPPUNIT_TEST(testSharedFormulasCopyPaste); CPPUNIT_TEST(testSharedFormulaInsertColumn); CPPUNIT_TEST(testFormulaPosition); diff --git a/sc/qa/unit/ucalc_sharedformula.cxx b/sc/qa/unit/ucalc_sharedformula.cxx index 04e917f35ebb..a64398b0e799 100644 --- a/sc/qa/unit/ucalc_sharedformula.cxx +++ b/sc/qa/unit/ucalc_sharedformula.cxx @@ -600,6 +600,45 @@ void Test::testSharedFormulasRefUpdateMoveSheets() m_pDoc->DeleteTab(0); } +void Test::testSharedFormulasRefUpdateCopySheets() +{ + sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // make sure auto calc is on. + + m_pDoc->InsertTab(0, "Sheet1"); + m_pDoc->InsertTab(1, "Sheet2"); + + m_pDoc->SetValue(ScAddress(0,0,1), 1.0); // A1 on Sheet2 + m_pDoc->SetValue(ScAddress(0,1,1), 2.0); // A2 on Sheet2 + + // Reference values on Sheet2, but use absolute sheet references. + m_pDoc->SetString(ScAddress(0,0,0), "=$Sheet2.A1"); + m_pDoc->SetString(ScAddress(0,1,0), "=$Sheet2.A2"); + + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // Copy Sheet1 and insert the copied sheet before the current Sheet1 position. + m_pDoc->CopyTab(0, 0); + + if (!checkFormula(*m_pDoc, ScAddress(0,0,0), "$Sheet2.A1")) + CPPUNIT_FAIL("Wrong formula"); + + if (!checkFormula(*m_pDoc, ScAddress(0,1,0), "$Sheet2.A2")) + CPPUNIT_FAIL("Wrong formula"); + + // Check the values on the copied sheet. + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // Check the values on the original sheet. + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,1))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(0,1,1))); + + m_pDoc->DeleteTab(2); + m_pDoc->DeleteTab(1); + m_pDoc->DeleteTab(0); +} + void Test::testSharedFormulasCopyPaste() { m_pDoc->InsertTab(0, "Test"); |