summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@collabora.com>2014-04-14 11:22:23 -0400
committerKohei Yoshida <kohei.yoshida@collabora.com>2014-04-14 11:41:04 -0400
commit85a070f93f4dc02a1c0142e4e8f03bde55227e76 (patch)
tree5892fd20e9f98f4dd5541926897bd8eb2cf9af38
parentfabea153cfe1ed109d2724b873655c254a152a38 (diff)
fdo#77209: Adjust this test to cover clip document use case as well.
Turns out that we do need to share pooled resources with clip documents in addition to undo documents. Change-Id: If220c2d4bfc2bece9e884e034525e72dff8e3d66
-rw-r--r--sc/qa/unit/ucalc.cxx52
1 files changed, 38 insertions, 14 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 06ef5660ad5a..7563012d0458 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -599,6 +599,36 @@ void Test::testSharedStringPool()
void Test::testSharedStringPoolUndoDoc()
{
+ struct
+ {
+ bool check( ScDocument& rSrcDoc, ScDocument& rCopyDoc )
+ {
+ // Copy A1:A4 to the undo document.
+ for (SCROW i = 0; i <= 4; ++i)
+ {
+ ScAddress aPos(0,i,0);
+ rCopyDoc.SetString(aPos, rSrcDoc.GetString(aPos));
+ }
+
+ // String values in A1:A4 should have identical hash.
+ for (SCROW i = 0; i <= 4; ++i)
+ {
+ ScAddress aPos(0,i,0);
+ svl::SharedString aSS1 = rSrcDoc.GetSharedString(aPos);
+ svl::SharedString aSS2 = rCopyDoc.GetSharedString(aPos);
+ if (aSS1.getDataIgnoreCase() != aSS2.getDataIgnoreCase())
+ {
+ cerr << "String hash values are not equal at row " << (i+1)
+ << " for string '" << aSS1.getString() << "'" << endl;
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ } aTest;
+
m_pDoc->InsertTab(0, "Test");
m_pDoc->SetString(ScAddress(0,0,0), "Header");
@@ -609,21 +639,15 @@ void Test::testSharedStringPoolUndoDoc()
ScDocument aUndoDoc(SCDOCMODE_UNDO);
aUndoDoc.InitUndo(m_pDoc, 0, 0);
- // Copy A1:A4 to the undo document.
- for (SCROW i = 0; i <= 4; ++i)
- {
- ScAddress aPos(0,i,0);
- aUndoDoc.SetString(aPos, m_pDoc->GetString(aPos));
- }
+ bool bSuccess = aTest.check(*m_pDoc, aUndoDoc);
+ CPPUNIT_ASSERT_MESSAGE("Check failed with undo document.", bSuccess);
- // String values in A1:A4 should have identical hash.
- for (SCROW i = 0; i <= 4; ++i)
- {
- ScAddress aPos(0,i,0);
- svl::SharedString aSS1 = m_pDoc->GetSharedString(aPos);
- svl::SharedString aSS2 = aUndoDoc.GetSharedString(aPos);
- CPPUNIT_ASSERT_MESSAGE("String hash values are not equal.", aSS1.getDataIgnoreCase() == aSS2.getDataIgnoreCase());
- }
+ // Test the clip document as well.
+ ScDocument aClipDoc(SCDOCMODE_CLIP);
+ aClipDoc.ResetClip(m_pDoc, static_cast<SCTAB>(0));
+
+ bSuccess = aTest.check(*m_pDoc, aClipDoc);
+ CPPUNIT_ASSERT_MESSAGE("Check failed with clip document.", bSuccess);
m_pDoc->DeleteTab(0);
}