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

Varun varun.dhall at studentpartner.com
Mon Aug 17 12:21:30 PDT 2015


 sw/qa/extras/uiwriter/uiwriter.cxx |   54 +++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

New commits:
commit c5f2122f66cfbb1186fe8d77854edbcdccad9841
Author: Varun <varun.dhall at studentpartner.com>
Date:   Tue Aug 4 16:21:29 2015 +0530

    Added test for tdf#60967 deleting paragraph following a table
    
    Conflicts:
    	sw/qa/extras/uiwriter/uiwriter.cxx
    
    Change-Id: Idfb2e9dae026c639916cc5b919bc70ed8f15067f
    Reviewed-on: https://gerrit.libreoffice.org/17504
    Reviewed-by: Michael Stahl <mstahl at redhat.com>
    Tested-by: Michael Stahl <mstahl at redhat.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index edfd808..8d48c7b 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -132,6 +132,7 @@ public:
     void testTdf69282WithMirror();
     void testTdf78742();
     void testUnoParagraph();
+    void testTdf60967();
     void testSearchWithTransliterate();
     void testTdf74363();
     void testTdf80663();
@@ -202,6 +203,7 @@ public:
     CPPUNIT_TEST(testTdf69282WithMirror);
     CPPUNIT_TEST(testTdf78742);
     CPPUNIT_TEST(testUnoParagraph);
+    CPPUNIT_TEST(testTdf60967);
     CPPUNIT_TEST(testSearchWithTransliterate);
     CPPUNIT_TEST(testTdf74363);
     CPPUNIT_TEST(testTdf80663);
@@ -1544,6 +1546,58 @@ void SwUiWriterTest::testUnoParagraph()
     CPPUNIT_ASSERT_EQUAL(OUString("This is modified text in paragraph two"), xSecondPara->getString());
 }
 
+void SwUiWriterTest::testTdf60967()
+{
+    SwDoc* pDoc = createDoc();
+    SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+    SwPaM* pCrsr = pDoc->GetEditShell()->GetCrsr();
+    sw::UndoManager& rUndoManager = pDoc->GetUndoManager();
+    pWrtShell->ChangeHeaderOrFooter(OUString("Default Style"), true, true, true);
+    //Inserting table
+    SwInsertTableOptions TableOpt(tabopts::DEFAULT_BORDER, 0);
+    pWrtShell->InsertTable(TableOpt, 2, 2);
+    //getting the cursor's position just after the table insert
+    SwPosition xPosAfterTable(*(pCrsr->GetPoint()));
+    //moving cursor to B2 (bottom right cell)
+    pCrsr->Move(fnMoveBackward);
+    SwPosition xPosInTable(*(pCrsr->GetPoint()));
+    //deleting paragraph following table with Ctrl+Shift+Del
+    sal_Int32 val = pWrtShell->DelToEndOfSentence();
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1), val);
+    //getting the cursor's position just after the paragraph deletion
+    SwPosition xPosAfterDel(*(pCrsr->GetPoint()));
+    //moving cursor forward to check whether there is any node following the table, BTW there should not be any such node
+    pCrsr->Move(fnMoveForward);
+    SwPosition xPosMoveAfterDel(*(pCrsr->GetPoint()));
+    //checking the positons to verify that the paragraph is actually deleted
+    CPPUNIT_ASSERT(xPosInTable==xPosAfterDel);
+    CPPUNIT_ASSERT(xPosInTable==xPosMoveAfterDel);
+    //Undo the changes
+    rUndoManager.Undo();
+    {
+        //paragraph *text node* should be back
+        SwPosition xPosAfterUndo(*(pCrsr->GetPoint()));
+        //after undo xPosAfterTable increases the node position by one, since this contains the position *text node* so xPosAfterUndo should be less than xPosAfterTable
+        CPPUNIT_ASSERT(xPosAfterTable>xPosAfterUndo);
+        //moving cursor forward to check whether there is any node following the paragraph, BTW there should not be any such node as paragraph node is the last one in header
+        pCrsr->Move(fnMoveForward);
+        SwPosition xPosMoveAfterUndo(*(pCrsr->GetPoint()));
+        //checking positions to verify that paragraph node is the last one and we are paragraph node only
+        CPPUNIT_ASSERT(xPosAfterTable>xPosMoveAfterUndo);
+        CPPUNIT_ASSERT(xPosMoveAfterUndo==xPosAfterUndo);
+    }
+    //Redo the changes
+    rUndoManager.Redo();
+    //paragraph *text node* should not be there
+    SwPosition xPosAfterRedo(*(pCrsr->GetPoint()));
+    //position should be exactly same as it was after deletion of *text node*
+    CPPUNIT_ASSERT(xPosMoveAfterDel==xPosAfterRedo);
+    //moving the cursor forward, but it should not actually move as there is no *text node* after the table due to this same postion is expected after move as it was before move
+    pCrsr->Move(fnMoveForward);
+    SwPosition xPosAfterUndoMove(*(pCrsr->GetPoint()));
+    CPPUNIT_ASSERT(xPosAfterUndoMove==xPosAfterRedo);
+}
+
 void SwUiWriterTest::testSearchWithTransliterate()
 {
     SwDoc* pDoc = createDoc();


More information about the Libreoffice-commits mailing list