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

Varun Dhall varun.dhall at studentpartner.com
Fri Mar 24 21:50:25 UTC 2017


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

New commits:
commit 0115a5f908d2280d39381e616cec262fabf07ea0
Author: Varun Dhall <varun.dhall at studentpartner.com>
Date:   Thu Mar 23 14:42:40 2017 +0530

    Added Test for EditEngine - Copy/Paste with Tabs in Text
    
    Change-Id: If40dabc53d35c01e61f8a17799f26e6ef9fd6b08
    Reviewed-on: https://gerrit.libreoffice.org/35579
    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 f62430c18b64..98bfacf0d5a9 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -57,6 +57,9 @@ public:
     /// Test Copy/Paste using Legacy Format
     void testCopyPaste();
 
+    /// Test Copy/Paste with Tabs
+    void testTabsCopyPaste();
+
     /// Test hyperlinks
     void testHyperlinkSearch();
 
@@ -73,6 +76,7 @@ public:
     CPPUNIT_TEST(testUnoTextFields);
     CPPUNIT_TEST(testAutocorrect);
     CPPUNIT_TEST(testCopyPaste);
+    CPPUNIT_TEST(testTabsCopyPaste);
     CPPUNIT_TEST(testHyperlinkSearch);
     CPPUNIT_TEST(testBoldItalicCopyPaste);
     CPPUNIT_TEST(testUnderlineCopyPaste);
@@ -411,6 +415,59 @@ void Test::testCopyPaste()
     CPPUNIT_ASSERT_EQUAL( OUString(aText + aText), rDoc.GetParaAsString(sal_Int32(0)) );
 }
 
+void Test::testTabsCopyPaste()
+{
+    // Create EditEngine's instance
+    EditEngine aEditEngine( mpItemPool );
+
+    // Get EditDoc for current EditEngine's instance
+    EditDoc &rDoc = aEditEngine.GetEditDoc();
+
+    // New instance must be empty - no initial text
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(0), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( OUString(""), rDoc.GetParaAsString(sal_Int32(0)) );
+
+    // Get corresponding Item for inserting tabs in the text
+    SfxVoidItem aTab( EE_FEATURE_TAB );
+
+    // Insert initial text
+    OUString aParaText = "sampletextfortestingtab";
+    // Positions Ref      ......*6...............*23
+    sal_Int32 aTextLen = aParaText.getLength();
+    aEditEngine.SetText( aParaText );
+
+    // Assert changes
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( aParaText, rDoc.GetParaAsString(sal_Int32(0)) );
+
+    // Insert tab 1 at desired position
+    ContentNode *pNode = rDoc.GetObject(0);
+    EditSelection aSel1( EditPaM(pNode, 6), EditPaM(pNode, 6) );
+    aEditEngine.InsertFeature( aSel1, aTab );
+
+    // Assert changes
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen + 1), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( OUString("sample\ttextfortestingtab"), rDoc.GetParaAsString(sal_Int32(0)) );
+
+    // Insert tab 2 at desired position
+    EditSelection aSel2( EditPaM(pNode, 23+1), EditPaM(pNode, 23+1) );
+    aEditEngine.InsertFeature( aSel2, aTab );
+
+    // Assert changes
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen + 2), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( OUString("sample\ttextfortestingtab\t"), rDoc.GetParaAsString(sal_Int32(0)) );
+
+    // Copy text using legacy format
+    uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,6,0,aTextLen+2) );
+
+    // Paste text at the end
+    aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true );
+
+    // Assert changes
+    CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen + aTextLen - 6 + 4 ), rDoc.GetTextLen() );
+    CPPUNIT_ASSERT_EQUAL( OUString("sample\ttextfortestingtab\t\ttextfortestingtab\t"), rDoc.GetParaAsString(sal_Int32(0)) );
+}
+
 namespace {
     class UrlEditEngine : public EditEngine
     {


More information about the Libreoffice-commits mailing list