summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorVarun Dhall <varun.dhall@studentpartner.com>2017-03-23 14:42:40 +0530
committerMichael Stahl <mstahl@redhat.com>2017-03-24 21:50:00 +0000
commit0115a5f908d2280d39381e616cec262fabf07ea0 (patch)
tree5614422289623541cf7913806187bdc7be5fbd96 /editeng
parent075585928cc77cb53cce675d13dd7d55de8aa122 (diff)
Added Test for EditEngine - Copy/Paste with Tabs in Text
Change-Id: If40dabc53d35c01e61f8a17799f26e6ef9fd6b08 Reviewed-on: https://gerrit.libreoffice.org/35579 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/qa/unit/core-test.cxx57
1 files changed, 57 insertions, 0 deletions
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
{