Kaydet (Commit) 6e7300d1 authored tarafından Varun Dhall's avatar Varun Dhall Kaydeden (comit) Michael Stahl

EditEngine: Added test to check multi para start copy/paste

Change-Id: Ic253af5ab75783280926f2ed8387f69015014227
Reviewed-on: https://gerrit.libreoffice.org/39488Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst 9170d10c
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment