summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVarun Dhall <varun.dhall@studentpartner.com>2017-06-23 09:39:21 +0530
committerMichael Stahl <mstahl@redhat.com>2017-06-23 22:11:01 +0200
commit41f1474e63a40e682a424211e788cc4b801e6659 (patch)
tree690e9e65f3b6b940d4ba973f5a18a386da5c7f31
parenta64bbe6b1d2e64a609c588a66a5739ee03a65946 (diff)
EditEngine: Added test to check MultiPara SelectiveSelection Copy/Paste
Change-Id: Iffb55599c90483b231820f60536c93ec3bfec2c9 Reviewed-on: https://gerrit.libreoffice.org/39140 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--editeng/qa/unit/core-test.cxx50
1 files changed, 50 insertions, 0 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx
index 0249c0d0f4bf..ba76dd885ae8 100644
--- a/editeng/qa/unit/core-test.cxx
+++ b/editeng/qa/unit/core-test.cxx
@@ -60,6 +60,9 @@ public:
/// Test Copy/Paste using Legacy Format
void testCopyPaste();
+ /// Test Copy/Paste with selective selection over multiple paragraphs
+ void testMultiParaSelCopyPaste();
+
/// Test Copy/Paste with Tabs
void testTabsCopyPaste();
@@ -83,6 +86,7 @@ public:
CPPUNIT_TEST(testAutocorrect);
CPPUNIT_TEST(testHyperlinkCopyPaste);
CPPUNIT_TEST(testCopyPaste);
+ CPPUNIT_TEST(testMultiParaSelCopyPaste);
CPPUNIT_TEST(testTabsCopyPaste);
CPPUNIT_TEST(testHyperlinkSearch);
CPPUNIT_TEST(testBoldItalicCopyPaste);
@@ -567,6 +571,52 @@ void Test::testCopyPaste()
CPPUNIT_ASSERT_EQUAL( OUString(aText + aText), rDoc.GetParaAsString(sal_Int32(0)) );
}
+void Test::testMultiParaSelCopyPaste()
+{
+ // 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 end
+ aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true );
+
+ // Assert changes
+ OUString aThirdParaAfterCopyPaste = aThirdPara + "first paragraph";
+ OUString aFourthPara = "This is second";
+ CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen + aCopyTextLen), rDoc.GetTextLen() );
+ CPPUNIT_ASSERT_EQUAL( aFirstPara, rDoc.GetParaAsString(sal_Int32(0)) );
+ CPPUNIT_ASSERT_EQUAL( aSecondPara, rDoc.GetParaAsString(sal_Int32(1)) );
+ CPPUNIT_ASSERT_EQUAL( aThirdParaAfterCopyPaste, rDoc.GetParaAsString(sal_Int32(2)) );
+ CPPUNIT_ASSERT_EQUAL( aFourthPara, rDoc.GetParaAsString(sal_Int32(3)) );
+}
+
void Test::testTabsCopyPaste()
{
// Create EditEngine's instance