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

EditEngine: Added test to check MultiPara SelectiveSelection Copy/Paste

Change-Id: Iffb55599c90483b231820f60536c93ec3bfec2c9
Reviewed-on: https://gerrit.libreoffice.org/39140Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarMichael Stahl <mstahl@redhat.com>
üst a64bbe6b
...@@ -60,6 +60,9 @@ public: ...@@ -60,6 +60,9 @@ public:
/// Test Copy/Paste using Legacy Format /// Test Copy/Paste using Legacy Format
void testCopyPaste(); void testCopyPaste();
/// Test Copy/Paste with selective selection over multiple paragraphs
void testMultiParaSelCopyPaste();
/// Test Copy/Paste with Tabs /// Test Copy/Paste with Tabs
void testTabsCopyPaste(); void testTabsCopyPaste();
...@@ -83,6 +86,7 @@ public: ...@@ -83,6 +86,7 @@ public:
CPPUNIT_TEST(testAutocorrect); CPPUNIT_TEST(testAutocorrect);
CPPUNIT_TEST(testHyperlinkCopyPaste); CPPUNIT_TEST(testHyperlinkCopyPaste);
CPPUNIT_TEST(testCopyPaste); CPPUNIT_TEST(testCopyPaste);
CPPUNIT_TEST(testMultiParaSelCopyPaste);
CPPUNIT_TEST(testTabsCopyPaste); CPPUNIT_TEST(testTabsCopyPaste);
CPPUNIT_TEST(testHyperlinkSearch); CPPUNIT_TEST(testHyperlinkSearch);
CPPUNIT_TEST(testBoldItalicCopyPaste); CPPUNIT_TEST(testBoldItalicCopyPaste);
...@@ -567,6 +571,52 @@ void Test::testCopyPaste() ...@@ -567,6 +571,52 @@ void Test::testCopyPaste()
CPPUNIT_ASSERT_EQUAL( OUString(aText + aText), rDoc.GetParaAsString(sal_Int32(0)) ); 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() void Test::testTabsCopyPaste()
{ {
// Create EditEngine's instance // Create EditEngine's instance
......
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