summaryrefslogtreecommitdiff
path: root/sc/qa/unit
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@suse.com>2011-11-07 21:32:00 -0500
committerKohei Yoshida <kohei.yoshida@suse.com>2011-11-07 21:34:03 -0500
commita3ddd330bd7f60402e17fe74324c64a394516a01 (patch)
tree218ee04847532bbcb0488c6b7c094885a3823014 /sc/qa/unit
parentcbe46bbe3e7211b937171136405aabd4b8ceaa39 (diff)
Test for filtering empty and non-empty cells.
Diffstat (limited to 'sc/qa/unit')
-rw-r--r--sc/qa/unit/ucalc.cxx35
1 files changed, 33 insertions, 2 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 1b64ade1f824..b40b78836389 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2247,12 +2247,43 @@ void Test::testAutofilter()
CPPUNIT_ASSERT_MESSAGE("rows 2 & 3 should be hidden", bHidden && nRow1 == 2 && nRow2 == 3);
// Remove filtering.
- aParam.GetEntry(0).Clear();
- pDBData->SetQueryParam(aParam);
+ rEntry.Clear();
m_pDoc->Query(0, aParam, true);
bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
CPPUNIT_ASSERT_MESSAGE("All rows should be shown.", !bHidden && nRow1 == 0 && nRow2 == MAXROW);
+ // Filter for non-empty cells by column C.
+ rEntry.bDoQuery = true;
+ rEntry.nField = 2;
+ rEntry.GetQueryItem().meType = ScQueryEntry::ByValue;
+ rEntry.GetQueryItem().maString = rtl::OUString();
+ rEntry.GetQueryItem().mfVal = SC_NONEMPTYFIELDS;
+ m_pDoc->Query(0, aParam, true);
+
+ // only row 3 should be hidden. The rest should be visible.
+ bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 1 & 2 should be visible.", !bHidden && nRow1 == 0 && nRow2 == 1);
+ bHidden = m_pDoc->RowHidden(2, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("row 3 should be hidden.", bHidden && nRow1 == 2 && nRow2 == 2);
+ bHidden = m_pDoc->RowHidden(3, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("row 4 and down should be visible.", !bHidden && nRow1 == 3 && nRow2 == MAXROW);
+
+ // Now, filter for empty cells by column C.
+ rEntry.GetQueryItem().mfVal = SC_EMPTYFIELDS;
+ m_pDoc->Query(0, aParam, true);
+
+ // Now, only row 1 and 3, and 6 and down should be visible.
+ bHidden = m_pDoc->RowHidden(0, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("row 1 should be visible.", !bHidden && nRow1 == 0 && nRow2 == 0);
+ bHidden = m_pDoc->RowHidden(1, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("row 2 should be hidden.", bHidden && nRow1 == 1 && nRow2 == 1);
+ bHidden = m_pDoc->RowHidden(2, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("row 3 should be visible.", !bHidden && nRow1 == 2 && nRow2 == 2);
+ bHidden = m_pDoc->RowHidden(3, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 4 & 5 should be hidden.", bHidden && nRow1 == 3 && nRow2 == 4);
+ bHidden = m_pDoc->RowHidden(5, 0, &nRow1, &nRow2);
+ CPPUNIT_ASSERT_MESSAGE("rows 6 and down should be all visible.", !bHidden && nRow1 == 5 && nRow2 == MAXROW);
+
m_pDoc->DeleteTab(0);
}