Kaydet (Commit) 40cfaaa7 authored tarafından Markus Mohrhard's avatar Markus Mohrhard

first test for ScDocument::FindAreaPos

This is the first step into fixing the cursor navigation.
ScDocument::FindAreaPos contains still bugs in the handling of hidden
rows and hidden columns. This test checks only problems with rows and
moving downwards.

Change-Id: I204064a96a1abdb8ab5f46e395f8f7c391fb4824
üst 38feb1ef
...@@ -215,7 +215,10 @@ public: ...@@ -215,7 +215,10 @@ public:
void testCopyPasteFormulas(); void testCopyPasteFormulas();
void testCopyPasteFormulasExternalDoc(); void testCopyPasteFormulasExternalDoc();
void testFindAreaPosRowDown();
CPPUNIT_TEST_SUITE(Test); CPPUNIT_TEST_SUITE(Test);
#if 0
CPPUNIT_TEST(testCollator); CPPUNIT_TEST(testCollator);
CPPUNIT_TEST(testInput); CPPUNIT_TEST(testInput);
CPPUNIT_TEST(testCellFunctions); CPPUNIT_TEST(testCellFunctions);
...@@ -257,6 +260,8 @@ public: ...@@ -257,6 +260,8 @@ public:
CPPUNIT_TEST(testAutoFill); CPPUNIT_TEST(testAutoFill);
CPPUNIT_TEST(testCopyPasteFormulas); CPPUNIT_TEST(testCopyPasteFormulas);
CPPUNIT_TEST(testCopyPasteFormulasExternalDoc); CPPUNIT_TEST(testCopyPasteFormulasExternalDoc);
#endif
CPPUNIT_TEST(testFindAreaPosRowDown);
CPPUNIT_TEST_SUITE_END(); CPPUNIT_TEST_SUITE_END();
private: private:
...@@ -4585,6 +4590,76 @@ void Test::testCopyPasteFormulasExternalDoc() ...@@ -4585,6 +4590,76 @@ void Test::testCopyPasteFormulasExternalDoc()
CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$ExtSheet2.$B$2")); CPPUNIT_ASSERT_EQUAL(aFormula, rtl::OUString("=$ExtSheet2.$B$2"));
} }
void Test::testFindAreaPosRowDown()
{
const char* aData[][2] = {
{ "", "" },
{ "1", "" },
{ "1", "1" },
{ "", "1" },
{ "1", "1" },
{ "1", "" },
{ "1", "1" }, };
ScDocument* pDoc = m_xDocShRef->GetDocument();
rtl::OUString aTabName1("test1");
pDoc->InsertTab(0, aTabName1);
clearRange( pDoc, ScRange(0, 0, 0, 1, SAL_N_ELEMENTS(aData), 0));
ScAddress aPos(0,0,0);
ScRange aDataRange = insertRangeData( pDoc, aPos, aData, SAL_N_ELEMENTS(aData));
CPPUNIT_ASSERT_MESSAGE("failed to insert range data at correct position", aDataRange.aStart == aPos);
pDoc->SetRowHidden(4,4,0,true);
bool bHidden = pDoc->RowHidden(4,0);
CPPUNIT_ASSERT(bHidden);
SCCOL nCol = 0;
SCROW nRow = 0;
pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(1), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(2), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
// BUG! This returns right now 4 because FindAreaPos does
// not yet work correctly with hidden rows
//CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(5), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(MAXROW), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(0), nCol);
nCol = 1;
nRow = 2;
pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
// BUG! This returns right now 4 because FindAreaPos does
// not yet work correctly with hidden rows
//CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(3), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCol);
pDoc->FindAreaPos(nCol, nRow, 0, 0, 1);
CPPUNIT_ASSERT_EQUAL(static_cast<SCROW>(6), nRow);
CPPUNIT_ASSERT_EQUAL(static_cast<SCCOL>(1), nCol);
pDoc->DeleteTab(0);
}
CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_TEST_SUITE_REGISTRATION(Test);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment