diff options
author | Eike Rathke <erack@redhat.com> | 2015-09-11 19:23:52 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2015-09-11 19:26:08 +0200 |
commit | 04e66812efedb0be635d60b4c1bb3f89113dfdad (patch) | |
tree | 96bf076468c2975f9627c9222ce1e4181708e82c /sc | |
parent | 50b26404dee83974cf84749a9d492ed208464597 (diff) |
unit test for MoveBlock / ScUndoDragDrop caption life cycle, tdf#92995
Change-Id: Ide7ec10cee3aefaa89feda73181ac9c11ebcbb5a
Diffstat (limited to 'sc')
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 68c57c8d75f5..4a478ce14ebd 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); } |