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

Varun Dhall varun.dhall at studentpartner.com
Mon Jul 3 21:43:43 UTC 2017


 editeng/qa/unit/core-test.cxx |   49 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

New commits:
commit 6e7300d1046a195068fa97a0d91a95f19cc5c056
Author: Varun Dhall <varun.dhall at studentpartner.com>
Date:   Tue Jul 4 02:08:40 2017 +0530

    EditEngine: Added test to check multi para start copy/paste
    
    Change-Id: Ic253af5ab75783280926f2ed8387f69015014227
    Reviewed-on: https://gerrit.libreoffice.org/39488
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Michael Stahl <mstahl at redhat.com>

diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 637342ddf13a..427e19ca102f 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -81,6 +81,8 @@ public:
     /// Test Copy/Paste with multiple paragraphs having Bold/Italic text
     void testParaBoldItalicCopyPaste();
 
+    void testParaStartCopyPaste();
+
     void testSectionAttributes();
 
     CPPUNIT_TEST_SUITE(Test);
@@ -96,6 +98,7 @@ public:
     CPPUNIT_TEST(testUnderlineCopyPaste);
     CPPUNIT_TEST(testMultiParaCopyPaste);
     CPPUNIT_TEST(testParaBoldItalicCopyPaste);
+    CPPUNIT_TEST(testParaStartCopyPaste);
     CPPUNIT_TEST(testSectionAttributes);
     CPPUNIT_TEST_SUITE_END();
 
@@ -1432,6 +1435,52 @@ void Test::testParaBoldItalicCopyPaste()
     CPPUNIT_ASSERT_MESSAGE( "This section must be bold.", hasBold(*pSecAttr) );
 }
 
+void Test::testParaStartCopyPaste()
+{
+    // Create EditEngine's instance
+    EditEngine aEditEngine( mpItemPool );
+
+    // Get EditDoc for current EditEngine's instance
+    EditDoc &rDoc = aEditEngine.GetEditDoc();
+
+    // Initially no text should be there
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(0), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( OUString(), rDoc.GetParaAsString(sal_Int32(0)) );
+
+    // Insert initial text
+    OUString aFirstPara = "This is first paragraph";
+    // Selection Ref       ........8..............
+    OUString aSecondPara = "This is second paragraph";
+    // Selection Ref        .............14.........
+    OUString aThirdPara = "This is third paragraph";
+    OUString aText = aFirstPara + "\n" + aSecondPara + "\n" + aThirdPara;
+    sal_Int32 aTextLen = aFirstPara.getLength() + aSecondPara.getLength() + aThirdPara.getLength();
+    aEditEngine.SetText( aText );
+    OUString aCopyText = "first paragraphThis is second";
+    sal_Int32 aCopyTextLen = aCopyText.getLength();
+
+    // Assert changes
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) );
+    CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) );
+    CPPUNIT_ASSERT_EQUAL( aThirdPara, rDoc.GetParaAsString(sal_Int32(2)) );
+
+    // Copy initial text using legacy format
+    uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,8,1,14) );
+
+    // Paste text at the start
+    aEditEngine.InsertText( xData, OUString(), rDoc.GetStartPaM(), true );
+
+    // Assert changes
+    OUString aFirstParaAfterCopyPaste = "first paragraph";
+    OUString aSecondParaAfterCopyPaste = "This is second" + aFirstPara;
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen + aCopyTextLen), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( aFirstParaAfterCopyPaste, rDoc.GetParaAsString(sal_Int32(0)) );
+    CPPUNIT_ASSERT_EQUAL( aSecondParaAfterCopyPaste, rDoc.GetParaAsString(sal_Int32(1)) );
+    CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(2)) );
+    CPPUNIT_ASSERT_EQUAL( aThirdPara, rDoc.GetParaAsString(sal_Int32(3)) );
+}
+
 void Test::testSectionAttributes()
 {
     EditEngine aEngine(mpItemPool);


More information about the Libreoffice-commits mailing list