diff options
author | Caolán McNamara <caolanm@redhat.com> | 2011-08-23 15:21:04 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2011-08-23 15:23:21 +0100 |
commit | 7483d11c3ade957d09519a874556062c2f966fd9 (patch) | |
tree | 6d86a6f98bbc896e67ea49ec674cf95857f90124 /sw/qa | |
parent | 1640c883df327204113aa59c8e39669387aab617 (diff) |
add a regression test to confirm SwDocStat works the way I think
Diffstat (limited to 'sw/qa')
-rw-r--r-- | sw/qa/core/swdoc-test.cxx | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx index 10ee439180dc..41b82c9f52e4 100644 --- a/sw/qa/core/swdoc-test.cxx +++ b/sw/qa/core/swdoc-test.cxx @@ -55,6 +55,7 @@ #include "init.hxx" #include "swtypes.hxx" +#include "docstat.hxx" #include "doc.hxx" #include "docsh.hxx" #include "shellres.hxx" @@ -81,11 +82,13 @@ public: void randomTest(); void testPageDescName(); void testFileNameFields(); + void testDocStat(); CPPUNIT_TEST_SUITE(SwDocTest); CPPUNIT_TEST(randomTest); CPPUNIT_TEST(testPageDescName); CPPUNIT_TEST(testFileNameFields); + CPPUNIT_TEST(testDocStat); CPPUNIT_TEST_SUITE_END(); private: @@ -172,6 +175,28 @@ void SwDocTest::testFileNameFields() m_xDocShRef->DoInitNew(0); } +void SwDocTest::testDocStat() +{ + CPPUNIT_ASSERT_MESSAGE("Expected initial 0 count", m_pDoc->GetDocStat().nChar == 0); + + SwNodeIndex aIdx(m_pDoc->GetNodes().GetEndOfContent(), -1); + SwPaM aPaM(aIdx); + + rtl::OUString sText(RTL_CONSTASCII_USTRINGPARAM("Hello World")); + m_pDoc->InsertString(aPaM, sText); + + CPPUNIT_ASSERT_MESSAGE("Should still be non-updated 0 count", m_pDoc->GetDocStat().nChar == 0); + + SwDocStat aDocStat = m_pDoc->GetDocStat(); + m_pDoc->UpdateDocStat(aDocStat); + + sal_uLong nLen = static_cast<sal_uLong>(sText.getLength()); + + CPPUNIT_ASSERT_MESSAGE("Should now have updated count", aDocStat.nChar == nLen); + + CPPUNIT_ASSERT_MESSAGE("And cache is updated too", m_pDoc->GetDocStat().nChar == nLen); +} + static int getRand(int modulus) { |