summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-02-11 01:07:00 -0500
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-02-11 01:08:56 -0500
commitaa03bdcb5216ff82de22fc02ffa0746902f64972 (patch)
tree0f1d5e204a485e0a179a7e3bcaa47b8f3f04b16c
parent1da03a88a98b50633d61557de27e4c0702a665eb (diff)
fdo#74014: Additional test.
Though this one passes in unit test, but fails in real life session. No idea why. Change-Id: I657ed5aa8b1aa0046458d26badf3cb22e3778d41
-rw-r--r--sc/qa/unit/ucalc.cxx46
-rw-r--r--sc/qa/unit/ucalc.hxx2
2 files changed, 47 insertions, 1 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index fc539d9f1910..c06f82d93ebe 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5422,7 +5422,7 @@ void Test::testImportStream()
m_pDoc->InsertTab(0, "Test");
- m_pDoc->SetString(ScAddress(0,1,0), "=SUM(A1:C1)");
+ m_pDoc->SetString(ScAddress(0,1,0), "=SUM(A1:C1)"); // A2
CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,1,0)));
@@ -5430,6 +5430,7 @@ void Test::testImportStream()
ScAsciiOptions aOpt;
aOpt.SetFieldSeps(",");
+ // Import values to A1:C1.
ScImportExport aObj(m_pDoc, ScAddress(0,0,0));
aObj.SetImportBroadcast(true);
aObj.SetExtOptions(aOpt);
@@ -5463,6 +5464,49 @@ void Test::testImportStream()
CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0))); // formula
pUndoMgr->Clear();
+
+ m_pDoc->DeleteTab(0);
+}
+
+void Test::testDeleteContents()
+{
+ sc::AutoCalcSwitch aACSwitch(*m_pDoc, true); // turn on auto calc.
+ sc::UndoSwitch aUndoSwitch(*m_pDoc, true); // enable undo.
+
+ m_pDoc->InsertTab(0, "Test");
+
+ m_pDoc->SetValue(ScAddress(3,1,0), 1.0);
+ m_pDoc->SetValue(ScAddress(3,2,0), 1.0);
+ m_pDoc->SetValue(ScAddress(3,3,0), 1.0);
+ m_pDoc->SetValue(ScAddress(3,4,0), 1.0);
+ m_pDoc->SetValue(ScAddress(3,5,0), 1.0);
+ m_pDoc->SetValue(ScAddress(3,6,0), 1.0);
+ m_pDoc->SetValue(ScAddress(3,7,0), 1.0);
+ m_pDoc->SetValue(ScAddress(3,8,0), 1.0);
+ m_pDoc->SetString(ScAddress(3,15,0), "=SUM(D2:D15)");
+
+ CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
+ // Delete D2:D6.
+ ScRange aRange(3,1,0,3,5,0);
+ ScMarkData aMark;
+ aMark.SelectOneTable(0);
+ aMark.SetMarkArea(aRange);
+
+ ScDocument* pUndoDoc = new ScDocument(SCDOCMODE_UNDO);
+ pUndoDoc->InitUndo(m_pDoc, 0, 0);
+ m_pDoc->CopyToDocument(aRange, IDF_CONTENTS, false, pUndoDoc, &aMark);
+ ScUndoDeleteContents aUndo(&getDocShell(), aMark, aRange, pUndoDoc, false, IDF_CONTENTS, true);
+
+ clearRange(m_pDoc, aRange);
+ CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
+ aUndo.Undo();
+ CPPUNIT_ASSERT_EQUAL(8.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
+ aUndo.Redo();
+ CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(3,15,0))); // formula
+
m_pDoc->DeleteTab(0);
}
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx
index 64fde25dbbc8..f94ac91549b2 100644
--- a/sc/qa/unit/ucalc.hxx
+++ b/sc/qa/unit/ucalc.hxx
@@ -316,6 +316,7 @@ public:
void testCondCopyPaste();
void testImportStream();
+ void testDeleteContents();
void testTransliterateText();
void testColumnFindEditCells();
@@ -448,6 +449,7 @@ public:
CPPUNIT_TEST(testCondFormatInsertCol);
CPPUNIT_TEST(testCondCopyPaste);
CPPUNIT_TEST(testImportStream);
+ CPPUNIT_TEST(testDeleteContents);
CPPUNIT_TEST(testTransliterateText);
CPPUNIT_TEST(testColumnFindEditCells);
CPPUNIT_TEST_SUITE_END();