diff options
author | Varun Dhall <varun.dhall@studentpartner.com> | 2017-07-04 02:08:40 +0530 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-07-03 23:43:17 +0200 |
commit | 6e7300d1046a195068fa97a0d91a95f19cc5c056 (patch) | |
tree | ab1b80265c99c3703d21a66724b4cf1e96375cca /editeng | |
parent | 9170d10cc57c3f0f3e82b27ce4b2cd9c897e669d (diff) |
EditEngine: Added test to check multi para start copy/paste
Change-Id: Ic253af5ab75783280926f2ed8387f69015014227
Reviewed-on: https://gerrit.libreoffice.org/39488
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.cxx | 49 |
1 files changed, 49 insertions, 0 deletions
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); |