diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-07-29 16:42:22 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2011-07-29 16:43:53 +0200 |
commit | d79591d61e6efb8cb55e2eac68992c260cf4ffd6 (patch) | |
tree | cc9b412829c9109158b0308d8d04948ae8571ee9 /sc | |
parent | 745440174aa7244038d7915feb7df6731d2608f0 (diff) |
initial work for autofilter unit test
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index dba01824d0a5..2dc80635e676 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -63,6 +63,7 @@ #include "markdata.hxx" #include "docsh.hxx" +#include "dbdocfun.hxx" #include "funcdesc.hxx" #include "externalrefmgr.hxx" @@ -245,6 +246,7 @@ public: void testSheetMove(); void testExternalRef(); void testDataArea(); + void testAutofilter(); /** * Make sure the sheet streams are invalidated properly. @@ -285,6 +287,7 @@ public: CPPUNIT_TEST(testStreamValid); CPPUNIT_TEST(testFunctionLists); CPPUNIT_TEST(testToggleRefFlag); + CPPUNIT_TEST(testAutofilter); CPPUNIT_TEST_SUITE_END(); private: @@ -2117,6 +2120,59 @@ void Test::testToggleRefFlag() m_pDoc->DeleteTab(0); } +void Test::testAutofilter() +{ + OUString aTabName(RTL_CONSTASCII_USTRINGPARAM("Test")); + m_pDoc->InsertTab( 0, aTabName ); + + OUString aCol1(RTL_CONSTASCII_USTRINGPARAM("COL1")); + OUString aCol2(RTL_CONSTASCII_USTRINGPARAM("COL2")); + OUString aDBName(RTL_CONSTASCII_USTRINGPARAM("NONAME")); + + //set column headers + m_pDoc->SetString(0,0,0,aCol1); + m_pDoc->SetString(1,0,1,aCol2); + + //set values + m_pDoc->SetValue(0,1,0,0); + m_pDoc->SetValue(1,1,0,1); + m_pDoc->SetValue(0,2,0,1); + m_pDoc->SetValue(1,2,0,3); + m_pDoc->SetValue(0,3,0,1); + m_pDoc->SetValue(1,3,0,2); + + //create db data and set it to autofilter + ScDBData* pDBData = new ScDBData(aDBName,0,0,0,1,3); + m_pDoc->SetAnonymousDBData(0,pDBData); + + pDBData->SetAutoFilter(true); + ScRange aRange; + pDBData->GetArea(aRange); + m_pDoc->ApplyFlagsTab( aRange.aStart.Col(), aRange.aStart.Row(), + aRange.aEnd.Col(), aRange.aStart.Row(), + aRange.aStart.Tab(), 4 ); + + //create the query param + ScQueryParam aParam; + aParam.Resize(1); + ScQueryEntry& aEntry = aParam.GetEntry(0); + aEntry.bDoQuery = true; + aEntry.eOp = SC_EQUAL; + aEntry.nVal = 0; + //add queryParam to autofilter + pDBData->SetQueryParam(aParam); + //perform the query + ScDBDocFunc aDBFunc(*m_xDocShRef); + aDBFunc.RepeatDB(aCol1,true,true,true,0); + + //control output + SCROW nRow1, nRow2; + bool bHidden = m_pDoc->RowHidden(2, 0, &nRow1, &nRow2); + CPPUNIT_ASSERT_MESSAGE("rows 2 & 3 should be hidden", bHidden && nRow1 == 2 && nRow2 == 3); + + m_pDoc->DeleteTab(0); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); } |