[Libreoffice-commits] core.git: sc/qa

Eike Rathke erack at redhat.com
Fri Sep 11 10:26:58 PDT 2015


 sc/qa/unit/ucalc.cxx |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

New commits:
commit 04e66812efedb0be635d60b4c1bb3f89113dfdad
Author: Eike Rathke <erack at redhat.com>
Date:   Fri Sep 11 19:23:52 2015 +0200

    unit test for MoveBlock / ScUndoDragDrop caption life cycle, tdf#92995
    
    Change-Id: Ide7ec10cee3aefaa89feda73181ac9c11ebcbb5a

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 68c57c8..4a478ce 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -5137,6 +5137,48 @@ void Test::testNoteLifeCycle()
     CPPUNIT_ASSERT_MESSAGE("Note on the clipboard should share the same caption object from the original.",
                            pClipNote->GetCaption() == pCaption);
 
+
+    // Move B2 to B3 with note, which creates an ScUndoDragDrop, and Undo.
+
+    ScAddress aOrigPos(aPos);
+    ScAddress aMovePos(1,2,0);
+    ScPostIt* pOrigNote = m_pDoc->GetNote(aOrigPos);
+    const SdrCaptionObj* pOrigCaption = pOrigNote->GetOrCreateCaption(aOrigPos);
+    bool bCut = true;       // like Drag&Drop
+    bool bRecord = true;    // record Undo
+    bool bPaint = false;    // don't care about
+    bool bApi = true;       // API to prevent dialogs
+    ScDocFunc& rDocFunc = getDocShell().GetDocFunc();
+    bool bMoveDone = rDocFunc.MoveBlock(ScRange(aOrigPos, aOrigPos), aMovePos, bCut, bRecord, bPaint, bApi);
+    CPPUNIT_ASSERT_MESSAGE("Cells not moved", bMoveDone);
+
+    // Verify the note move.
+    ScPostIt* pGoneNote = m_pDoc->GetNote(aOrigPos);
+    CPPUNIT_ASSERT_MESSAGE("Failed to move the note from source.", !pGoneNote);
+    ScPostIt* pMoveNote = m_pDoc->GetNote(aMovePos);
+    CPPUNIT_ASSERT_MESSAGE("Failed to move the note to destination.", pMoveNote);
+
+    // The caption object should not be identical, it was newly created upon
+    // Drop from clipboard.
+    // pOrigCaption is a dangling pointer.
+    const SdrCaptionObj* pMoveCaption = pMoveNote->GetOrCreateCaption(aMovePos);
+    CPPUNIT_ASSERT_MESSAGE("Captions identical after move.", pOrigCaption != pMoveCaption);
+
+    SfxUndoManager* pUndoMgr = m_pDoc->GetUndoManager();
+    CPPUNIT_ASSERT(pUndoMgr);
+    pUndoMgr->Undo();   // this should not crash ... tdf#92995
+
+    // Verify the note move Undo.
+    pMoveNote = m_pDoc->GetNote(aMovePos);
+    CPPUNIT_ASSERT_MESSAGE("Failed to undo the note move from destination.", !pMoveNote);
+    pOrigNote = m_pDoc->GetNote(aOrigPos);
+    CPPUNIT_ASSERT_MESSAGE("Failed to undo the note move to source.", pOrigNote);
+
+    // The caption object still should not be identical.
+    // pMoveCaption is a dangling pointer.
+    pOrigCaption = pOrigNote->GetOrCreateCaption(aOrigPos);
+    CPPUNIT_ASSERT_MESSAGE("Captions identical after move undo.", pOrigCaption != pMoveCaption);
+
     m_pDoc->DeleteTab(0);
 }
 


More information about the Libreoffice-commits mailing list