diff options
author | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-03 11:47:10 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@collabora.com> | 2014-02-03 11:49:21 -0500 |
commit | fc5eefc903529d1c3548c680b3077eee4e2c7a73 (patch) | |
tree | 33e1d5506c7f6067d6dfcf90adcd6b896d2e7f76 /sc/qa | |
parent | e753233e2e8af04048a17c7163ff5d9d3ffbbf3d (diff) |
Add test code to exercise ScColumn::HasEditCells().
Change-Id: Ibacf3585a6d15d541a50cb7bb50905d34a7d598b
Diffstat (limited to 'sc/qa')
-rw-r--r-- | sc/qa/unit/ucalc.hxx | 3 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_column.cxx | 70 |
2 files changed, 73 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.hxx b/sc/qa/unit/ucalc.hxx index 84f54708fcef..48234e5c94a3 100644 --- a/sc/qa/unit/ucalc.hxx +++ b/sc/qa/unit/ucalc.hxx @@ -311,6 +311,8 @@ public: void testImportStream(); + void testColumnFindEditCells(); + CPPUNIT_TEST_SUITE(Test); #if CALC_TEST_PERF CPPUNIT_TEST(testPerf); @@ -433,6 +435,7 @@ public: CPPUNIT_TEST(testCondFormatInsertCol); CPPUNIT_TEST(testCondCopyPaste); CPPUNIT_TEST(testImportStream); + CPPUNIT_TEST(testColumnFindEditCells); CPPUNIT_TEST_SUITE_END(); private: diff --git a/sc/qa/unit/ucalc_column.cxx b/sc/qa/unit/ucalc_column.cxx new file mode 100644 index 000000000000..0959ee1d47b9 --- /dev/null +++ b/sc/qa/unit/ucalc_column.cxx @@ -0,0 +1,70 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * 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 <editutil.hxx> +#include <cellvalue.hxx> + +void Test::testColumnFindEditCells() +{ + m_pDoc->InsertTab(0, "Test"); + + bool bRes = m_pDoc->HasEditText(ScRange(0,0,0,0,MAXROW,0)); + CPPUNIT_ASSERT_MESSAGE("There should be no edit cells.", !bRes); + bRes = m_pDoc->HasEditText(ScRange(0,0,0,0,0,0)); + CPPUNIT_ASSERT_MESSAGE("There should be no edit cells.", !bRes); + bRes = m_pDoc->HasEditText(ScRange(0,0,0,0,10,0)); + CPPUNIT_ASSERT_MESSAGE("There should be no edit cells.", !bRes); + + ScFieldEditEngine& rEE = m_pDoc->GetEditEngine(); + rEE.SetText("Test"); + m_pDoc->SetEditText(ScAddress(0,0,0), rEE.CreateTextObject()); + const EditTextObject* pObj = m_pDoc->GetEditText(ScAddress(0,0,0)); + CPPUNIT_ASSERT_MESSAGE("There should be an edit cell here.", pObj); + + ScRange aRange(0,0,0,0,0,0); + bRes = m_pDoc->HasEditText(aRange); + CPPUNIT_ASSERT_MESSAGE("There is an edit cell here.", bRes); + + aRange.aStart.SetRow(1); + aRange.aEnd.SetRow(1); + bRes = m_pDoc->HasEditText(aRange); + CPPUNIT_ASSERT_MESSAGE("There shouldn't be an edit cell in specified range.", !bRes); + + aRange.aStart.SetRow(2); + aRange.aEnd.SetRow(4); + bRes = m_pDoc->HasEditText(aRange); + CPPUNIT_ASSERT_MESSAGE("There shouldn't be an edit cell in specified range.", !bRes); + + aRange.aStart.SetRow(0); + aRange.aEnd.SetRow(MAXROW); + bRes = m_pDoc->HasEditText(aRange); + CPPUNIT_ASSERT_MESSAGE("There shouldn be an edit cell in specified range.", bRes); + + m_pDoc->SetString(ScAddress(0,0,0), "Test"); + m_pDoc->SetValue(ScAddress(0,2,0), 1.0); + ScRefCellValue aCell; + aCell.assign(*m_pDoc, ScAddress(0,0,0)); + CPPUNIT_ASSERT_MESSAGE("This should be a string cell.", aCell.meType == CELLTYPE_STRING); + aCell.assign(*m_pDoc, ScAddress(0,1,0)); + CPPUNIT_ASSERT_MESSAGE("This should be an empty cell.", aCell.meType == CELLTYPE_NONE); + aCell.assign(*m_pDoc, ScAddress(0,2,0)); + CPPUNIT_ASSERT_MESSAGE("This should be a numeric cell.", aCell.meType == CELLTYPE_VALUE); + aCell.assign(*m_pDoc, ScAddress(0,3,0)); + CPPUNIT_ASSERT_MESSAGE("This should be an empty cell.", aCell.meType == CELLTYPE_NONE); + + aRange.aStart.SetRow(1); + aRange.aEnd.SetRow(1); + bRes = m_pDoc->HasEditText(aRange); + CPPUNIT_ASSERT_MESSAGE("There shouldn't be an edit cell in specified range.", !bRes); + + m_pDoc->DeleteTab(0); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |