summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter/uiwriter.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-01-16 11:00:36 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-01-16 11:19:43 +0100
commit82587e9bd4659200ea13ba416f881ff4285ec86e (patch)
treed0beff2817f3ffb47b780757dbe7b5a98321a999 /sw/qa/extras/uiwriter/uiwriter.cxx
parent6a445e3231969b4a45f6e9db6f9d8f4044559d6f (diff)
CppunitTest_sw_uiwriter: add testcase for ImportRTF()
Change-Id: I334b21532337c1895a148c949dde60ad774b4759
Diffstat (limited to 'sw/qa/extras/uiwriter/uiwriter.cxx')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx24
1 files changed, 24 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index 8b2c1227124a..dd1e63bb2a7c 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -9,6 +9,8 @@
#include <swmodeltestbase.hxx>
#include <ndtxt.hxx>
#include <wrtsh.hxx>
+#include <crsskip.hxx>
+#include <shellio.hxx>
#include "UndoManager.hxx"
@@ -24,12 +26,14 @@ public:
void testReplaceBackward();
void testFdo69893();
void testFdo70807();
+ void testImportRTF();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
CPPUNIT_TEST(testReplaceBackward);
CPPUNIT_TEST(testFdo69893);
CPPUNIT_TEST(testFdo70807);
+ CPPUNIT_TEST(testImportRTF);
CPPUNIT_TEST_SUITE_END();
private:
@@ -144,6 +148,26 @@ void SwUiWriterTest::testFdo70807()
}
}
+void SwUiWriterTest::testImportRTF()
+{
+ // Insert "foobar" and position the cursor between "foo" and "bar".
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Insert("foobar");
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 3, /*bBasicCall=*/false);
+
+ // Insert the RTF at the cursor position.
+ OString aData = "{\\rtf1 Hello world!\\par}";
+ SvMemoryStream aStream(const_cast<sal_Char*>(aData.getStr()), aData.getLength(), STREAM_READ);
+ SwReader aReader(aStream, OUString(), OUString(), *pWrtShell->GetCrsr());
+ Reader* pRTFReader = SwReaderWriter::GetReader(READER_WRITER_RTF);
+ CPPUNIT_ASSERT_EQUAL(sal_uLong(0), aReader.Read(*pRTFReader));
+
+ sal_uLong nIndex = pWrtShell->GetCrsr()->GetNode()->GetIndex();
+ CPPUNIT_ASSERT_EQUAL(OUString("fooHello world!"), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex - 1])->GetTxt());
+ CPPUNIT_ASSERT_EQUAL(OUString("bar"), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex])->GetTxt());
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();