diff options
author | Varun Dhall <varun.vd1994@gmail.com> | 2017-02-22 21:57:44 +0530 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2017-02-24 16:41:12 +0000 |
commit | 685767dbe7dc6677eaee8edf3c9f94105705fafa (patch) | |
tree | ef15e0607271abf1133c8eb2bd3e3a4cd794d4b2 /editeng/qa | |
parent | f21994e7a240563283b7a17dcb435ce7c5156b60 (diff) |
Added Test for EditEngine - Copy/Paste using Legacy Format
Change-Id: I3153010f4e327abd2ef48bdefa50ade1c0ba2f81
Reviewed-on: https://gerrit.libreoffice.org/34552
Reviewed-by: Michael Stahl <mstahl@redhat.com>
Tested-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'editeng/qa')
-rw-r--r-- | editeng/qa/unit/core-test.cxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/editeng/qa/unit/core-test.cxx b/editeng/qa/unit/core-test.cxx index 8048feabf131..23defaa4e8c1 100644 --- a/editeng/qa/unit/core-test.cxx +++ b/editeng/qa/unit/core-test.cxx @@ -52,6 +52,9 @@ public: /// AutoCorrect tests void testAutocorrect(); + /// Test Copy/Paste using Legacy Format + void testCopyPaste(); + /// Test hyperlinks void testHyperlinkSearch(); @@ -61,6 +64,7 @@ public: CPPUNIT_TEST(testConstruction); CPPUNIT_TEST(testUnoTextFields); CPPUNIT_TEST(testAutocorrect); + CPPUNIT_TEST(testCopyPaste); CPPUNIT_TEST(testHyperlinkSearch); CPPUNIT_TEST(testSectionAttributes); CPPUNIT_TEST_SUITE_END(); @@ -363,6 +367,38 @@ void Test::testAutocorrect() } } +void Test::testCopyPaste() +{ + // 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)) ); + + // Set initial text + OUString aText = "This is custom initial text"; + sal_Int32 aTextLen = aText.getLength(); + aEditEngine.SetText( aText ); + + // Assert changes + CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen), rDoc.GetTextLen() ); + CPPUNIT_ASSERT_EQUAL( aText, rDoc.GetParaAsString(sal_Int32(0)) ); + + // Copy initial text using legacy format + uno::Reference< datatransfer::XTransferable > xData = aEditEngine.CreateTransferable( ESelection(0,0,0,aTextLen) ); + + // Paste text at the end + aEditEngine.InsertText( xData, OUString(), rDoc.GetEndPaM(), true ); + + // Assert changes + CPPUNIT_ASSERT_EQUAL( sal_uLong(aTextLen + aTextLen), rDoc.GetTextLen() ); + CPPUNIT_ASSERT_EQUAL( OUString(aText + aText), rDoc.GetParaAsString(sal_Int32(0)) ); +} + namespace { class UrlEditEngine : public EditEngine { |