diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-01-29 12:32:10 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-01-29 15:46:05 -0500 |
commit | ccd7953e0042c8063e3cbd8e3a3dd9004c1b4f7e (patch) | |
tree | 465eee8bff01da80e635b30f9c8de943a74981be /sc/qa/unit | |
parent | 8a36879eaf0977448b113c2239014d2e2b7ab258 (diff) |
fdo#74014: Add unit test for pasting an unformatted text into cells.
Change-Id: I87f7b3012a2c139b0ecc3dd699ccecb31af77ac7
Diffstat (limited to 'sc/qa/unit')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 58 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 3 |
2 files changed, 59 insertions, 2 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 8cdcb4d2258a..4a9907a4453e 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -6,6 +6,9 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "ucalc.hxx" + #include <sal/config.h> #include <test/bootstrapfixture.hxx> @@ -50,6 +53,8 @@ #include "queryparam.hxx" #include "edittextiterator.hxx" #include "editutil.hxx" +#include <asciiopt.hxx> +#include <impex.hxx> #include "formula/IFunctionDescription.hxx" @@ -72,8 +77,6 @@ #include <sstream> #include <vector> -#include "ucalc.hxx" - struct TestImpl { ScDocShellRef m_xDocShell; @@ -5167,6 +5170,57 @@ void Test::testCondCopyPaste() m_pDoc->DeleteTab(0); } +void Test::testImportStream() +{ + sc::AutoCalcSwitch aAC(*m_pDoc, true); // turn on auto calc. + sc::UndoSwitch aUndo(*m_pDoc, true); // enable undo. + + m_pDoc->InsertTab(0, "Test"); + + m_pDoc->SetString(ScAddress(0,1,0), "=SUM(A1:C1)"); + + CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // CSV import options. + ScAsciiOptions aOpt; + aOpt.SetFieldSeps(","); + + ScImportExport aObj(m_pDoc, ScAddress(0,0,0)); + aObj.SetExtOptions(aOpt); + aObj.ImportString("1,2,3", FORMAT_STRING); + + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(2,0,0))); + + // Formula value should have been updated. + CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0))); + + // Undo, and check the result. + SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager(); + CPPUNIT_ASSERT_MESSAGE("Failed to get the undo manager.", pUndoMgr); + pUndoMgr->Undo(); + + CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(2,0,0))); + + CPPUNIT_ASSERT_EQUAL(0.0, m_pDoc->GetValue(ScAddress(0,1,0))); // formula + + // Redo, and check the result. + pUndoMgr->Redo(); + + CPPUNIT_ASSERT_EQUAL(1.0, m_pDoc->GetValue(ScAddress(0,0,0))); + CPPUNIT_ASSERT_EQUAL(2.0, m_pDoc->GetValue(ScAddress(1,0,0))); + CPPUNIT_ASSERT_EQUAL(3.0, m_pDoc->GetValue(ScAddress(2,0,0))); + + CPPUNIT_ASSERT_EQUAL(6.0, m_pDoc->GetValue(ScAddress(0,1,0))); // formula + + + pUndoMgr->Clear(); + m_pDoc->DeleteTab(0); +} + void Test::testMixData() { m_pDoc->InsertTab(0, "Test"); diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 8a4e350bab3d..8ddd6f00f449 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -307,6 +307,8 @@ public: void testCondFormatInsertCol(); void testCondCopyPaste(); + void testImportStream(); + CPPUNIT_TEST_SUITE(Test); #if CALC_TEST_PERF CPPUNIT_TEST(testPerf); @@ -425,6 +427,7 @@ public: CPPUNIT_TEST(testCondFormatInsertRow); CPPUNIT_TEST(testCondFormatInsertCol); CPPUNIT_TEST(testCondCopyPaste); + CPPUNIT_TEST(testImportStream); CPPUNIT_TEST_SUITE_END(); private: |