[Libreoffice-commits] .: sw/qa

Caolán McNamara caolan at kemper.freedesktop.org
Tue Aug 23 07:23:53 PDT 2011


 sw/qa/core/swdoc-test.cxx |   25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

New commits:
commit 7483d11c3ade957d09519a874556062c2f966fd9
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Tue Aug 23 15:21:04 2011 +0100

    add a regression test to confirm SwDocStat works the way I think

diff --git a/sw/qa/core/swdoc-test.cxx b/sw/qa/core/swdoc-test.cxx
index 10ee439..41b82c9 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)
 {


More information about the Libreoffice-commits mailing list