summaryrefslogtreecommitdiff
path: root/sw/qa/extras/uiwriter/uiwriter.cxx
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-01-16 15:07:01 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-01-16 15:17:45 +0100
commit8477394f9bbe001d8648c38cd6e3c1c72dd17d8e (patch)
tree0758132613de3d1b88f22a405212e9bb29b09f00 /sw/qa/extras/uiwriter/uiwriter.cxx
parent9758961f6c6d2e40eec2d89c7bb1a5d065a6a1d8 (diff)
CppunitTest_sw_uiwriter: add testcase for ExportRTF()
Change-Id: I49a86e6a5cd525118d902b37825cfdb7dc8e70d2
Diffstat (limited to 'sw/qa/extras/uiwriter/uiwriter.cxx')
-rw-r--r--sw/qa/extras/uiwriter/uiwriter.cxx30
1 files changed, 30 insertions, 0 deletions
diff --git a/sw/qa/extras/uiwriter/uiwriter.cxx b/sw/qa/extras/uiwriter/uiwriter.cxx
index dd1e63bb2a7c..dc9004b335b0 100644
--- a/sw/qa/extras/uiwriter/uiwriter.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter.cxx
@@ -27,6 +27,7 @@ public:
void testFdo69893();
void testFdo70807();
void testImportRTF();
+ void testExportRTF();
CPPUNIT_TEST_SUITE(SwUiWriterTest);
CPPUNIT_TEST(testReplaceForward);
@@ -34,6 +35,7 @@ public:
CPPUNIT_TEST(testFdo69893);
CPPUNIT_TEST(testFdo70807);
CPPUNIT_TEST(testImportRTF);
+ CPPUNIT_TEST(testExportRTF);
CPPUNIT_TEST_SUITE_END();
private:
@@ -168,6 +170,34 @@ void SwUiWriterTest::testImportRTF()
CPPUNIT_ASSERT_EQUAL(OUString("bar"), static_cast<SwTxtNode*>(pDoc->GetNodes()[nIndex])->GetTxt());
}
+void SwUiWriterTest::testExportRTF()
+{
+ // Insert "aaabbbccc" and select "bbb".
+ SwDoc* pDoc = createDoc();
+ SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell();
+ pWrtShell->Insert("aaabbbccc");
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/false, 3, /*bBasicCall=*/false);
+ pWrtShell->Left(CRSR_SKIP_CHARS, /*bSelect=*/true, 3, /*bBasicCall=*/false);
+
+ // Create the clipboard document.
+ boost::shared_ptr<SwDoc> pClpDoc(new SwDoc());
+ pClpDoc->SetClipBoard(true);
+ pWrtShell->Copy(pClpDoc.get());
+
+ // And finally export it as RTF.
+ WriterRef xWrt;
+ SwReaderWriter::GetWriter("RTF", OUString(), xWrt);
+ SvMemoryStream aStream;
+ SwWriter aWrt(aStream, *pClpDoc);
+ aWrt.Write(xWrt);
+
+ OString aData(static_cast<const sal_Char*>(aStream.GetBuffer()), aStream.GetSize());
+ CPPUNIT_ASSERT(aData.startsWith("{\\rtf1"));
+ CPPUNIT_ASSERT_EQUAL(-1, aData.indexOf("aaa"));
+ CPPUNIT_ASSERT(aData.indexOf("bbb") != -1);
+ CPPUNIT_ASSERT_EQUAL(-1, aData.indexOf("ccc"));
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(SwUiWriterTest);
CPPUNIT_PLUGIN_IMPLEMENT();