[Libreoffice-commits] .: sc/qa
Markus Mohrhard
mmohrhard at kemper.freedesktop.org
Fri Jul 29 07:46:05 PDT 2011
sc/qa/unit/ucalc.cxx | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
New commits:
commit 806d21d8a7aee0ab1482a780756ced2394792995
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date: Fri Jul 29 16:42:22 2011 +0200
initial work for autofilter unit test
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index dba0182..2dc8063 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);
}
More information about the Libreoffice-commits
mailing list