diff options
Diffstat (limited to 'editeng/qa/unit/core-test.cxx')
-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); |